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\Interfaces\SessionCheckInterface;
  34. use ApplicationBundle\Modules\Accounts\Accounts;
  35. use ApplicationBundle\Modules\Authentication\Constants\UserConstants;
  36. use ApplicationBundle\Modules\Buddybee\Buddybee;
  37. use ApplicationBundle\Modules\HumanResource\HumanResource;
  38. use ApplicationBundle\Modules\Inventory\Inventory;
  39. use ApplicationBundle\Modules\Sales\Client;
  40. use ApplicationBundle\Modules\System\DeleteDocument;
  41. use ApplicationBundle\Modules\System\DocValidation;
  42. use ApplicationBundle\Modules\System\MiscActions;
  43. use ApplicationBundle\Modules\System\System;
  44. use ApplicationBundle\Modules\User\Company;
  45. use CompanyGroupBundle\Entity\EntityApplicantDetails;
  46. use CompanyGroupBundle\Entity\EntityCountryConsultantRequirements;
  47. use CompanyGroupBundle\Entity\EntityCreateBlog;
  48. use CompanyGroupBundle\Entity\EntityCreateDocument;
  49. use CompanyGroupBundle\Entity\EntityCreateTopic;
  50. use CompanyGroupBundle\Entity\EntityFile;
  51. use CompanyGroupBundle\Entity\EntityInvoice;
  52. use CompanyGroupBundle\Entity\EntitySkill;
  53. use CompanyGroupBundle\Entity\PromoCode;
  54. use CompanyGroupBundle\Modules\ApplicantM;
  55. use Ps\PdfBundle\Annotation\Pdf;
  56. use Symfony\Component\HttpFoundation\JsonResponse;
  57. use Symfony\Component\HttpFoundation\Request;
  58. use Symfony\Component\HttpFoundation\Response;
  59. use Symfony\Component\Routing\Generator\UrlGenerator;
  60. //use Symfony\Bundle\FrameworkBundle\Console\Application;
  61. //use Symfony\Component\Console\Input\ArrayInput;
  62. //use Symfony\Component\Console\Output\NullOutput;
  63. class HumanResourceController extends GenericController implements SessionCheckInterface
  64. {
  65. //temporary for adding session
  66.     public function CheckoutPageAction(Request $request$encData '')
  67.     {
  68.         $em $this->getDoctrine()->getManager('company_group');
  69.         $em_goc $this->getDoctrine()->getManager('company_group');
  70.         $sandBoxMode $this->container->hasParameter('sand_box_mode') ? $this->container->getParameter('sand_box_mode') : 0;
  71.         $invoiceId $request->request->get('invoiceId'$request->query->get('invoiceId'0));
  72.         if ($encData != "") {
  73.             $encryptedData json_decode($this->get('url_encryptor')->decrypt($encData), true);
  74.             if ($encryptedData == null$encryptedData = [];
  75.             if (isset($encryptedData['invoiceId'])) $invoiceId $encryptedData['invoiceId'];
  76.         }
  77.         $session $request->getSession();
  78.         $currencyForGateway 'eur';
  79.         $gatewayInvoice null;
  80.         if ($invoiceId != 0)
  81.             $gatewayInvoice $em->getRepository(EntityInvoice::class)->find($invoiceId);
  82.         $paymentGateway $request->request->get('paymentGateway''stripe'); //aamarpay,bkash
  83.         $paymentType $request->request->get('paymentType''credit');
  84.         $retailerId $request->request->get('retailerId'0);
  85.         if ($request->query->has('currency'))
  86.             $currencyForGateway $request->query->get('currency');
  87.         else
  88.             $currencyForGateway $request->request->get('currency''eur');
  89. //        {
  90. //            if ($request->query->has('meetingSessionId'))
  91. //                $id = $request->query->get('meetingSessionId');
  92. //        }
  93.         $currentUserBalance 0;
  94.         $currentUserCoinBalance 0;
  95.         $gatewayAmount 0;
  96.         $redeemedAmount 0;
  97.         $redeemedSessionCount 0;
  98.         $toConsumeSessionCount 0;
  99.         $invoiceSessionCount 0;
  100.         $payableAmount 0;
  101.         $promoClaimedAmount 0;
  102.         $promoCodeId 0;
  103.         $promoClaimedSession 0;
  104.         $bookingExpireTime null;
  105.         $bookingExpireTs 0;
  106.         $imageBySessionCount = [
  107.             => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  108.             100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  109.             200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  110.             300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  111.             400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  112.             500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  113.             600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  114.             700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  115.             800 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  116.             900 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  117.             1000 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  118.             1100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  119.             1200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  120.             1300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  121.             1400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  122.             1500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  123.             1600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  124.             1700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  125.             1800 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  126.             1900 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  127.             2000 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  128.             2100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  129.             2200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  130.             2300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  131.             2400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  132.             2500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  133.             2600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  134.             2700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  135.             2800 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  136.             2900 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  137.             3000 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  138.             3100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  139.             3200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  140.             3300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  141.             3400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  142.             3500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  143.             3600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  144.             3700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  145.         ];
  146.         if (!$gatewayInvoice) {
  147.             if ($request->isMethod('POST')) {
  148.                 $totalAmount 0;
  149.                 $totalSessionCount 0;
  150.                 $consumedAmount 0;
  151.                 $consumedSessionCount 0;
  152.                 $bookedById 0;
  153.                 $bookingRefererId 0;
  154.                 if ($session->get(UserConstants::USER_ID)) {
  155.                     $bookedById $session->get(UserConstants::USER_ID);
  156.                     $bookingRefererId 0;
  157. //                    $toConsumeSessionCount = 1 * $request->request->get('meetingSessionConsumeCount', 0);
  158.                     $invoiceSessionCount * ($request->request->get('sessionCount'0) == '' $request->request->get('sessionCount'0));
  159.                     //1st do the necessary
  160.                     $extMeeting null;
  161.                     $meetingSessionId 0;
  162.                     if ($request->request->has('purchasePackage')) {
  163.                         //1. check if any bee card if yes try to claim it , modify current balance then
  164.                         $beeCodeSerial $request->request->get('beeCodeSerial''');
  165.                         $promoCode $request->request->get('promoCode''');
  166.                         $beeCodePin $request->request->get('beeCodePin''');
  167.                         $userId $request->request->get('userId'$session->get(UserConstants::USER_ID));
  168.                         $studentDetails null;
  169.                         $studentDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($userId);
  170.                         if ($studentDetails) {
  171.                             $currentUserBalance $studentDetails->getAccountBalance();
  172.                         }
  173.                         if ($beeCodeSerial != '' && $beeCodePin != '') {
  174.                             $claimData MiscActions::ClaimBeeCode($em,
  175.                                 [
  176.                                     'claimFlag' => 1,
  177.                                     'pin' => $beeCodePin,
  178.                                     'serial' => $beeCodeSerial,
  179.                                     'userId' => $userId,
  180.                                 ]);
  181.                             if ($userId == $session->get(UserConstants::USER_ID)) {
  182.                                 MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  183.                                 $claimData['newCoinBalance'] = $session->get('BUDDYBEE_COIN_BALANCE');
  184.                                 $claimData['newBalance'] = $session->get('BUDDYBEE_BALANCE');
  185.                             }
  186.                             $redeemedAmount $claimData['data']['claimedAmount'];
  187.                             $redeemedSessionCount $claimData['data']['claimedCoin'];
  188.                         } else
  189.                             if ($userId == $session->get(UserConstants::USER_ID)) {
  190.                                 MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  191.                             }
  192.                         $payableAmount round($request->request->get('payableAmount'0), 0);
  193.                         $totalAmountWoDiscount round($request->request->get('totalAmountWoDiscount'0), 0);
  194.                         //now claim and process promocode
  195.                         if ($promoCode != '') {
  196.                             $claimData MiscActions::ClaimPromoCode($em,
  197.                                 [
  198.                                     'claimFlag' => 1,
  199.                                     'promoCode' => $promoCode,
  200.                                     'decryptedPromoCodeData' => json_decode($this->get('url_encryptor')->decrypt($promoCode), true),
  201.                                     'orderValue' => $totalAmountWoDiscount,
  202.                                     'currency' => $currencyForGateway,
  203.                                     'orderCoin' => $invoiceSessionCount,
  204.                                     'userId' => $userId,
  205.                                 ]);
  206.                             $promoClaimedAmount 0;
  207. //                            $promoClaimedAmount = $claimData['data']['claimedAmount']*(BuddybeeConstant::$convMultFromTo['eur'][$currencyForGateway]);
  208.                             $promoCodeId $claimData['promoCodeId'];
  209.                             $promoClaimedSession $claimData['data']['claimedCoin'];
  210.                         }
  211.                         if ($userId == $session->get(UserConstants::USER_ID)) {
  212.                             MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  213.                             $currentUserBalance $session->get('BUDDYBEE_BALANCE');
  214.                             $currentUserCoinBalance $session->get('BUDDYBEE_COIN_BALANCE');
  215.                         } else {
  216.                             if ($bookingRefererId == 0)
  217.                                 $bookingRefererId $session->get(UserConstants::USER_ID);
  218.                             $studentDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($userId);
  219.                             if ($studentDetails) {
  220.                                 $currentUserBalance $studentDetails->getAccountBalance();
  221.                                 $currentUserCoinBalance $studentDetails->getSessionCountBalance();
  222.                                 if ($bookingRefererId != $userId && $bookingRefererId != 0) {
  223.                                     $bookingReferer $em_goc->getRepository(EntityApplicantDetails::class)->find($bookingRefererId);
  224.                                     if ($bookingReferer)
  225.                                         if ($bookingReferer->getIsAdmin()) {
  226.                                             $studentDetails->setAssignedSalesRepresentativeId($bookingRefererId);
  227.                                             $em_goc->flush();
  228.                                         }
  229.                                 }
  230.                             }
  231.                         }
  232.                         //2. check if any promo code  if yes add it to promo discount
  233.                         //3. check if scheule is still temporarily booked if not return that you cannot book it
  234.                         Buddybee::ExpireAnyMeetingSessionIfNeeded($em);
  235.                         Buddybee::ExpireAnyEntityInvoiceIfNeeded($em);
  236. //                        if ($request->request->get('autoAssignMeetingSession', 0) == 1
  237. //                            && $request->request->get('consultancyScheduleId', 0) != 0
  238. //                            && $request->request->get('consultancyScheduleId', 0) != ''
  239. //                        )
  240.                         {
  241.                             //1st check if a meeting session exxists with same TS, student id , consultant id
  242. //                            $scheduledStartTime = new \DateTime('@' . $request->request->get('consultancyScheduleId', ''));
  243. //                            $extMeeting = $em->getRepository('CompanyGroupBundle:EntityMeetingSession')
  244. //                                ->findOneBy(
  245. //                                    array(
  246. //                                        'scheduledTimeTs' => $scheduledStartTime->format('U'),
  247. //                                        'consultantId' => $request->request->get('consultantId', 0),
  248. //                                        'studentId' => $request->request->get('studentId', 0),
  249. //                                        'durationAllowedMin' => $request->request->get('meetingSessionScheduledDuration', BuddybeeConstant::PER_SESSION_MINUTE),
  250. //                                    )
  251. //                                );
  252. //                            if ($extMeeting) {
  253. //                                $new = $extMeeting;
  254. //                                $meetingSessionId = $new->getSessionId();
  255. //                                $periodMarker = $scheduledStartTime->format('Ym');
  256. //
  257. //                            }
  258. //                            else {
  259. //
  260. //
  261. //                                $scheduleValidity = MiscActions::CheckIfScheduleCanBeConfirmed(
  262. //                                    $em,
  263. //                                    $request->request->get('consultantId', 0),
  264. //                                    $request->request->get('studentId', 0),
  265. //                                    $scheduledStartTime->format('U'),
  266. //                                    $request->request->get('meetingSessionScheduledDuration', BuddybeeConstant::PER_SESSION_MINUTE),
  267. //                                    1
  268. //                                );
  269. //
  270. //                                if (!$scheduleValidity) {
  271. //                                    $url = $this->generateUrl(
  272. //                                        'consultant_profile'
  273. //                                    );
  274. //                                    $output = [
  275. //
  276. //                                        'proceedToCheckout' => 0,
  277. //                                        'message' => 'Session Booking Expired or not Found!',
  278. //                                        'errorFlag' => 1,
  279. //                                        'redirectUrl' => $url . '/' . $request->request->get('consultantId', 0)
  280. //                                    ];
  281. //                                    return new JsonResponse($output);
  282. //                                }
  283. //                                $new = new EntityMeetingSession();
  284. //
  285. //                                $new->setTopicId($request->request->get('consultancyTopic', 0));
  286. //                                $new->setConsultantId($request->request->get('consultantId', 0));
  287. //                                $new->setStudentId($request->request->get('studentId', 0));
  288. //                                $consultancyTopic = $em_goc->getRepository(EntityCreateTopic::class)->find($request->request->get('consultancyTopic', 0));
  289. //                                $new->setMeetingType($consultancyTopic ? $consultancyTopic->getMeetingType() : 0);
  290. //                                $new->setConsultantCanUpload($consultancyTopic ? $consultancyTopic->getConsultantCanUpload() : 0);
  291. //
  292. //
  293. //                                $scheduledEndTime = new \DateTime($request->request->get('scheduledTime', ''));
  294. //                                $scheduledEndTime = $scheduledEndTime->modify('+' . $request->request->get('meetingSessionScheduledDuration', 30) . ' minute');
  295. //
  296. //                                //$new->setScheduledTime($request->request->get('setScheduledTime'));
  297. //                                $new->setScheduledTime($scheduledStartTime);
  298. //                                $new->setDurationAllowedMin($request->request->get('meetingSessionScheduledDuration', 30));
  299. //                                $new->setDurationLeftMin($request->request->get('meetingSessionScheduledDuration', 30));
  300. //                                $new->setSessionExpireDate($scheduledEndTime);
  301. //                                $new->setSessionExpireDateTs($scheduledEndTime->format('U'));
  302. //                                $new->setEquivalentSessionCount($request->request->get('meetingSessionConsumeCount', 0));
  303. //                                $new->setMeetingSpecificNote($request->request->get('meetingSpecificNote', ''));
  304. //
  305. //                                $new->setUsableSessionCount($request->request->get('meetingSessionConsumeCount', 0));
  306. //                                $new->setRedeemSessionCount($request->request->get('meetingSessionConsumeCount', 0));
  307. //                                $new->setMeetingActionFlag(0);// no action waiting for meeting
  308. //                                $new->setScheduledTime($scheduledStartTime);
  309. //                                $new->setScheduledTimeTs($scheduledStartTime->format('U'));
  310. //                                $new->setPayableAmount($request->request->get('payableAmount', 0));
  311. //                                $new->setDueAmount($request->request->get('dueAmount', 0));
  312. //                                //$new->setScheduledTime(new \DateTime($request->get('setScheduledTime')));
  313. //                                //$new->setPcakageDetails(json_encode(($request->request->get('packageData'))));
  314. //                                $new->setPackageName(($request->request->get('packageName', '')));
  315. //                                $new->setPcakageDetails(($request->request->get('packageData', '')));
  316. //                                $new->setScheduleId(($request->request->get('consultancyScheduleId', 0)));
  317. //                                $currentUnixTime = new \DateTime();
  318. //                                $currentUnixTimeStamp = $currentUnixTime->format('U');
  319. //                                $studentId = $request->request->get('studentId', 0);
  320. //                                $consultantId = $request->request->get('consultantId', 0);
  321. //                                $new->setMeetingRoomId(str_pad($consultantId, 4, STR_PAD_LEFT) . $currentUnixTimeStamp . str_pad($studentId, 4, STR_PAD_LEFT));
  322. //                                $new->setSessionValue(($request->request->get('sessionValue', 0)));
  323. ////                        $new->setIsPayment(0);
  324. //                                $new->setConsultantIsPaidFull(0);
  325. //
  326. //                                if ($bookingExpireTs == 0) {
  327. //
  328. //                                    $bookingExpireTime = new \DateTime();
  329. //                                    $currTime = new \DateTime();
  330. //                                    $currTimeTs = $currTime->format('U');
  331. //                                    $bookingExpireTs = (1 * $scheduledStartTime->format('U')) - (24 * 3600);
  332. //                                    if ($bookingExpireTs < $currTimeTs) {
  333. //                                        if ((1 * $scheduledStartTime->format('U')) - $currTimeTs > (12 * 3600))
  334. //                                            $bookingExpireTs = (1 * $scheduledStartTime->format('U')) - (2 * 3600);
  335. //                                        else
  336. //                                            $bookingExpireTs = (1 * $scheduledStartTime->format('U'));
  337. //                                    }
  338. //
  339. ////                                    $bookingExpireTs = $bookingExpireTime->format('U');
  340. //                                }
  341. //
  342. //                                $new->setPaidSessionCount(0);
  343. //                                $new->setBookedById($bookedById);
  344. //                                $new->setBookingRefererId($bookingRefererId);
  345. //                                $new->setDueSessionCount($request->request->get('meetingSessionConsumeCount', 0));
  346. //                                $new->setExpireIfUnpaidTs($bookingExpireTs);
  347. //                                $new->setBookingExpireTs($bookingExpireTs);
  348. //                                $new->setConfirmationExpireTs($bookingExpireTs);
  349. //                                $new->setIsPaidFull(0);
  350. //                                $new->setIsExpired(0);
  351. //
  352. //
  353. //                                $em_goc->persist($new);
  354. //                                $em_goc->flush();
  355. //                                $meetingSessionId = $new->getSessionId();
  356. //                                $periodMarker = $scheduledStartTime->format('Ym');
  357. //                                MiscActions::UpdateSchedulingRestrictions($em_goc, $consultantId, $periodMarker, (($request->request->get('meetingSessionScheduledDuration', 30)) / 60), -(($request->request->get('meetingSessionScheduledDuration', 30)) / 60));
  358. //                            }
  359.                         }
  360.                         //4. if after all this stages passed then calcualte gateway payable
  361.                         if ($request->request->get('isRecharge'0) == 1) {
  362.                             if (($redeemedAmount $promoClaimedAmount) >= $payableAmount) {
  363.                                 $payableAmount = ($redeemedAmount $promoClaimedAmount);
  364.                                 $gatewayAmount 0;
  365.                             } else
  366.                                 $gatewayAmount $payableAmount - ($redeemedAmount $promoClaimedAmount);
  367.                         } else {
  368.                             if ($toConsumeSessionCount <= $currentUserCoinBalance && $invoiceSessionCount <= $toConsumeSessionCount) {
  369.                                 $payableAmount 0;
  370.                                 $gatewayAmount 0;
  371.                             } else if (($redeemedAmount $promoClaimedAmount) >= $payableAmount) {
  372.                                 $payableAmount = ($redeemedAmount $promoClaimedAmount);
  373.                                 $gatewayAmount 0;
  374.                             } else
  375.                                 $gatewayAmount $payableAmount <= ($currentUserBalance + ($redeemedAmount $promoClaimedAmount)) ? : ($payableAmount $currentUserBalance - ($redeemedAmount $promoClaimedAmount));
  376.                         }
  377.                         $gatewayAmount round($gatewayAmount2);
  378.                         $dueAmount round($request->request->get('dueAmount'$payableAmount), 0);
  379.                         if ($request->request->has('gatewayProductData'))
  380.                             $gatewayProductData $request->request->get('gatewayProductData');
  381.                         $gatewayProductData = [[
  382.                             'price_data' => [
  383.                                 'currency' => $currencyForGateway,
  384.                                 'unit_amount' => $gatewayAmount != ? ((100 $gatewayAmount) / ($invoiceSessionCount != $invoiceSessionCount 1)) : 200000,
  385.                                 'product_data' => [
  386. //                            'name' => $request->request->has('packageName') ? $request->request->get('packageName') : 'Advanced Consultancy Package',
  387.                                     'name' => 'Bee Coins',
  388.                                     'images' => [$imageBySessionCount[0]],
  389.                                 ],
  390.                             ],
  391.                             'quantity' => $invoiceSessionCount != $invoiceSessionCount 1,
  392.                         ]];
  393.                         $new_invoice null;
  394.                         if ($extMeeting) {
  395.                             $new_invoice $em->getRepository('CompanyGroupBundle:EntityInvoice')
  396.                                 ->findOneBy(
  397.                                     array(
  398.                                         'invoiceType' => $request->request->get('invoiceType'BuddybeeConstant::ENTITY_INVOICE_TYPE_PAYMENT_TO_HONEYBEE),
  399.                                         'meetingId' => $extMeeting->getSessionId(),
  400.                                     )
  401.                                 );
  402.                         }
  403.                         if ($new_invoice) {
  404.                         } else {
  405.                             $new_invoice = new EntityInvoice();
  406.                             $invoiceDate = new \DateTime();
  407.                             $new_invoice->setInvoiceDate($invoiceDate);
  408.                             $new_invoice->setInvoiceDateTs($invoiceDate->format('U'));
  409.                             $new_invoice->setStudentId($userId);
  410.                             $new_invoice->setBillerId($retailerId == $retailerId);
  411.                             $new_invoice->setRetailerId($retailerId);
  412.                             $new_invoice->setBillToId($userId);
  413.                             $new_invoice->setAmountTransferGateWayHash($paymentGateway);
  414.                             $new_invoice->setAmountCurrency($currencyForGateway);
  415.                             $cardIds $request->request->get('cardIds', []);
  416.                             $new_invoice->setMeetingId($meetingSessionId);
  417.                             $new_invoice->setGatewayBillAmount($gatewayAmount);
  418.                             $new_invoice->setRedeemedAmount($redeemedAmount);
  419.                             $new_invoice->setPromoDiscountAmount($promoClaimedAmount);
  420.                             $new_invoice->setPromoCodeId($promoCodeId);
  421.                             $new_invoice->setRedeemedSessionCount($redeemedSessionCount);
  422.                             $new_invoice->setPaidAmount($payableAmount $dueAmount);
  423.                             $new_invoice->setProductDataForPaymentGateway(json_encode($gatewayProductData));
  424.                             $new_invoice->setDueAmount($dueAmount);
  425.                             $new_invoice->setInvoiceType($request->request->get('invoiceType'BuddybeeConstant::ENTITY_INVOICE_TYPE_PAYMENT_TO_HONEYBEE));
  426.                             $new_invoice->setDocumentHash(MiscActions::GenerateRandomCrypto('BEI' microtime(true)));
  427.                             $new_invoice->setCardIds(json_encode($cardIds));
  428.                             $new_invoice->setAmountType($request->request->get('amountType'1));
  429.                             $new_invoice->setAmount($payableAmount);
  430.                             $new_invoice->setConsumeAmount($payableAmount);
  431.                             $new_invoice->setSessionCount($invoiceSessionCount);
  432.                             $new_invoice->setConsumeSessionCount($toConsumeSessionCount);
  433.                             $new_invoice->setIsPaidfull(0);
  434.                             $new_invoice->setIsProcessed(0);
  435.                             $new_invoice->setApplicantId($userId);
  436.                             $new_invoice->setBookedById($bookedById);
  437.                             $new_invoice->setBookingRefererId($bookingRefererId);
  438.                             $new_invoice->setIsRecharge($request->request->get('isRecharge'0));
  439.                             $new_invoice->setAutoConfirmTaggedMeeting($request->request->get('autoConfirmTaggedMeeting'0));
  440.                             $new_invoice->setAutoConfirmOtherMeeting($request->request->get('autoConfirmOtherMeeting'0));
  441.                             $new_invoice->setAutoClaimPurchasedCards($request->request->get('autoClaimPurchasedCards'0));
  442.                             $new_invoice->setIsPayment(0); //0 means receive
  443.                             $new_invoice->setStatus(GeneralConstant::ACTIVE); //0 means receive
  444.                             $new_invoice->setStage(BuddybeeConstant::ENTITY_INVOICE_STAGE_INITIATED); //0 means receive
  445.                             if ($bookingExpireTs == 0) {
  446.                                 $bookingExpireTime = new \DateTime();
  447.                                 $bookingExpireTime->modify('+30 day');
  448.                                 $bookingExpireTs $bookingExpireTime->format('U');
  449.                             }
  450.                             $new_invoice->setExpireIfUnpaidTs($bookingExpireTs);
  451.                             $new_invoice->setBookingExpireTs($bookingExpireTs);
  452.                             $new_invoice->setConfirmationExpireTs($bookingExpireTs);
  453. //            $new_invoice->setStatus($request->request->get(0));
  454.                             $em_goc->persist($new_invoice);
  455.                             $em_goc->flush();
  456.                         }
  457.                         $invoiceId $new_invoice->getId();
  458.                         $gatewayInvoice $new_invoice;
  459.                         if ($request->request->get('isRecharge'0) == 1) {
  460.                         } else {
  461.                             if ($gatewayAmount <= 0) {
  462.                                 $meetingId 0;
  463.                                 if ($invoiceId != 0) {
  464.                                     $retData Buddybee::ProcessEntityInvoice($em_goc$invoiceId, ['stage' => BuddybeeConstant::ENTITY_INVOICE_STAGE_COMPLETED], false,
  465.                                         $this->container->getParameter('notification_enabled'),
  466.                                         $this->container->getParameter('notification_server')
  467.                                     );
  468.                                     $meetingId $retData['meetingId'];
  469.                                 }
  470.                                 MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  471.                                 if (GeneralConstant::EMAIL_ENABLED == 1) {
  472.                                     $billerDetails = [];
  473.                                     $billToDetails = [];
  474.                                     $invoice $gatewayInvoice;
  475.                                     if ($invoice) {
  476.                                         $billerDetails $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
  477.                                             ->findOneBy(
  478.                                                 array(
  479.                                                     'applicantId' => $invoice->getBillerId(),
  480.                                                 )
  481.                                             );
  482.                                         $billToDetails $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
  483.                                             ->findOneBy(
  484.                                                 array(
  485.                                                     'applicantId' => $invoice->getBillToId(),
  486.                                                 )
  487.                                             );
  488.                                     }
  489.                                     $bodyTemplate 'ApplicationBundle:email/templates:buddybeeInvoiceEmail.html.twig';
  490.                                     $bodyData = array(
  491.                                         'page_title' => 'Invoice',
  492. //            'studentDetails' => $student,
  493.                                         'billerDetails' => $billerDetails,
  494.                                         'billToDetails' => $billToDetails,
  495.                                         'invoice' => $invoice,
  496.                                         'currencyList' => BuddybeeConstant::$currency_List,
  497.                                         'currencyListByMarker' => BuddybeeConstant::$currency_List_by_marker,
  498.                                     );
  499.                                     $attachments = [];
  500.                                     $forwardToMailAddress $billToDetails->getOAuthEmail();
  501. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  502.                                     $new_mail $this->get('mail_module');
  503.                                     $new_mail->sendMyMail(array(
  504.                                         'senderHash' => '_CUSTOM_',
  505.                                         //                        'senderHash'=>'_CUSTOM_',
  506.                                         'forwardToMailAddress' => $forwardToMailAddress,
  507.                                         '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 ',
  508. //                        'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
  509.                                         'attachments' => $attachments,
  510.                                         'toAddress' => $forwardToMailAddress,
  511.                                         'fromAddress' => 'no-reply@buddybee.eu',
  512.                                         'userName' => 'no-reply@buddybee.eu',
  513.                                         'password' => 'Honeybee@0112',
  514.                                         'smtpServer' => 'smtp.hostinger.com',
  515.                                         'smtpPort' => 465,
  516. //                            'emailBody' => $bodyHtml,
  517.                                         'mailTemplate' => $bodyTemplate,
  518.                                         'templateData' => $bodyData,
  519.                                         'embedCompanyImage' => 0,
  520.                                         'companyId' => 0,
  521.                                         'companyImagePath' => ''
  522. //                        'embedCompanyImage' => 1,
  523. //                        'companyId' => $companyId,
  524. //                        'companyImagePath' => $company_data->getImage()
  525.                                     ));
  526.                                 }
  527.                                 if ($meetingId != 0) {
  528.                                     $url $this->generateUrl(
  529.                                         'consultancy_session'
  530.                                     );
  531.                                     $output = [
  532.                                         'invoiceId' => $gatewayInvoice->getId(),
  533.                                         'meetingId' => $meetingId,
  534.                                         'proceedToCheckout' => 0,
  535.                                         'redirectUrl' => $url '/' $meetingId
  536.                                     ];
  537.                                 } else {
  538.                                     $url $this->generateUrl(
  539.                                         'buddybee_dashboard'
  540.                                     );
  541.                                     $output = [
  542.                                         'invoiceId' => $gatewayInvoice->getId(),
  543.                                         'meetingId' => 0,
  544.                                         'proceedToCheckout' => 0,
  545.                                         'redirectUrl' => $url
  546.                                     ];
  547.                                 }
  548.                                 return new JsonResponse($output);
  549. //                return $this->redirect($url);
  550.                             } else {
  551.                             }
  552. //                $url = $this->generateUrl(
  553. //                    'checkout_page'
  554. //                );
  555. //
  556. //                return $this->redirect($url."?meetingSessionId=".$new->getSessionId().'&invoiceId='.$invoiceId);
  557.                         }
  558.                     }
  559.                 } else {
  560.                     $url $this->generateUrl(
  561.                         'user_login'
  562.                     );
  563.                     $session->set('LAST_REQUEST_URI_BEFORE_LOGIN'$this->generateUrl(
  564.                         'pricing_plan_page', [
  565.                         'autoRedirected' => 1
  566.                     ],
  567.                         UrlGenerator::ABSOLUTE_URL
  568.                     ));
  569.                     $output = [
  570.                         'proceedToCheckout' => 0,
  571.                         'redirectUrl' => $url,
  572.                         'clearLs' => 0
  573.                     ];
  574.                     return new JsonResponse($output);
  575.                 }
  576.                 //now proceed to checkout page if the user has lower balance or recharging
  577.                 //$invoiceDetails = $em->getRepository('CompanyGroupBundle:EntityInvoice')->
  578.             }
  579.         }
  580.         if ($gatewayInvoice) {
  581.             $gatewayProductData json_decode($gatewayInvoice->getProductDataForPaymentGateway(), true);
  582.             if ($gatewayProductData == null$gatewayProductData = [];
  583.             if (empty($gatewayProductData))
  584.                 $gatewayProductData = [
  585.                     [
  586.                         'price_data' => [
  587.                             'currency' => 'eur',
  588.                             'unit_amount' => $gatewayAmount != ? (100 $gatewayAmount) : 200000,
  589.                             'product_data' => [
  590. //                            'name' => $request->request->has('packageName') ? $request->request->get('packageName') : 'Advanced Consultancy Package',
  591.                                 'name' => 'Bee Coins',
  592.                                 'images' => [$imageBySessionCount[0]],
  593.                             ],
  594.                         ],
  595.                         'quantity' => 1,
  596.                     ]
  597.                 ];
  598.             $productDescStr '';
  599.             $productDescArr = [];
  600.             foreach ($gatewayProductData as $gpd) {
  601.                 $productDescArr[] = $gpd['price_data']['product_data']['name'];
  602.             }
  603.             $productDescStr implode(','$productDescArr);
  604.             $paymentGatewayFromInvoice $gatewayInvoice->getAmountTransferGateWayHash();
  605. //            return new JsonResponse(
  606. //                [
  607. //                    'paymentGateway' => $paymentGatewayFromInvoice,
  608. //                    'gateWayData' => $gatewayProductData[0]
  609. //                ]
  610. //            );
  611.             if ($paymentGateway == null$paymentGatewayFromInvoice 'stripe';
  612.             if ($paymentGatewayFromInvoice == 'stripe' || $paymentGatewayFromInvoice == 'aamarpay' || $paymentGatewayFromInvoice == 'bkash') {
  613.                 if (GeneralConstant::EMAIL_ENABLED == 1) {
  614.                     $billerDetails = [];
  615.                     $billToDetails = [];
  616.                     $invoice $gatewayInvoice;
  617.                     if ($invoice) {
  618.                         $billerDetails $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
  619.                             ->findOneBy(
  620.                                 array(
  621.                                     'applicantId' => $invoice->getBillerId(),
  622.                                 )
  623.                             );
  624.                         $billToDetails $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
  625.                             ->findOneBy(
  626.                                 array(
  627.                                     'applicantId' => $invoice->getBillToId(),
  628.                                 )
  629.                             );
  630.                     }
  631.                     $bodyTemplate 'ApplicationBundle:email/templates:buddybeeInvoiceEmail.html.twig';
  632.                     $bodyData = array(
  633.                         'page_title' => 'Invoice',
  634. //            'studentDetails' => $student,
  635.                         'billerDetails' => $billerDetails,
  636.                         'billToDetails' => $billToDetails,
  637.                         'invoice' => $invoice,
  638.                         'currencyList' => BuddybeeConstant::$currency_List,
  639.                         'currencyListByMarker' => BuddybeeConstant::$currency_List_by_marker,
  640.                     );
  641.                     $attachments = [];
  642.                     $forwardToMailAddress $billToDetails->getOAuthEmail();
  643. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  644.                     $new_mail $this->get('mail_module');
  645.                     $new_mail->sendMyMail(array(
  646.                         'senderHash' => '_CUSTOM_',
  647.                         //                        'senderHash'=>'_CUSTOM_',
  648.                         'forwardToMailAddress' => $forwardToMailAddress,
  649.                         '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 ',
  650. //                        'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
  651.                         'attachments' => $attachments,
  652.                         'toAddress' => $forwardToMailAddress,
  653.                         'fromAddress' => 'no-reply@buddybee.eu',
  654.                         'userName' => 'no-reply@buddybee.eu',
  655.                         'password' => 'Honeybee@0112',
  656.                         'smtpServer' => 'smtp.hostinger.com',
  657.                         'smtpPort' => 465,
  658. //                            'emailBody' => $bodyHtml,
  659.                         'mailTemplate' => $bodyTemplate,
  660.                         'templateData' => $bodyData,
  661.                         'embedCompanyImage' => 0,
  662.                         'companyId' => 0,
  663.                         'companyImagePath' => ''
  664. //                        'embedCompanyImage' => 1,
  665. //                        'companyId' => $companyId,
  666. //                        'companyImagePath' => $company_data->getImage()
  667.                     ));
  668.                 }
  669.             }
  670.             if ($paymentGatewayFromInvoice == 'stripe') {
  671.                 $stripe = new \Stripe\Stripe();
  672.                 \Stripe\Stripe::setApiKey('sk_test_51IxYTAJXs21fVb0QMop2Nb0E7u9Da4LwGrym1nGHUHqaSNtT3p9HBgHd7YyDsTKHscgPPECPQniTy79Ab8Sgxfbm00JF2AndUz');
  673.                 $stripe::setApiKey('sk_test_51IxYTAJXs21fVb0QMop2Nb0E7u9Da4LwGrym1nGHUHqaSNtT3p9HBgHd7YyDsTKHscgPPECPQniTy79Ab8Sgxfbm00JF2AndUz');
  674.                 {
  675.                     if ($request->query->has('meetingSessionId'))
  676.                         $id $request->query->get('meetingSessionId');
  677.                 }
  678.                 $paymentIntent = [
  679.                     "id" => "pi_1DoWjK2eZvKYlo2Csy9J3BHs",
  680.                     "object" => "payment_intent",
  681.                     "amount" => 3000,
  682.                     "amount_capturable" => 0,
  683.                     "amount_received" => 0,
  684.                     "application" => null,
  685.                     "application_fee_amount" => null,
  686.                     "canceled_at" => null,
  687.                     "cancellation_reason" => null,
  688.                     "capture_method" => "automatic",
  689.                     "charges" => [
  690.                         "object" => "list",
  691.                         "data" => [],
  692.                         "has_more" => false,
  693.                         "url" => "/v1/charges?payment_intent=pi_1DoWjK2eZvKYlo2Csy9J3BHs"
  694.                     ],
  695.                     "client_secret" => "pi_1DoWjK2eZvKYlo2Csy9J3BHs_secret_vmxAcWZxo2kt1XhpWtZtnjDtd",
  696.                     "confirmation_method" => "automatic",
  697.                     "created" => 1546523966,
  698.                     "currency" => $currencyForGateway,
  699.                     "customer" => null,
  700.                     "description" => null,
  701.                     "invoice" => null,
  702.                     "last_payment_error" => null,
  703.                     "livemode" => false,
  704.                     "metadata" => [],
  705.                     "next_action" => null,
  706.                     "on_behalf_of" => null,
  707.                     "payment_method" => null,
  708.                     "payment_method_options" => [],
  709.                     "payment_method_types" => [
  710.                         "card"
  711.                     ],
  712.                     "receipt_email" => null,
  713.                     "review" => null,
  714.                     "setup_future_usage" => null,
  715.                     "shipping" => null,
  716.                     "statement_descriptor" => null,
  717.                     "statement_descriptor_suffix" => null,
  718.                     "status" => "requires_payment_method",
  719.                     "transfer_data" => null,
  720.                     "transfer_group" => null
  721.                 ];
  722.                 $checkout_session = \Stripe\Checkout\Session::create([
  723.                     'payment_method_types' => ['card'],
  724.                     'line_items' => $gatewayProductData,
  725.                     'mode' => 'payment',
  726.                     'success_url' => $this->generateUrl(
  727.                         'payment_gateway_success',
  728.                         ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  729.                             'invoiceId' => $invoiceId'autoRedirect' => $request->request->get('autoRedirect'1)
  730.                         ))), 'hbeeSessionToken' => $session->get('token'0)], UrlGenerator::ABSOLUTE_URL
  731.                     ),
  732.                     'cancel_url' => $this->generateUrl(
  733.                         'payment_gateway_cancel', ['invoiceId' => $invoiceId'autoRedirect' => $request->request->get('autoRedirect'1), 'hbeeSessionToken' => $session->get('token'0)], UrlGenerator::ABSOLUTE_URL
  734.                     ),
  735.                 ]);
  736.                 $output = [
  737.                     'clientSecret' => $paymentIntent['client_secret'],
  738.                     'id' => $checkout_session->id,
  739.                     'paymentGateway' => $paymentGatewayFromInvoice,
  740.                     'proceedToCheckout' => 1
  741.                 ];
  742.                 return new JsonResponse($output);
  743.             }
  744.             if ($paymentGatewayFromInvoice == 'aamarpay') {
  745.                 $studentDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($gatewayInvoice->getBillToId());
  746.                 $url $sandBoxMode == 'https://sandbox.aamarpay.com/request.php' 'https://secure.aamarpay.com/request.php';
  747.                 $fields = array(
  748. //                    'store_id' => 'aamarpaytest', //store id will be aamarpay,  contact integration@aamarpay.com for test/live id
  749.                     'store_id' => $sandBoxMode == 'aamarpaytest' 'buddybee'//store id will be aamarpay,  contact integration@aamarpay.com for test/live id
  750.                     'amount' => $gatewayInvoice->getGateWayBillamount(), //transaction amount
  751.                     'payment_type' => 'VISA'//no need to change
  752.                     'currency' => strtoupper($currencyForGateway),  //currenct will be USD/BDT
  753.                     'tran_id' => $gatewayInvoice->getDocumentHash(), //transaction id must be unique from your end
  754.                     'cus_name' => $studentDetails->getFirstname() . ' ' $studentDetails->getLastName(),  //customer name
  755.                     'cus_email' => $studentDetails->getEmail(), //customer email address
  756.                     'cus_add1' => $studentDetails->getCurrAddr(),  //customer address
  757.                     'cus_add2' => $studentDetails->getCurrAddrCity(), //customer address
  758.                     'cus_city' => $studentDetails->getCurrAddrCity(),  //customer city
  759.                     'cus_state' => $studentDetails->getCurrAddrState(),  //state
  760.                     'cus_postcode' => $studentDetails->getCurrAddrZip(), //postcode or zipcode
  761.                     'cus_country' => 'Bangladesh',  //country
  762.                     'cus_phone' => ($studentDetails->getPhone() == null || $studentDetails->getPhone() == '') ? '+8801911706483' $studentDetails->getPhone(), //customer phone number
  763.                     'cus_fax' => '',  //fax
  764.                     'ship_name' => ''//ship name
  765.                     'ship_add1' => '',  //ship address
  766.                     'ship_add2' => '',
  767.                     'ship_city' => '',
  768.                     'ship_state' => '',
  769.                     'ship_postcode' => '',
  770.                     'ship_country' => 'Bangladesh',
  771.                     'desc' => $productDescStr,
  772.                     'success_url' => $this->generateUrl(
  773.                         'payment_gateway_success',
  774.                         ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  775.                             'invoiceId' => $invoiceId'autoRedirect' => $request->request->get('autoRedirect'1)
  776.                         ))), 'hbeeSessionToken' => $session->get('token'0)], UrlGenerator::ABSOLUTE_URL
  777.                     ),
  778.                     'fail_url' => $this->generateUrl(
  779.                         'payment_gateway_cancel', ['invoiceId' => $invoiceId'autoRedirect' => $request->request->get('autoRedirect'1), 'hbeeSessionToken' => $session->get('token'0)], UrlGenerator::ABSOLUTE_URL
  780.                     ),
  781.                     'cancel_url' => $this->generateUrl(
  782.                         'payment_gateway_cancel', ['invoiceId' => $invoiceId'autoRedirect' => $request->request->get('autoRedirect'1), 'hbeeSessionToken' => $session->get('token'0)], UrlGenerator::ABSOLUTE_URL
  783.                     ),
  784. //                    'opt_a' => 'Reshad',  //optional paramter
  785. //                    'opt_b' => 'Akil',
  786. //                    'opt_c' => 'Liza',
  787. //                    'opt_d' => 'Sohel',
  788. //                    'signature_key' => 'dbb74894e82415a2f7ff0ec3a97e4183',  //sandbox
  789.                     'signature_key' => $sandBoxMode == 'dbb74894e82415a2f7ff0ec3a97e4183' 'b7304a40e21fe15af3be9a948307f524'  //live
  790.                 ); //signature key will provided aamarpay, contact integration@aamarpay.com for test/live signature key
  791.                 $fields_string http_build_query($fields);
  792. //                $ch = curl_init();
  793. //                curl_setopt($ch, CURLOPT_VERBOSE, true);
  794. //                curl_setopt($ch, CURLOPT_URL, $url);
  795. //
  796. //                curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
  797. //                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  798. //                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  799. //                $url_forward = str_replace('"', '', stripslashes(curl_exec($ch)));
  800. //                curl_close($ch);
  801. //                $this->redirect_to_merchant($url_forward);
  802.                 $output = [
  803. //
  804. //                    'redirectUrl' => ($sandBoxMode == 1 ? 'https://sandbox.aamarpay.com/' : 'https://secure.aamarpay.com/') . $url_forward, //keeping it off temporarily
  805. //                    'fields'=>$fields,
  806. //                    'fields_string'=>$fields_string,
  807. //                    'redirectUrl' => $this->generateUrl(
  808. //                        'payment_gateway_success',
  809. //                        ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  810. //                            'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
  811. //                        ))), 'hbeeSessionToken' => $request->request->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  812. //                    ),
  813.                     'paymentGateway' => $paymentGatewayFromInvoice,
  814.                     'proceedToCheckout' => 1,
  815.                     'data' => $fields
  816.                 ];
  817.                 return new JsonResponse($output);
  818.             }
  819.             else if ($paymentGatewayFromInvoice == 'bkash') {
  820.                 $studentDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($gatewayInvoice->getBillToId());
  821.                 $baseUrl = ($sandBoxMode == 1) ? 'https://tokenized.sandbox.bka.sh/v1.2.0-beta' 'https://tokenized.pay.bka.sh/v1.2.0-beta';
  822.                 $username_value = ($sandBoxMode == 1) ? 'sandboxTokenizedUser02' '01891962953';
  823.                 $password_value = ($sandBoxMode == 1) ? 'sandboxTokenizedUser02@12345' ',a&kPV4deq&';
  824.                 $app_key_value = ($sandBoxMode == 1) ? '4f6o0cjiki2rfm34kfdadl1eqq' '2ueVHdwz5gH3nxx7xn8wotlztc';
  825.                 $app_secret_value = ($sandBoxMode == 1) ? '2is7hdktrekvrbljjh44ll3d9l1dtjo4pasmjvs5vl5qr3fug4b' '49Ay3h3wWJMBFD7WF5CassyLrtA1jt6ONhspqjqFx5hTjhqh5dHU';
  826.                 $request_data = array(
  827.                     'app_key' => $app_key_value,
  828.                     'app_secret' => $app_secret_value
  829.                 );
  830.                 $url curl_init($baseUrl '/tokenized/checkout/token/grant');
  831.                 $request_data_json json_encode($request_data);
  832.                 $header = array(
  833.                     'Content-Type:application/json',
  834.                     'username:' $username_value,
  835.                     'password:' $password_value
  836.                 );
  837.                 curl_setopt($urlCURLOPT_HTTPHEADER$header);
  838.                 curl_setopt($urlCURLOPT_CUSTOMREQUEST"POST");
  839.                 curl_setopt($urlCURLOPT_RETURNTRANSFERtrue);
  840.                 curl_setopt($urlCURLOPT_POSTFIELDS$request_data_json);
  841.                 curl_setopt($urlCURLOPT_FOLLOWLOCATION1);
  842.                 curl_setopt($urlCURLOPT_IPRESOLVECURL_IPRESOLVE_V4);
  843.                 $tokenData json_decode(curl_exec($url), true);
  844.                 curl_close($url);
  845.                 $id_token $tokenData['id_token'];
  846.                 $goToBkashPage 0;
  847.                 if ($tokenData['statusCode'] == '0000') {
  848.                     $auth $id_token;
  849.                     $requestbody = array(
  850.                         "mode" => "0011",
  851. //                        "payerReference" => "01723888888",
  852.                         "payerReference" => $invoiceDate->format('U'),
  853.                         "callbackURL" => $this->generateUrl(
  854.                             'bkash_callback', [], UrlGenerator::ABSOLUTE_URL
  855.                         ),
  856. //                    "merchantAssociationInfo" => "MI05MID54RF09123456One",
  857.                         "amount" => number_format($gatewayInvoice->getGateWayBillamount(), 2'.'''),
  858.                         "currency" => "BDT",
  859.                         "intent" => "sale",
  860.                         "merchantInvoiceNumber" => $invoiceId
  861.                     );
  862.                     $url curl_init($baseUrl '/tokenized/checkout/create');
  863.                     $requestbodyJson json_encode($requestbody);
  864.                     $header = array(
  865.                         'Content-Type:application/json',
  866.                         'Authorization:' $auth,
  867.                         'X-APP-Key:' $app_key_value
  868.                     );
  869.                     curl_setopt($urlCURLOPT_HTTPHEADER$header);
  870.                     curl_setopt($urlCURLOPT_CUSTOMREQUEST"POST");
  871.                     curl_setopt($urlCURLOPT_RETURNTRANSFERtrue);
  872.                     curl_setopt($urlCURLOPT_POSTFIELDS$requestbodyJson);
  873.                     curl_setopt($urlCURLOPT_FOLLOWLOCATION1);
  874.                     curl_setopt($urlCURLOPT_IPRESOLVECURL_IPRESOLVE_V4);
  875.                     $resultdata curl_exec($url);
  876. //                    curl_close($url);
  877. //                    echo $resultdata;
  878.                     $obj json_decode($resultdatatrue);
  879.                     $goToBkashPage 1;
  880.                     $justNow = new \DateTime();
  881.                     $justNow->modify('+' $tokenData['expires_in'] . ' second');
  882.                     $gatewayInvoice->setGatewayIdTokenExpireTs($justNow->format('U'));
  883.                     $gatewayInvoice->setGatewayIdToken($tokenData['id_token']);
  884.                     $gatewayInvoice->setGatewayPaymentId($obj['paymentID']);
  885.                     $gatewayInvoice->setGatewayIdRefreshToken($tokenData['refresh_token']);
  886.                     $em->flush();
  887.                     $output = [
  888. //                        'redirectUrl' => $obj['bkashURL'],
  889.                         'paymentGateway' => $paymentGatewayFromInvoice,
  890.                         'proceedToCheckout' => $goToBkashPage,
  891.                         'tokenData' => $tokenData,
  892.                         'obj' => $obj,
  893.                         'id_token' => $tokenData['id_token'],
  894.                         'data' => [
  895.                             'amount' => $gatewayInvoice->getGateWayBillamount(), //transaction amount
  896. //                            'payment_type' => 'VISA', //no need to change
  897.                             'currency' => strtoupper($currencyForGateway),  //currenct will be USD/BDT
  898.                             'tran_id' => $gatewayInvoice->getDocumentHash(), //transaction id must be unique from your end
  899.                             'cus_name' => $studentDetails->getFirstname() . ' ' $studentDetails->getLastName(),  //customer name
  900.                             'cus_email' => $studentDetails->getEmail(), //customer email address
  901.                             'cus_add1' => $studentDetails->getCurrAddr(),  //customer address
  902.                             'cus_add2' => $studentDetails->getCurrAddrCity(), //customer address
  903.                             'cus_city' => $studentDetails->getCurrAddrCity(),  //customer city
  904.                             'cus_state' => $studentDetails->getCurrAddrState(),  //state
  905.                             'cus_postcode' => $studentDetails->getCurrAddrZip(), //postcode or zipcode
  906.                             'cus_country' => 'Bangladesh',  //country
  907.                             'cus_phone' => ($studentDetails->getPhone() == null || $studentDetails->getPhone() == '') ? '+8801911706483' $studentDetails->getPhone(), //customer phone number
  908.                             'cus_fax' => '',  //fax
  909.                             'ship_name' => ''//ship name
  910.                             'ship_add1' => '',  //ship address
  911.                             'ship_add2' => '',
  912.                             'ship_city' => '',
  913.                             'ship_state' => '',
  914.                             'ship_postcode' => '',
  915.                             'ship_country' => 'Bangladesh',
  916.                             'desc' => $productDescStr,
  917.                         ]
  918.                     ];
  919.                     return new JsonResponse($output);
  920.                 }
  921. //                $fields = array(
  922. //
  923. //                    "mode" => "0011",
  924. //                    "payerReference" => "01723888888",
  925. //                    "callbackURL" => $this->generateUrl(
  926. //                        'payment_gateway_success',
  927. //                        ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  928. //                            'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
  929. //                        ))), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  930. //                    ),
  931. //                    "merchantAssociationInfo" => "MI05MID54RF09123456One",
  932. //                    "amount" => 1*number_format($gatewayInvoice->getGateWayBillamount(),2,'.',''),,
  933. //                    "currency" => "BDT",
  934. //                    "intent" => "sale",
  935. //                    "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)
  936. //
  937. //                );
  938. //                $fields = array(
  939. ////                    'store_id' => 'aamarpaytest', //store id will be aamarpay,  contact integration@aamarpay.com for test/live id
  940. //                    'store_id' => $sandBoxMode == 1 ? 'aamarpaytest' : 'buddybee', //store id will be aamarpay,  contact integration@aamarpay.com for test/live id
  941. //                    'amount' => 1*number_format($gatewayInvoice->getGateWayBillamount(),2,'.',''),, //transaction amount
  942. //                    'payment_type' => 'VISA', //no need to change
  943. //                    'currency' => strtoupper($currencyForGateway),  //currenct will be USD/BDT
  944. //                    '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
  945. //                    'cus_name' => $studentDetails->getFirstname() . ' ' . $studentDetails->getLastName(),  //customer name
  946. //                    'cus_email' => $studentDetails->getEmail(), //customer email address
  947. //                    'cus_add1' => $studentDetails->getCurrAddr(),  //customer address
  948. //                    'cus_add2' => $studentDetails->getCurrAddrCity(), //customer address
  949. //                    'cus_city' => $studentDetails->getCurrAddrCity(),  //customer city
  950. //                    'cus_state' => $studentDetails->getCurrAddrState(),  //state
  951. //                    'cus_postcode' => $studentDetails->getCurrAddrZip(), //postcode or zipcode
  952. //                    'cus_country' => 'Bangladesh',  //country
  953. //                    'cus_phone' => ($studentDetails->getPhone() == null || $studentDetails->getPhone() == '') ? ' + 8801911706483' : $studentDetails->getPhone(), //customer phone number
  954. //                    'cus_fax' => '',  //fax
  955. //                    'ship_name' => '', //ship name
  956. //                    'ship_add1' => '',  //ship address
  957. //                    'ship_add2' => '',
  958. //                    'ship_city' => '',
  959. //                    'ship_state' => '',
  960. //                    'ship_postcode' => '',
  961. //                    'ship_country' => 'Bangladesh',
  962. //                    'desc' => $productDescStr,
  963. //                    'success_url' => $this->generateUrl(
  964. //                        'payment_gateway_success',
  965. //                        ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  966. //                            'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
  967. //                        ))), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  968. //                    ),
  969. //                    'fail_url' => $this->generateUrl(
  970. //                        'payment_gateway_cancel', ['invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  971. //                    ),
  972. //                    'cancel_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. ////                    'opt_a' => 'Reshad',  //optional paramter
  976. ////                    'opt_b' => 'Akil',
  977. ////                    'opt_c' => 'Liza',
  978. ////                    'opt_d' => 'Sohel',
  979. ////                    'signature_key' => 'dbb74894e82415a2f7ff0ec3a97e4183',  //sandbox
  980. //                    'signature_key' => $sandBoxMode == 1 ? 'dbb74894e82415a2f7ff0ec3a97e4183' : 'b7304a40e21fe15af3be9a948307f524'  //live
  981. //
  982. //                ); //signature key will provided aamarpay, contact integration@aamarpay.com for test/live signature key
  983. //
  984. //                $fields_string = http_build_query($fields);
  985. //
  986. //                $ch = curl_init();
  987. //                curl_setopt($ch, CURLOPT_VERBOSE, true);
  988. //                curl_setopt($ch, CURLOPT_URL, $url);
  989. //
  990. //                curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
  991. //                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  992. //                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  993. //                $url_forward = str_replace('"', '', stripslashes(curl_exec($ch)));
  994. //                curl_close($ch);
  995. //                $this->redirect_to_merchant($url_forward);
  996.             }
  997.             else if ($paymentGatewayFromInvoice == 'onsite_pos' || $paymentGatewayFromInvoice == 'onsite_cash' || $paymentGatewayFromInvoice == 'onsite_bkash') {
  998.                 $meetingId 0;
  999.                 if ($gatewayInvoice->getId() != 0) {
  1000.                     if ($gatewayInvoice->getDueAmount() <= 0) {
  1001.                         $retData Buddybee::ProcessEntityInvoice($em_goc$gatewayInvoice->getId(), ['stage' => BuddybeeConstant::ENTITY_INVOICE_STAGE_COMPLETED], false,
  1002.                             $this->container->getParameter('notification_enabled'),
  1003.                             $this->container->getParameter('notification_server')
  1004.                         );
  1005.                         $meetingId $retData['meetingId'];
  1006.                     }
  1007.                     if (GeneralConstant::EMAIL_ENABLED == 1) {
  1008.                         $billerDetails = [];
  1009.                         $billToDetails = [];
  1010.                         $invoice $gatewayInvoice;
  1011.                         if ($invoice) {
  1012.                             $billerDetails $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
  1013.                                 ->findOneBy(
  1014.                                     array(
  1015.                                         'applicantId' => $invoice->getBillerId(),
  1016.                                     )
  1017.                                 );
  1018.                             $billToDetails $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
  1019.                                 ->findOneBy(
  1020.                                     array(
  1021.                                         'applicantId' => $invoice->getBillToId(),
  1022.                                     )
  1023.                                 );
  1024.                         }
  1025.                         $bodyTemplate 'ApplicationBundle:email/templates:buddybeeInvoiceEmail.html.twig';
  1026.                         $bodyData = array(
  1027.                             'page_title' => 'Invoice',
  1028. //            'studentDetails' => $student,
  1029.                             'billerDetails' => $billerDetails,
  1030.                             'billToDetails' => $billToDetails,
  1031.                             'invoice' => $invoice,
  1032.                             'currencyList' => BuddybeeConstant::$currency_List,
  1033.                             'currencyListByMarker' => BuddybeeConstant::$currency_List_by_marker,
  1034.                         );
  1035.                         $attachments = [];
  1036.                         $forwardToMailAddress $billToDetails->getOAuthEmail();
  1037. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  1038.                         $new_mail $this->get('mail_module');
  1039.                         $new_mail->sendMyMail(array(
  1040.                             'senderHash' => '_CUSTOM_',
  1041.                             //                        'senderHash'=>'_CUSTOM_',
  1042.                             'forwardToMailAddress' => $forwardToMailAddress,
  1043.                             '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 ',
  1044. //                        'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
  1045.                             'attachments' => $attachments,
  1046.                             'toAddress' => $forwardToMailAddress,
  1047.                             'fromAddress' => 'no-reply@buddybee.eu',
  1048.                             'userName' => 'no-reply@buddybee.eu',
  1049.                             'password' => 'Honeybee@0112',
  1050.                             'smtpServer' => 'smtp.hostinger.com',
  1051.                             'smtpPort' => 465,
  1052. //                            'emailBody' => $bodyHtml,
  1053.                             'mailTemplate' => $bodyTemplate,
  1054.                             'templateData' => $bodyData,
  1055.                             'embedCompanyImage' => 0,
  1056.                             'companyId' => 0,
  1057.                             'companyImagePath' => ''
  1058. //                        'embedCompanyImage' => 1,
  1059. //                        'companyId' => $companyId,
  1060. //                        'companyImagePath' => $company_data->getImage()
  1061.                         ));
  1062.                     }
  1063.                 }
  1064.                 MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  1065.                 if ($meetingId != 0) {
  1066.                     $url $this->generateUrl(
  1067.                         'consultancy_session'
  1068.                     );
  1069.                     $output = [
  1070.                         'proceedToCheckout' => 0,
  1071.                         'invoiceId' => $gatewayInvoice->getId(),
  1072.                         'meetingId' => $meetingId,
  1073.                         'redirectUrl' => $url '/' $meetingId
  1074.                     ];
  1075.                 } else {
  1076.                     $url $this->generateUrl(
  1077.                         'buddybee_dashboard'
  1078.                     );
  1079.                     $output = [
  1080.                         'proceedToCheckout' => 0,
  1081.                         'invoiceId' => $gatewayInvoice->getId(),
  1082.                         'meetingId' => $meetingId,
  1083.                         'redirectUrl' => $url
  1084.                     ];
  1085.                 }
  1086.                 return new JsonResponse($output);
  1087.             }
  1088.         }
  1089.         $output = [
  1090.             'clientSecret' => 0,
  1091.             'id' => 0,
  1092.             'proceedToCheckout' => 0
  1093.         ];
  1094.         return new JsonResponse($output);
  1095. //        return $this->render('ApplicationBundle:pages/stripe:checkout.html.twig', array(
  1096. //            'page_title' => 'Checkout',
  1097. ////            'stripe' => $stripe,
  1098. //            'stripe' => null,
  1099. ////            'PaymentIntent' => $paymentIntent,
  1100. //
  1101. ////            'consultantDetail' => $consultantDetail,
  1102. ////            'consultantDetails'=> $consultantDetails,
  1103. ////
  1104. ////            'meetingSession' => $meetingSession,
  1105. ////            'packageDetails' => json_decode($meetingSession->getPcakageDetails(),true),
  1106. ////            'packageName' => json_decode($meetingSession->getPackageName(),true),
  1107. ////            'pay' => $payableAmount,
  1108. ////            'balance' => $currStudentBal
  1109. //        ));
  1110.     }
  1111.     public function AddEmployeeAction(Request $data$id=0)
  1112.     {
  1113.         $em $this->getDoctrine()->getManager();
  1114.         $skills $em->getRepository(Skill::class)->findAll();
  1115.         $session=$data->getSession();
  1116.         $ownOnly=0;
  1117. //        $session=$data->getSession()->get(UserConstants::USER_LOGIN_ID);
  1118.         $consultancyLevel HumanResourceConstant::$consultantLevel;
  1119.         $systemType $this->container->hasParameter('system_type') ? $this->container->getParameter('system_type') : '_ERP_';
  1120.         $banks $em->getRepository(BankList::class)->findAll();
  1121.         $bankListObj=[];
  1122.         $id=$data->request->get('employeeId',$id);
  1123.         foreach ($banks as $bank) {
  1124.             $bankListObj[$bank->getBankId()]=$bank->getName();
  1125.         }
  1126.         if($id === "my")
  1127.         {
  1128. //            return $this->redirectToRoute('permission_denied_page');
  1129. //            return new JsonResponse([$id]);
  1130.             $id=$session->get(UserConstants::USER_EMPLOYEE_ID);
  1131.             $ownOnly=1;
  1132.             if($id==|| $id==null)
  1133.             {
  1134.                 return $this->redirectToRoute('permission_denied_page');
  1135.             }
  1136.         }
  1137.         if ($id) {
  1138.             if ($data->isMethod('GET'))
  1139.             {
  1140.                 $Employee $this->getDoctrine()->getRepository(EmployeeDetails::class)->find($id);
  1141.                 if (!$Employee) {
  1142.                     $this->addFlash(
  1143.                         'error',
  1144.                         'Invalid User ID!'
  1145.                     );
  1146.                     return $this->redirectToRoute('add_employee');
  1147.                 } else {
  1148.                     $EmployeeRes HumanResource::TwigDataForAddEmployee($em$id);
  1149.                     $Employee $EmployeeRes['employee'];
  1150.                     $EmployeeMain $EmployeeRes['employeeMain'];
  1151.                     $sysUserId $EmployeeRes['sysId'];
  1152.                     $existingSysUser $sysUserId $em->getRepository('ApplicationBundle:SysUser')->find($sysUserId) : [];
  1153.                     $regionIdsArray json_decode($EmployeeMain->getRegionIds(), true) ?: [];
  1154.                     $regionLeaderFlagsArray json_decode($EmployeeMain->getRegionLeaderFlags(), true) ?: [];
  1155.                     $existingRegionAssociations = [];
  1156.                     if (!empty($regionIdsArray)) {
  1157.                         $regionRepo $this->getDoctrine()->getRepository('ApplicationBundle:Region');
  1158.                         $regions $regionRepo->findBy(['id' => $regionIdsArray]);
  1159.                         $regionMap = [];
  1160.                         foreach ($regions as $region) {
  1161.                             $regionMap[$region->getId()] = $region;
  1162.                         }
  1163.                         foreach ($regionIdsArray as $index => $regionId) {
  1164.                             if (!isset($regionMap[$regionId])) continue;
  1165.                             $region $regionMap[$regionId];
  1166.                             $existingRegionAssociations[] = [
  1167.                                 'regionLevelId' => $region->getRegionLevelId(),
  1168.                                 'regionId' => $region->getId(),
  1169.                                 'isLeader' => isset($regionLeaderFlagsArray[$index]) ? (int)$regionLeaderFlagsArray[$index] : 0
  1170.                             ];
  1171.                         }
  1172.                     }
  1173.                     $TwigData HumanResource::TwigDataForAddEmployee($em0);
  1174.                     return $this->render(
  1175.                         'ApplicationBundle:pages/human_resource/input_forms:add_employee.html.twig',
  1176.                         array(
  1177.                             'page_title' => 'Update Employee',
  1178.                             'ownOnly' => $ownOnly,
  1179.                             'branches' => $TwigData['branches'],
  1180.                             'bankListObj' => $bankListObj,
  1181.                             'heads' => Accounts::getLedgerHeadsWithParents($em),
  1182.                             'departments' => $TwigData['departments'],
  1183.                             'departmentPositions' => $TwigData['departmentPositions'],
  1184.                             'regions' => $TwigData['regions'],
  1185.                             'supervisors' => $TwigData['supervisors'],
  1186.                             'sysUsers' => $TwigData['sysUser'],
  1187.                             'EmploymentStatus' => $TwigData['EmploymentStatus'],
  1188.                             'sex' => $TwigData['sex'],
  1189.                             'BloodGroup' => $TwigData['BloodGroup'],
  1190.                             'days' => $TwigData['days'],
  1191.                             'employeeMain' => $EmployeeMain,
  1192.                             'employee' => $Employee,
  1193.                             'skills' => $skills,
  1194.                             'existingSysUser' => $existingSysUser,
  1195.                             'id' => $id,
  1196.                             'default_route' => $EmployeeRes['defaultRoute'],
  1197.                             'user_type' => $EmployeeRes['userType'],
  1198.                             'user_type_data' => HumanResourceConstant::$userType,
  1199.                             'AccountTypes' => $TwigData['AccountType'],
  1200.                             'weekends' => explode(','$Employee->getWeeklyHoliday()),
  1201.                             'consultancyLevel' => $consultancyLevel,
  1202.                             'module_data_array' => $TwigData['module_data_array'],
  1203.                             'HasUpdateMode' => true,
  1204.                             'brand_list' => Inventory::GetBrandList($em$this->getLoggedUserCompanyId($data)),
  1205.                             'branch_list' => Client::BranchList($this->getDoctrine()->getManager(), $this->getLoggedUserCompanyId($data)),
  1206.                             'region_data' => Client::RegionList($this->getDoctrine()->getManager(),  $this->getLoggedUserCompanyId($data)),
  1207.                             'leaveSettings' => $TwigData['leaveSettings'],
  1208.                             'leaveData'=>$EmployeeRes['leaveData'],
  1209.                             'positions' => $EmployeeRes['positions'],
  1210.                             'existing_region_associations' => $existingRegionAssociations
  1211.                         )
  1212.                     );
  1213.                 }
  1214.             } else {
  1215.                 $approveHash $data->request->get('approvalHash');
  1216.                 $loginId $data->getSession()->get(UserConstants::USER_LOGIN_ID);
  1217.                 $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  1218.                 $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Users/';
  1219.                 $image $data->files->get('img');
  1220.                 $profileImage $this->uploadImage($image,$data);
  1221.                 $path='';
  1222.                 if ($isSignatureOk) {
  1223.                     $CompanyId $this->getLoggedUserCompanyId($data);
  1224.                     $isSuccess HumanResource::StoreDataForAddEmployee($em$data$id$CompanyId,$profileImage);
  1225.                     if ($isSuccess) {
  1226.                         // $EmployeeDetails = $em->getRepository(EmployeeDetails::class)->find($id);
  1227.                         $Employee $em->getRepository(Employee::class)->find($id);
  1228.                         $EmployeeDetails $em->getRepository(EmployeeDetails::class)->findOneBy(
  1229.                             array(
  1230.                                 'id'=>$id
  1231.                             )
  1232.                         );
  1233.                         $sysUserId $isSuccess->getUserId();
  1234.                         $message $this->get('user_module')->updateUser(
  1235.                             $sysUserId,
  1236.                             $data->request->get('firstname') . " " $data->request->get('lastname'),
  1237.                             $data->request->has('email') ? $data->request->get('email') : '_UNCHANGED_',
  1238.                             $data->request->has('username') ? $data->request->get('username') : '_UNCHANGED_',
  1239.                             $data->request->get('password'),
  1240.                             1,
  1241.                             $data->request->get('user_type','_UNCHANGED_'),
  1242.                             $data->request->get('supervisor'),
  1243.                             $data->request->get('default_route'),
  1244.                             $data->request->get('branch'),
  1245.                             $data->request->has('access_module') ? 0,
  1246.                             $data->getSession()->get(UserConstants::USER_LOGIN_ID),
  1247.                             $data->request->get('global_user_id',null),
  1248.                             $profileImage,
  1249.                             $upl_dir
  1250.                         );
  1251.                         if(isset($message[0]) && $message[0] === 'success')
  1252.                         {
  1253.                             if ($systemType == '_CENTRAL_') {
  1254.                             } else {
  1255.                                 $em_goc $this->getDoctrine()->getManager('company_group');
  1256.                                 $em_goc->getConnection()->connect();
  1257.                                 $connected $em_goc->getConnection()->isConnected();
  1258.                                 $gocDataList = [];
  1259.                                 $gocDataListByAppId = [];
  1260.                                 $retDataDebug = array();
  1261.                                 $appIds $message[3]->getUserAppId();
  1262.                                 $userIds $message[3]->getUserId();
  1263.                                 if ($connected) {
  1264.                                     $findByQuery = array(
  1265.                                         'active' => 1
  1266.                                     );
  1267.                                     if ($appIds !== '_UNSET_')
  1268.                                         $findByQuery['appId'] = $appIds;
  1269.                                     $gocList $this->getDoctrine()->getManager('company_group')
  1270.                                         ->getRepository("CompanyGroupBundle:CompanyGroup")
  1271.                                         ->findBy($findByQuery);
  1272.                                     foreach ($gocList as $entry) {
  1273.                                         $d = array(
  1274.                                             'name' => $entry->getName(),
  1275.                                             'id' => $entry->getId(),
  1276.                                             'image' => $entry->getImage(),
  1277.                                             'companyGroupHash' => $entry->getCompanyGroupHash(),
  1278.                                             'dbName' => $entry->getDbName(),
  1279.                                             'dbUser' => $entry->getDbUser(),
  1280.                                             'dbPass' => $entry->getDbPass(),
  1281.                                             'dbHost' => $entry->getDbHost(),
  1282.                                             'appId' => $entry->getAppId(),
  1283.                                             'companyRemaining' => $entry->getCompanyRemaining(),
  1284.                                             'companyAllowed' => $entry->getCompanyAllowed(),
  1285.                                         );
  1286.                                         $gocDataList[$entry->getId()] = $d;
  1287.                                         $gocDataListByAppId[$entry->getAppId()] = $d;
  1288.                                     }
  1289.                                     $debugCount 0;
  1290.                                     foreach ($gocDataList as $gocId => $entry) {
  1291. //                    if($debugCount>0)
  1292. //                        continue;
  1293.                                         $skipSend 1;
  1294.                                         $connector $this->container->get('application_connector');
  1295.                                         $connector->resetConnection(
  1296.                                             'default',
  1297.                                             $gocDataList[$gocId]['dbName'],
  1298.                                             $gocDataList[$gocId]['dbUser'],
  1299.                                             $gocDataList[$gocId]['dbPass'],
  1300.                                             $gocDataList[$gocId]['dbHost'],
  1301.                                             $reset true);
  1302.                                         $em $this->getDoctrine()->getManager();
  1303.                                         if ($userIds !== '_UNSET_')
  1304.                                             $users $this->getDoctrine()
  1305.                                                 ->getRepository('ApplicationBundle:SysUser')
  1306.                                                 ->findBy(
  1307.                                                     array(
  1308.                                                         'userId' => $userIds
  1309.                                                     )
  1310.                                                 );
  1311.                                         else
  1312.                                             $users $this->getDoctrine()
  1313.                                                 ->getRepository('ApplicationBundle:SysUser')
  1314.                                                 ->findBy(
  1315.                                                     array()
  1316.                                                 );
  1317.                                         $output '';
  1318.                                         $userData = array();
  1319.                                         $userFiles = array();
  1320.                                         foreach ($users as $user) {
  1321.                                             $file $this->container->getParameter('kernel.root_dir') . '/../web/' $user->getImage(); //<-- Path could be relative
  1322. //                            $output=$file;
  1323.                                             if ($user->getImage() != '' && $user->getImage() != null && file_exists($file)) {
  1324. //                        $file = new \CURLFile($this->container->getParameter('kernel.root_dir') . '/../web/uploads/CompanyImage/' . $company->getImage()); //<-- Path could be relative
  1325.                                                 $mime mime_content_type($file);
  1326.                                                 $info pathinfo($file);
  1327.                                                 $name $info['basename'];
  1328.                                                 if (strpos($mime'image') !== false) {
  1329.                                                     $output = new \CURLFile($file$mime$name);
  1330.                                                 }
  1331.                                                 $skipSend 0;
  1332.                                                 $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = $output;
  1333.                                             } else {
  1334. //                                    unlink($this->container->getParameter('kernel.root_dir') . '/../web'. $centralUser->getImage());
  1335.                                                 $user->setImage(null);
  1336.                                                 $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = 'pika';
  1337.                                                 $em->flush();
  1338.                                             }
  1339.                                             $getters array_filter(get_class_methods($user), function ($method) {
  1340.                                                 return 'get' === substr($method03);
  1341.                                             });
  1342.                                             $userDataSingle = array(//                                'file'=>$output
  1343.                                             );
  1344.                                             foreach ($getters as $getter) {
  1345.                                                 if ($getter == 'getCreatedAt' || $getter == 'getUpdatedAt' || $getter == 'getImage')
  1346.                                                     continue;
  1347. //                                if(is_string($user->{$getter}())|| is_numeric($user->{$getter}()))
  1348. //                                {
  1349. //                                    $userDataSingle[$getter]= $user->{$getter}();
  1350. //                                }
  1351.                                                 if ($user->{$getter}() instanceof \DateTime) {
  1352.                                                     $ggtd $user->{$getter}();
  1353.                                                     $userDataSingle[$getter] = $ggtd->format('Y-m-d');
  1354.                                                 } else
  1355.                                                     $userDataSingle[$getter] = $user->{$getter}();
  1356.                                             }
  1357.                                             $employeeGetters = array(
  1358.                                                 'getFirstname''getLastname''getImage''getIsImgLegal''getNid''getDob''getSex''getReligion''getFather',
  1359.                                                 'getMother''getSpouse''getChild1''getChild2''getBlood''getPhone''getOfficailPhone''getCurrAddr',
  1360.                                                 'getCurrAddrLat''getCurrAddrLng''getPermAddr''getEmmContact''getUsername''getEmail''getPassword',
  1361.                                                 'getUserId''getJoiningDate''getEmpValidTill''getEmpStatus''getEmpType''getEmpCode''getEmpLabel''getTin',
  1362.                                                 'getTinValidTill''getMedIns''getMedInsValidTill''getDocs''getNocApproval''getInst1''getYr1''getDur1',
  1363.                                                 'getInst2''getYr2''getDur2''getInst3''getYr3''getDur3''getEinst1''getEyr1''getEdeg1''getEinst2',
  1364.                                                 'getEyr2''getEdeg2''getEinst3''getEyr3''getEdeg3''getBankAcc''getBankAccType''getBankAccValidFrom',
  1365.                                                 'getBankAccValidTo''getRoutingCode''getSwiftCode''getEar1''getEar2''getEar3''getEar4''getEar5''getEar6',
  1366.                                                 'getEart''getDed1''getDed2''getDed3''getDed4''getDedt''getPayable''getHandCash''getBankTransfer',
  1367.                                                 'getSecDep''getSecDepSpan''getSecDepRemMon''getSecDepRemAmount''getSlQty''getSlTkn''getSlFreq''getMlQty',
  1368.                                                 'getMlTkn''getMlFreq''getElQty''getElTkn''getElFreq''getClQty''getClTkn''getClFreq''getLevt',
  1369.                                                 'getWeeklyHoliday''getFiles''getSupervisor''getDept''getDesg''getBranch''getDivision''getCreatedAt',
  1370.                                                 'getUpdatedAt''getEmployeeLevel''getSkill''getProbationaryPeriod''getDocBookedFlag''getTimeStampOfForm',
  1371.                                                 'getIsConsultant''getConsultantLevel''getApplicationText''getCurrentEmployment''getEmergencyContactNumber',
  1372.                                                 'getPostalCode''getCountry''getEducationData''getWorkExperienceData''getCertificateData''getLanguagesData',
  1373.                                                 'getBeneficiaryName''getBankName''getBranchName''getClockedIn'
  1374.                                             );
  1375.                                             foreach ($employeeGetters as $getter) {
  1376.                                                 if (!method_exists($EmployeeDetails$getter)) continue;
  1377.                                                 try {
  1378.                                                     $value $EmployeeDetails->{$getter}();
  1379.                                                     if ($value instanceof \DateTime) {
  1380.                                                         $userDataSingle[$getter] = $value->format('Y-m-d');
  1381.                                                     } elseif (is_object($value)) {
  1382.                                                         continue; // skip non-scalar objects
  1383.                                                     } else {
  1384.                                                         $userDataSingle[$getter] = $value;
  1385.                                                     }
  1386.                                                 } catch (\Exception $e) {
  1387.                                                     continue;
  1388.                                                 }
  1389.                                             }
  1390. //                                            $userDataSingle['getNid']=$EmployeeDetails->getNid();
  1391. //                                            $userDataSingle['getDob']=$EmployeeDetails->getDob();
  1392. //                                            $userDataSingle['getSex']=$EmployeeDetails->getSex();
  1393. //                                            $userDataSingle['getCurrAddr'] = $EmployeeDetails->getCurrAddr();
  1394.                                             $userData[] = $userDataSingle;
  1395.                                         }
  1396.                                         $retDataDebug[$debugCount] = array(
  1397.                                             'skipSend' => $skipSend
  1398.                                         );
  1399. //                    if ($skipSend == 0)
  1400.                                         {
  1401.                                             $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/SyncUserToCentralUser';
  1402.                                             $userFiles['userData'] = json_encode($userData);
  1403.                                             $curl curl_init();
  1404.                                             curl_setopt_array($curl, array(
  1405.                                                 CURLOPT_RETURNTRANSFER => 1,
  1406.                                                 CURLOPT_POST => 1,
  1407.                                                 CURLOPT_URL => $urlToCall,
  1408.                                                 CURLOPT_CONNECTTIMEOUT => 10,
  1409.                                                 CURLOPT_SSL_VERIFYPEER => false,
  1410.                                                 CURLOPT_SSL_VERIFYHOST => false,
  1411. //                            CURLOPT_SAFE_UPLOAD => false,
  1412.                                                 CURLOPT_HTTPHEADER => array(//                                "Accept: multipart/form-data",
  1413.                                                 ),
  1414.                                                 //                        CURLOPT_USERAGENT => 'InnoPM',
  1415. //                            CURLOPT_POSTFIELDS => array(
  1416. //                                'userData'=>json_encode($userData),
  1417. //                                'userFiles'=>$userFiles
  1418. //                            ),
  1419.                                                 CURLOPT_POSTFIELDS => $userFiles
  1420.                                             ));
  1421.                                             $retData curl_exec($curl);
  1422.                                             $errData curl_error($curl);
  1423.                                             curl_close($curl);
  1424.                                             $retDataObj json_decode($retDatatrue);
  1425.                                             $retDataDebug[$debugCount] = $retDataObj;
  1426.                                             if (isset($retDataObj['globalIdsData']))
  1427.                                                 foreach ($retDataObj['globalIdsData'] as $app_id => $usrList) {
  1428.                                                     $connector $this->container->get('application_connector');
  1429.                                                     $connector->resetConnection(
  1430.                                                         'default',
  1431.                                                         $gocDataListByAppId[$app_id]['dbName'],
  1432.                                                         $gocDataListByAppId[$app_id]['dbUser'],
  1433.                                                         $gocDataListByAppId[$app_id]['dbPass'],
  1434.                                                         $gocDataListByAppId[$app_id]['dbHost'],
  1435.                                                         $reset true);
  1436.                                                     $em $this->getDoctrine()->getManager();
  1437.                                                     foreach ($usrList as $sys_id => $globaldata) {
  1438.                                                         $user $this->getDoctrine()
  1439.                                                             ->getRepository('ApplicationBundle:SysUser')
  1440.                                                             ->findOneBy(
  1441.                                                                 array(
  1442.                                                                     'userId' => $sys_id
  1443.                                                                 )
  1444.                                                             );
  1445.                                                         if ($user) {
  1446.                                                             $user->setGlobalId($globaldata['gid']);
  1447.                                                             $em->flush();
  1448.                                                         }
  1449.                                                     }
  1450.                                                 }
  1451.                                         }
  1452.                                         $debugCount++;
  1453.                                     }
  1454.                                 }
  1455. //                    return new JsonResponse($retDataDebug);
  1456.                             }
  1457.                         }
  1458.                         else {
  1459.                             $errorMsg $message['message'] ?? 'Unknown error occurred.';
  1460.                             $this->addFlash('error'$errorMsg);
  1461.                             return $this->redirectToRoute('add_employee');
  1462.                         }
  1463.                         // $SysUserRepo = $em->getRepository(SysUser::class);
  1464.                         // $SysUser = $SysUserRepo->findOneBy(array(
  1465.                         //   'email' => $data->request->get('email')
  1466.                         // ));
  1467.                         // $isSuccess->setUserId($SysUser->getUserId());
  1468.                         // $em->persist($isSuccess);
  1469.                         // $em->flush();
  1470.                         // $companyData = $message[2];
  1471.                         // $emailmessage = (new \Swift_Message('Update to Entity'))
  1472.                         //   ->setFrom('registration@entity.innobd.com')
  1473.                         //   ->setTo($data->request->get('email'))
  1474.                         //   ->setBody(
  1475.                         //     $this->renderView(
  1476.                         //       'ApplicationBundle:email/user:registration.html.twig',
  1477.                         //       array(
  1478.                         //         'name' => $data->request->get('name'),
  1479.                         //         'companyData' => $companyData,
  1480.                         //         'userName' => $data->request->get('email'),
  1481.                         //         'password' => $data->request->get('password'),
  1482.                         //       )
  1483.                         //     ),
  1484.                         //     'text/html'
  1485.                         //   );
  1486.                         // $this->get('mailer')->send($emailmessage);
  1487.                         $userType $data->getSession()->get(UserConstants::USER_TYPE);
  1488.                         $redirctUrl $this->generateUrl('employee_list', [], UrlGenerator::ABSOLUTE_URL);
  1489.                         if ($userType == 1) {
  1490.                             $redirctUrl $this->generateUrl('employee_list', [], UrlGenerator::ABSOLUTE_URL);
  1491.                         } else {
  1492.                             $redirctUrl $this->generateUrl('edit_employee', [], UrlGenerator::ABSOLUTE_URL).'/my';
  1493.                         }
  1494.                         return new JsonResponse(array(
  1495.                             'employeeId'=> $Employee->getEmployeeId(),
  1496.                             'redirectToNew'=>0,
  1497.                             'success'=>true,
  1498.                             'redirectUrl'=>$redirctUrl,
  1499.                         ));
  1500.                     }
  1501.                 } else {
  1502.                     $this->addFlash(
  1503.                         'error',
  1504.                         'Invalid Approval Hash!'
  1505.                     );
  1506.                     return $this->redirectToRoute('add_employee');
  1507.                 }
  1508.             }
  1509.         }
  1510.         else {
  1511.             if ($data->isMethod('GET')) {
  1512.                 $TwigData HumanResource::TwigDataForAddEmployee($em0);
  1513.                 $existingRegionAssociations = [];
  1514.                 return $this->render(
  1515.                     'ApplicationBundle:pages/human_resource/input_forms:add_employee.html.twig',
  1516.                     array(
  1517.                         'page_title' => 'Add Employee',
  1518.                         'ownOnly' => $ownOnly,
  1519.                         'heads' => Accounts::getLedgerHeadsWithParents($em),
  1520.                         'bankListObj' => $bankListObj,
  1521.                         'branches' => $TwigData['branches'],
  1522.                         'departments' => $TwigData['departments'],
  1523.                         'departmentPositions' => $TwigData['departmentPositions'],
  1524.                         'regions' => $TwigData['regions'],
  1525.                         'supervisors' => $TwigData['supervisors'],
  1526.                         'sysUsers' => $TwigData['sysUser'],
  1527.                         'EmploymentStatus' => $TwigData['EmploymentStatus'],
  1528.                         'sex' => $TwigData['sex'],
  1529.                         'skills' => $skills,
  1530.                         'id' => $id,
  1531.                         'consultancyLevel' => $consultancyLevel,
  1532.                         'existingSysUser' => null,
  1533.                         'BloodGroup' => $TwigData['BloodGroup'],
  1534.                         'days' => $TwigData['days'],
  1535.                         'AccountTypes' => $TwigData['AccountType'],
  1536.                         'module_data_array' => $TwigData['module_data_array'],
  1537.                         'user_type_data' => HumanResourceConstant::$userType,
  1538.                         'HasUpdateMode' => false,
  1539.                         'brand_list' => Inventory::GetBrandList($em$this->getLoggedUserCompanyId($data)),
  1540.                         'leaveSettings'=>$TwigData['leaveSettings'],
  1541.                         'employee'=>[],
  1542.                         'positions' => $TwigData['positions'],
  1543.                         'existing_region_associations' => $existingRegionAssociations ?? [],
  1544.                         'branch_list' => Client::BranchList($this->getDoctrine()->getManager(), $this->getLoggedUserCompanyId($data)),
  1545.                         'region_data' => Client::RegionList($this->getDoctrine()->getManager(),  $this->getLoggedUserCompanyId($data)),
  1546.                     )
  1547.                 );
  1548.             }
  1549.             else {
  1550.                 $approveHash $data->request->get('approvalHash');
  1551.                 $loginId $data->getSession()->get(UserConstants::USER_LOGIN_ID);
  1552.                 $CompanyId $this->getLoggedUserCompanyId($data);
  1553.                 $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  1554.                 $isSuccess HumanResource::StoreDataForAddEmployee($em$datafalse$CompanyId);
  1555.                 $Employee $isSuccess;
  1556.                 $EmployeeDetails $em->getRepository(EmployeeDetails::class)->findOneBy(
  1557.                     array(
  1558.                         'id'=>$id
  1559.                     )
  1560.                 );
  1561.                 $isUserExist $em->getRepository(EmployeeDetails::class)
  1562.                     ->findOneBy(array('email' => $data->request->get('email')));
  1563.                 if ($isSignatureOk) {
  1564.                     if ($isUserExist) {
  1565.                                 if($isSuccess){
  1566.                                     $message $this->get('user_module')->addNewUser(
  1567.                                         $data->request->get('firstname') . " " $data->request->get('lastname'),
  1568.                                         $data->request->get('email'),
  1569.                                         $data->request->get('username'),
  1570.                                         $data->request->get('password'),
  1571.                                         $data->request->get('desg'),
  1572.                                         $this->getLoggedUserLoginId($data),
  1573.                                         $data->request->get('company'),
  1574.                                         $data->request->get('user_type'),
  1575.                                         $data->request->get('companyIdList'),
  1576.                                         $data->request->get('branch'),
  1577.                                         $data->request->get('supervisor'),
  1578.                                         $data->request->get('default_route'),
  1579.                                         $data->request->has('access_module') ? 0,
  1580.                                         "",
  1581.                                         $data->files->get('img'), ''00,
  1582.                                         '''',''0'',0,$data->request->get('global_user_id',null)
  1583.                                     );
  1584.                                     if($message[0]=='success')
  1585.                                     {
  1586.                                         $Employee->setUserId($message[3]->getUserId());
  1587.                                         $em->persist($Employee);
  1588.                                         if ($EmployeeDetails) {
  1589.                                             $EmployeeDetails->setUserId($message[3]->getUserId());
  1590.                                             $em->persist($EmployeeDetails);
  1591.                                         }
  1592.                                         $em->flush();
  1593.                                         if ($systemType == '_CENTRAL_') {
  1594.                                         } else {
  1595.                                             $em_goc $this->getDoctrine()->getManager('company_group');
  1596.                                             $em_goc->getConnection()->connect();
  1597.                                             $connected $em_goc->getConnection()->isConnected();
  1598.                                             $gocDataList = [];
  1599.                                             $gocDataListByAppId = [];
  1600.                                             $retDataDebug = array();
  1601.                                             $appIds $message[2]->getAppId();
  1602.                                             $userIds $message[3]->getUserId();
  1603.                                             if ($connected) {
  1604.                                                 $findByQuery = array(
  1605.                                                     'active' => 1
  1606.                                                 );
  1607.                                                 if ($appIds !== '_UNSET_')
  1608.                                                     $findByQuery['appId'] = $appIds;
  1609.                                                 $gocList $this->getDoctrine()->getManager('company_group')
  1610.                                                     ->getRepository("CompanyGroupBundle:CompanyGroup")
  1611.                                                     ->findBy($findByQuery);
  1612.                                                 foreach ($gocList as $entry) {
  1613.                                                     $d = array(
  1614.                                                         'name' => $entry->getName(),
  1615.                                                         'id' => $entry->getId(),
  1616.                                                         'image' => $entry->getImage(),
  1617.                                                         'companyGroupHash' => $entry->getCompanyGroupHash(),
  1618.                                                         'dbName' => $entry->getDbName(),
  1619.                                                         'dbUser' => $entry->getDbUser(),
  1620.                                                         'dbPass' => $entry->getDbPass(),
  1621.                                                         'dbHost' => $entry->getDbHost(),
  1622.                                                         'appId' => $entry->getAppId(),
  1623.                                                         'companyRemaining' => $entry->getCompanyRemaining(),
  1624.                                                         'companyAllowed' => $entry->getCompanyAllowed(),
  1625.                                                     );
  1626.                                                     $gocDataList[$entry->getId()] = $d;
  1627.                                                     $gocDataListByAppId[$entry->getAppId()] = $d;
  1628.                                                 }
  1629.                                                 $debugCount 0;
  1630.                                                 foreach ($gocDataList as $gocId => $entry) {
  1631.                                                     $skipSend 1;
  1632.                                                     $connector $this->container->get('application_connector');
  1633.                                                     $connector->resetConnection(
  1634.                                                         'default',
  1635.                                                         $gocDataList[$gocId]['dbName'],
  1636.                                                         $gocDataList[$gocId]['dbUser'],
  1637.                                                         $gocDataList[$gocId]['dbPass'],
  1638.                                                         $gocDataList[$gocId]['dbHost'],
  1639.                                                         $reset true);
  1640.                                                     $em $this->getDoctrine()->getManager();
  1641.                                                     if ($userIds !== '_UNSET_')
  1642.                                                         $users $this->getDoctrine()
  1643.                                                             ->getRepository('ApplicationBundle:SysUser')
  1644.                                                             ->findBy(
  1645.                                                                 array(
  1646.                                                                     'userId' => $userIds
  1647.                                                                 )
  1648.                                                             );
  1649.                                                     else
  1650.                                                         $users $this->getDoctrine()
  1651.                                                             ->getRepository('ApplicationBundle:SysUser')
  1652.                                                             ->findBy(
  1653.                                                                 array()
  1654.                                                             );
  1655.                                                     $output '';
  1656.                                                     $userData = array();
  1657.                                                     $userFiles = array();
  1658.                                                     foreach ($users as $user) {
  1659.                                                         $file $this->container->getParameter('kernel.root_dir') . '/../web/' $user->getImage();
  1660.                                                         if ($user->getImage() != '' && $user->getImage() != null && file_exists($file)) {
  1661.                                                             $mime mime_content_type($file);
  1662.                                                             $info pathinfo($file);
  1663.                                                             $name $info['basename'];
  1664.                                                             if (strpos($mime'image') !== false) {
  1665.                                                                 $output = new \CURLFile($file$mime$name);
  1666.                                                             }
  1667.                                                             $skipSend 0;
  1668.                                                             $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = $output;
  1669.                                                         } else {
  1670.                                                             $user->setImage(null);
  1671.                                                             $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = 'pika';
  1672.                                                             $em->flush();
  1673.                                                         }
  1674.                                                         $getters array_filter(get_class_methods($user), function ($method) {
  1675.                                                             return 'get' === substr($method03);
  1676.                                                         });
  1677.                                                         $userDataSingle = array(
  1678.                                                         );
  1679.                                                         foreach ($getters as $getter) {
  1680.                                                             if ($getter == 'getCreatedAt' || $getter == 'getUpdatedAt' || $getter == 'getImage')
  1681.                                                                 continue;
  1682. //                                if(is_string($user->{$getter}())|| is_numeric($user->{$getter}()))
  1683. //                                {
  1684. //                                    $userDataSingle[$getter]= $user->{$getter}();
  1685. //                                }
  1686.                                                             if ($user->{$getter}() instanceof \DateTime) {
  1687.                                                                 $ggtd $user->{$getter}();
  1688.                                                                 $userDataSingle[$getter] = $ggtd->format('Y-m-d');
  1689.                                                             } else
  1690.                                                                 $userDataSingle[$getter] = $user->{$getter}();
  1691.                                                         }
  1692.                                                         $employeeGetters = array(
  1693.                                                             'getFirstname''getLastname''getImage''getIsImgLegal''getNid''getDob''getSex''getReligion''getFather',
  1694.                                                             'getMother''getSpouse''getChild1''getChild2''getBlood''getPhone''getOfficailPhone''getCurrAddr',
  1695.                                                             'getCurrAddrLat''getCurrAddrLng''getPermAddr''getEmmContact''getUsername''getEmail''getPassword',
  1696.                                                             'getUserId''getJoiningDate''getEmpValidTill''getEmpStatus''getEmpType''getEmpCode''getEmpLabel''getTin',
  1697.                                                             'getTinValidTill''getMedIns''getMedInsValidTill''getDocs''getNocApproval''getInst1''getYr1''getDur1',
  1698.                                                             'getInst2''getYr2''getDur2''getInst3''getYr3''getDur3''getEinst1''getEyr1''getEdeg1''getEinst2',
  1699.                                                             'getEyr2''getEdeg2''getEinst3''getEyr3''getEdeg3''getBankAcc''getBankAccType''getBankAccValidFrom',
  1700.                                                             'getBankAccValidTo''getRoutingCode''getSwiftCode''getEar1''getEar2''getEar3''getEar4''getEar5''getEar6',
  1701.                                                             'getEart''getDed1''getDed2''getDed3''getDed4''getDedt''getPayable''getHandCash''getBankTransfer',
  1702.                                                             'getSecDep''getSecDepSpan''getSecDepRemMon''getSecDepRemAmount''getSlQty''getSlTkn''getSlFreq''getMlQty',
  1703.                                                             'getMlTkn''getMlFreq''getElQty''getElTkn''getElFreq''getClQty''getClTkn''getClFreq''getLevt',
  1704.                                                             'getWeeklyHoliday''getFiles''getSupervisor''getDept''getDesg''getBranch''getDivision''getCreatedAt',
  1705.                                                             'getUpdatedAt''getEmployeeLevel''getSkill''getProbationaryPeriod''getDocBookedFlag''getTimeStampOfForm',
  1706.                                                             'getIsConsultant''getConsultantLevel''getApplicationText''getCurrentEmployment''getEmergencyContactNumber',
  1707.                                                             'getPostalCode''getCountry''getEducationData''getWorkExperienceData''getCertificateData''getLanguagesData',
  1708.                                                             'getBeneficiaryName''getBankName''getBranchName''getClockedIn'
  1709.                                                         );
  1710.                                                         foreach ($employeeGetters as $getter) {
  1711.                                                             if (!method_exists($EmployeeDetails$getter)) continue;
  1712.                                                             try {
  1713.                                                                 $value $EmployeeDetails->{$getter}();
  1714.                                                                 if ($value instanceof \DateTime) {
  1715.                                                                     $userDataSingle[$getter] = $value->format('Y-m-d');
  1716.                                                                 } elseif (is_object($value)) {
  1717.                                                                     continue; // skip non-scalar objects
  1718.                                                                 } else {
  1719.                                                                     $userDataSingle[$getter] = $value;
  1720.                                                                 }
  1721.                                                             } catch (\Exception $e) {
  1722.                                                                 continue;
  1723.                                                             }
  1724.                                                         }
  1725. //                                                    $userDataSingle['getNid']=$Employee->getNid();
  1726. //                                                    $userDataSingle['getCurrAddr'] = $Employee->getCurrAddr();
  1727.                                                         $userData[] = $userDataSingle;
  1728.                                                     }
  1729.                                                     $retDataDebug[$debugCount] = array(
  1730.                                                         'skipSend' => $skipSend
  1731.                                                     );
  1732.                                                     {
  1733.                                                         $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/SyncUserToCentralUser';
  1734.                                                         $userFiles['userData'] = json_encode($userData);
  1735.                                                         $curl curl_init();
  1736.                                                         curl_setopt_array($curl, array(
  1737.                                                             CURLOPT_RETURNTRANSFER => 1,
  1738.                                                             CURLOPT_POST => 1,
  1739.                                                             CURLOPT_URL => $urlToCall,
  1740.                                                             CURLOPT_CONNECTTIMEOUT => 10,
  1741.                                                             CURLOPT_SSL_VERIFYPEER => false,
  1742.                                                             CURLOPT_SSL_VERIFYHOST => false,
  1743. //                            CURLOPT_SAFE_UPLOAD => false,
  1744.                                                             CURLOPT_HTTPHEADER => array(//                                "Accept: multipart/form-data",
  1745.                                                             ),
  1746.                                                             //                        CURLOPT_USERAGENT => 'InnoPM',
  1747. //                            CURLOPT_POSTFIELDS => array(
  1748. //                                'userData'=>json_encode($userData),
  1749. //                                'userFiles'=>$userFiles
  1750. //                            ),
  1751.                                                             CURLOPT_POSTFIELDS => $userFiles
  1752.                                                         ));
  1753.                                                         $retData curl_exec($curl);
  1754.                                                         $errData curl_error($curl);
  1755.                                                         curl_close($curl);
  1756.                                                         $response = [];
  1757.                                                         if ($errData) {
  1758.                                                             $response['status'] = 'error';
  1759.                                                             $response['message'] = 'cURL Error: ' $errData;
  1760.                                                         } else {
  1761.                                                             $retDataObj json_decode($retDatatrue);
  1762.                                                             if (!$retDataObj) {
  1763.                                                                 $response['status'] = 'error';
  1764.                                                                 $response['message'] = 'Invalid response from central server';
  1765.                                                                 $response['raw_response'] = $retData;
  1766.                                                             } else {
  1767.                                                                 $response['status'] = 'success';
  1768.                                                                 $response['data'] = $retDataObj;
  1769.                                                             }
  1770.                                                         }
  1771. // Return JSON response
  1772. //                                                    return new JsonResponse($response);
  1773.                                                         $retDataDebug[$debugCount] = $retDataObj;
  1774.                                                         if (isset($retDataObj['globalIdsData']))
  1775.                                                             foreach ($retDataObj['globalIdsData'] as $app_id => $usrList) {
  1776.                                                                 $connector $this->container->get('application_connector');
  1777.                                                                 $connector->resetConnection(
  1778.                                                                     'default',
  1779.                                                                     $gocDataListByAppId[$app_id]['dbName'],
  1780.                                                                     $gocDataListByAppId[$app_id]['dbUser'],
  1781.                                                                     $gocDataListByAppId[$app_id]['dbPass'],
  1782.                                                                     $gocDataListByAppId[$app_id]['dbHost'],
  1783.                                                                     $reset true);
  1784.                                                                 $em $this->getDoctrine()->getManager();
  1785.                                                                 foreach ($usrList as $sys_id => $globaldata) {
  1786.                                                                     $user $this->getDoctrine()
  1787.                                                                         ->getRepository('ApplicationBundle:SysUser')
  1788.                                                                         ->findOneBy(
  1789.                                                                             array(
  1790.                                                                                 'userId' => $sys_id
  1791.                                                                             )
  1792.                                                                         );
  1793.                                                                     if ($user) {
  1794.                                                                         $user->setGlobalId($globaldata['gid']);
  1795.                                                                         $em->persist($user);
  1796.                                                                         $em->flush();
  1797.                                                                     }
  1798.                                                                 }
  1799.                                                             }
  1800.                                                     }
  1801.                                                     $debugCount++;
  1802.                                                 }
  1803.                                             }
  1804. //                    return new JsonResponse($retDataDebug);
  1805.                                         }
  1806.                                     }
  1807.                                     else if($message[0] == 'error'){
  1808.                                         $this->addFlash(
  1809.                                             'error',
  1810.                                             'Invalid Approval Hash!'
  1811.                                         );
  1812.                                     }
  1813. //                                    if($message[0]=='success'){
  1814. //                                        $SysUserRepo = $em->getRepository('ApplicationBundle:SysUser');
  1815. //                                        $SysUser = $SysUserRepo->findOneBy([
  1816. //                                            'email' => $data->request->get('email')
  1817. //                                        ]);
  1818. //
  1819. //                                        if ($SysUser === null) {
  1820. //                                            throw new \Exception("User with email " . $data->request->get('email') . " not found.");
  1821. //                                        }
  1822. //
  1823. //                                        $isSuccess->setUserId($SysUser->getUserId());
  1824. //                                        $em->persist($isSuccess);
  1825. //                                        $em->flush();
  1826. //                                    }
  1827.                                     $companyData $message[2];
  1828.                                     if ($message[0] == 'success' && GeneralConstant::EMAIL_ENABLED == 1) {
  1829.                                         $bodyHtml '';
  1830.                                         $bodyTemplate 'ApplicationBundle:email/user:registration.html.twig';
  1831.                                         $bodyData = array(
  1832.                                             'name' => $data->request->get('name'),
  1833.                                             'companyData' => $companyData,
  1834.                                             'userName' => $data->request->get('username'),
  1835.                                             'password' => $data->request->get('password'),
  1836.                                         );
  1837.                                         $attachments = [];
  1838.                                         $new_mail $this->get('mail_module');
  1839.                                         $new_mail->sendMyMail(array(
  1840.                                             'senderHash' => '_CUSTOM_',
  1841.                                             //                        'senderHash'=>'_CUSTOM_',
  1842.                                             'forwardToMailAddress' => $data->request->get('email'),
  1843.                                             'fromAddress' => 'no-reply@ourhoneybee.eu',
  1844.                                             'userName' => 'no-reply@ourhoneybee.eu',
  1845.                                             'password' => 'Honeybee@0112',
  1846.                                             'smtpServer' => 'smtp.hostinger.com',
  1847.                                             'smtpPort' => 465,
  1848.                                             'subject' => 'User Registration on HoneyBee Ecosystem under Entity ' $companyData->getName(),
  1849.                                             'fileName' => '',
  1850.                                             'attachments' => $attachments,
  1851.                                             'toAddress' => $data->request->get('email'),
  1852.                                             'mailTemplate' => $bodyTemplate,
  1853.                                             'templateData' => $bodyData,
  1854.                                             'embedCompanyImage' => 1,
  1855.                                             'companyId' => $data->request->get('company'),
  1856.                                             'companyImagePath' => $companyData->getImage()
  1857.                                         ));
  1858.                                     }
  1859.                                 }
  1860.                         $this->addFlash(
  1861.                             'success',
  1862.                             'New Employee Successfully Added!'
  1863.                         );
  1864.                         $userType $data->getSession()->get(UserConstants::USER_TYPE);
  1865.                         $redirctUrl $this->generateUrl('employee_list', [], UrlGenerator::ABSOLUTE_URL);
  1866.                         if ($userType == 1) {
  1867.                             $redirctUrl $this->generateUrl('employee_list', [], UrlGenerator::ABSOLUTE_URL);
  1868.                         } else {
  1869.                             $redirctUrl $this->generateUrl('add_employee', [], UrlGenerator::ABSOLUTE_URL);
  1870.                         }
  1871.                         return new JsonResponse(array(
  1872.                             'employeeId'=> $Employee->getEmployeeId(),
  1873.                             'redirectToNew'=>1,
  1874.                             'success'=>true,
  1875.                             'redirectUrl'=>$redirctUrl,
  1876.                         ));
  1877. //                        return $this->redirectToRoute('add_employee');
  1878.                     }
  1879.                     else {
  1880. //                        $requiredFields = [
  1881. //                            'email', 'username', 'password', 'firstname', 'lastname', 'nid', 'dob',
  1882. //                            'sex', 'blood', 'phone', 'perm_addr', 'dept', 'desg', 'branch',
  1883. //                            'emp_type', 'tin'
  1884. //                        ];
  1885. //
  1886. //                        $missingFields = [];
  1887. //
  1888. //                        foreach ($requiredFields as $field) {
  1889. //                            if (!$data->request->get($field)) {
  1890. //                                $missingFields[] = $field;
  1891. //                            }
  1892. //                        }
  1893. //                        if (!empty($missingFields)) {
  1894. //                            $this->addFlash('error', 'Missing fields: ' . implode(', ', $missingFields));
  1895. //                            return $this->redirectToRoute('add_employee');
  1896. //                        }
  1897. //                        $password = $data->request->get('password');
  1898. //                        $passwordPattern = '/^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[\W_]).{8,}$/';
  1899. //                        if (!preg_match($passwordPattern, $password)) {
  1900. //                            $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));
  1901. //                            return $this->redirectToRoute('add_employee');
  1902. //                        }
  1903.                         $CompanyId $this->getLoggedUserCompanyId($data);
  1904.                         $isSuccess HumanResource::StoreDataForAddEmployee($em$datafalse$CompanyId);
  1905.                         if ($isSuccess) {
  1906.                             if ($data->request->has('send_appointment')) {
  1907.                                 $email $data->request->get('email');
  1908.                                 $bodyHtml '';
  1909.                                 $bodyTemplate 'ApplicationBundle:email/general:appointment_letter_test.html.twig';
  1910.                                 $bodyData = [];
  1911.                                 $attachments = [];
  1912.                                 $forwardToMailAddress $email;
  1913.                                 $new_mail $this->get('mail_module');
  1914.                                 $new_mail->sendMyMail(array(
  1915.                                     'senderHash' => '_CUSTOM_',
  1916.                                     'forwardToMailAddress' => $forwardToMailAddress,
  1917.                                     'subject' => 'Appointment Letter',
  1918.                                     'attachments' => $attachments,
  1919.                                     'toAddress' => $forwardToMailAddress,
  1920.                                     'fromAddress' => 'no-reply@ourhoneybee.eu',
  1921.                                     'userName' => 'no-reply@ourhoneybee.eu',
  1922.                                     'password' => 'Honeybee@0112',
  1923.                                     'smtpServer' => 'smtp.hostinger.com',
  1924.                                     'smtpPort' => 465,
  1925.                                     'emailBody' => $bodyHtml,
  1926.                                     'mailTemplate' => $bodyTemplate,
  1927.                                     'templateData' => $bodyData,
  1928.                                 ));
  1929.                             }
  1930.                             // Mailer function
  1931.                             if ($data->get("send_mail") && empty($data->get('sys_user'))) {
  1932.                                 $message $this->get('user_module')->addNewUser(
  1933.                                     $data->request->get('firstname') . " " $data->request->get('lastname'),
  1934.                                     $data->request->get('email'),
  1935.                                     $data->request->get('username'),
  1936.                                     $data->request->get('password'),
  1937.                                     $data->request->get('desg'),
  1938.                                     $this->getLoggedUserLoginId($data),
  1939.                                     $data->request->get('company'),
  1940.                                     $data->request->get('user_type'),
  1941.                                     $data->request->get('companyIdList'),
  1942.                                     $data->request->get('branch'),
  1943.                                     $data->request->get('supervisor'),
  1944.                                     $data->request->get('default_route'),
  1945.                                     $data->request->has('access_module') ? 0
  1946.                                 );
  1947.                                 if($message[0]=='success')
  1948.                                 {
  1949.                                     if ($systemType == '_CENTRAL_') {
  1950.                                     } else {
  1951.                                         $em_goc $this->getDoctrine()->getManager('company_group');
  1952.                                         $em_goc->getConnection()->connect();
  1953.                                         $connected $em_goc->getConnection()->isConnected();
  1954.                                         $gocDataList = [];
  1955.                                         $gocDataListByAppId = [];
  1956.                                         $retDataDebug = array();
  1957.                                         $appIds $message[2]->getAppId();
  1958.                                         $userIds $message[3]->getUserId();
  1959.                                         if ($connected) {
  1960.                                             $findByQuery = array(
  1961.                                                 'active' => 1
  1962.                                             );
  1963.                                             if ($appIds !== '_UNSET_')
  1964.                                                 $findByQuery['appId'] = $appIds;
  1965.                                             $gocList $this->getDoctrine()->getManager('company_group')
  1966.                                                 ->getRepository("CompanyGroupBundle:CompanyGroup")
  1967.                                                 ->findBy($findByQuery);
  1968.                                             foreach ($gocList as $entry) {
  1969.                                                 $d = array(
  1970.                                                     'name' => $entry->getName(),
  1971.                                                     'id' => $entry->getId(),
  1972.                                                     'image' => $entry->getImage(),
  1973.                                                     'companyGroupHash' => $entry->getCompanyGroupHash(),
  1974.                                                     'dbName' => $entry->getDbName(),
  1975.                                                     'dbUser' => $entry->getDbUser(),
  1976.                                                     'dbPass' => $entry->getDbPass(),
  1977.                                                     'dbHost' => $entry->getDbHost(),
  1978.                                                     'appId' => $entry->getAppId(),
  1979.                                                     'companyRemaining' => $entry->getCompanyRemaining(),
  1980.                                                     'companyAllowed' => $entry->getCompanyAllowed(),
  1981.                                                 );
  1982.                                                 $gocDataList[$entry->getId()] = $d;
  1983.                                                 $gocDataListByAppId[$entry->getAppId()] = $d;
  1984.                                             }
  1985.                                             $debugCount 0;
  1986.                                             foreach ($gocDataList as $gocId => $entry) {
  1987.                                                 $skipSend 1;
  1988.                                                 $connector $this->container->get('application_connector');
  1989.                                                 $connector->resetConnection(
  1990.                                                     'default',
  1991.                                                     $gocDataList[$gocId]['dbName'],
  1992.                                                     $gocDataList[$gocId]['dbUser'],
  1993.                                                     $gocDataList[$gocId]['dbPass'],
  1994.                                                     $gocDataList[$gocId]['dbHost'],
  1995.                                                     $reset true);
  1996.                                                 $em $this->getDoctrine()->getManager();
  1997.                                                 if ($userIds !== '_UNSET_')
  1998.                                                     $users $this->getDoctrine()
  1999.                                                         ->getRepository('ApplicationBundle:SysUser')
  2000.                                                         ->findBy(
  2001.                                                             array(
  2002.                                                                 'userId' => $userIds
  2003.                                                             )
  2004.                                                         );
  2005.                                                 else
  2006.                                                     $users $this->getDoctrine()
  2007.                                                         ->getRepository('ApplicationBundle:SysUser')
  2008.                                                         ->findBy(
  2009.                                                             array()
  2010.                                                         );
  2011.                                                 $output '';
  2012.                                                 $userData = array();
  2013.                                                 $userFiles = array();
  2014.                                                 foreach ($users as $user) {
  2015.                                                     $file $this->container->getParameter('kernel.root_dir') . '/../web/' $user->getImage();
  2016.                                                     if ($user->getImage() != '' && $user->getImage() != null && file_exists($file)) {
  2017.                                                         $mime mime_content_type($file);
  2018.                                                         $info pathinfo($file);
  2019.                                                         $name $info['basename'];
  2020.                                                         if (strpos($mime'image') !== false) {
  2021.                                                             $output = new \CURLFile($file$mime$name);
  2022.                                                         }
  2023.                                                         $skipSend 0;
  2024.                                                         $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = $output;
  2025.                                                     } else {
  2026.                                                         $user->setImage(null);
  2027.                                                         $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = 'pika';
  2028.                                                         $em->flush();
  2029.                                                     }
  2030.                                                     $getters array_filter(get_class_methods($user), function ($method) {
  2031.                                                         return 'get' === substr($method03);
  2032.                                                     });
  2033.                                                     $userDataSingle = array(
  2034.                                                     );
  2035.                                                     foreach ($getters as $getter) {
  2036.                                                         if ($getter == 'getCreatedAt' || $getter == 'getUpdatedAt' || $getter == 'getImage')
  2037.                                                             continue;
  2038. //                                if(is_string($user->{$getter}())|| is_numeric($user->{$getter}()))
  2039. //                                {
  2040. //                                    $userDataSingle[$getter]= $user->{$getter}();
  2041. //                                }
  2042.                                                         if ($user->{$getter}() instanceof \DateTime) {
  2043.                                                             $ggtd $user->{$getter}();
  2044.                                                             $userDataSingle[$getter] = $ggtd->format('Y-m-d');
  2045.                                                         } else
  2046.                                                             $userDataSingle[$getter] = $user->{$getter}();
  2047.                                                     }
  2048. //                                                    $userDataSingle['getNid']=$Employee->getNid();
  2049. //                                                    $userDataSingle['getCurrAddr'] = $Employee->getCurrAddr();
  2050.                                                     $userData[] = $userDataSingle;
  2051.                                                 }
  2052.                                                 $retDataDebug[$debugCount] = array(
  2053.                                                     'skipSend' => $skipSend
  2054.                                                 );
  2055.                                                 {
  2056.                                                         $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/SyncUserToCentralUser';
  2057.                                                     $userFiles['userData'] = json_encode($userData);
  2058.                                                     $curl curl_init();
  2059.                                                     curl_setopt_array($curl, array(
  2060.                                                         CURLOPT_RETURNTRANSFER => 1,
  2061.                                                         CURLOPT_POST => 1,
  2062.                                                         CURLOPT_URL => $urlToCall,
  2063.                                                         CURLOPT_CONNECTTIMEOUT => 10,
  2064.                                                         CURLOPT_SSL_VERIFYPEER => false,
  2065.                                                         CURLOPT_SSL_VERIFYHOST => false,
  2066. //                            CURLOPT_SAFE_UPLOAD => false,
  2067.                                                         CURLOPT_HTTPHEADER => array(//                                "Accept: multipart/form-data",
  2068.                                                         ),
  2069.                                                         //                        CURLOPT_USERAGENT => 'InnoPM',
  2070. //                            CURLOPT_POSTFIELDS => array(
  2071. //                                'userData'=>json_encode($userData),
  2072. //                                'userFiles'=>$userFiles
  2073. //                            ),
  2074.                                                         CURLOPT_POSTFIELDS => $userFiles
  2075.                                                     ));
  2076.                                                     $retData curl_exec($curl);
  2077.                                                     $errData curl_error($curl);
  2078.                                                     curl_close($curl);
  2079.                                                     $response = [];
  2080.                                                     if ($errData) {
  2081.                                                         $response['status'] = 'error';
  2082.                                                         $response['message'] = 'cURL Error: ' $errData;
  2083.                                                     } else {
  2084.                                                         $retDataObj json_decode($retDatatrue);
  2085.                                                         if (!$retDataObj) {
  2086.                                                             $response['status'] = 'error';
  2087.                                                             $response['message'] = 'Invalid response from central server';
  2088.                                                             $response['raw_response'] = $retData;
  2089.                                                         } else {
  2090.                                                             $response['status'] = 'success';
  2091.                                                             $response['data'] = $retDataObj;
  2092.                                                         }
  2093.                                                     }
  2094. // Return JSON response
  2095. //                                                    return new JsonResponse($response);
  2096.                                                     $retDataDebug[$debugCount] = $retDataObj;
  2097.                                                     if (isset($retDataObj['globalIdsData']))
  2098.                                                         foreach ($retDataObj['globalIdsData'] as $app_id => $usrList) {
  2099.                                                             $connector $this->container->get('application_connector');
  2100.                                                             $connector->resetConnection(
  2101.                                                                 'default',
  2102.                                                                 $gocDataListByAppId[$app_id]['dbName'],
  2103.                                                                 $gocDataListByAppId[$app_id]['dbUser'],
  2104.                                                                 $gocDataListByAppId[$app_id]['dbPass'],
  2105.                                                                 $gocDataListByAppId[$app_id]['dbHost'],
  2106.                                                                 $reset true);
  2107.                                                             $em $this->getDoctrine()->getManager();
  2108.                                                             foreach ($usrList as $sys_id => $globaldata) {
  2109.                                                                 $user $this->getDoctrine()
  2110.                                                                     ->getRepository('ApplicationBundle:SysUser')
  2111.                                                                     ->findOneBy(
  2112.                                                                         array(
  2113.                                                                             'userId' => $sys_id
  2114.                                                                         )
  2115.                                                                     );
  2116.                                                                 if ($user) {
  2117.                                                                     $user->setGlobalId($globaldata['gid']);
  2118.                                                                     $em->persist($user);
  2119.                                                                     $em->flush();
  2120.                                                                 }
  2121.                                                             }
  2122.                                                         }
  2123.                                                 }
  2124.                                                 $debugCount++;
  2125.                                             }
  2126.                                         }
  2127. //                    return new JsonResponse($retDataDebug);
  2128.                                     }
  2129.                                 }
  2130.                                 $SysUserRepo $em->getRepository(SysUser::class);
  2131.                                 $SysUser $SysUserRepo->findOneBy(array(
  2132.                                     'email' => $data->request->get('email')
  2133.                                 ));
  2134.                                 $isSuccess->setUserId($SysUser->getUserId());
  2135.                                 $em->persist($isSuccess);
  2136.                                 $em->flush();
  2137.                                 $companyData $message[2];
  2138.                                 if ($message[0] == 'success' && GeneralConstant::EMAIL_ENABLED == 1) {
  2139.                                     $bodyHtml '';
  2140.                                     $bodyTemplate 'ApplicationBundle:email/user:registration.html.twig';
  2141.                                     $bodyData = array(
  2142.                                         'name' => $data->request->get('name'),
  2143.                                         'companyData' => $companyData,
  2144.                                         'userName' => $data->request->get('username'),
  2145.                                         'password' => $data->request->get('password'),
  2146.                                     );
  2147.                                     $attachments = [];
  2148. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  2149.                                     $new_mail $this->get('mail_module');
  2150.                                     $new_mail->sendMyMail(array(
  2151.                                         'senderHash' => '_CUSTOM_',
  2152.                                         //                        'senderHash'=>'_CUSTOM_',
  2153.                                         'forwardToMailAddress' => $data->request->get('email'),
  2154.                                         'subject' => 'User Registration on HoneyBee Ecosystem under Entity ' $companyData->getName(),
  2155.                                         'fileName' => '',
  2156.                                         'attachments' => $attachments,
  2157.                                         'toAddress' => $data->request->get('email'),
  2158.                                         'fromAddress' => 'no-reply@ourhoneybee.eu',
  2159.                                         'userName' => 'no-reply@ourhoneybee.eu',
  2160.                                         'password' => 'Y41dh8g0112',
  2161.                                         'smtpServer' => 'smtp.hostinger.com',
  2162.                                         'smtpPort' => 465,
  2163. //                        'fromAddress'=>'sales@entity.innobd.com',
  2164. //                        'userName'=>'sales@entity.innobd.com',
  2165. //                        'password'=>'Y41dh8g0112',
  2166. //                        'smtpServer'=>'smtp.hostinger.com',
  2167. //                        'smtpPort'=>587,
  2168. //                        'emailBody'=>$bodyHtml,
  2169.                                         'mailTemplate' => $bodyTemplate,
  2170.                                         'templateData' => $bodyData,
  2171.                                         'embedCompanyImage' => 1,
  2172.                                         'companyId' => $data->request->get('company'),
  2173.                                         'companyImagePath' => $companyData->getImage()
  2174.                                     ));
  2175. //                  $emailmessage = (new \Swift_Message('Registration to Entity'))
  2176. //                    ->setFrom('registration@entity.innobd.com')
  2177. //                    ->setTo($data->request->get('email'))
  2178. //                    ->setBody(
  2179. //                      $this->renderView(
  2180. //                        'ApplicationBundle:email/user:registration.html.twig',
  2181. //                        array(
  2182. //                          'name' => $data->request->get('name'),
  2183. //                          'companyData' => $companyData,
  2184. //                          'userName' => $data->request->get('email'),
  2185. //                          'password' => $data->request->get('password'),
  2186. //                        )
  2187. //                      ),
  2188. //                      'text/html'
  2189. //                    );
  2190. //                  $this->get('mailer')->send($emailmessage);
  2191.                                 }
  2192.                             }
  2193.                             // End Mailer function
  2194.                             $this->addFlash(
  2195.                                 'success',
  2196.                                 'New Employee Successfully Added!'
  2197.                             );
  2198.                             $userType HumanResourceConstant::$userType;
  2199.                             if ($userType == 1) {
  2200.                                 return $this->redirectToRoute('employee_list');
  2201.                             } else {
  2202.                                 return $this->redirectToRoute('edit_employee');
  2203.                             }
  2204.                         }
  2205.                         else {
  2206.                             $this->addFlash(
  2207.                                 'error',
  2208.                                 'Something Went Wrong!'
  2209.                             );
  2210.                             $userType HumanResourceConstant::$userType;
  2211.                             if ($userType == 1) {
  2212.                                 return $this->redirectToRoute('employee_list');
  2213.                             } else {
  2214.                                 return $this->redirectToRoute('edit_employee');
  2215.                             }
  2216.                         }
  2217.                     }
  2218.                 } else {
  2219.                     $this->addFlash(
  2220.                         'error',
  2221.                         'Invalid Approval Hash!'
  2222.                     );
  2223.                     return $this->redirectToRoute('add_employee');
  2224.                 }
  2225.             }
  2226.         }
  2227.     }
  2228.     public function AddNewEmployeeAction(Request $request,$id)
  2229.     {
  2230.         $em $this->getDoctrine()->getManager();
  2231.         $systemType $this->container->hasParameter('system_type') ? $this->container->getParameter('system_type') : '_ERP_';
  2232.         $approveHash $request->request->get('approvalHash');
  2233.         $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  2234.         $CompanyId $this->getLoggedUserCompanyId($request);
  2235.         $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  2236.         $employee HumanResource::StoreDataForAddEmployee($em$requestfalse$CompanyId);
  2237.         $isUserExist $em->getRepository(EmployeeDetails::class);
  2238.         if ($isSignatureOk) {
  2239.             if ($isUserExist) {
  2240.                 if($employee){
  2241.                     $message $this->get('user_module')->addNewUser(
  2242.                         $request->request->get('firstname') . " " $request->request->get('lastname'),
  2243.                         $request->request->get('email'),
  2244.                         $request->request->get('username'),
  2245.                         $request->request->get('password'),
  2246.                         $request->request->get('desg'),
  2247.                         $request->getLoggedUserLoginId($request),
  2248.                         $request->request->get('company'),
  2249.                         $request->request->get('user_type'),
  2250.                         $request->request->get('companyIdList'),
  2251.                         $request->request->get('branch'),
  2252.                         $request->request->get('supervisor'),
  2253.                         $request->request->get('default_route'),
  2254.                         $request->request->has('access_module') ? 0
  2255.                     );
  2256.                     if($message[0]=='success')
  2257.                     {
  2258.                         $employee->setUserId($message[3]->getUserId());
  2259.                         $em->flush();
  2260.                         if ($systemType == '_CENTRAL_') {
  2261.                         } else {
  2262.                             $em_goc $this->getDoctrine()->getManager('company_group');
  2263.                             $em_goc->getConnection()->connect();
  2264.                             $connected $em_goc->getConnection()->isConnected();
  2265.                             $gocDataList = [];
  2266.                             $gocDataListByAppId = [];
  2267.                             $retDataDebug = array();
  2268.                             $appIds $message[2]->getAppId();
  2269.                             $userIds $message[3]->getUserId();
  2270.                             if ($connected) {
  2271.                                 $findByQuery = array(
  2272.                                     'active' => 1
  2273.                                 );
  2274.                                 if ($appIds !== '_UNSET_')
  2275.                                     $findByQuery['appId'] = $appIds;
  2276.                                 $gocList $this->getDoctrine()->getManager('company_group')
  2277.                                     ->getRepository("CompanyGroupBundle:CompanyGroup")
  2278.                                     ->findBy($findByQuery);
  2279.                                 foreach ($gocList as $entry) {
  2280.                                     $d = array(
  2281.                                         'name' => $entry->getName(),
  2282.                                         'id' => $entry->getId(),
  2283.                                         'image' => $entry->getImage(),
  2284.                                         'companyGroupHash' => $entry->getCompanyGroupHash(),
  2285.                                         'dbName' => $entry->getDbName(),
  2286.                                         'dbUser' => $entry->getDbUser(),
  2287.                                         'dbPass' => $entry->getDbPass(),
  2288.                                         'dbHost' => $entry->getDbHost(),
  2289.                                         'appId' => $entry->getAppId(),
  2290.                                         'companyRemaining' => $entry->getCompanyRemaining(),
  2291.                                         'companyAllowed' => $entry->getCompanyAllowed(),
  2292.                                     );
  2293.                                     $gocDataList[$entry->getId()] = $d;
  2294.                                     $gocDataListByAppId[$entry->getAppId()] = $d;
  2295.                                 }
  2296.                                 $debugCount 0;
  2297.                                 foreach ($gocDataList as $gocId => $entry) {
  2298.                                     $skipSend 1;
  2299.                                     $connector $this->container->get('application_connector');
  2300.                                     $connector->resetConnection(
  2301.                                         'default',
  2302.                                         $gocDataList[$gocId]['dbName'],
  2303.                                         $gocDataList[$gocId]['dbUser'],
  2304.                                         $gocDataList[$gocId]['dbPass'],
  2305.                                         $gocDataList[$gocId]['dbHost'],
  2306.                                         $reset true);
  2307.                                     $em $this->getDoctrine()->getManager();
  2308.                                     if ($userIds !== '_UNSET_')
  2309.                                         $users $this->getDoctrine()
  2310.                                             ->getRepository('ApplicationBundle:SysUser')
  2311.                                             ->findBy(
  2312.                                                 array(
  2313.                                                     'userId' => $userIds
  2314.                                                 )
  2315.                                             );
  2316.                                     else
  2317.                                         $users $this->getDoctrine()
  2318.                                             ->getRepository('ApplicationBundle:SysUser')
  2319.                                             ->findBy(
  2320.                                                 array()
  2321.                                             );
  2322.                                     $output '';
  2323.                                     $userData = array();
  2324.                                     $userFiles = array();
  2325.                                     foreach ($users as $user) {
  2326.                                         $file $this->container->getParameter('kernel.root_dir') . '/../web/' $user->getImage();
  2327.                                         if ($user->getImage() != '' && $user->getImage() != null && file_exists($file)) {
  2328.                                             $mime mime_content_type($file);
  2329.                                             $info pathinfo($file);
  2330.                                             $name $info['basename'];
  2331.                                             if (strpos($mime'image') !== false) {
  2332.                                                 $output = new \CURLFile($file$mime$name);
  2333.                                             }
  2334.                                             $skipSend 0;
  2335.                                             $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = $output;
  2336.                                         } else {
  2337.                                             $user->setImage(null);
  2338.                                             $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = 'pika';
  2339.                                             $em->flush();
  2340.                                         }
  2341.                                         $getters array_filter(get_class_methods($user), function ($method) {
  2342.                                             return 'get' === substr($method03);
  2343.                                         });
  2344.                                         $userDataSingle = array(
  2345.                                         );
  2346.                                         foreach ($getters as $getter) {
  2347.                                             if ($getter == 'getCreatedAt' || $getter == 'getUpdatedAt' || $getter == 'getImage')
  2348.                                                 continue;
  2349. //                                if(is_string($user->{$getter}())|| is_numeric($user->{$getter}()))
  2350. //                                {
  2351. //                                    $userDataSingle[$getter]= $user->{$getter}();
  2352. //                                }
  2353.                                             if ($user->{$getter}() instanceof \DateTime) {
  2354.                                                 $ggtd $user->{$getter}();
  2355.                                                 $userDataSingle[$getter] = $ggtd->format('Y-m-d');
  2356.                                             } else
  2357.                                                 $userDataSingle[$getter] = $user->{$getter}();
  2358.                                         }
  2359. //                                                    $userDataSingle['getNid']=$Employee->getNid();
  2360. //                                                    $userDataSingle['getCurrAddr'] = $Employee->getCurrAddr();
  2361.                                         $userData[] = $userDataSingle;
  2362.                                     }
  2363.                                     $retDataDebug[$debugCount] = array(
  2364.                                         'skipSend' => $skipSend
  2365.                                     );
  2366.                                     {
  2367.                                         $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/SyncUserToCentralUser';
  2368.                                         $userFiles['userData'] = json_encode($userData);
  2369.                                         $curl curl_init();
  2370.                                         curl_setopt_array($curl, array(
  2371.                                             CURLOPT_RETURNTRANSFER => 1,
  2372.                                             CURLOPT_POST => 1,
  2373.                                             CURLOPT_URL => $urlToCall,
  2374.                                             CURLOPT_CONNECTTIMEOUT => 10,
  2375.                                             CURLOPT_SSL_VERIFYPEER => false,
  2376.                                             CURLOPT_SSL_VERIFYHOST => false,
  2377. //                            CURLOPT_SAFE_UPLOAD => false,
  2378.                                             CURLOPT_HTTPHEADER => array(//                                "Accept: multipart/form-data",
  2379.                                             ),
  2380.                                             //                        CURLOPT_USERAGENT => 'InnoPM',
  2381. //                            CURLOPT_POSTFIELDS => array(
  2382. //                                'userData'=>json_encode($userData),
  2383. //                                'userFiles'=>$userFiles
  2384. //                            ),
  2385.                                             CURLOPT_POSTFIELDS => $userFiles
  2386.                                         ));
  2387.                                         $retData curl_exec($curl);
  2388.                                         $errData curl_error($curl);
  2389.                                         curl_close($curl);
  2390.                                         $response = [];
  2391.                                         if ($errData) {
  2392.                                             $response['status'] = 'error';
  2393.                                             $response['message'] = 'cURL Error: ' $errData;
  2394.                                         } else {
  2395.                                             $retDataObj json_decode($retDatatrue);
  2396.                                             if (!$retDataObj) {
  2397.                                                 $response['status'] = 'error';
  2398.                                                 $response['message'] = 'Invalid response from central server';
  2399.                                                 $response['raw_response'] = $retData;
  2400.                                             } else {
  2401.                                                 $response['status'] = 'success';
  2402.                                                 $response['data'] = $retDataObj;
  2403.                                             }
  2404.                                         }
  2405. // Return JSON response
  2406. //                                                    return new JsonResponse($response);
  2407.                                         $retDataDebug[$debugCount] = $retDataObj;
  2408.                                         if (isset($retDataObj['globalIdsData']))
  2409.                                             foreach ($retDataObj['globalIdsData'] as $app_id => $usrList) {
  2410.                                                 $connector $this->container->get('application_connector');
  2411.                                                 $connector->resetConnection(
  2412.                                                     'default',
  2413.                                                     $gocDataListByAppId[$app_id]['dbName'],
  2414.                                                     $gocDataListByAppId[$app_id]['dbUser'],
  2415.                                                     $gocDataListByAppId[$app_id]['dbPass'],
  2416.                                                     $gocDataListByAppId[$app_id]['dbHost'],
  2417.                                                     $reset true);
  2418.                                                 $em $this->getDoctrine()->getManager();
  2419.                                                 foreach ($usrList as $sys_id => $globaldata) {
  2420.                                                     $user $this->getDoctrine()
  2421.                                                         ->getRepository('ApplicationBundle:SysUser')
  2422.                                                         ->findOneBy(
  2423.                                                             array(
  2424.                                                                 'userId' => $sys_id
  2425.                                                             )
  2426.                                                         );
  2427.                                                     if ($user) {
  2428.                                                         $user->setGlobalId($globaldata['gid']);
  2429.                                                         $em->persist($user);
  2430.                                                         $em->flush();
  2431.                                                     }
  2432.                                                 }
  2433.                                             }
  2434.                                     }
  2435.                                     $debugCount++;
  2436.                                 }
  2437.                             }
  2438. //                    return new JsonResponse($retDataDebug);
  2439.                         }
  2440.                     }
  2441. //                                    if($message[0]=='success'){
  2442. //                                        $SysUserRepo = $em->getRepository('ApplicationBundle:SysUser');
  2443. //                                        $SysUser = $SysUserRepo->findOneBy([
  2444. //                                            'email' => $data->request->get('email')
  2445. //                                        ]);
  2446. //
  2447. //                                        if ($SysUser === null) {
  2448. //                                            throw new \Exception("User with email " . $data->request->get('email') . " not found.");
  2449. //                                        }
  2450. //
  2451. //                                        $isSuccess->setUserId($SysUser->getUserId());
  2452. //                                        $em->persist($isSuccess);
  2453. //                                        $em->flush();
  2454. //                                    }
  2455.                     $companyData $message[2];
  2456.                     if ($message[0] == 'success' && GeneralConstant::EMAIL_ENABLED == 1) {
  2457.                         $bodyHtml '';
  2458.                         $bodyTemplate 'ApplicationBundle:email/user:registration.html.twig';
  2459.                         $bodyData = array(
  2460.                             'name' => $request->request->get('name'),
  2461.                             'companyData' => $companyData,
  2462.                             'userName' => $request->request->get('username'),
  2463.                             'password' => $request->request->get('password'),
  2464.                         );
  2465.                         $attachments = [];
  2466.                         $new_mail $this->get('mail_module');
  2467.                         $new_mail->sendMyMail(array(
  2468.                             'senderHash' => '_CUSTOM_',
  2469.                             //                        'senderHash'=>'_CUSTOM_',
  2470.                             'forwardToMailAddress' => $request->request->get('email'),
  2471.                             'fromAddress' => 'no-reply@ourhoneybee.eu',
  2472.                             'userName' => 'no-reply@ourhoneybee.eu',
  2473.                             'password' => 'Honeybee@0112',
  2474.                             'smtpServer' => 'smtp.hostinger.com',
  2475.                             'smtpPort' => 465,
  2476.                             'subject' => 'User Registration on HoneyBee Ecosystem under Entity ' $companyData->getName(),
  2477.                             'fileName' => '',
  2478.                             'attachments' => $attachments,
  2479.                             'toAddress' => $request->request->get('email'),
  2480.                             'mailTemplate' => $bodyTemplate,
  2481.                             'templateData' => $bodyData,
  2482.                             'embedCompanyImage' => 1,
  2483.                             'companyId' => $request->request->get('company'),
  2484.                             'companyImagePath' => $companyData->getImage()
  2485.                         ));
  2486.                     }
  2487.                 }
  2488.                 $this->addFlash(
  2489.                     'success',
  2490.                     'New Employee Successfully Added!'
  2491.                 );
  2492.                 return $this->redirectToRoute('add_employee');
  2493.             }
  2494.             else {
  2495. //                        $requiredFields = [
  2496. //                            'email', 'username', 'password', 'firstname', 'lastname', 'nid', 'dob',
  2497. //                            'sex', 'blood', 'phone', 'perm_addr', 'dept', 'desg', 'branch',
  2498. //                            'emp_type', 'tin'
  2499. //                        ];
  2500. //
  2501. //                        $missingFields = [];
  2502. //
  2503. //                        foreach ($requiredFields as $field) {
  2504. //                            if (!$data->request->get($field)) {
  2505. //                                $missingFields[] = $field;
  2506. //                            }
  2507. //                        }
  2508. //                        if (!empty($missingFields)) {
  2509. //                            $this->addFlash('error', 'Missing fields: ' . implode(', ', $missingFields));
  2510. //                            return $this->redirectToRoute('add_employee');
  2511. //                        }
  2512. //                        $password = $data->request->get('password');
  2513. //                        $passwordPattern = '/^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[\W_]).{8,}$/';
  2514. //                        if (!preg_match($passwordPattern, $password)) {
  2515. //                            $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));
  2516. //                            return $this->redirectToRoute('add_employee');
  2517. //                        }
  2518.                 $CompanyId $this->getLoggedUserCompanyId($request);
  2519.                 $isSuccess HumanResource::StoreDataForAddEmployee($em$requestfalse$CompanyId);
  2520.                 if ($isSuccess) {
  2521.                     if ($request->request->has('send_appointment')) {
  2522.                         $email $request->request->get('email');
  2523.                         $bodyHtml '';
  2524.                         $bodyTemplate 'ApplicationBundle:email/general:appointment_letter_test.html.twig';
  2525.                         $bodyData = [];
  2526.                         $attachments = [];
  2527.                         $forwardToMailAddress $email;
  2528.                         $new_mail $this->get('mail_module');
  2529.                         $new_mail->sendMyMail(array(
  2530.                             'senderHash' => '_CUSTOM_',
  2531.                             'forwardToMailAddress' => $forwardToMailAddress,
  2532.                             'subject' => 'Appointment Letter',
  2533.                             'attachments' => $attachments,
  2534.                             'toAddress' => $forwardToMailAddress,
  2535.                             'fromAddress' => 'no-reply@ourhoneybee.eu',
  2536.                             'userName' => 'no-reply@ourhoneybee.eu',
  2537.                             'password' => 'Honeybee@0112',
  2538.                             'smtpServer' => 'smtp.hostinger.com',
  2539.                             'smtpPort' => 465,
  2540.                             'emailBody' => $bodyHtml,
  2541.                             'mailTemplate' => $bodyTemplate,
  2542.                             'templateData' => $bodyData,
  2543.                         ));
  2544.                     }
  2545.                     // Mailer function
  2546.                     if ($request->get("send_mail") && empty($request->get('sys_user'))) {
  2547.                         $message $this->get('user_module')->addNewUser(
  2548.                             $request->request->get('firstname') . " " $request->request->get('lastname'),
  2549.                             $request->request->get('email'),
  2550.                             $request->request->get('username'),
  2551.                             $request->request->get('password'),
  2552.                             $request->request->get('desg'),
  2553.                             $request->getLoggedUserLoginId($request),
  2554.                             $request->request->get('company'),
  2555.                             $request->request->get('user_type'),
  2556.                             $request->request->get('companyIdList'),
  2557.                             $request->request->get('branch'),
  2558.                             $request->request->get('supervisor'),
  2559.                             $request->request->get('default_route'),
  2560.                             $request->request->has('access_module') ? 0
  2561.                         );
  2562.                         if($message[0]=='success')
  2563.                         {
  2564.                             if ($systemType == '_CENTRAL_') {
  2565.                             } else {
  2566.                                 $em_goc $this->getDoctrine()->getManager('company_group');
  2567.                                 $em_goc->getConnection()->connect();
  2568.                                 $connected $em_goc->getConnection()->isConnected();
  2569.                                 $gocDataList = [];
  2570.                                 $gocDataListByAppId = [];
  2571.                                 $retDataDebug = array();
  2572.                                 $appIds $message[2]->getAppId();
  2573.                                 $userIds $message[3]->getUserId();
  2574.                                 if ($connected) {
  2575.                                     $findByQuery = array(
  2576.                                         'active' => 1
  2577.                                     );
  2578.                                     if ($appIds !== '_UNSET_')
  2579.                                         $findByQuery['appId'] = $appIds;
  2580.                                     $gocList $this->getDoctrine()->getManager('company_group')
  2581.                                         ->getRepository("CompanyGroupBundle:CompanyGroup")
  2582.                                         ->findBy($findByQuery);
  2583.                                     foreach ($gocList as $entry) {
  2584.                                         $d = array(
  2585.                                             'name' => $entry->getName(),
  2586.                                             'id' => $entry->getId(),
  2587.                                             'image' => $entry->getImage(),
  2588.                                             'companyGroupHash' => $entry->getCompanyGroupHash(),
  2589.                                             'dbName' => $entry->getDbName(),
  2590.                                             'dbUser' => $entry->getDbUser(),
  2591.                                             'dbPass' => $entry->getDbPass(),
  2592.                                             'dbHost' => $entry->getDbHost(),
  2593.                                             'appId' => $entry->getAppId(),
  2594.                                             'companyRemaining' => $entry->getCompanyRemaining(),
  2595.                                             'companyAllowed' => $entry->getCompanyAllowed(),
  2596.                                         );
  2597.                                         $gocDataList[$entry->getId()] = $d;
  2598.                                         $gocDataListByAppId[$entry->getAppId()] = $d;
  2599.                                     }
  2600.                                     $debugCount 0;
  2601.                                     foreach ($gocDataList as $gocId => $entry) {
  2602.                                         $skipSend 1;
  2603.                                         $connector $this->container->get('application_connector');
  2604.                                         $connector->resetConnection(
  2605.                                             'default',
  2606.                                             $gocDataList[$gocId]['dbName'],
  2607.                                             $gocDataList[$gocId]['dbUser'],
  2608.                                             $gocDataList[$gocId]['dbPass'],
  2609.                                             $gocDataList[$gocId]['dbHost'],
  2610.                                             $reset true);
  2611.                                         $em $this->getDoctrine()->getManager();
  2612.                                         if ($userIds !== '_UNSET_')
  2613.                                             $users $this->getDoctrine()
  2614.                                                 ->getRepository('ApplicationBundle:SysUser')
  2615.                                                 ->findBy(
  2616.                                                     array(
  2617.                                                         'userId' => $userIds
  2618.                                                     )
  2619.                                                 );
  2620.                                         else
  2621.                                             $users $this->getDoctrine()
  2622.                                                 ->getRepository('ApplicationBundle:SysUser')
  2623.                                                 ->findBy(
  2624.                                                     array()
  2625.                                                 );
  2626.                                         $output '';
  2627.                                         $userData = array();
  2628.                                         $userFiles = array();
  2629.                                         foreach ($users as $user) {
  2630.                                             $file $this->container->getParameter('kernel.root_dir') . '/../web/' $user->getImage();
  2631.                                             if ($user->getImage() != '' && $user->getImage() != null && file_exists($file)) {
  2632.                                                 $mime mime_content_type($file);
  2633.                                                 $info pathinfo($file);
  2634.                                                 $name $info['basename'];
  2635.                                                 if (strpos($mime'image') !== false) {
  2636.                                                     $output = new \CURLFile($file$mime$name);
  2637.                                                 }
  2638.                                                 $skipSend 0;
  2639.                                                 $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = $output;
  2640.                                             } else {
  2641.                                                 $user->setImage(null);
  2642.                                                 $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = 'pika';
  2643.                                                 $em->flush();
  2644.                                             }
  2645.                                             $getters array_filter(get_class_methods($user), function ($method) {
  2646.                                                 return 'get' === substr($method03);
  2647.                                             });
  2648.                                             $userDataSingle = array(
  2649.                                             );
  2650.                                             foreach ($getters as $getter) {
  2651.                                                 if ($getter == 'getCreatedAt' || $getter == 'getUpdatedAt' || $getter == 'getImage')
  2652.                                                     continue;
  2653. //                                if(is_string($user->{$getter}())|| is_numeric($user->{$getter}()))
  2654. //                                {
  2655. //                                    $userDataSingle[$getter]= $user->{$getter}();
  2656. //                                }
  2657.                                                 if ($user->{$getter}() instanceof \DateTime) {
  2658.                                                     $ggtd $user->{$getter}();
  2659.                                                     $userDataSingle[$getter] = $ggtd->format('Y-m-d');
  2660.                                                 } else
  2661.                                                     $userDataSingle[$getter] = $user->{$getter}();
  2662.                                             }
  2663. //                                                    $userDataSingle['getNid']=$Employee->getNid();
  2664. //                                                    $userDataSingle['getCurrAddr'] = $Employee->getCurrAddr();
  2665.                                             $userData[] = $userDataSingle;
  2666.                                         }
  2667.                                         $retDataDebug[$debugCount] = array(
  2668.                                             'skipSend' => $skipSend
  2669.                                         );
  2670.                                         {
  2671.                                             $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/SyncUserToCentralUser';
  2672.                                             $userFiles['userData'] = json_encode($userData);
  2673.                                             $curl curl_init();
  2674.                                             curl_setopt_array($curl, array(
  2675.                                                 CURLOPT_RETURNTRANSFER => 1,
  2676.                                                 CURLOPT_POST => 1,
  2677.                                                 CURLOPT_URL => $urlToCall,
  2678.                                                 CURLOPT_CONNECTTIMEOUT => 10,
  2679.                                                 CURLOPT_SSL_VERIFYPEER => false,
  2680.                                                 CURLOPT_SSL_VERIFYHOST => false,
  2681. //                            CURLOPT_SAFE_UPLOAD => false,
  2682.                                                 CURLOPT_HTTPHEADER => array(//                                "Accept: multipart/form-data",
  2683.                                                 ),
  2684.                                                 //                        CURLOPT_USERAGENT => 'InnoPM',
  2685. //                            CURLOPT_POSTFIELDS => array(
  2686. //                                'userData'=>json_encode($userData),
  2687. //                                'userFiles'=>$userFiles
  2688. //                            ),
  2689.                                                 CURLOPT_POSTFIELDS => $userFiles
  2690.                                             ));
  2691.                                             $retData curl_exec($curl);
  2692.                                             $errData curl_error($curl);
  2693.                                             curl_close($curl);
  2694.                                             $response = [];
  2695.                                             if ($errData) {
  2696.                                                 $response['status'] = 'error';
  2697.                                                 $response['message'] = 'cURL Error: ' $errData;
  2698.                                             } else {
  2699.                                                 $retDataObj json_decode($retDatatrue);
  2700.                                                 if (!$retDataObj) {
  2701.                                                     $response['status'] = 'error';
  2702.                                                     $response['message'] = 'Invalid response from central server';
  2703.                                                     $response['raw_response'] = $retData;
  2704.                                                 } else {
  2705.                                                     $response['status'] = 'success';
  2706.                                                     $response['data'] = $retDataObj;
  2707.                                                 }
  2708.                                             }
  2709. // Return JSON response
  2710. //                                                    return new JsonResponse($response);
  2711.                                             $retDataDebug[$debugCount] = $retDataObj;
  2712.                                             if (isset($retDataObj['globalIdsData']))
  2713.                                                 foreach ($retDataObj['globalIdsData'] as $app_id => $usrList) {
  2714.                                                     $connector $this->container->get('application_connector');
  2715.                                                     $connector->resetConnection(
  2716.                                                         'default',
  2717.                                                         $gocDataListByAppId[$app_id]['dbName'],
  2718.                                                         $gocDataListByAppId[$app_id]['dbUser'],
  2719.                                                         $gocDataListByAppId[$app_id]['dbPass'],
  2720.                                                         $gocDataListByAppId[$app_id]['dbHost'],
  2721.                                                         $reset true);
  2722.                                                     $em $this->getDoctrine()->getManager();
  2723.                                                     foreach ($usrList as $sys_id => $globaldata) {
  2724.                                                         $user $this->getDoctrine()
  2725.                                                             ->getRepository('ApplicationBundle:SysUser')
  2726.                                                             ->findOneBy(
  2727.                                                                 array(
  2728.                                                                     'userId' => $sys_id
  2729.                                                                 )
  2730.                                                             );
  2731.                                                         if ($user) {
  2732.                                                             $user->setGlobalId($globaldata['gid']);
  2733.                                                             $em->persist($user);
  2734.                                                             $em->flush();
  2735.                                                         }
  2736.                                                     }
  2737.                                                 }
  2738.                                         }
  2739.                                         $debugCount++;
  2740.                                     }
  2741.                                 }
  2742. //                    return new JsonResponse($retDataDebug);
  2743.                             }
  2744.                         }
  2745.                         $SysUserRepo $em->getRepository(SysUser::class);
  2746.                         $SysUser $SysUserRepo->findOneBy(array(
  2747.                             'email' => $request->request->get('email')
  2748.                         ));
  2749.                         $isSuccess->setUserId($SysUser->getUserId());
  2750.                         $em->persist($isSuccess);
  2751.                         $em->flush();
  2752.                         $companyData $message[2];
  2753.                         if ($message[0] == 'success' && GeneralConstant::EMAIL_ENABLED == 1) {
  2754.                             $bodyHtml '';
  2755.                             $bodyTemplate 'ApplicationBundle:email/user:registration.html.twig';
  2756.                             $bodyData = array(
  2757.                                 'name' => $request->request->get('name'),
  2758.                                 'companyData' => $companyData,
  2759.                                 'userName' => $request->request->get('username'),
  2760.                                 'password' => $request->request->get('password'),
  2761.                             );
  2762.                             $attachments = [];
  2763. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  2764.                             $new_mail $this->get('mail_module');
  2765.                             $new_mail->sendMyMail(array(
  2766.                                 'senderHash' => '_CUSTOM_',
  2767.                                 //                        'senderHash'=>'_CUSTOM_',
  2768.                                 'forwardToMailAddress' => $request->request->get('email'),
  2769.                                 'subject' => 'User Registration on HoneyBee Ecosystem under Entity ' $companyData->getName(),
  2770.                                 'fileName' => '',
  2771.                                 'attachments' => $attachments,
  2772.                                 'toAddress' => $request->request->get('email'),
  2773.                                 'fromAddress' => 'no-reply@ourhoneybee.eu',
  2774.                                 'userName' => 'no-reply@ourhoneybee.eu',
  2775.                                 'password' => 'Y41dh8g0112',
  2776.                                 'smtpServer' => 'smtp.hostinger.com',
  2777.                                 'smtpPort' => 465,
  2778. //                        'fromAddress'=>'sales@entity.innobd.com',
  2779. //                        'userName'=>'sales@entity.innobd.com',
  2780. //                        'password'=>'Y41dh8g0112',
  2781. //                        'smtpServer'=>'smtp.hostinger.com',
  2782. //                        'smtpPort'=>587,
  2783. //                        'emailBody'=>$bodyHtml,
  2784.                                 'mailTemplate' => $bodyTemplate,
  2785.                                 'templateData' => $bodyData,
  2786.                                 'embedCompanyImage' => 1,
  2787.                                 'companyId' => $request->request->get('company'),
  2788.                                 'companyImagePath' => $companyData->getImage()
  2789.                             ));
  2790. //                  $emailmessage = (new \Swift_Message('Registration to Entity'))
  2791. //                    ->setFrom('registration@entity.innobd.com')
  2792. //                    ->setTo($data->request->get('email'))
  2793. //                    ->setBody(
  2794. //                      $this->renderView(
  2795. //                        'ApplicationBundle:email/user:registration.html.twig',
  2796. //                        array(
  2797. //                          'name' => $data->request->get('name'),
  2798. //                          'companyData' => $companyData,
  2799. //                          'userName' => $data->request->get('email'),
  2800. //                          'password' => $data->request->get('password'),
  2801. //                        )
  2802. //                      ),
  2803. //                      'text/html'
  2804. //                    );
  2805. //                  $this->get('mailer')->send($emailmessage);
  2806.                         }
  2807.                     }
  2808.                     // End Mailer function
  2809.                     $this->addFlash(
  2810.                         'success',
  2811.                         'New Employee Successfully Added!'
  2812.                     );
  2813.                     return $this->redirectToRoute('employee_list');
  2814.                 }
  2815.                 else {
  2816.                     $this->addFlash(
  2817.                         'error',
  2818.                         'Something Went Wrong!'
  2819.                     );
  2820.                     return $this->redirectToRoute('add_employee');
  2821.                 }
  2822.             }
  2823.         } else {
  2824.             $this->addFlash(
  2825.                 'error',
  2826.                 'Invalid Approval Hash!'
  2827.             );
  2828.             return $this->redirectToRoute('add_employee');
  2829.         }
  2830.     }
  2831.     public function UpdateEmployeeAction(Request $request,$id)
  2832.     {
  2833.     }
  2834.     private function uploadImage($image,$request){
  2835.         $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Users/';
  2836.         $profileImage '';
  2837.         if($image != null){
  2838.             $fileName $request->request->get('firstname') . '.' $request->request->get('global_user_id') . '.' $image->guessExtension();
  2839.             $path $fileName;
  2840.             if(!file_exists($upl_dir)){
  2841.                 mkdir($upl_dir,0777,true);
  2842.             }
  2843.             $image->move($upl_dir,$path);
  2844.             $profileImage 'uploads/Users/'.$path;
  2845.         }
  2846.         return $profileImage;
  2847.     }
  2848.     public function OnboardEmployeeAction(Request $request)
  2849.     {
  2850.         $systemType $this->container->hasParameter('system_type') ? $this->container->getParameter('system_type') : '_ERP_';
  2851.         $email $request->request->get('email');
  2852.         $applicantId $request->request->get('applicant_id');
  2853.         $em $this->getDoctrine()->getManager();
  2854.         $session $request->getSession();
  2855.         $companyId $session->get('userCompanyId');
  2856.         $appId $session->get('userAppId');
  2857.         $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/get_applicant_data_central';
  2858.         $applicantFiles = [
  2859.             'email' => $email,
  2860.             'applicantId' => $applicantId
  2861.         ];
  2862.         $entityToken $em->getRepository('ApplicationBundle:EntityTokenStorage')
  2863.             ->findOneBy(['userId' => $applicantId]);
  2864.         $curl curl_init();
  2865.         curl_setopt_array($curl, array(
  2866.             CURLOPT_RETURNTRANSFER => 1,
  2867.             CURLOPT_POST => 1,
  2868.             CURLOPT_URL => $urlToCall,
  2869.             CURLOPT_CONNECTTIMEOUT => 10,
  2870.             CURLOPT_SSL_VERIFYPEER => false,
  2871.             CURLOPT_SSL_VERIFYHOST => false,
  2872.             CURLOPT_HTTPHEADER => array(),
  2873.             CURLOPT_POSTFIELDS => $applicantFiles
  2874.         ));
  2875.         $retData curl_exec($curl);
  2876.         $errData curl_error($curl);
  2877.         curl_close($curl);
  2878.         $retDataObj json_decode($retDatatrue);
  2879.         if (!isset($retDataObj['status']) || $retDataObj['status'] !== 'success') {
  2880.             return new JsonResponse([
  2881.                 'status' => 'error',
  2882.                 'message' => 'Failed to get applicant data from central server',
  2883.                 'response' => $retDataObj
  2884.             ]);
  2885.         }
  2886.         $centralData $retDataObj['centralData'];
  2887.         $em $this->getDoctrine()->getManager();
  2888.         $existingUser $em->getRepository('ApplicationBundle:SysUser')->findOneBy([
  2889.             'globalId' => $centralData['globalId']
  2890.         ]);
  2891.         if ($existingUser) {
  2892.             return new JsonResponse([
  2893.                 'status' => 'info',
  2894.                 'message' => 'User is already onboarded',
  2895.                 'userId' => $existingUser->getUserId(),
  2896.                 'redirectUrl' => 'dashboard'
  2897.             ]);
  2898.         }
  2899.         $sysUser = new SysUser();
  2900.         $sysUser->setGlobalId($centralData['globalId'] ?? '');
  2901.         $sysUser->setUsername($centralData['username'] ?? '');
  2902.         $sysUser->setEmail($centralData['email'] ?? '');
  2903.         $sysUser->setName($centralData['firstname'] ?? '');
  2904.         $sysUser->setUserType(1);
  2905.         $sysUser->setUserAppId($appId);
  2906.         $sysUser->setUserCompanyId($companyId);
  2907.         $sysUser->setStatus(1);
  2908.         $sysUser->setDefaultRoute('sales_dashboard');
  2909.         $em->persist($sysUser);
  2910.         $em->flush();
  2911.         $employee $em->getRepository('ApplicationBundle:Employee')
  2912.             ->findOneBy(
  2913.                 array(
  2914.                     'userId' => $sysUser->getUserId(),
  2915.                 )
  2916.             );
  2917.         if (!$employee) {
  2918.             $employee = new Employee();
  2919.             if ($sysUser->getUserId()) {
  2920.                 $employee->setEmail($sysUser->getEmail());
  2921.                 $employee->setFirstName($sysUser->getUsername());
  2922.                 $employee->setLastName($sysUser->getName());
  2923.                 $employee->setCompanyId($sysUser->getUserCompanyId());
  2924.                 $employee->setStatus(1);
  2925.                 $employee->setUserId($sysUser->getUserId());
  2926.                 $em->persist($employee);
  2927.                 $em->flush();
  2928.             } else {
  2929.                 return new JsonResponse([
  2930.                     'status' => 'error',
  2931.                     'message' => 'Missing employee data',
  2932.                 ]);
  2933.             }
  2934.         }
  2935.         $employeeDetails $em->getRepository('ApplicationBundle:EmployeeDetails')
  2936.             ->findOneBy([
  2937.                 'userId' => $sysUser->getUserId(),
  2938.             ]);
  2939.         if (!$employeeDetails) {
  2940.             $employeeDetails = new EmployeeDetails();
  2941.             if ($sysUser->getUserId() && $employee->getEmployeeId()) {
  2942.                 $employeeDetails->setId($employee->getEmployeeId());
  2943.                 $employeeDetails->setEmail($sysUser->getEmail());
  2944.                 $employeeDetails->setFirstName($sysUser->getUsername());
  2945.                 $employeeDetails->setLastName($sysUser->getName());
  2946.                 $employeeDetails->setUsername($sysUser->getUsername());
  2947.                 $employeeDetails->setUserId($sysUser->getUserId());
  2948.                 $employeeDetails->setEmpStatus(1);
  2949.                 $em->persist($employeeDetails);
  2950.                 $em->flush();
  2951.             } else {
  2952.                 return new JsonResponse([
  2953.                     'status' => 'error',
  2954.                     'message' => 'Missing employee details data',
  2955.                 ]);
  2956.             }
  2957.         }
  2958.         $company $em->getRepository('ApplicationBundle:Company')->find($companyId);
  2959.         $companyName $company $company->getName() : '';
  2960.         $newAccess = [
  2961.             'userType' => 2,
  2962.             'userTypeName' =>UserConstants::$userTypeName[2] ,
  2963.             'globalId' => $applicantId,
  2964.             'serverId' => 1,
  2965.             'serverUrl' => $request->getSchemeAndHttpHost(),
  2966.             'serverPort' => 80,
  2967.             'systemType' => '_ERP_',
  2968.             'companyId' => 1,
  2969.             'appId' =>$appId,
  2970.             'companyLogoUrl' => '/uploads/CompanyImage/company_image' $request->request->get('appId') . '.png',
  2971.             'companyName' => $companyName,
  2972.             'authenticationStr' => $this->get('url_encryptor')->encrypt(json_encode(
  2973.                     array(
  2974.                         'globalId' =>$applicantId,
  2975.                         'appId' => $appId,
  2976.                         'authenticate' => 1,
  2977.                         'userType' => 2,
  2978.                         'userTypeName' => UserConstants::$userTypeName[2]
  2979.                     )
  2980.                 )
  2981.             ),
  2982.             'userCompanyList' => [],
  2983.         ];
  2984.         $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/update_token_storage';
  2985.         $curl curl_init();
  2986.         curl_setopt_array($curl, array(
  2987.             CURLOPT_RETURNTRANSFER => 1,
  2988.             CURLOPT_POST => 1,
  2989.             CURLOPT_URL => $urlToCall,
  2990.             CURLOPT_CONNECTTIMEOUT => 10,
  2991.             CURLOPT_SSL_VERIFYPEER => false,
  2992.             CURLOPT_SSL_VERIFYHOST => false,
  2993.             CURLOPT_HTTPHEADER => array(),
  2994.             CURLOPT_POSTFIELDS => json_encode($newAccess)
  2995.         ));
  2996.         $retData curl_exec($curl);
  2997.         $errData curl_error($curl);
  2998.         return new JsonResponse([
  2999.             'status' => 'success',
  3000.             'message' => 'User onboarded successfully',
  3001.             'redirectUlr'=> 'dashboard',
  3002.             'returnData'=>$retData,
  3003.             'errorData' =>$errData
  3004.         ]);
  3005.     }
  3006.     public function DecodeQrAction(Request $request)
  3007.     {
  3008.         $applicantId $request->request->get('applicant_id');
  3009.         $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/get_applicant_data_central';
  3010.         $applicantFiles = [
  3011.             'applicantId' => $applicantId
  3012.         ];
  3013.         $curl curl_init();
  3014.         curl_setopt_array($curl, array(
  3015.             CURLOPT_RETURNTRANSFER => 1,
  3016.             CURLOPT_POST => 1,
  3017.             CURLOPT_URL => $urlToCall,
  3018.             CURLOPT_CONNECTTIMEOUT => 10,
  3019.             CURLOPT_SSL_VERIFYPEER => false,
  3020.             CURLOPT_SSL_VERIFYHOST => false,
  3021.             CURLOPT_HTTPHEADER => array(),
  3022.             CURLOPT_POSTFIELDS => $applicantFiles
  3023.         ));
  3024.         $retData curl_exec($curl);
  3025.         $errData curl_error($curl);
  3026.         curl_close($curl);
  3027.         $retDataObj json_decode($retDatatrue);
  3028.         return new JsonResponse($retDataObj['centralData']);
  3029.     }
  3030.     public function GetApplicantDataForErpAction(Request $request)
  3031.     {
  3032.         $applicantId $request->request->get('applicantId');
  3033.         if (!$applicantId) {
  3034.             return new JsonResponse([
  3035.                 'status' => 'error',
  3036.                 'message' => 'Missing applicantId in request.'
  3037.             ]);
  3038.         }
  3039.         $em_goc $this->getDoctrine()->getManager('company_group');
  3040.         $entityApplicant $em_goc->getRepository("CompanyGroupBundle:EntityApplicantDetails")
  3041.             ->findOneBy(['applicantId' => $applicantId]);
  3042.         if (!$entityApplicant) {
  3043.             return new JsonResponse([
  3044.                 'status' => 'error',
  3045.                 'message' => 'Applicant not found.'
  3046.             ]);
  3047.         }
  3048.         return new JsonResponse([
  3049.             'status' => 'success',
  3050.             'centralData' => [
  3051.                 'globalId' => $entityApplicant->getApplicantId(),
  3052.                 'username' => $entityApplicant->getUsername(),
  3053.                 'email' => $entityApplicant->getEmail(),
  3054.                 'firstname' => $entityApplicant->getFirstname(),
  3055.                 'lastname' => $entityApplicant->getLastname(),
  3056.                 'image' => $entityApplicant->getImage(),
  3057.                 'phone' => $entityApplicant->getPhone(),
  3058.                 'address' => $entityApplicant->getPermAddr()
  3059.             ]
  3060.         ]);
  3061.     }
  3062.     public function UpdateTokenStorageAction(Request $request)
  3063.     {
  3064.         $em_goc $this->getDoctrine()->getManager('company_group');
  3065.         $newAccess $request->request->all();
  3066.         $appId = isset($newAccess['appId']) ? $newAccess['appId'] : null;
  3067.         $globalId = isset($newAccess['globalId']) ? $newAccess['globalId'] : null;
  3068.         $sesssionData MiscActions::UpdateCompanyListInSession(
  3069.             $em_goc,
  3070.             $globalId,
  3071.             1,
  3072.             1,
  3073.             1,
  3074.             $newAccess
  3075.         );
  3076.         return new JsonResponse([
  3077.             'status' => 'success',
  3078.             'message' => 'Token storage updated',
  3079.             'newaccess' => $newAccess
  3080.         ]);
  3081.     }
  3082.     public function EmployeeListAction(Request $data)
  3083.     {
  3084.         $em $this->getDoctrine()->getManager();
  3085.         if ($data->isMethod('GET')) {
  3086.             return $this->render("ApplicationBundle:pages/human_resource/list:list_employee.html.twig", array(
  3087.                 'page_title' => 'Employee List',
  3088.             ));
  3089.         }
  3090.     }
  3091.     public function OrganizationChartAction()
  3092.     {
  3093.         $em $this->getDoctrine()->getManager();
  3094.         $Reponse HumanResource::TwigDataForOrgChart($em);
  3095.         return $this->render('ApplicationBundle:pages/human_resource/views:org_chart.html.twig', array(
  3096.             'page_title' => 'Organization Chart',
  3097.             'supervisors' => $Reponse['TreantJsData'],
  3098.             'alluser' => $Reponse['TreantJsInitUser']
  3099.         ));
  3100.     }
  3101.     public function EmployeeListSelectizeAjaxAction(Request $request$str '_EMPTY_')
  3102.     {
  3103.         $em $this->getDoctrine()->getManager();
  3104.         $companyId $this->getLoggedUserCompanyId($request);
  3105.         $company_data Company::getCompanyData($em$companyId);
  3106.         $data = [];
  3107.         $html '';
  3108.         $qryStrs explode(' '$str);
  3109.         $qryStrAddedForSpacedName "";
  3110.         if ($str == '_EMPTY_') {
  3111.             $query "SELECT *
  3112. from  employee  order by employee_id asc limit 10";
  3113.         } else {
  3114.             foreach ($qryStrs as $qryStr) {
  3115.                 $qryStrAddedForSpacedName .= "or first_name like '%$qryStr%' or last_name like '%$qryStr%' ";
  3116.             }
  3117.             $query "SELECT  *
  3118. 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";
  3119.         }
  3120.         $stmt $em->getConnection()->prepare($query);
  3121.         $stmt->execute();
  3122.         $res $stmt->fetchAll();
  3123. //    if(!empty($res)) {
  3124.         foreach ($res as $i => $r) {
  3125.             $res[$i]['id_padded'] = str_pad($r['employee_id'], 8'0'STR_PAD_LEFT);
  3126.         }
  3127. //    }
  3128.         return new JsonResponse(
  3129.             array(
  3130.                 'success' => true,
  3131.                 'data' => $res,
  3132.             )
  3133.         );
  3134.     }
  3135.     public function AttendanceAction(Request $data$remoteVerify 0)
  3136.     {
  3137.         $em $this->getDoctrine()->getManager();
  3138.         $em_goc $this->getDoctrine()->getManager('company_group');
  3139.         $workHourPolicy $em->getRepository('ApplicationBundle:WorkHourPolicy')->findAll();
  3140.         $options = array(
  3141.             'notification_enabled' => $this->container->getParameter('notification_enabled'),
  3142.             'notification_server' => $this->container->getParameter('notification_server'),
  3143.         );
  3144.         if ($data->get('DataTable')) {
  3145.             $response HumanResource::HandelAjaxRequestForManualAttendance($em$data);
  3146.             return new JsonResponse($response);
  3147.         }
  3148.         if ($data->request->get('getAttendanceStatus')) {
  3149.             $response HumanResource::getAttendanceStatus($em$data);
  3150.             return new JsonResponse($response);
  3151.         }
  3152.         $session $data->getSession();
  3153. //        if ($session->get('devAdminMode', 0) != 1 && $data->get('returnJson', 0) == 0)
  3154. //            return $this->redirectToRoute('permission_denied_page');
  3155.         // Auto attendance
  3156.         if ($data->get('autoAttendance') && $data->request->has('position_array')) {
  3157. //            $empId = $data->query->get('id');
  3158.             $empId $data->request->get('id'$session->get(UserConstants::USER_EMPLOYEE_ID));
  3159.             $positionsArray $data->request->get('position_array', []);
  3160.             if (is_string($positionsArray)) $positionsArray json_decode($positionsArraytrue);
  3161.             if ($positionsArray == null$positionsArray = [];
  3162.             $dataByAttId = [];
  3163.             $workPlaceType '_UNSET_';
  3164.             foreach ($positionsArray as $d) {
  3165.                 $sysUserId 0;
  3166.                 $userId 0;
  3167.                 $empId 0;
  3168.                 $dtTs 0;
  3169.                 $timeZoneStr '+0000';
  3170. //                $timeZoneStr = '+0600';
  3171.                 $token '_unset_';
  3172.                 if (isset($d['token'])) $token $d['token'];
  3173.                 if (isset($d['employeeId'])) $empId $d['employeeId'];
  3174.                 if (isset($d['userId'])) $userId $d['userId'];
  3175.                 if (isset($d['sysUserId'])) $sysUserId $d['sysUserId'];
  3176.                 if (isset($d['tsMilSec'])) {
  3177.                     $dtTs ceil(($d['tsMilSec']) / 1000);
  3178.                 }
  3179.                 if ($token != '_unset_') {
  3180.                     $sessionData MiscActions::GetSessionDataFromToken($em_goc$token)['sessionData'];
  3181.                     if (isset($sessionData[UserConstants::USER_EMPLOYEE_ID]))
  3182.                         $empId $sessionData[UserConstants::USER_EMPLOYEE_ID];
  3183.                 }
  3184.                 if ($sysUserId == 0)
  3185.                     $sysUserId $userId;
  3186.                 if ($sysUserId == 0)
  3187.                     $sysUserId $em->getRepository(Employee::class)
  3188.                         ->findOneBy(['employeeId' => $empId])->getUserId();
  3189.                 if ($dtTs == 0) {
  3190.                     $currTsTime = new \DateTime();
  3191.                     $dtTs $currTsTime->format('U');
  3192.                 } else {
  3193.                     $currTsTime = new \DateTime('@' $dtTs);
  3194.                 }
  3195.                 $currTsTime->setTimezone(new \DateTimeZone('UTC'));
  3196.                 $attDate = new \DateTime($currTsTime->format('Y-m-d') . ' 00:00:00' $timeZoneStr);
  3197.                 $EmployeeAttendance $this->getDoctrine()
  3198.                     ->getRepository(EmployeeAttendance::class)
  3199.                     ->findOneBy(array('employeeId' => $empId'date' => $attDate));
  3200.                 if (!$EmployeeAttendance)
  3201.                     $EmployeeAttendance = new EmployeeAttendance;
  3202.                 $attendanceInfo HumanResource::StoreAttendance($em$empId$sysUserId$data$EmployeeAttendance$attDate$dtTs$timeZoneStr$d['markerId']);
  3203.                 if ($d['markerId'] == HumanResourceConstant::ATTENDANCE_MARKER_CLOCK_IN) {
  3204.                     if ($empId == 24)
  3205.                         $workPlaceType '_HYBRID_';
  3206.                     else
  3207.                         $workPlaceType '_STATIC_';
  3208.                 }
  3209.                 if (!isset($dataByAttId[$attendanceInfo->getId()]))
  3210.                     $dataByAttId[$attendanceInfo->getId()] = array(
  3211.                         'attendanceInfo' => $attendanceInfo,
  3212.                         'empId' => $empId,
  3213.                         'lat' => 0,
  3214.                         'lng' => 0,
  3215.                         'address' => 0,
  3216.                         'sysUserId' => $sysUserId,
  3217.                         'companyId' => $data->getSession()->get(UserConstants::USER_COMPANY_ID),
  3218.                         'appId' => $data->getSession()->get(UserConstants::USER_APP_ID),
  3219.                         'positionArray' => []
  3220.                     );
  3221.                 $posData = array(
  3222.                     'ts' => $dtTs,
  3223.                     'lat' => $d['lat'],
  3224.                     'lng' => $d['lng'],
  3225.                     'marker' => $d['markerId'],
  3226.                     'src' => 2,
  3227.                 );
  3228.                 $posDataArray = array(
  3229.                     $dtTs,
  3230.                     $d['lat'],
  3231.                     $d['lng'],
  3232.                     $d['markerId'],
  3233.                     2
  3234.                 );
  3235.                 $dataByAttId[$attendanceInfo->getId()]['markerId'] = $d['markerId'];
  3236.                 //this markerId will be calclulted and modified to check if user is in our out of office/workplace later
  3237.                 $dataByAttId[$attendanceInfo->getId()]['attendanceInfo'] = $attendanceInfo;
  3238.                 $dataByAttId[$attendanceInfo->getId()]['positionArray'][] = $posData;
  3239.                 $dataByAttId[$attendanceInfo->getId()]['lat'] = $d['lat'];  //for last lat lng etc
  3240.                 $dataByAttId[$attendanceInfo->getId()]['lng'] = $d['lng'];  //for last lat lng etc
  3241.                 if (isset($d['address']))
  3242.                     $dataByAttId[$attendanceInfo->getId()]['address'] = $d['address'];  //for last lat lng etc
  3243. //                $dataByAttId[$attendanceInfo->getId()]['positionArray'][]=$posDataArray;
  3244.             }
  3245.             $response = array(
  3246.                 'success' => true,
  3247.             );
  3248.             foreach ($dataByAttId as $attInfoId => $d) {
  3249.                 $response HumanResource::setAttendanceLogFlutterApp($em,
  3250.                     $d['empId'],
  3251.                     $d['sysUserId'],
  3252.                     $d['companyId'],
  3253.                     $d['appId'],
  3254.                     $data,
  3255.                     $d['attendanceInfo'],
  3256.                     $options,
  3257.                     $d['positionArray'],
  3258.                     $d['lat'],
  3259.                     $d['lng'],
  3260.                     $d['address'],
  3261.                     $d['markerId']
  3262.                 );
  3263.             }
  3264.             if ($data->request->get('requestFromMobile')) {
  3265.                 $today = new \DateTime(date('y-m-d'));
  3266.                 $repository $this->getDoctrine()->getRepository(EmployeeAttendance::class);
  3267.                 $ActivitiesTemplate HumanResource::getCurrentStatusFromDb($repository$empId$today);
  3268.                 return new JsonResponse(array(
  3269.                     'success' => $response['success'] == true true false,
  3270.                     'msg' => $response['success'] == true 'Employee activities successfully updated.' 'Action Failed',
  3271.                     'workPlaceType' => $workPlaceType,
  3272.                     'data' => $ActivitiesTemplate
  3273.                 ));
  3274.             }
  3275.             return new JsonResponse(
  3276.                 array(
  3277.                     'success' => true,
  3278.                     'msg' => 'Employee activities successfully updated.',
  3279.                     'workPlaceType' => $workPlaceType,
  3280.                 )
  3281.             );
  3282.         } else if ($data->get('autoAttendance')) {
  3283.             $sysUserId 0;
  3284.             $userId 0;
  3285.             $empId 0;
  3286.             $dtTs 0;
  3287. //            $timeZoneStr = '+0600';
  3288.             $timeZoneStr '+0000';
  3289.             if ($data->request->get('requestFromMobile')) {
  3290.                 $empId $data->request->get('employeeId');
  3291.                 $userId $data->request->get('userId'0);
  3292.                 $sysUserId $data->request->get('id'0);
  3293. //        $empId = $em->getRepository(Employee::class)
  3294. //            ->findOneBy(['userId' => $userId])->getEmployeeId();
  3295.             } else {
  3296.                 $empId $data->request->get('employeeId'0);
  3297.                 $sysUserId $data->request->get('userId'0);
  3298.             }
  3299.             $dtTs $data->request->get('timeTs'0);
  3300.             if ($sysUserId == 0)
  3301.                 $sysUserId $userId;
  3302.             if ($sysUserId == 0)
  3303.                 $sysUserId $em->getRepository(Employee::class)
  3304.                     ->findOneBy(['employeeId' => $empId])->getUserId();
  3305.             if ($dtTs == 0) {
  3306.                 $currTsTime = new \DateTime();
  3307.                 $dtTs $currTsTime->format('U');
  3308.             } else {
  3309.                 $currTsTime = new \DateTime('@' $dtTs);
  3310.             }
  3311.             if ($sysUserId == 0)
  3312.                 $sysUserId $userId;
  3313.             if ($sysUserId == 0)
  3314.                 $sysUserId $em->getRepository(Employee::class)
  3315.                     ->findOneBy(['employeeId' => $empId])->getUserId();
  3316.             $today = new \DateTime(date('y-m-d'));
  3317.             $currTsTime->setTimezone(new \DateTimeZone('UTC'));
  3318.             $attDate = new \DateTime($currTsTime->format('Y-m-d') . ' 00:00:00' $timeZoneStr);
  3319.             $EmployeeAttendance $this->getDoctrine()
  3320.                 ->getRepository(EmployeeAttendance::class)
  3321.                 ->findOneBy(array('employeeId' => $empId'date' => $attDate));
  3322.             if (!$EmployeeAttendance)
  3323.                 $EmployeeAttendance = new EmployeeAttendance;
  3324. //            return new JsonResponse(["success" => true, "data" => $ActivitiesTemplate]);
  3325. //            $attendanceInfo = HumanResource::StoreAttendance($em, $empId, $sysUserId, $data, $EmployeeAttendance, $customTime);
  3326.             $attendanceInfo HumanResource::StoreAttendance($em$empId$sysUserId$data$EmployeeAttendance$attDate$dtTs$timeZoneStrHumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED);
  3327.             if (!isset($dataByAttId[$attendanceInfo->getId()]))
  3328.                 $dataByAttId[$attendanceInfo->getId()] = array(
  3329.                     'attendanceInfo' => $attendanceInfo,
  3330.                     'empId' => $empId,
  3331.                     'lat' => 0,
  3332.                     'lng' => 0,
  3333.                     'address' => 0,
  3334.                     'sysUserId' => $sysUserId,
  3335.                     'companyId' => $data->getSession()->get(UserConstants::USER_COMPANY_ID),
  3336.                     'appId' => $data->getSession()->get(UserConstants::USER_APP_ID),
  3337.                     'positionArray' => []
  3338.                 );
  3339.             $posData = array(
  3340.                 'ts' => $dtTs,
  3341.                 'lat' => 0,
  3342.                 'lng' => 0,
  3343.                 'marker' => HumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED,
  3344.                 'src' => 1,
  3345.             );
  3346.             $posDataArray = array(
  3347.                 $dtTs,
  3348.                 0,
  3349.                 0,
  3350.                 HumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED,
  3351.                 1
  3352.             );
  3353.             $dataByAttId[$attendanceInfo->getId()]['markerId'] = HumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED;
  3354.             //this markerId will be calclulted and modified to check if user is in our out of office/workplace later
  3355.             $dataByAttId[$attendanceInfo->getId()]['attendanceInfo'] = $attendanceInfo;
  3356.             $dataByAttId[$attendanceInfo->getId()]['positionArray'][] = $posData;
  3357.             $dataByAttId[$attendanceInfo->getId()]['lat'] = 0;  //for last lat lng etc
  3358.             $dataByAttId[$attendanceInfo->getId()]['lng'] = 0;  //for last lat lng etc
  3359.             if (isset($d['address']))
  3360.                 $dataByAttId[$attendanceInfo->getId()]['address'] = '';  //for last lat lng etc
  3361.             $response = array(
  3362.                 'success' => true
  3363.             );
  3364.             foreach ($dataByAttId as $attInfoId => $d) {
  3365.                 $response HumanResource::setAttendanceLogFlutterApp($em,
  3366.                     $d['empId'],
  3367.                     $d['sysUserId'],
  3368.                     $d['companyId'],
  3369.                     $d['appId'],
  3370.                     $data,
  3371.                     $d['attendanceInfo'],
  3372.                     $options,
  3373.                     $d['positionArray'],
  3374.                     $d['lat'],
  3375.                     $d['lng'],
  3376.                     $d['address'],
  3377.                     $d['markerId']
  3378.                 );
  3379.             }
  3380.             if ($data->request->get('requestFromMobile')) {
  3381.                 return new JsonResponse(array(
  3382.                     'success' => $response['success'] == true true false,
  3383.                     'msg' => $response['success'] == true 'Employee activities successfully updated.' 'Action Failed',
  3384.                 ));
  3385.             }
  3386.             return new JsonResponse(
  3387.                 array(
  3388.                     'success' => true,
  3389.                     'dtTs' => $dtTs,
  3390.                     'attDate' => $attDate->format(DATE_RFC822),
  3391.                     'currTsTime' => $currTsTime->format(DATE_RFC822),
  3392.                     'msg' => 'Employee activities successfully updated.',
  3393.                 )
  3394.             );
  3395. //
  3396. //
  3397. //            $response = HumanResource::setAttendanceLog($em, $empId, $sysUserId,
  3398. //                $data->getSession()->get(UserConstants::USER_COMPANY_ID),
  3399. //                $data->getSession()->get(UserConstants::USER_APP_ID),
  3400. //                $data, $attendanceInfo, $options);
  3401. //
  3402. //            if ($data->request->get('requestFromMobile')) {
  3403. //                return new JsonResponse($response);
  3404. //            }
  3405. //
  3406. //            return new JsonResponse(
  3407. //                array(
  3408. //                    'success' => true,
  3409. //                    'msg' => 'Employee activities successfully updated.'
  3410. //                )
  3411. //            );
  3412.             // }
  3413.             // else {
  3414.             //   return new JsonResponse(
  3415.             //     array(
  3416.             //       'success' => false,
  3417.             //       'msg' => "Invalid employee ID"
  3418.             //     )
  3419.             //   );
  3420.             // }
  3421.         } else {
  3422.             if ($data->get('manualAttendance')) {
  3423.                 return $this->render(
  3424.                     'ApplicationBundle:pages/human_resource/input_forms:manual_attendance.html.twig',
  3425.                     array(
  3426.                         'page_title' => 'Manual Attendance',
  3427.                         'workPolicy' => $workHourPolicy,
  3428. //                        'workTime' => json_decode($workHourPolicy->getRepeatationData()),
  3429. //                        'workTime' => json_decode($workHourPolicy->getRepeatationData()),
  3430. //                        'workTime' => json_decode($workHourPolicy->getEmployeeTypeIds(),true),
  3431.                     )
  3432.                 );
  3433.             }
  3434.             // Show all matching employee list during ajax request
  3435.             // Show current location according to id
  3436.             if ($data->get('getCurrLocById')) {
  3437.                 $Id $data->get("id");
  3438.                 $options = array(
  3439.                     'employeeId' => $Id,
  3440.                     'entityDbaseName' => 'work_hour_policy',
  3441.                     'entityDbaseIdField' => 'id',
  3442.                     'entityDbaseEmployeeIdsField' => 'employeeIds',
  3443.                     'entityDesignationIdsField' => 'designationIds',
  3444.                     'entityDepartmentIdsField' => 'departmentIds',
  3445.                     'entityEmployeeTypeIdsField' => 'employee_types',
  3446.                     'limit' => 1,
  3447.                     'single' => 1,
  3448.                 );
  3449.                 $workHourPolicyData HumanResource::getApplicableSettingsDataForEmployee($em$options);
  3450.                 $today = new \DateTime(date('y-m-d'));
  3451.                 $repository $this->getDoctrine()->getRepository(EmployeeAttendance::class);
  3452.                 $ActivitiesTemplate HumanResource::getActivitiesTemplate($repository$Id$today);
  3453.                 return new JsonResponse(["success" => true"workHourPolicyData" => $workHourPolicyData"template" => $ActivitiesTemplate]);
  3454.             }
  3455.         }
  3456.     }
  3457.     public function getCurrentStatusAction($id)
  3458.     {
  3459.         $today = new \DateTime(date('y-m-d'));
  3460.         $repository $this->getDoctrine()->getRepository(EmployeeAttendance::class);
  3461.         $ActivitiesTemplate HumanResource::getCurrentStatusFromDb($repository$id$today);
  3462.         return new JsonResponse(["success" => true"data" => $ActivitiesTemplate]);
  3463.     }
  3464.     public function CurrentAttendanceAction(Request $data)
  3465.     {
  3466.         $em $this->getDoctrine()->getManager();
  3467.         $options = array(
  3468.             'notification_enabled' => $this->container->getParameter('notification_enabled'),
  3469.             'notification_server' => $this->container->getParameter('notification_server'),
  3470.         );
  3471.         if ($data->get('DataTable')) {
  3472.             $response HumanResource::HandelAjaxRequestForManualAttendance($em$data);
  3473.             return new JsonResponse($response);
  3474.         }
  3475.         if ($data->request->get('getAttendanceStatus')) {
  3476.             $response HumanResource::getAttendanceStatus($em$data);
  3477.             return new JsonResponse($response);
  3478.         }
  3479.         // Auto attendance
  3480.         if ($data->get('autoAttendance')) {
  3481.             $empId $data->query->get('id');
  3482.             $sysUserId 0;
  3483.             if ($data->get('requestFromMobile')) {
  3484.                 $sysUserId $data->request->get('id');
  3485.                 $empId $em->getRepository(Employee::class)
  3486.                     ->findOneBy(['userId' => $sysUserId])->getEmployeeId();
  3487.             } else {
  3488.                 $sysUserId $em->getRepository(Employee::class)
  3489.                     ->findOneBy(['employeeId' => $empId])->getUserId();
  3490.             }
  3491.             $customTime $data->get('time');
  3492.             $today = new \DateTime(date('y-m-d'));
  3493.             $EmployeeAttendance $this->getDoctrine()
  3494.                 ->getRepository(EmployeeAttendance::class)
  3495.                 ->findOneBy(array('employeeId' => $empId'date' => $today));
  3496.             if (!$EmployeeAttendance)
  3497.                 $EmployeeAttendance = new EmployeeAttendance;
  3498.             $attendanceInfo HumanResource::StoreAttendance($em$empId$sysUserId$data$EmployeeAttendance$customTime);
  3499.             $response HumanResource::setAttendanceLog($em$empId$sysUserId,
  3500.                 $data->getSession()->get(UserConstants::USER_COMPANY_ID),
  3501.                 $data->getSession()->get(UserConstants::USER_APP_ID),
  3502.                 $data$attendanceInfo$options);
  3503.             if ($data->get('requestFromMobile')) {
  3504.                 return new JsonResponse([$response]);
  3505.             }
  3506.             return new JsonResponse(
  3507.                 array(
  3508.                     'success' => true,
  3509.                     'msg' => 'Employee activities successfully updated.'
  3510.                 )
  3511.             );
  3512.             // }
  3513.             // else {
  3514.             //   return new JsonResponse(
  3515.             //     array(
  3516.             //       'success' => false,
  3517.             //       'msg' => "Invalid employee ID"
  3518.             //     )
  3519.             //   );
  3520.             // }
  3521.         } else {
  3522.             if ($data->get('manualAttendance')) {
  3523.                 return $this->render(
  3524.                     'ApplicationBundle:pages/human_resource/report:current_attendance.html.twig',
  3525.                     array(
  3526.                         'page_title' => 'Current Attendance Status',
  3527.                     )
  3528.                 );
  3529.             }
  3530.             // Show all matching employee list during ajax request
  3531.             // Show current location according to id
  3532.             if ($data->get('getCurrLocById')) {
  3533.                 $Id $data->get("id");
  3534.                 $today = new \DateTime(date('y-m-d'));
  3535.                 $repository $this->getDoctrine()->getRepository(EmployeeAttendance::class);
  3536.                 $ActivitiesTemplate HumanResource::getActivitiesTemplate($repository$Id$today);
  3537.                 return new JsonResponse(["success" => true"template" => $ActivitiesTemplate]);
  3538.             }
  3539.         }
  3540.     }
  3541.     public function EmployeeLeaveAction(Request $data$id=0)
  3542.     {
  3543.         $em $this->getDoctrine()->getManager();
  3544.         $request=$data;
  3545.         if (!$id) {
  3546.             if ($data->isMethod('GET')) {
  3547.                 $EmpID $data->query->get('id');
  3548.                 $LeaveType $data->query->get('leaveType');
  3549.                 if ($data->query->has('id') && $data->query->has('leaveType')) {
  3550.                     $response HumanResource::HandelAjaxRequestForLeaveApp($em$EmpID$LeaveType);
  3551.                     return new JsonResponse($response);
  3552.                 }
  3553.                 if ($data->query->has('id')) {
  3554.                     $Response HumanResource::HandelAjaxRequestForLeaveApp($em$EmpID);
  3555.                     return new JsonResponse($Response);
  3556.                 }
  3557.                 $TemplateData HumanResource::TwigDataForLeaveApp($emFalse);
  3558.                 return $this->render(
  3559.                     'ApplicationBundle:pages/human_resource/input_forms:employee_leave.html.twig',
  3560.                     array(
  3561.                         'page_title' => $TemplateData['Title'],
  3562.                         'EmployeeList' => $TemplateData['EmployeeList'],
  3563.                         'DesignationList' => $TemplateData['DesignationList'],
  3564.                         'HasUpdateMode' => false
  3565.                     )
  3566.                 );
  3567.             } else {
  3568.                 $CompanyId $this->getLoggedUserCompanyId($data);
  3569.                 $Response HumanResource::StoreDataForLeaveApplication($em$id$datafalse$CompanyId);
  3570.                 if ($Response['HasErr']) {
  3571.                     $this->addFlash('error'$Response['msg']);
  3572.                     if ($data->request->has('returnJson')) {
  3573.                         return new JsonResponse(array(
  3574.                             'success' => false,
  3575.                             'errorStr' => $Response['msg'],
  3576.                         ));
  3577.                     } else {
  3578.                         return $this->redirectToRoute('employee_leave');
  3579.                     }
  3580.                 }
  3581.                 $applicationId $Response['applicationId'];
  3582.                 $em_goc $this->getDoctrine()->getManager('company_group');
  3583.                 $file_path_list=[];
  3584.                 if($applicationId!=0) {
  3585.                     if (!empty($request->files)) {
  3586.                         MiscActions::RemoveFilesForEntityDoc($em_goc'EmployeeLeaveApplication'$applicationId);
  3587.                         $storePath 'uploads/LeaveDoc/';
  3588.                         $path "";
  3589.                         $file_path "";
  3590.                         $session $request->getSession();
  3591.                         MiscActions::RemoveExpiredFiles($em_goc);
  3592.                         foreach ($request->files as $uploadedFileGG) {
  3593.                             //            if($uploadedFile->getImage())
  3594.                             //                var_dump($uploadedFile->getFile());
  3595.                             //                var_dump($uploadedFile);
  3596.                             $tempD $uploadedFileGG;
  3597.                             if (!is_array($uploadedFileGG)) {
  3598.                                 $uploadedFileGG = array();
  3599.                                 $uploadedFileGG[] = $tempD;
  3600.                             }
  3601.                             foreach ($uploadedFileGG as $uploadedFile) {
  3602.                                 if ($uploadedFile != null) {
  3603.                                     $extension $uploadedFile->guessExtension();
  3604.                                     $size $uploadedFile->getSize();
  3605.                                     $fileName 'LDOC_' $applicationId '_' . (md5(uniqid())) . '.' $uploadedFile->guessExtension();
  3606.                                     $path $fileName;
  3607.                                     $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/' $storePath;
  3608.                                     if (!file_exists($upl_dir)) {
  3609.                                         mkdir($upl_dir0777true);
  3610.                                     }
  3611.                                     if (file_exists($upl_dir '' $path)) {
  3612.                                         chmod($upl_dir '' $path0755);
  3613.                                         unlink($upl_dir '' $path);
  3614.                                     }
  3615.                                     $file $uploadedFile->move($upl_dir$path);
  3616.                                     $expireNever 1;
  3617.                                     $expireTs 0;
  3618.                                     $EntityFile = new EntityFile();
  3619.                                     $EntityFile->setPath($this->container->getParameter('kernel.root_dir') . '/../web/' $storePath $path);
  3620.                                     $EntityFile->setMarker('_GEN_');
  3621.                                     $EntityFile->setExtension($extension);
  3622.                                     $EntityFile->setExpireTs($expireTs);
  3623.                                     $EntityFile->setSize($size);
  3624.                                     $EntityFile->setRelativePath($storePath $path);
  3625.                                     $EntityFile->setEntityName('EmployeeLeaveApplication');
  3626.                                     $EntityFile->setEntityBundle('EmployeeLeaveApplication');
  3627.                                     $EntityFile->setEntityId($applicationId);
  3628.                                     $EntityFile->setEntityIdField('employeeLeaveApplicationId');
  3629.                                     $EntityFile->setModifyFieldSetter('setFiles');
  3630.                                     $EntityFile->setDocIdForApplicant(0);
  3631.                                     $EntityFile->setUserId($session->get(UserConstants::USER_ID0));
  3632.                                     $EntityFile->setAppId($session->get(UserConstants::USER_APP_ID0));
  3633.                                     $EntityFile->setEmployeeId($session->get(UserConstants::USER_EMPLOYEE_ID0));
  3634.                                     $EntityFile->setUserType($session->get(UserConstants::USER_TYPE0));
  3635.                                     $em_goc->persist($EntityFile);
  3636.                                     $em_goc->flush();
  3637.                                     $EntityFileId $EntityFile->getId();
  3638.                                 }
  3639.                                 if ($path != "")
  3640.                                     $file_path_list[] = ($storePath $path);
  3641.                             }
  3642.                         }
  3643.                         $g_path $this->container->getParameter('kernel.root_dir') . '/../web/' $storePath $path;
  3644.                         $v $em->getRepository('ApplicationBundle:EmployeeLeaveApplication')->findOneBy(array(
  3645.                             'employeeLeaveApplicationId' => $applicationId,
  3646.                         ));
  3647.                         if ($v) {
  3648.                             $v->setFiles(implode(','$file_path_list));
  3649.                             $em->flush();
  3650.                         } else {
  3651.                         }
  3652.                     }
  3653.                 }
  3654.                 // $this->addFlash('success', 'Application submitted successfully!');
  3655.                 // return $this->redirectToRoute('leave_application_list');
  3656.                 if ($data->request->has('returnJson')) {
  3657.                     return new JsonResponse(array(
  3658.                         'success' => true,
  3659.                     ));
  3660.                 } else {
  3661.                     return $this->redirectToRoute('view_employee_leave_application', array('id' => $applicationId));
  3662.                 }
  3663.             }
  3664.         }
  3665.         else {
  3666.             if ($data->isMethod('GET')) {
  3667.                 $ApplicationRepo $em->getRepository(EmployeeLeaveApplication::class);
  3668.                 $OldData $ApplicationRepo->find(array('employeeLeaveApplicationId' => $id));
  3669.                 $TemplateData HumanResource::TwigDataForLeaveApp($em$OldData);
  3670.                 return $this->render(
  3671.                     'ApplicationBundle:pages/human_resource/input_forms:employee_leave.html.twig',
  3672.                     array(
  3673.                         'page_title' => $TemplateData['Title'],
  3674.                         'EmployeeList' => $TemplateData['EmployeeList'],
  3675.                         'DesignationList' => $TemplateData['DesignationList'],
  3676.                         'OldData' => $TemplateData['OldData'],
  3677.                         'AvailableLeave' => $TemplateData['AvailableLeave'],
  3678.                         'HasUpdateMode' => true
  3679.                     )
  3680.                 );
  3681.             } else {
  3682.                 $CompanyId $this->getLoggedUserCompanyId($data);
  3683.                 $Response HumanResource::StoreDataForLeaveApplication($em$id$datatrue$CompanyId);
  3684.                 if ($Response['HasErr']) {
  3685.                     $this->addFlash('error'$Response['msg']);
  3686.                     return $this->redirectToRoute('employee_leave');
  3687.                 }
  3688.                 $this->addFlash('success'"Application updated successfully!");
  3689.                 return $this->redirectToRoute('leave_application_list');
  3690.             }
  3691.         }
  3692.     }
  3693.     public function ViewLeaveApplicationAction(Request $request$id)
  3694.     {
  3695.         $em $this->getDoctrine()->getManager();
  3696.         if ($id) {
  3697.             $TwigData HumanResource::TwigDataForViewLeaveApplication($em$request$id);
  3698.             if ($TwigData['HasErr']) {
  3699.                 return new JsonResponse(array(
  3700.                     'success' => false,
  3701.                     'msg' => $TwigData['Msg']
  3702.                 ));
  3703.             }
  3704.             return $this->render(
  3705.                 'ApplicationBundle:pages/human_resource/views:leave_application_view.html.twig',
  3706.                 array(
  3707.                     'page_title' => 'View Leave Application',
  3708.                     'Applicant' => $TwigData['Applicant'],
  3709.                     'Application' => $TwigData['Application'],
  3710.                     'LeaveType' => $TwigData['LeaveType'],
  3711.                     'LeaveCategory' => $TwigData['LeaveCategory'],
  3712.                     'leaveDataArray' => $TwigData['leaveDataArray'],
  3713.                     'FrwdEmp' => $TwigData['FrwdEmp'],
  3714.                     'ApplicantDesg' => $TwigData['ApplicantDesg'],
  3715.                     'approval_status' => $TwigData['approval_status'],
  3716.                     'approval_data' => $TwigData['approval_data'],
  3717.                     'document_log' => $TwigData['document_log'],
  3718.                     'auto_created' => 0,
  3719.                 )
  3720.             );
  3721.         }
  3722.         return new JsonResponse(array(
  3723.             'success' => false,
  3724.             'msg' => 'Wrong URL format! Please try with application ID'
  3725.         ));
  3726.     }
  3727.     public function PrintLeaveApplicationAction(Request $request$id)
  3728.     {
  3729.         if ($id) {
  3730.             $em $this->getDoctrine()->getManager();
  3731.             $company_data Company::getCompanyData($em1);
  3732.             $Application $em->getRepository(EmployeeLeaveApplication::class)->find($id);
  3733.             $Authorizations System::getSignatureListForDocumentPrint($emarray_flip(GeneralConstant::$Entity_list)['EmployeeLeaveApplication'], $id);
  3734.             $ApplicationCategory $Application->getLeaveCategory();
  3735.             $ApplicationType = ($ApplicationCategory!=&& $ApplicationCategory!= 2)?HumanResourceConstant::$LeaveType[$Application->getLeaveTypeId()]:'';
  3736.             $Applicant $em->getRepository(EmployeeDetails::class)
  3737.                 ->find($Application->getEmployeeId());
  3738.             return $this->render(
  3739.                 'ApplicationBundle:pages/human_resource/print:leave_application_print.html.twig',
  3740.                 array(
  3741.                     'page_title' => 'Print Leave Application',
  3742.                     'export' => 'pdf,print',
  3743.                     'company_name' => $company_data->getName(),
  3744.                     'company_data' => $company_data,
  3745.                     'company_address' => $company_data->getAddress(),
  3746.                     'company_image' => $company_data->getImage(),
  3747.                     'Application' => $Application,
  3748.                     'Applicant' => $Applicant,
  3749.                     'Authorizations' => $Authorizations,
  3750.                     'ApplicationType' => $ApplicationType,
  3751.                     'ApplicationCategory' => $ApplicationCategory,
  3752.                     'red' => 0
  3753.                 )
  3754.             );
  3755.         }
  3756.         return new JsonResponse(array(
  3757.             'success' => false,
  3758.             'msg' => 'Wrong URL format! Please try with application ID'
  3759.         ));
  3760.     }
  3761.     public function LeaveApplicationListAction(Request $request)
  3762.     {
  3763.         $em $this->getDoctrine()->getManager();
  3764.         $response HumanResource::GetEmployeeLeaveApplicationList($em$request);
  3765.         if ($request->isMethod('GET')) {
  3766.             return $this->render("ApplicationBundle:pages/human_resource/list:leave_application_list.html.twig", array(
  3767.                 'page_title' => 'Leave Application List',
  3768.                 'application_data' => $response,
  3769.             ));
  3770.         }
  3771.     }
  3772.     public function PayrollPolicySettingsAction(Request $request$id)
  3773.     {
  3774.         $em $this->getDoctrine()->getManager();
  3775.         $CompanyId $this->getLoggedUserCompanyId($request);
  3776.         if ($id) {
  3777.             if ($request->isMethod('GET')) {
  3778.                 $Row $em->getRepository(PayrollPolicy::class)->find($id);
  3779.                 if (!$Row) {
  3780.                     $this->addFlash('error''Invalid Payroll Policy Id');
  3781.                     return $this->redirectToRoute('payroll_policy_settings');
  3782.                 }
  3783.                 $TwigData HumanResource::GetPayrollPolicyTwigData($em);
  3784.                 $OldData HumanResource::GetPayrollPolicyTwigData($em$id);
  3785.                 return $this->render('ApplicationBundle:pages/human_resource/input_forms:payroll_policy_settings.html.twig', array(
  3786.                     'page_title' => 'Update Payroll Policy Settings',
  3787.                     'EmployeeIds' => $TwigData['EmployeeIds'],
  3788.                     'EmployeeType' => $TwigData['EmployeeType'],//
  3789.                     'department' => $TwigData['department'],
  3790.                     'Designation' => $TwigData['Designation'],
  3791.                     'WorkingDays' => $TwigData['WorkingDays'],
  3792.                     'OldData' => $OldData['Row'],
  3793.                     'earningAspects' => HumanResourceConstant::$earningAspectsForPayrollPolicy,
  3794.                     'leaveTypes' => HumanResourceConstant::$LeaveTypeForPayrollPolicy,
  3795.                     'leaveTypesArray' => HumanResourceConstant::$LeaveTypeArrayForPayrollPolicy,
  3796.                     'deductionAspects' => HumanResourceConstant::$deductionAspects,
  3797.                     'deductionCondition' => json_decode($Row->getDeductionCondition(), true),
  3798.                     'HasUpdateMode' => true,
  3799.                 ));
  3800.             } else {
  3801.                 $Response HumanResource::StorePayrollPolicyData($em$id$CompanyId$request);
  3802.                 if ($Response['HasErr']) {
  3803.                     $this->addFlash('error'$Response['msg']);
  3804.                     return $this->redirectToRoute('payroll_policy_settings');
  3805.                 }
  3806.                 return $this->redirectToRoute('payroll_policy_settings');
  3807. //        if ($Response['isSuccess']) {
  3808. //          return new JsonResponse(array('success' => true, 'msg' => 'don\'t forget to redirect'));
  3809. //        }
  3810. //        return new JsonResponse(array('success' => false, 'msg' => 'Sorry something went wrong'));
  3811.             }
  3812.         } else {
  3813.             if ($request->isMethod('GET')) {
  3814.                 if ($request->query->get('GetDocHash')) {
  3815.                     $Dochash HumanResource::GenerateDocHashForPayrollSettings($em$request);
  3816.                     return new JsonResponse($Dochash);
  3817.                 }
  3818.                 $TwigData HumanResource::GetPayrollPolicyTwigData($em);
  3819.                 return $this->render(
  3820.                     'ApplicationBundle:pages/human_resource/input_forms:payroll_policy_settings.html.twig',
  3821.                     array(
  3822.                         'page_title' => 'Create Payroll Policy Settings',
  3823.                         'EmployeeIds' => $TwigData['EmployeeIds'],
  3824.                         'EmployeeType' => $TwigData['EmployeeType'],
  3825.                         'WorkingDays' => $TwigData['WorkingDays'],
  3826.                         'Designation' => $TwigData['Designation'],
  3827.                         'department' => $TwigData['department'],
  3828.                         'earningAspects' => HumanResourceConstant::$earningAspectsForPayrollPolicy,
  3829.                         'leaveTypes' => HumanResourceConstant::$LeaveTypeForPayrollPolicy,
  3830.                         'leaveTypesArray' => HumanResourceConstant::$LeaveTypeArrayForPayrollPolicy,
  3831.                         'deductionAspects' => HumanResourceConstant::$deductionAspects,
  3832.                         'HasUpdateMode' => false
  3833.                     )
  3834.                 );
  3835.             } else {
  3836.                 $Response HumanResource::StorePayrollPolicyData($em$id$CompanyId$request);
  3837.                 if ($Response['HasErr']) {
  3838.                     $this->addFlash('error'$Response['msg']);
  3839.                     return $this->redirectToRoute('payroll_policy_settings');
  3840.                 }
  3841.                 return $this->redirectToRoute('payroll_policy_settings');
  3842. //        return new JsonResponse(array("success" => true, 'msg' => 'Dont forget to redirect!'));
  3843.             }
  3844.         }
  3845.     }
  3846.     public function AttendanceReportAction(Request $request,$apiKey='impose')
  3847.     {
  3848.         $em $this->getDoctrine()->getManager();
  3849.         $attendanceSource HumanResourceConstant::$attendanceSources;
  3850.         $routeName $request->attributes->get('_route');
  3851.         if($routeName=='app_get_attendendance_data')
  3852.         {
  3853.             $ReportData HumanResource::GenerateAttendanceReport($em$request,$request->get('considerCurrTsIfNoOut',1));
  3854.             $newReports=[];
  3855.             foreach($ReportData['Reports'] as $gg)
  3856.             {
  3857.               foreach($gg as $d)
  3858.               {
  3859.                   $newReports[]=$d;
  3860. //                if(!isset($newReports[$d['id']]))
  3861. //                    $newReports[$d['id']]=array();
  3862. //                    $newReports[$d['id']][]=$d;
  3863.               }
  3864.             }
  3865.             return new JsonResponse (array(
  3866.                 'attendanceSource' => $attendanceSource,
  3867.                 
  3868. //                'Reports' => $ReportData['Reports'],
  3869.                 'Reports' => $newReports,
  3870.                 'from_date' => $ReportData['from_date'],
  3871.                 'to_date' => $ReportData['to_date'],
  3872.                 'report_for' => $ReportData['generated_for'],
  3873.                 'attendance' => $ReportData['attendance'],
  3874.             ));
  3875.         }
  3876.         else
  3877.         {
  3878.             $EmployeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  3879.             $Departments $em->getRepository(SysDepartment::class)->findAll();
  3880.                 if ($request->isMethod('GET')) 
  3881.                 {
  3882.                     return $this->render('ApplicationBundle:pages/human_resource/report:attendance_report.html.twig', array(
  3883.                         'page_title' => 'Attendance Report',
  3884.                         'employes' => $EmployeeIds,
  3885.                         'departments' => $Departments,
  3886.                         'isMethodGet' => true,
  3887.                         'from_date' => '',
  3888.                         'to_date' => '',
  3889.                         'report_for' => '',
  3890.                         'attendance' => [],
  3891.                         'Reports' => [],
  3892.                         'qry' => ''
  3893.                     ));
  3894.                 }
  3895.                 $ReportData HumanResource::GenerateAttendanceReport($em$request,$request->request->get('considerCurrTsIfNoOut',0));
  3896.                 if($request->request->get('returnJson',0)==1)
  3897.                 {
  3898.                 return new JsonResponse($ReportData);
  3899.                 }
  3900.                 $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') : []));
  3901.                 return $this->render('ApplicationBundle:pages/human_resource/report:attendance_report.html.twig', array(
  3902.                     'page_title' => 'Attendance Report',
  3903.                     'isMethodGet' => false,
  3904.                     'departments' => $Departments,
  3905.                     'employes' => $EmployeeIds,
  3906.                     'attendanceSource' => $attendanceSource,
  3907.                     'Reports' => $ReportData['Reports'],
  3908.                     'from_date' => $ReportData['from_date'],
  3909.                     'to_date' => $ReportData['to_date'],
  3910.                     'report_for' => $ReportData['generated_for'],
  3911.                     'attendance' => $ReportData['attendance'],
  3912.                     'qry' => $Qry
  3913.                 ));
  3914.         }
  3915.     }
  3916.     public function PrintAttendanceReportAction(Request $request)
  3917.     {
  3918.         $em $this->getDoctrine()->getManager();
  3919.         $company_data Company::getCompanyData($em1);
  3920.         $ReportData HumanResource::GenerateAttendanceReport($em$request);
  3921.         return $this->render(
  3922.             'ApplicationBundle:pages/human_resource/print:print_attendance_report.html.twig',
  3923.             array(
  3924.                 'page_title' => 'Print Attendance Report',
  3925.                 'export' => 'pdf,print',
  3926.                 'company_name' => $company_data->getName(),
  3927.                 'company_data' => $company_data,
  3928.                 'company_address' => $company_data->getAddress(),
  3929.                 'company_image' => $company_data->getImage(),
  3930.                 'Reports' => $ReportData['Reports'],
  3931.                 'from_date' => $ReportData['from_date'],
  3932.                 'to_date' => $ReportData['to_date'],
  3933.                 'report_for' => $ReportData['generated_for'],
  3934.                 'attendance' => $ReportData['attendance'],
  3935.                 'red' => 0
  3936.             )
  3937.         );
  3938.     }
  3939.     public function DisburseSalaryAction(Request $request)
  3940.     {
  3941.         $em $this->getDoctrine()->getManager();
  3942.         $EmployeeIds $em->getRepository(EmployeeDetails::class)->findBy(
  3943.             array(
  3944.                 'emp_status'=>1
  3945.             )
  3946.         );
  3947.         $startDate=$request->get('salary_start_date','');
  3948.         $endDate=$request->get('salary_till_date','');
  3949.         $filterType=$request->get('filterType',1);
  3950.         $filterBranchIds=$request->get('branchIds',[]);
  3951.         $filterBankIds=$request->get('bankIds',[]);
  3952.         $filterDepartmentIds=$request->get('departmentIds',[]);
  3953.         $filterEmployeeIds=$request->get('employeeIds',[]);
  3954.         $Departments $em->getRepository(SysDepartment::class)->findAll();
  3955.         $attendance $em->getRepository(EmployeeAttendanceLog::class)->findAll();
  3956.         $banks $em->getRepository(BankList::class)->findAll();
  3957.         $branches $em->getRepository(Branch::class)->findAll();
  3958.         if ($request->isMethod('GET')) {
  3959.             return $this->render('ApplicationBundle:pages/human_resource/report:disburse_salary.html.twig', array(
  3960.                 'page_title' => 'Disburse Salary',
  3961.                 'EmployeeIds' => $EmployeeIds,
  3962.                 'departments' => $Departments,
  3963.                 'attendance' => $attendance,
  3964.                 'branches' => $branches,
  3965.                 'banks' => $banks,
  3966.                 'SalaryReports' => [],
  3967.                 'from_date' => '',
  3968.                 'to_date' => '',
  3969.                 'Qry' => '',
  3970.                 'isMethodGet' => true,
  3971.                 'filterType' => $filterType,
  3972.                 'startDate' => $startDate,
  3973.                 'endDate' => $endDate,
  3974.                 'filterBranchIds' => $filterBranchIds,
  3975.                 'filterBankIds' => $filterBankIds,
  3976.                 'filterDepartmentIds' => $filterDepartmentIds,
  3977.                 'filterEmployeeIds' => $filterEmployeeIds,
  3978.             ));
  3979.         }
  3980.         $SalaryReports HumanResource::BasicDeduction($em$request);
  3981. //        $SalaryReportsNew = HumanResource::calculateSalary($em,
  3982. //            array(
  3983. //                'startDate' => $request->get('salary_start_date', ''),
  3984. //                'endDate' => $request->get('salary_end_date', ''),
  3985. //                'timeZone' => $request->get('time_zone', '+0600'),
  3986. //                'employeeIds' => $request->get('employeeIds', []),
  3987. //                'departmentIds' => $request->get('department', []),
  3988. //                'allFlag' => $request->get('show_all', 0),
  3989. //
  3990. //            )
  3991. //        );
  3992.         $Qry "salary_till_date=" $endDate '&'  "departmentIds=" implode(',',$filterDepartmentIds) . '&' "employeeIds=" implode(','$filterEmployeeIds).
  3993.                 '&'  "salary_start_date=" $startDate.
  3994.                 '&'  "filterType=" $filterType.
  3995.                 '&'  "branchIds=" implode(',',$filterBranchIds).
  3996.                 '&'  "bankIds=" implode(',',$filterBankIds);
  3997. //        if ($request->get('returnJson', 0) == 1) {
  3998.         if ($request->get('returnJson'0) == 1) {
  3999.             return new JsonResponse(array(
  4000.                 'SalaryReports' => $SalaryReports,
  4001.             ));
  4002.         } else {
  4003.             return $this->render('ApplicationBundle:pages/human_resource/report:disburse_salary.html.twig', array(
  4004.                 'page_title' => 'Disburse Salary',
  4005.                 'EmployeeIds' => $EmployeeIds,
  4006.                 'departments' => $Departments,
  4007.                 'branches' => $branches,
  4008.                 'banks' => $banks,
  4009.                 'SalaryReports' => $SalaryReports,
  4010.                 'for_month' => $SalaryReports[0]['for_month'],
  4011.                 'from_date' => $SalaryReports[0]['from_date'],
  4012.                 'to_date' => $SalaryReports[0]['to_date'],
  4013.                 'Qry' => $Qry,
  4014.                 'isMethodGet' => false,
  4015.                 'startDate' => $startDate,
  4016.                 'endDate' => $endDate,
  4017.                 'filterType' => $filterType,
  4018.                 'filterBranchIds' => $filterBranchIds,
  4019.                 'filterBankIds' => $filterBankIds,
  4020.                 'filterDepartmentIds' => $filterDepartmentIds,
  4021.                 'filterEmployeeIds' => $filterEmployeeIds,
  4022.             ));
  4023.         }
  4024.     }
  4025.     public function PrintDisburseSalaryAction(Request $Req)
  4026.     {
  4027.         $em $this->getDoctrine()->getManager();
  4028.         $company_data Company::getCompanyData($em1);
  4029.         $SalaryReports HumanResource::BasicDeduction($em$Req);
  4030.         return $this->render(
  4031.             'ApplicationBundle:pages/human_resource/print:print_disburse_salary.html.twig',
  4032.             array(
  4033.                 'page_title' => 'Print Disburse Salary',
  4034.                 'export' => 'pdf,print',
  4035.                 'company_name' => $company_data->getName(),
  4036.                 'company_data' => $company_data,
  4037.                 'company_address' => $company_data->getAddress(),
  4038.                 'company_image' => $company_data->getImage(),
  4039.                 'SalaryReports' => $SalaryReports,
  4040.                 'for_month' => $SalaryReports[0]['for_month'],
  4041.                 'from_date' => $SalaryReports[0]['from_date'],
  4042.                 'to_date' => $SalaryReports[0]['to_date'],
  4043.                 'red' => 0
  4044.             )
  4045.         );
  4046.     }
  4047.     public function SalaryReportAction(Request $request)
  4048.     {
  4049.         $em $this->getDoctrine()->getManager();
  4050.         $startDate $request->get('salary_start_date''');
  4051.         $endDate $request->get('salary_till_date''');
  4052.         $segregationType $request->get('segregationType'1);
  4053.         $filterBranchIds $request->get('branchIds', []);
  4054.         $filterBankIds $request->get('bankIds', []);
  4055.         $approvalFilterTypes $request->get('approvalFilterTypes', []);
  4056.         $filterDepartmentIds $request->get('departmentIds', []);
  4057.         $filterEmployeeIds $request->get('employeeIds', []);
  4058.         $Departments $em->getRepository(SysDepartment::class)->findAll();
  4059.         $attendance $em->getRepository(EmployeeAttendanceLog::class)->findAll();
  4060.         $banks $em->getRepository(BankList::class)->findAll();
  4061.         $branches $em->getRepository(Branch::class)->findAll();
  4062.         $SalaryReports HumanResource::GenerateSalaryReport($em$request);
  4063. //        dump($SalaryReports);
  4064.         $Qry "salary_till_date=" $endDate '&' "departmentIds=" implode(','$filterDepartmentIds) . '&' "employeeIds=" implode(','$filterEmployeeIds) .
  4065.             '&' "salary_start_date=" $startDate .
  4066.             '&' "segregationType=" $segregationType .
  4067.             '&' "branchIds=" implode(','$filterBranchIds) .
  4068.             '&' "bankIds=" implode(','$filterBankIds);
  4069. //        if ($request->get('returnJson', 0) == 1) {
  4070.         if ($request->get('returnJson'0) == 1) {
  4071.             return new JsonResponse(array(
  4072.                 'SalaryReports' => $SalaryReports,
  4073.             ));
  4074.         } else {
  4075.             return $this->render('ApplicationBundle:pages/human_resource/report:salary_report.html.twig', array(
  4076.                 'page_title' => 'Salary Report',
  4077.                 'departments' => $Departments,
  4078.                 'branches' => $branches,
  4079.                 'banks' => $banks,
  4080.                 'approvalFilterTypes' => $approvalFilterTypes,
  4081.                 'salaryInfo' => $SalaryReports,
  4082.                 'SalaryReports' => $SalaryReports,
  4083.                 'for_month' => '',
  4084.                 'from_date' => $startDate,
  4085.                 'to_date' => $endDate,
  4086.                 'Qry' => $Qry,
  4087.                 'isMethodGet' => false,
  4088.                 'startDate' => $startDate,
  4089.                 'endDate' => $endDate,
  4090.                 'segregationType' => $segregationType,
  4091.                 'filterBranchIds' => $filterBranchIds,
  4092.                 'filterBankIds' => $filterBankIds,
  4093.                 'filterDepartmentIds' => $filterDepartmentIds,
  4094.                 'filterEmployeeIds' => $filterEmployeeIds,
  4095.             ));
  4096.         }
  4097.     }
  4098.     public function createJobRecruitmentAction(Request $request$id 0)
  4099.     {
  4100.         $data = [];
  4101.         $em_goc $this->getDoctrine()->getManager('company_group');
  4102.         $skillDetails $em_goc->getRepository(EntitySkill::class)->findAll();
  4103.         $em $this->getDoctrine()->getManager();
  4104.         $companyId $this->getLoggedUserCompanyId($request);
  4105.         if ($request->isMethod('POST')) {
  4106.             $em $this->getDoctrine()->getManager();
  4107.             $entity_id array_flip(GeneralConstant::$Entity_list)['JobRecruitment']; //change
  4108.             $dochash $request->request->get('docHash'); //change
  4109.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  4110.             $approveRole $request->request->get('approvalRole');
  4111.             $approveHash $request->request->get('approvalHash');
  4112.             if (!DocValidation::isInsertable($em$entity_id$dochash,
  4113.                 $loginId$approveRole$approveHash$id)
  4114.             ) {
  4115.                 $this->addFlash(
  4116.                     'error',
  4117.                     'Sorry Could not insert Data.'
  4118.                 );
  4119.             } else {
  4120.                 $data $request->request;
  4121.                 $docId HumanResource::createJobRecruitment($em$loginId$id$data$companyId);
  4122.                 //now add Approval info
  4123.                 $approveRole $request->request->get('approvalRole');
  4124.                 $options = array(
  4125.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  4126.                     'notification_server' => $this->container->getParameter('notification_server'),
  4127.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  4128.                     'url' => $this->generateUrl(
  4129.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['JobRecruitment']]
  4130.                         ['entity_view_route_path_name']
  4131.                     )
  4132.                 );
  4133.                 System::setApprovalInfo($this->getDoctrine()->getManager(), $options,
  4134.                     array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  4135.                     $docId,
  4136.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)    //journal voucher
  4137.                 );
  4138.                 System::createEditSignatureHash($this->getDoctrine()->getManager(), array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  4139.                     $docId,
  4140.                     $loginId,
  4141.                     $approveRole,
  4142.                     $request->request->get('approvalHash'));
  4143.                 $this->addFlash(
  4144.                     'success',
  4145.                     'New Recruitment Document Added.'
  4146.                 );
  4147.                 $url $this->generateUrl(
  4148.                     'view_job_recruitment'
  4149.                 );
  4150.                 return $this->redirect($url "/" $docId);
  4151.             }
  4152.         }
  4153.         if ($id == 0) {
  4154.         } else {
  4155.             $extDoc $em->getRepository('ApplicationBundle:JobRecruitment')->findOneBy(
  4156.                 array(
  4157.                     'jobRecruitmentId' => $id///material
  4158.                 )
  4159.             );
  4160.             //now if its not editable, redirect to view
  4161.             if ($extDoc) {
  4162.                 if ($extDoc->getEditFlag() != 1) {
  4163.                     $url $this->generateUrl(
  4164.                         'view_job_recruitment'
  4165.                     );
  4166.                     return $this->redirect($url "/" $id);
  4167.                 }
  4168.             }
  4169.         }
  4170.         $jobType HumanResourceConstant::$employeeType;
  4171.         //$skillDetails = $em->getRepository(Skill::class)->findAll();
  4172.         $educationDetails $em->getRepository('ApplicationBundle:EducationQualification')->findAll();
  4173.         $employeeIds $em->getRepository('ApplicationBundle:Employee')->findAll();
  4174.         $location HumanResourceConstant::$location;
  4175.         $salaryPer HumanResourceConstant::$salaryPer;
  4176.         $workExperience HumanResourceConstant::$workExperience;
  4177.         $jobOpeningStatus HumanResourceConstant::$jobOpeningStatus;
  4178.         $compatibility HumanResourceConstant::$compatibility;
  4179.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_new_job_post.html.twig', [
  4180.             'page_title' => 'Create New Job Post',
  4181.             'jobType' => $jobType,
  4182.             'skillDetails' => $skillDetails,
  4183.             'educationDetails' => $educationDetails,
  4184.             'employeeIds' => $employeeIds,
  4185.             'location' => $location,
  4186.             'salaryPer' => $salaryPer,
  4187.             'workExperience' => $workExperience,
  4188.             'jobOpeningStatus' => $jobOpeningStatus,
  4189.             'compatibility' => $compatibility
  4190.         ]);
  4191.     }
  4192.     public function viewApplicantInfoAction(Request $request$id)
  4193.     {
  4194.         $em $this->getDoctrine()->getManager('company_group');
  4195.         //$session = $request->getSession();
  4196.         $consultantDetails $em->getRepository(EntityApplicantDetails::class)->find($id);
  4197.         $skillDetails $em->getRepository('CompanyGroupBundle:EntitySkill')->findAll();
  4198.         //$companyId = $this->getLoggedUserCompanyId($request);
  4199.         $gender HumanResourceConstant::$sex;
  4200.         $blood HumanResourceConstant::$BloodGroup;
  4201.         //$userId = $session->get(UserConstants::USER_ID);
  4202.         return $this->render('ApplicationBundle:pages/human_resource/views:view_applicant_info.html.twig', [
  4203.             'page_title' => 'Applicant Information',
  4204.             'gender' => $gender,
  4205.             'blood' => $blood,
  4206.             'consultantDetails' => $consultantDetails,
  4207.             'education' => json_decode($consultantDetails->getEducationData(), true),
  4208.             'workExperience' => json_decode($consultantDetails->getWorkExperienceData(), true),
  4209.             'certificate' => json_decode($consultantDetails->getCertificateData(), true),
  4210.             'courses' => json_decode($consultantDetails->getCoursesData(), true),
  4211.             'languages' => json_decode($consultantDetails->getLanguagesData(), true),
  4212.             'skillDetails' => $skillDetails
  4213.         ]);
  4214.     }
  4215.     public function ListJobRecruitmentAction()
  4216.     {
  4217.         $em $this->getDoctrine()->getManager();
  4218.         $jobRecruitmentList = [];
  4219.         $jobRecruitments $em->getRepository('ApplicationBundle:JobRecruitment')->findAll();
  4220.         foreach ($jobRecruitments as $jobRecruitment) {
  4221.             $jobData = array(
  4222.                 'jobRecruitmentId' => $jobRecruitment->getJobRecruitmentId(),
  4223.                 'title' => $jobRecruitment->getTitle(),
  4224.                 'date' => $jobRecruitment->getDate(),
  4225.                 'jobOpeningStatus' => $jobRecruitment->getJobOpeningStatus(),
  4226.                 'applicationOpeningDate' => $jobRecruitment->getApplicationOpeningDate(),
  4227.                 'applicationClosingDate' => $jobRecruitment->getApplicationClosingDate(),
  4228.             );
  4229.             $jobRecruitmentList[] = $jobData;
  4230.         }
  4231.         return $this->render('ApplicationBundle:pages/human_resource/list:job_recruitment_list.html.twig', [
  4232.             'page_title' => 'Job RecruitmentAction List',
  4233.             'jobRecruitments' => $jobRecruitmentList
  4234.         ]);
  4235.     }
  4236.     public function ViewJobRecruitmentAction(Request $request$id 0)
  4237.     {
  4238.         $em_goc $this->getDoctrine()->getManager('company_group');
  4239.         $skillDetails $em_goc->getRepository('CompanyGroupBundle:EntitySkill')->findAll();
  4240.         $em $this->getDoctrine()->getManager();
  4241.         $companyId $this->getLoggedUserCompanyId($request);
  4242.         $company_data Company::getCompanyData($em$companyId);
  4243. //        return new JsonResponse($encryptedDataArray);
  4244.         $location HumanResourceConstant::$location;
  4245.         $salaryPer HumanResourceConstant::$salaryPer;
  4246.         $workExperience HumanResourceConstant::$workExperience;
  4247.         $jobOpeningStatus HumanResourceConstant::$jobOpeningStatus;
  4248.         $compatibility HumanResourceConstant::$compatibility;
  4249.         $jobType HumanResourceConstant::$employeeType;
  4250.         $educationDetail $em->getRepository(EducationQualification::class)->findAll();
  4251.         $jobRecruitments $em->getRepository('ApplicationBundle:JobRecruitment')->find($id);
  4252.         $em_goc $this->getDoctrine()->getManager('company_group');
  4253.         $applicantApplicationList $em_goc->getRepository("CompanyGroupBundle:EntityApplicantApplicationList")->findBy(
  4254.             array(
  4255.                 'jobPostId' => $id,
  4256.                 'CompanyId' => $companyId,
  4257.                 'appId' => $company_data->getAppId()
  4258.             )
  4259.         );
  4260.         $applicantIdList = [];
  4261.         foreach ($applicantApplicationList as $dt) {
  4262.             $applicantIdList[] = $dt->getApplicantId();
  4263.         }
  4264.         $applicantList ApplicantM::getApplicantList($em_goc$applicantIdList);
  4265.         $Approval_data = [
  4266.             'exists' => 0,
  4267.             'approvalId' => 0,
  4268.             'roleType' => 0,
  4269.             'required' => 0,
  4270.             'acted' => 0,
  4271.             'entity' => array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  4272.             'entityId' => $id,
  4273.         ];
  4274.         if (in_array($request->getSession()->get(UserConstants::USER_TYPE), [125]))
  4275.             $Approval_data System::checkIfApprovalExists(
  4276.                 $em,
  4277.                 array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  4278.                 $id,
  4279.                 $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  4280.             );
  4281.         return $this->render('ApplicationBundle:pages/human_resource/views:view_job_recruitment.html.twig', [
  4282.             'page_title' => 'View Job RecruitmentAction',
  4283.             'jobRecruitments' => $jobRecruitments,
  4284.             'applicantApplicationList' => $applicantApplicationList,
  4285.             'applicantList' => $applicantList,
  4286. //            'encryptedData' => $encryptedData,
  4287.             'skills' => json_decode($jobRecruitments->getskills()),
  4288.             'skillDetails' => $skillDetails,
  4289.             'education' => json_decode($jobRecruitments->getEducations()),
  4290.             'educationDetails' => $educationDetail,
  4291.             'location' => $location,
  4292.             'salaryPer' => $salaryPer,
  4293.             'workExperience' => $workExperience,
  4294.             'jobType' => $jobType,
  4295.             'compatibility' => $compatibility,
  4296.             'approval_status' => $jobRecruitments->getApproved(),
  4297.             'jobOpeningStatus' => $jobOpeningStatus,
  4298.             'approval_data' => $Approval_data,
  4299.             'auto_created' => $jobRecruitments->getAutocreated(),
  4300.             'document_log' => $jobRecruitments->getAutocreated() == System::getDocumentLog(
  4301.                 $em,
  4302.                 array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  4303.                 $id,
  4304.                 $jobRecruitments->getCreatedLoginId(),
  4305.                 $jobRecruitments->getEditedLoginId()
  4306.             ) : []
  4307.         ]);
  4308.     }
  4309.     public function ViewApplicantScheduleAction(Request $request$id 0)
  4310.     {
  4311.         $em $this->getDoctrine()->getManager();
  4312.         $companyId $this->getLoggedUserCompanyId($request);
  4313.         $company_data Company::getCompanyData($em$companyId);
  4314.         $em_goc $this->getDoctrine()->getManager('company_group');
  4315.         $applicantApplicationList $em_goc->getRepository("CompanyGroupBundle:EntityApplicantApplicationList")->findBy(
  4316.             array(
  4317.                 'jobPostId' => $id,
  4318.                 'CompanyId' => $companyId,
  4319.                 'appId' => $company_data->getAppId()
  4320.             )
  4321.         );
  4322.         $applicantIdList = [];
  4323.         foreach ($applicantApplicationList as $dt) {
  4324.             $applicantIdList[] = $dt->getApplicantId();
  4325.         }
  4326.         $applicantList ApplicantM::getApplicantList($em_goc$applicantIdList);
  4327.         return $this->render('ApplicationBundle:pages/human_resource/views:view_applicant_scheduled.html.twig', [
  4328.             'page_title' => 'View Applicant Scheduled',
  4329.             'applicantApplicationList' => $applicantApplicationList,
  4330.             'applicantList' => $applicantList,
  4331.         ]);
  4332.     }
  4333.     public function ViewApplicantReportAction(Request $request$id 0)
  4334.     {
  4335.         $em $this->getDoctrine()->getManager();
  4336.         $companyId $this->getLoggedUserCompanyId($request);
  4337.         $company_data Company::getCompanyData($em$companyId);
  4338.         $em_goc $this->getDoctrine()->getManager('company_group');
  4339.         $applicantApplicationList $em_goc->getRepository("CompanyGroupBundle:EntityApplicantApplicationList")->findBy(
  4340.             array(
  4341.                 'jobPostId' => $id,
  4342.                 'CompanyId' => $companyId,
  4343.                 'appId' => $company_data->getAppId()
  4344.             )
  4345.         );
  4346.         $applicantIdList = [];
  4347.         foreach ($applicantApplicationList as $dt) {
  4348.             $applicantIdList[] = $dt->getApplicantId();
  4349.         }
  4350.         $applicantList ApplicantM::getApplicantList($em_goc$applicantIdList);
  4351.         return $this->render('ApplicationBundle:pages/human_resource/views:view_applicant_report.html.twig', [
  4352.             'page_title' => 'View Applicant Report',
  4353.             'applicantApplicationList' => $applicantApplicationList,
  4354.             'applicantList' => $applicantList,
  4355.         ]);
  4356.     }
  4357.     public function createEmployeePerformanceEvaluationAction(Request $request$id 0)
  4358.     {
  4359.         $data = [];
  4360.         $em $this->getDoctrine()->getManager();
  4361.         $companyId $this->getLoggedUserCompanyId($request);
  4362.         if ($request->isMethod('POST')) {
  4363.             $em $this->getDoctrine()->getManager();
  4364.             $entity_id array_flip(GeneralConstant::$Entity_list)['EmployeePerformanceEvolution']; //change
  4365.             $dochash $request->request->get('docHash'); //change
  4366.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  4367.             $approveRole $request->request->get('approvalRole');
  4368.             $approveHash $request->request->get('approvalHash');
  4369.             if (!DocValidation::isInsertable($em$entity_id$dochash,
  4370.                 $loginId$approveRole$approveHash$id)
  4371.             ) {
  4372.                 $this->addFlash(
  4373.                     'error',
  4374.                     'Sorry Could not insert Data.'
  4375.                 );
  4376.             } else {
  4377.                 $data $request->request;
  4378.                 $docId HumanResource::createEmployeePerformanceEvaluation($em$loginId$id$data$companyId);
  4379.                 //now add Approval info
  4380.                 $approveRole $request->request->get('approvalRole');
  4381.                 $options = array(
  4382.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  4383.                     'notification_server' => $this->container->getParameter('notification_server'),
  4384.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  4385.                     'url' => $this->generateUrl(
  4386.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['EmployeePerformanceEvolution']]
  4387.                         ['entity_view_route_path_name']
  4388.                     )
  4389.                 );
  4390.                 System::setApprovalInfo($this->getDoctrine()->getManager(), $options,
  4391.                     array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  4392.                     $docId,
  4393.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)    //journal voucher
  4394.                 );
  4395.                 System::createEditSignatureHash($this->getDoctrine()->getManager(), array_flip(GeneralConstant::$Entity_list)['EmployeePerformanceEvolution'],
  4396.                     $docId,
  4397.                     $loginId,
  4398.                     $approveRole,
  4399.                     $request->request->get('approvalHash'));
  4400.                 $this->addFlash(
  4401.                     'success',
  4402.                     'New Recruitment Document Added.'
  4403.                 );
  4404.                 $url $this->generateUrl(
  4405.                     'view_employee_performance_evolution'
  4406.                 );
  4407.                 return $this->redirect($url "/" $docId);
  4408.             }
  4409.         }
  4410.         $skill $em->getRepository(Skill::class)->findAll();
  4411.         $educationDetail $em->getRepository(EducationQualification::class)->findAll();
  4412.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  4413.         $employeeType HumanResourceConstant::$employeeType;
  4414.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  4415.         $branch $em->getRepository(Branch::class)->findAll();
  4416.         $departments $em->getRepository(SysDepartment::class)->findAll();
  4417.         $department = [];
  4418.         foreach ($departments as $entry) {
  4419.             $department[$entry->getDepartmentId()] = array(
  4420.                 'id' => $entry->getDepartmentId(),
  4421.                 'name' => $entry->getDepartmentName(),
  4422.             );
  4423.         }
  4424.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:employee_performance_evolution.html.twig',
  4425.             array(
  4426.                 'page_title' => 'Create Employee Performance Evaluation',
  4427.                 'employeeIds' => $employeeIds,
  4428.                 'employeeType' => $employeeType,
  4429.                 'Designation' => $Designation,
  4430.                 'branch' => $branch,
  4431.                 'department' => $department,
  4432.                 'skill' => $skill,
  4433.                 'educationDetail' => $educationDetail
  4434.             )
  4435.         );
  4436.     }
  4437.     public function ViewIndividualReviewAction()
  4438.     {
  4439.         return $this->render('ApplicationBundle:pages/human_resource/views:individual_review.html.twig',
  4440.             array(
  4441.                 'page_title' => 'Individual Performance View',
  4442.             )
  4443.         );
  4444.     }
  4445.     public function EmployeeListBySkillPerformanceAction()
  4446.     {
  4447.         $em $this->getDoctrine()->getManager();
  4448.         $employee $em->getRepository('ApplicationBundle:EmployeeDetails')->findAll();
  4449.         $skill $em->getRepository('ApplicationBundle:Skill')->findAll();
  4450.         return $this->render('ApplicationBundle:pages/human_resource/list:employee_performance_evolution_list.html.twig',
  4451.             array(
  4452.                 'page_title' => 'Employee Skill & Performance',
  4453.                 'employee' => $employee,
  4454.                 //'employeeSkill' => json_decode($employee->getSkill(),true),
  4455.                 'skill' => $skill,
  4456.             )
  4457.         );
  4458.     }
  4459.     public function setWorkPlaceAction(Request $req)
  4460.     {
  4461.         $em $this->getDoctrine()->getManager();
  4462.         $companyId $this->getLoggedUserCompanyId($req);
  4463.         $docHash='';
  4464.         if ($req->request->has('XHRreq')) {
  4465.             $docHash=HumanResource::HandelXHRreqForEmpWorkplace($em$req);
  4466.             return new JsonResponse([$docHash]);
  4467.         }
  4468.         if ($req->isMethod('GET')) {
  4469.             $TwigData HumanResource::TwigDataForEmployeeWorkplace($em);
  4470.             return $this->render(
  4471.                 'ApplicationBundle:pages/human_resource/input_forms:update_workplace.html.twig',
  4472.                 [
  4473.                     'page_title' => 'Set Workplace',
  4474.                     'employeeIds' => $TwigData['employeeIds']
  4475.                 ]
  4476.             );
  4477.         }
  4478.         if ($req->isMethod('POST')) {
  4479.             $approveHash $req->request->get('approvalHash');
  4480.             $loginId $req->getSession()->get(UserConstants::USER_LOGIN_ID);
  4481.             $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  4482.             if ($isSignatureOk) {
  4483.                 $isSuccess HumanResource::CreateOrUpdateForEmpWorkplace($em$req$companyId,false,$docHash);
  4484.                 if ($isSuccess) {
  4485.                     $this->addFlash(
  4486.                         'success',
  4487.                         'Workplace set!'
  4488.                     );
  4489.                     return $this->redirectToRoute('set_workplace');
  4490.                 }
  4491.             } else {
  4492.                 $this->addFlash(
  4493.                     'error',
  4494.                     'Invalid Approval Hash!'
  4495.                 );
  4496.                 return $this->redirectToRoute('set_workplace');
  4497.             }
  4498.         }
  4499.     }
  4500.     public function setWorkPlaceForAppAction(Request $req)
  4501.     {
  4502.         $em $this->getDoctrine()->getManager();
  4503.         $companyId $this->getLoggedUserCompanyId($req);
  4504.         $docHash=HumanResource::HandelXHRreqForEmpWorkplace($em$req);
  4505.         if ($req->isMethod('GET')) {
  4506.             $TwigData HumanResource::TwigDataForEmployeeWorkplace($em);
  4507.             return $this->render(
  4508.                 'ApplicationBundle:pages/human_resource/input_forms:update_workplace.html.twig',
  4509.                 [
  4510.                     'page_title' => 'Set Workplace',
  4511.                     'employeeIds' => $TwigData['employeeIds']
  4512.                 ]
  4513.             );
  4514.         }
  4515.         if ($req->isMethod('POST')) {
  4516.             $approveHash $req->request->get('approvalHash');
  4517.             $loginId $req->getSession()->get(UserConstants::USER_LOGIN_ID);
  4518.             $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  4519.             if ($isSignatureOk) {
  4520.                 $isSuccess HumanResource::CreateOrUpdateForEmpWorkplace($em$req$companyId,false,$docHash);
  4521.                 if ($isSuccess) {
  4522.                     $this->addFlash(
  4523.                         'success',
  4524.                         'Workplace set!'
  4525.                     );
  4526. //                    return $this->redirectToRoute('set_workplace');
  4527.                     return new JsonResponse(array(
  4528.                         "success" => true
  4529.                     ));
  4530.                 }
  4531.             } else {
  4532.                 $this->addFlash(
  4533.                     'error',
  4534.                     'Invalid Approval Hash!'
  4535.                 );
  4536. //                return $this->redirectToRoute('set_workplace');
  4537.             }
  4538.         }
  4539.     }
  4540.     public function ViewMeetingAction(Request $req$action 0$id 0)
  4541.     {
  4542.         $em $this->getDoctrine()->getManager();
  4543.         $companyId $this->getLoggedUserCompanyId($req);
  4544.         if ($req->request->has('XHRreq')) {
  4545.             return new JsonResponse([HumanResource::HandelXHRreqForMeetingScheduling($em$req)]);
  4546.         }
  4547.         if ($action === 'view') {
  4548.             $response HumanResource::TwigDataForScheduledMeetingView($em$req$id);
  4549.             return $this->render(
  4550.                 'ApplicationBundle:pages/human_resource/views:scheduled_meeting_view.html.twig',
  4551.                 [
  4552.                     'page_title' => 'View Scheduled Meeting',
  4553.                     'duration' => $response['duration'],
  4554.                     'appId' => $response['appId'],
  4555.                     'publicView' => 0,
  4556.                     'meeting_data' => $response['meeting_data'],
  4557.                     'agenda_list' => $response['agenda_list'],
  4558.                     'id' => $req->query->get('view_meeting'),
  4559.                     'approval_data' => $response['approval_data'],
  4560.                     'document_log' => $response['document_log'],
  4561.                     'approval_status' => $response['approval_status'],
  4562.                     'created_by' => $response['created_by'],
  4563.                     'updated_at' => $response['updated_at'],
  4564.                     'auto_created' => 0,
  4565.                 ]
  4566.             );
  4567.         }
  4568.         if ($action === 'print') {
  4569.             $response HumanResource::TwigDataForScheduledMeetingView($em$req$id);
  4570. //      $id = $req->query->get('print_meeting');
  4571.             $em $this->getDoctrine()->getManager();
  4572.             $company_data Company::getCompanyData($em1);
  4573.             $Authorizations System::getSignatureListForDocumentPrint($emarray_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'], $id);
  4574.             return $this->render(
  4575.                 'ApplicationBundle:pages/human_resource/print:scheduled_meeting_print.html.twig',
  4576.                 array(
  4577.                     'page_title' => 'View Scheduled Meeting',
  4578.                     'duration' => $response['duration'],
  4579.                     'meeting_data' => $response['meeting_data'],
  4580.                     'agenda_list' => $response['agenda_list'],
  4581.                     'export' => 'pdf,print',
  4582.                     'company_name' => $company_data->getName(),
  4583.                     'company_data' => $company_data,
  4584.                     'company_address' => $company_data->getAddress(),
  4585.                     'company_image' => $company_data->getImage(),
  4586.                     'Authorizations' => $Authorizations,
  4587.                     'red' => 0
  4588.                 )
  4589.             );
  4590.         }
  4591.     }
  4592.     public function UpdateMeetingMinutesAction(Request $req$action 0$id 0)
  4593.     {
  4594.         $em $this->getDoctrine()->getManager();
  4595.         $companyId $this->getLoggedUserCompanyId($req);
  4596.         $scheduleId $req->request->get('scheduleId');
  4597.         $minuteText $req->request->get('minuteText');
  4598.         $agendaKey $req->request->get('key');
  4599.         $scheduledMeeting $em->getRepository(ScheduledMeeting::class)
  4600.             ->find($scheduleId);
  4601.         $agendaList json_decode($scheduledMeeting->getAgendaList(), true);
  4602.         foreach ($agendaList as $key => $item) {
  4603.             if ($key == $agendaKey)
  4604.                 $agendaList[$key]['minutes'] = $minuteText;
  4605.         }
  4606.         $scheduledMeeting->setAgendaList(json_encode($agendaList));
  4607.         $em->flush();
  4608.         return new JsonResponse(array(
  4609.             'success' => true
  4610.         ));
  4611.     }
  4612.     public function SendMeetingUpdatesAction(Request $req$action 0$id 0)
  4613.     {
  4614.         $em $this->getDoctrine()->getManager();
  4615.         $companyId $this->getLoggedUserCompanyId($req);
  4616.         $session $req->getSession();
  4617.         $companyData Company::getCompanyData($em$companyId);
  4618.         $scheduleId $req->request->get('scheduleId');
  4619.         $minuteText $req->request->get('minuteText');
  4620.         $agendaKey $req->request->get('key');
  4621.         $scheduledMeeting $em->getRepository(ScheduledMeeting::class)
  4622.             ->find($scheduleId);
  4623.         $sendEmailInvitationTo json_decode($scheduledMeeting->getAllParticipantsNameEmail(), true);
  4624.         if ($sendEmailInvitationTo == null)
  4625.             $sendEmailInvitationTo = [];
  4626.         $agendaList json_decode($scheduledMeeting->getAgendaList(), true);
  4627.         if ($agendaList == null)
  4628.             $agendaList = [];
  4629.         $EmployeeList HumanResource::GetEmployeeList($em, []);
  4630.         $meetingType MeetingSchedulingConstant::$meetingType[$scheduledMeeting->getMeetingType()];
  4631.         foreach ($sendEmailInvitationTo as $key => $email) {
  4632.             $name ucWords(str_replace("_"" "$key));
  4633.             $bodyHtml '';
  4634.             $bodyTemplate 'ApplicationBundle:email/meeting_scheduling:scheduled_meeting_update.html.twig';
  4635.             $bodyData = array(
  4636.                 'name' => $name,
  4637.                 'gocId' => $session->get(UserConstants::USER_GOC_ID),
  4638.                 'appId' => $session->get(UserConstants::USER_APP_ID),
  4639.                 'email' => $email,
  4640.                 'meetingData' => $scheduledMeeting,
  4641.                 'meeting_type' => $meetingType,
  4642.                 'agenda_list' => $agendaList,
  4643.                 'companyData' => $companyData,
  4644.                 'employeeList' => $EmployeeList,
  4645.             );
  4646.             $attachments = [];
  4647.             $new_mail $this->get('mail_module');
  4648.             $new_mail->sendMyMail(array(
  4649.                 'senderHash' => '_MEETING_',
  4650.                 'forwardToMailAddress' => $email,
  4651.                 'subject' => "Meeting Updates Arranged By - " $companyData->getName() . " on " $scheduledMeeting->getTitle() . ". ",
  4652.                 'fileName' => '',
  4653.                 'attachments' => $attachments,
  4654.                 'toAddress' => $email,
  4655.                 'mailTemplate' => $bodyTemplate,
  4656.                 'templateData' => $bodyData,
  4657.                 'embedCompanyImage' => 1,
  4658.                 'companyId' => $companyId,
  4659.                 'companyImagePath' => $companyData->getImage()
  4660.             ));
  4661.         }
  4662.         return new JsonResponse(array(
  4663.             'success' => true
  4664.         ));
  4665.     }
  4666.     public function meetingSchedulingAction(Request $req$action 0)
  4667.     {
  4668.         $em $this->getDoctrine()->getManager();
  4669.         $companyId $this->getLoggedUserCompanyId($req);
  4670.         $session $req->getSession();
  4671.         if ($req->request->has('XHRreq')) {
  4672.             return new JsonResponse([HumanResource::HandelXHRreqForMeetingScheduling($em$req)]);
  4673.         }
  4674.         if ($action === 'list') {
  4675.             $response HumanResource::TwigDataForScheduledMeetingList($em, [0null]);
  4676.             return $this->render(
  4677.                 'ApplicationBundle:pages/human_resource/list:scheduled_meeting_list.html.twig',
  4678.                 [
  4679.                     'page_title' => 'Scheduled Meeting List',
  4680.                     'list' => $response
  4681.                 ]
  4682.             );
  4683.         }
  4684.         if ($req->isMethod('GET')) {
  4685.             $response HumanResource::twigDataForMeetingScheduling($em);
  4686.             return $this->render(
  4687.                 'ApplicationBundle:pages/human_resource/input_forms:meeting_scheduling.html.twig',
  4688.                 [
  4689.                     'page_title' => 'Schedule a Meeting',
  4690.                     'employeeIds' => $response['employeeIds'],
  4691.                     'branches' => $response['branches'],
  4692.                     'asset' => $response['asset'],
  4693.                     'rooms' => $response['rooms'],
  4694.                     'sales_orders' => $response['salesOrders'],
  4695.                     'purchase_orders' => $response['purchaseOrders'],
  4696.                     'meeting_types' => $response['meetingType'],
  4697.                 ]
  4698.             );
  4699.         }
  4700.         if ($req->isMethod('POST')) {
  4701.             $approveHash $req->request->get('approvalHash');
  4702.             $approveRole $req->request->get('approvalRole');
  4703.             $loginId $req->getSession()->get(UserConstants::USER_LOGIN_ID);
  4704.             $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  4705.             $companyData Company::getCompanyData($em$companyId);
  4706.             if ($isSignatureOk) {
  4707.                 $isSuccess HumanResource::createOrUpdateDataForMeetingScheduling($em$req);
  4708.                 if ($isSuccess) {
  4709.                     $options = array(
  4710.                         'notification_enabled' => $this->container->getParameter('notification_enabled'),
  4711.                         'notification_server' => $this->container->getParameter('notification_server'),
  4712.                         'appId' => $req->getSession()->get(UserConstants::USER_APP_ID),
  4713.                         'url' => $this->generateUrl(
  4714.                             GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting']]['entity_view_route_path_name']
  4715.                         )
  4716.                     );
  4717.                     $meetingId $isSuccess[1];
  4718.                     System::setApprovalInfo(
  4719.                         $this->getDoctrine()->getManager(),
  4720.                         $options,
  4721.                         array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'],
  4722.                         $meetingId,
  4723.                         $req->getSession()->get(UserConstants::USER_LOGIN_ID),
  4724.                         0//normal meeting
  4725.                         0,
  4726.                         $this->get('mail_module')
  4727.                     );
  4728.                     System::createEditSignatureHash(
  4729.                         $this->getDoctrine()->getManager(),
  4730.                         array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'],
  4731.                         $meetingId,
  4732.                         $loginId,
  4733.                         $approveRole,
  4734.                         $req->request->get('approvalHash')
  4735.                     );
  4736.                     $url $this->generateUrl(
  4737.                         'view_scheduled_meeting'
  4738.                     );
  4739.                     return $this->redirect($url "/" $meetingId);
  4740.                 } else {
  4741.                     return new JsonResponse(array(
  4742.                         'success' => false
  4743.                     ));
  4744.                 }
  4745.             } else {
  4746.                 $this->addFlash(
  4747.                     'error',
  4748.                     'Invalid Approval Hash!'
  4749.                 );
  4750.                 return $this->redirectToRoute('meeting_scheduling');
  4751.             }
  4752.         }
  4753.         return $this->redirectToRoute('meeting_scheduling');
  4754.     }
  4755.     public function CreateTrainingScheduleAction(Request $req$action 0)
  4756.     {
  4757.         $em $this->getDoctrine()->getManager();
  4758.         $companyId $this->getLoggedUserCompanyId($req);
  4759.         $session $req->getSession();
  4760.         if ($req->request->has('XHRreq')) {
  4761.             return new JsonResponse([HumanResource::HandelXHRreqForMeetingScheduling($em$req)]);
  4762.         }
  4763.         if ($action === 'list') {
  4764.             $response HumanResource::TwigDataForScheduledMeetingList($em, [1]);
  4765.             return $this->render(
  4766.                 'ApplicationBundle:pages/human_resource/list:scheduled_meeting_list.html.twig',
  4767.                 [
  4768.                     'page_title' => 'Training Schedule List',
  4769.                     'list' => $response
  4770.                 ]
  4771.             );
  4772.         }
  4773.         if ($req->isMethod('GET')) {
  4774.         }
  4775.         if ($req->isMethod('POST')) {
  4776.             $approveHash $req->request->get('approvalHash');
  4777.             $approveRole $req->request->get('approvalRole');
  4778.             $loginId $req->getSession()->get(UserConstants::USER_LOGIN_ID);
  4779.             $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  4780.             $companyData Company::getCompanyData($em$companyId);
  4781.             if ($isSignatureOk) {
  4782.                 $isSuccess HumanResource::createOrUpdateDataForMeetingScheduling($em$req);
  4783.                 if ($isSuccess) {
  4784.                     $options = array(
  4785.                         'notification_enabled' => $this->container->getParameter('notification_enabled'),
  4786.                         'notification_server' => $this->container->getParameter('notification_server'),
  4787.                         'appId' => $req->getSession()->get(UserConstants::USER_APP_ID),
  4788.                         'url' => $this->generateUrl(
  4789.                             GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting']]['entity_view_route_path_name']
  4790.                         )
  4791.                     );
  4792.                     $meetingId $isSuccess[1];
  4793.                     System::setApprovalInfo(
  4794.                         $this->getDoctrine()->getManager(),
  4795.                         $options,
  4796.                         array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'],
  4797.                         $meetingId,
  4798.                         $req->getSession()->get(UserConstants::USER_LOGIN_ID),
  4799.                         '',
  4800.                         0,
  4801.                         $this->get('mail_module')
  4802.                     );
  4803.                     System::createEditSignatureHash(
  4804.                         $this->getDoctrine()->getManager(),
  4805.                         array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'],
  4806.                         $meetingId,
  4807.                         $loginId,
  4808.                         $approveRole,
  4809.                         $req->request->get('approvalHash')
  4810.                     );
  4811.                     $url $this->generateUrl(
  4812.                         'view_scheduled_meeting'
  4813.                     );
  4814.                     return $this->redirect($url "/" $meetingId);
  4815.                 } else {
  4816.                     return new JsonResponse(array(
  4817.                         'success' => false
  4818.                     ));
  4819.                 }
  4820.             } else {
  4821.                 $this->addFlash(
  4822.                     'error',
  4823.                     'Invalid Approval Hash!'
  4824.                 );
  4825.                 return $this->redirectToRoute('create_training_schedule');
  4826.             }
  4827.         }
  4828.         $response HumanResource::twigDataForTrainingScheduling($em);
  4829.         return $this->render(
  4830.             'ApplicationBundle:pages/human_resource/input_forms:create_training_schedule.html.twig',
  4831.             [
  4832.                 'page_title' => 'Schedule a Training',
  4833.                 'employeeIds' => $response['employeeIds'],
  4834.                 'branches' => $response['branches'],
  4835.                 'asset' => $response['asset'],
  4836.                 'rooms' => $response['rooms'],
  4837.                 'courseList' => $response['courseList'],
  4838.                 'sales_orders' => $response['salesOrders'],
  4839.                 'purchase_orders' => $response['purchaseOrders'],
  4840.                 'meeting_types' => $response['meetingType'],
  4841.                 'skillList' => $response['skillList'],
  4842.             ]
  4843.         );
  4844.     }
  4845.     public function ScheduledTrainingListAction(Request $req$action 0)
  4846.     {
  4847.         $em $this->getDoctrine()->getManager();
  4848.         $companyId $this->getLoggedUserCompanyId($req);
  4849.         $session $req->getSession();
  4850.         $response HumanResource::TwigDataForScheduledMeetingList($em, [1]);
  4851.         return $this->render(
  4852.             'ApplicationBundle:pages/human_resource/list:scheduled_training_list.html.twig',
  4853.             [
  4854.                 'page_title' => 'Scheduled Trainings ',
  4855.                 'list' => $response
  4856.             ]
  4857.         );
  4858.     }
  4859.     public function ScheduledInterviewListAction(Request $req$action 0)
  4860.     {
  4861.         $em $this->getDoctrine()->getManager();
  4862.         $companyId $this->getLoggedUserCompanyId($req);
  4863.         $session $req->getSession();
  4864.         $response HumanResource::TwigDataForScheduledMeetingList($em, [2]);
  4865.         return $this->render(
  4866.             'ApplicationBundle:pages/human_resource/list:scheduled_interview_list.html.twig',
  4867.             [
  4868.                 'page_title' => 'Scheduled Interviews ',
  4869.                 'list' => $response
  4870.             ]
  4871.         );
  4872.     }
  4873.     public function GetFilteredQuestionsAction(Request $request$search '')
  4874.     {
  4875.         $em $this->getDoctrine()->getManager();
  4876.         $companyId $this->getLoggedUserCompanyId($request);
  4877.         if ($search == '' || $search == '_EMPTY_')
  4878.             $Query "SELECT  * FROM questionnaire WHERE 1 limit 10;";
  4879.         else
  4880.             $Query "SELECT  * FROM questionnaire WHERE question_text like '%$search%'  limit 10;";
  4881.         $stmt $em->getConnection()->prepare($Query);
  4882.         $stmt->execute();
  4883.         $queryResult $stmt->fetchAll();
  4884.         $parent_head_ids = [];
  4885.         $queryResultIndexed = [];
  4886.         foreach ($queryResult as $dt) {
  4887.             $queryResultIndexed[$dt['question_id']] = $dt;
  4888.         }
  4889.         return new JsonResponse(array(
  4890.             'data' => $queryResult,
  4891.             'queryResultIndexed' => $queryResultIndexed,
  4892.         ));
  4893.     }
  4894.     public function CreateTrainingCourseAction(Request $request$id 0)
  4895.     {
  4896.         $em $this->getDoctrine()->getManager();
  4897.         $companyId $this->getLoggedUserCompanyId($request);
  4898.         $skills $em->getRepository('ApplicationBundle:Skill')->findAll();
  4899.         $courses $em->getRepository('ApplicationBundle:TrainingCourse')->findAll();
  4900.         if ($request->isMethod('POST')) {
  4901.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  4902.             $skill = new TrainingCourse;
  4903.             $skill->setTitle($request->request->get('name'));
  4904.             $skill->setCourseHash($request->request->get('coursehash'));
  4905.             $skill->setTrainingMaterialText($request->request->get('overview'));
  4906.             $skill->setTaggedSkillHashes(json_encode($request->request->get('skill')));
  4907.             $skill->setCompanyId($companyId);
  4908.             //$skill->setEditFlag(1); //editable usually
  4909.             $skill->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  4910.             //$skill->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
  4911.             //$skill->setAutocreated(0);
  4912.             $em->persist($skill);
  4913.             $em->flush();
  4914.         }
  4915.         return $this->render(
  4916.             'ApplicationBundle:pages/human_resource/input_forms:create_training_course.html.twig',
  4917.             [
  4918.                 'page_title' => 'Create Training Course',
  4919.                 'skills' => $skills,
  4920.                 'courses' => $courses
  4921.             ]
  4922.         );
  4923.     }
  4924.     public function CreateEmployeeExpenseAllowanceSettingsAction(Request $request$id 0)
  4925.     {
  4926.         $em $this->getDoctrine()->getManager();
  4927.         $companyId $this->getLoggedUserCompanyId($request);
  4928.         $extDocData = [];
  4929.         $extDetailsData = [];
  4930.         if ($request->isMethod('POST')) {
  4931.             //            Generic::debugMessage($_POST);
  4932.             $em $this->getDoctrine()->getManager();
  4933.             $entity_id array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings']; //change
  4934.             $dochash $request->request->get('docHash'); //change
  4935.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  4936.             $approveRole $request->request->get('approvalRole');
  4937.             $approveHash $request->request->get('approvalHash');
  4938.             if (!DocValidation::isInsertable(
  4939.                 $em,
  4940.                 $entity_id,
  4941.                 $dochash,
  4942.                 $loginId,
  4943.                 $approveRole,
  4944.                 $approveHash,
  4945.                 $id
  4946.             )
  4947.             ) {
  4948.                 $this->addFlash(
  4949.                     'error',
  4950.                     'Sorry Could not insert Data.'
  4951.                 );
  4952.             } else {
  4953.                 $funcname 'EmployeeExpenseAllowanceSettings';
  4954.                 DeleteDocument::$funcname($em$id0);
  4955.                 $docId HumanResource::CreateSalarySegregationPolicy($em$request$companyId0);
  4956.                 //now add Approval info
  4957.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  4958.                 $approveRole $request->request->get('approvalRole');
  4959.                 $options = array(
  4960.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  4961.                     'notification_server' => $this->container->getParameter('notification_server'),
  4962.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  4963.                     'url' => $this->generateUrl(
  4964.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings']]['entity_view_route_path_name']
  4965.                     )
  4966.                 );
  4967.                 System::setApprovalInfo(
  4968.                     $this->getDoctrine()->getManager(),
  4969.                     $options,
  4970.                     array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings'],
  4971.                     $docId,
  4972.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  4973.                 );
  4974.                 System::createEditSignatureHash(
  4975.                     $this->getDoctrine()->getManager(),
  4976.                     array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings'],
  4977.                     $docId,
  4978.                     $loginId,
  4979.                     $approveRole,
  4980.                     $request->request->get('approvalHash')
  4981.                 );
  4982.                 $doc_here $this->getDoctrine()
  4983.                     ->getRepository('ApplicationBundle:EmployeeExpenseAllowanceSettings')
  4984.                     ->findOneBy(
  4985.                         array(
  4986.                             'id' => $docId
  4987.                         )
  4988.                     );
  4989.                 //notify
  4990.                 $this->addFlash(
  4991.                     'success',
  4992.                     'Settings Successfully Updated.'
  4993.                 );
  4994.                 $url $this->generateUrl(
  4995.                     GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings']]['entity_view_route_path_name']
  4996.                 );
  4997.                 System::AddNewNotification(
  4998.                     $this->container->getParameter('notification_enabled'),
  4999.                     $this->container->getParameter('notification_server'),
  5000.                     $request->getSession()->get(UserConstants::USER_APP_ID),
  5001.                     $request->getSession()->get(UserConstants::USER_COMPANY_ID),
  5002.                     "Salary Segregation Policy : " $doc_here->getDocumentHash() . " Has Been Created And is Under Processing",
  5003.                     'pos',
  5004.                     System::getPositionIdsByDepartment($emGeneralConstant::HRM_DEPARTMENT),
  5005.                     'success',
  5006.                     //                    $url . "/" . $TransID,
  5007.                     $url "/" $docId,
  5008.                     "Journal"
  5009.                 );
  5010.                 return $this->redirect($url "/" $docId);
  5011.             }
  5012.         }
  5013.         //for edits
  5014.         if ($id == 0) {
  5015.         } else {
  5016.             $extDocData $em->getRepository('ApplicationBundle:EmployeeExpenseAllowanceSettings')->findOneBy(
  5017.                 array(
  5018.                     'id' => $id///material
  5019.                 )
  5020.             );
  5021.             //now if its not editable, redirect to view
  5022.             if ($extDocData) {
  5023.                 if ($extDocData->getEditFlag() != 1) {
  5024. //          $url = $this->generateUrl(
  5025. ////              'view_salary_segregation_policy'
  5026. //              'salary_segregation_policy'
  5027. //          );
  5028. //          return $this->redirect($url . "/" . $id);
  5029.                 } else {
  5030. //          $extVoucherDetailsData = Accounts::GetVoucherDataForEdit($em, $voucherId);
  5031. //          $extDetailsData = $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
  5032. //              array(
  5033. //                  'transactionId' => $id, ///material
  5034. //
  5035. //              )
  5036. //          );
  5037.                 }
  5038.             } else {
  5039.             }
  5040.         }
  5041.         $employeeIds $em->getRepository("ApplicationBundle:Employee")->findAll();
  5042.         $employeeType HumanResourceConstant::$employeeType;
  5043.         $employeeExpenseAllowanceTypes HumanResourceConstant::$employeeExpenseAllowanceTypes;
  5044.         $Designation $em->getRepository("ApplicationBundle:SysDepartmentPosition")->findAll();
  5045.         $branch $em->getRepository("ApplicationBundle:Branch")->findAll();
  5046.         $departments $em->getRepository("ApplicationBundle:SysDepartment")->findAll();
  5047.         $department = [];
  5048.         foreach ($departments as $entry) {
  5049.             $department[$entry->getDepartmentId()] = array(
  5050.                 'id' => $entry->getDepartmentId(),
  5051.                 'name' => $entry->getDepartmentName(),
  5052.             );
  5053.         }
  5054.         return $this->render(
  5055.             'ApplicationBundle:pages/human_resource/input_forms:create_employee_expense_allowance_settings.html.twig',
  5056.             [
  5057.                 'page_title' => 'Employee Expense Allowance Settings',
  5058.                 'employeeIds' => $employeeIds,
  5059.                 'extId' => $id,
  5060.                 'extDocData' => $extDocData,
  5061.                 'employeeType' => $employeeType,
  5062.                 'employeeExpenseAllowanceTypes' => $employeeExpenseAllowanceTypes,
  5063.                 'Designation' => $Designation,
  5064.                 'branch' => $branch,
  5065.                 'department' => $department,
  5066.             ]
  5067.         );
  5068.     }
  5069.     public function EmployeeExpenseAllowanceSettingsListAction(Request $request)
  5070.     {
  5071.         $em $this->getDoctrine()->getManager();
  5072.         $allowed_ids = [];
  5073.         $companyId $this->getLoggedUserCompanyId($request);
  5074.         $listData HumanResource::GetDataForEmployeeExpenseAllowanceSettingsListAction($em$request->isMethod('POST') ? 'POST' 'GET'$request->request$companyId);
  5075.         if ($request->isMethod('POST')) {
  5076.             if ($request->query->has('dataTableQry')) {
  5077.                 return new JsonResponse(
  5078.                     $listData
  5079.                 );
  5080.             }
  5081.         }
  5082.         return $this->render('ApplicationBundle:pages/human_resource/list:employee_expense_allowance_settings_list.html.twig',
  5083. //         return $this->render('ApplicationBundle:pages/dashboard:test_pix_invent.html.twig',
  5084.             array(
  5085.                 'page_title' => 'Expense Allowance Settings List',
  5086. //            'data' => SalesOrderM::GetClientList($em, [], $companyId),
  5087. //            'client_types' => Client::GetClientType($em, $companyId),
  5088. //            'region_list' => Client::RegionList($em, $companyId),
  5089. //            'geographical_region_list' => Client::GeographicalRegionList($em, $companyId)
  5090.             )
  5091.         );
  5092.     }
  5093.     public function salarySegAction(Request $request$id 0)
  5094.     {
  5095.         $em $this->getDoctrine()->getManager();
  5096.         $companyId $this->getLoggedUserCompanyId($request);
  5097.         $extDocData = [];
  5098.         $extDetailsData = [];
  5099.         if ($request->isMethod('POST')) {
  5100.             //            Generic::debugMessage($_POST);
  5101.             $em $this->getDoctrine()->getManager();
  5102.             $entity_id array_flip(GeneralConstant::$Entity_list)['SalarySegregationPolicy']; //change
  5103.             $dochash $request->request->get('docHash'); //change
  5104.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  5105.             $approveRole $request->request->get('approvalRole');
  5106.             $approveHash $request->request->get('approvalHash');
  5107.             if (!DocValidation::isInsertable(
  5108.                 $em,
  5109.                 $entity_id,
  5110.                 $dochash,
  5111.                 $loginId,
  5112.                 $approveRole,
  5113.                 $approveHash,
  5114.                 $id
  5115.             )
  5116.             ) {
  5117.                 $this->addFlash(
  5118.                     'error',
  5119.                     'Sorry Couldnot insert Data.'
  5120.                 );
  5121.             } else {
  5122.                 $funcname 'SalarySegregationPolicy';
  5123.                 DeleteDocument::$funcname($em$id0);
  5124.                 $docId HumanResource::CreateSalarySegregationPolicy($em$request$companyId0);
  5125.                 //now add Approval info
  5126.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  5127.                 $approveRole $request->request->get('approvalRole');
  5128.                 $options = array(
  5129.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  5130.                     'notification_server' => $this->container->getParameter('notification_server'),
  5131.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  5132.                     'url' => $this->generateUrl(
  5133.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['SalarySegregationPolicy']]['entity_view_route_path_name']
  5134.                     )
  5135.                 );
  5136.                 System::setApprovalInfo(
  5137.                     $this->getDoctrine()->getManager(),
  5138.                     $options,
  5139.                     array_flip(GeneralConstant::$Entity_list)['SalarySegregationPolicy'],
  5140.                     $docId,
  5141.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID),
  5142.                     3    //journal voucher
  5143.                 );
  5144.                 System::createEditSignatureHash(
  5145.                     $this->getDoctrine()->getManager(),
  5146.                     array_flip(GeneralConstant::$Entity_list)['SalarySegregationPolicy'],
  5147.                     $docId,
  5148.                     $loginId,
  5149.                     $approveRole,
  5150.                     $request->request->get('approvalHash')
  5151.                 );
  5152.                 $doc_here $this->getDoctrine()
  5153.                     ->getRepository('ApplicationBundle:SalarySegregationPolicy')
  5154.                     ->findOneBy(
  5155.                         array(
  5156.                             'id' => $docId
  5157.                         )
  5158.                     );
  5159.                 //notify
  5160.                 $this->addFlash(
  5161.                     'success',
  5162.                     'Policy Successfully Updated.'
  5163.                 );
  5164.                 $url $this->generateUrl(
  5165.                     'salary_segregation_policy'
  5166.                 );
  5167.                 System::AddNewNotification(
  5168.                     $this->container->getParameter('notification_enabled'),
  5169.                     $this->container->getParameter('notification_server'),
  5170.                     $request->getSession()->get(UserConstants::USER_APP_ID),
  5171.                     $request->getSession()->get(UserConstants::USER_COMPANY_ID),
  5172.                     "Salary Segregation Policy : " $doc_here->getDocumentHash() . " Has Been Created And is Under Processing",
  5173.                     'pos',
  5174.                     System::getPositionIdsByDepartment($emGeneralConstant::HRM_DEPARTMENT),
  5175.                     'success',
  5176.                     //                    $url . "/" . $TransID,
  5177.                     $url "/" $docId,
  5178.                     "Journal"
  5179.                 );
  5180.                 return $this->redirect($url "/" $docId);
  5181.             }
  5182.         }
  5183.         //for edits
  5184.         if ($id == 0) {
  5185.         } else {
  5186.             $extDocData $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
  5187.                 array(
  5188.                     'id' => $id///material
  5189.                 )
  5190.             );
  5191.             //now if its not editable, redirect to view
  5192.             if ($extDocData) {
  5193.                 if ($extDocData->getEditFlag() != 1) {
  5194. //          $url = $this->generateUrl(
  5195. ////              'view_salary_segregation_policy'
  5196. //              'salary_segregation_policy'
  5197. //          );
  5198. //          return $this->redirect($url . "/" . $id);
  5199.                 } else {
  5200. //          $extVoucherDetailsData = Accounts::GetVoucherDataForEdit($em, $voucherId);
  5201. //          $extDetailsData = $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
  5202. //              array(
  5203. //                  'transactionId' => $id, ///material
  5204. //
  5205. //              )
  5206. //          );
  5207.                 }
  5208.             } else {
  5209.             }
  5210.         }
  5211.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  5212.         $employeeType HumanResourceConstant::$employeeType;
  5213.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  5214.         $branch $em->getRepository(Branch::class)->findAll();
  5215.         $departments $em->getRepository(SysDepartment::class)->findAll();
  5216.         $department = [];
  5217.         foreach ($departments as $entry) {
  5218.             $department[$entry->getDepartmentId()] = array(
  5219.                 'id' => $entry->getDepartmentId(),
  5220.                 'name' => $entry->getDepartmentName(),
  5221.             );
  5222.         }
  5223.         return $this->render(
  5224.             'ApplicationBundle:pages/human_resource/input_forms:salary_segregation_policy.html.twig',
  5225.             [
  5226.                 'page_title' => 'Salary Segregation Policy',
  5227.                 'employeeIds' => $employeeIds,
  5228.                 'extId' => $id,
  5229.                 'extDocData' => $extDocData,
  5230.                 'employeeType' => $employeeType,
  5231.                 'Designation' => $Designation,
  5232.                 'branch' => $branch,
  5233.                 'department' => $department,
  5234.             ]
  5235.         );
  5236.     }
  5237.     public function GetSalarySegregationDataForEmployeeEntryAction(Request $request)
  5238.     {
  5239.         $em $this->getDoctrine()->getManager();
  5240.         $companyId $this->getLoggedUserCompanyId($request);
  5241.         if ($request->request->has('salSagDataReq')) {
  5242.             $ajaxData HumanResource::handelXhrForSalSeg($em$request);
  5243.             return new JsonResponse($ajaxData);
  5244.         }
  5245.         return new JsonResponse(array('success' => false));
  5246.     }
  5247.     public function WorkHourPolicyAction(Request $req$id 0)
  5248.     {
  5249.         $em $this->getDoctrine()->getManager();
  5250.         $companyId $this->getLoggedUserCompanyId($req);
  5251.         $extData = [];
  5252.         if ($id != 0) {
  5253.             $extData $em->getRepository('ApplicationBundle:WorkHourPolicy')
  5254.                 ->findOneBy(
  5255.                     array(
  5256.                         'id' => $id
  5257.                     )
  5258.                 );
  5259.         }
  5260.         if ($req->isMethod('POST')) {
  5261.             $storeDataRes HumanResource::checkSignature($em$req);
  5262.             if ($storeDataRes['hasErr']) {
  5263.                 $msg $storeDataRes['msg'];
  5264.                 $this->addFlash(
  5265.                     'error',
  5266.                     $msg
  5267.                 );
  5268.                 return $this->redirectToRoute('work_hour_policy');
  5269.             } else {
  5270.                 HumanResource::storeDataForWhPolicy($em$req$companyId);
  5271.                 $this->addFlash(
  5272.                     'success',
  5273.                     'Policy Successfully Created!'
  5274.                 );
  5275.                 return $this->redirectToRoute('work_hour_policy');
  5276.             }
  5277.         }
  5278.         $twigData HumanResource::twigDataForWorkHourPolicy($em);
  5279.         $timeZonesArray = array();
  5280.         return $this->render(
  5281.             'ApplicationBundle:pages/human_resource/input_forms:work_hour_policy.html.twig',
  5282.             [
  5283.                 'page_title' => 'Work Hour Policy',
  5284.                 'extId' => $id,
  5285.                 'extData' => $extData,
  5286.                 'employeeIds' => $twigData['employeeIds'],
  5287.                 'employeeType' => $twigData['employeeType'],
  5288.                 'Designation' => $twigData['Designation'],
  5289.                 'branch' => $twigData['branch'],
  5290.                 'department' => $twigData['department'],
  5291.             ]
  5292.         );
  5293.     }
  5294.     public function WorkHourPolicyListAction(Request $request)
  5295.     {
  5296.         $em $this->getDoctrine()->getManager();
  5297.         $allowed_ids = [];
  5298.         $companyId $this->getLoggedUserCompanyId($request);
  5299.         $listData HumanResource::GetDataForWorkHourPolicyListAction($em$request->isMethod('POST') ? 'POST' 'GET'$request->request$companyId);
  5300.         if ($request->isMethod('POST')) {
  5301.             if ($request->query->has('dataTableQry')) {
  5302.                 return new JsonResponse(
  5303.                     $listData
  5304.                 );
  5305.             }
  5306.         }
  5307.         return $this->render('ApplicationBundle:pages/human_resource/list:work_hour_policy_list.html.twig',
  5308. //         return $this->render('ApplicationBundle:pages/dashboard:test_pix_invent.html.twig',
  5309.             array(
  5310.                 'page_title' => 'Work Hour Policy List',
  5311. //            'data' => SalesOrderM::GetClientList($em, [], $companyId),
  5312. //            'client_types' => Client::GetClientType($em, $companyId),
  5313. //            'region_list' => Client::RegionList($em, $companyId),
  5314. //            'geographical_region_list' => Client::GeographicalRegionList($em, $companyId)
  5315.             )
  5316.         );
  5317.     }
  5318.     public function WorkPlacePolicyListAction(Request $request)
  5319.     {
  5320.         $em $this->getDoctrine()->getManager();
  5321.         $workplacePolicyDetails $em->getRepository('ApplicationBundle:EmployeeWorkplace')->findAll();
  5322. //        $employee = $em->getRepository('ApplicationBundle:Employee')->findAll();
  5323.         return $this->render('ApplicationBundle:pages/human_resource/list:work_place_policy_list.html.twig', array(
  5324.             'page_title' => 'Work Place Policy List',
  5325.             'workplacePolicyDetails' => $workplacePolicyDetails,
  5326. //            'employee'=>$employee
  5327.         ));
  5328.     }
  5329.     public function workPlacePolicyAction(Request $data$id)
  5330.     {
  5331.         $em $this->getDoctrine()->getManager();
  5332.         $workPlacePolicy $em->getRepository('ApplicationBundle:EmployeeWorkplace')->find($id);
  5333.         $employee $em->getRepository(Employee::class)->findAll();
  5334.         $Approval_data System::checkIfApprovalExists(
  5335.             $em,
  5336.             array_flip(GeneralConstant::$Entity_list)['EmployeeWorkplace'],
  5337.             $id,
  5338.             $data->getSession()->get(UserConstants::USER_LOGIN_ID)
  5339.         );
  5340.         $ApprovalStatus GeneralConstant::$approvalStatus;
  5341.         return $this->render('ApplicationBundle:pages/human_resource/views:viewWorkPlacePolicy.html.twig', array(
  5342.             'page_title' => 'Work Place Policy  View',
  5343.             'workPlacePolicy' => $workPlacePolicy,
  5344.             'employee' => $employee,
  5345.             'approval_data' => $Approval_data,
  5346.             'approval_status' => $workPlacePolicy->getApproved(),
  5347.             'id' => $id,
  5348.         ));
  5349.     }
  5350.     public function SalarySegregationPolicyListAction(Request $request)
  5351.     {
  5352.         $em $this->getDoctrine()->getManager();
  5353.         $allowed_ids = [];
  5354.         $companyId $this->getLoggedUserCompanyId($request);
  5355.         $listData HumanResource::GetDataForSalarySegregationPolicyListAction($em$request->isMethod('POST') ? 'POST' 'GET'$request->request$companyId);
  5356.         if ($request->isMethod('POST')) {
  5357.             if ($request->query->has('dataTableQry')) {
  5358.                 return new JsonResponse(
  5359.                     $listData
  5360.                 );
  5361.             }
  5362.         }
  5363.         return $this->render('ApplicationBundle:pages/human_resource/list:salary_segregation_policy_list.html.twig',
  5364. //         return $this->render('ApplicationBundle:pages/dashboard:test_pix_invent.html.twig',
  5365.             array(
  5366.                 'page_title' => 'Salary Segregation Policy List',
  5367. //            'data' => SalesOrderM::GetClientList($em, [], $companyId),
  5368. //            'client_types' => Client::GetClientType($em, $companyId),
  5369. //            'region_list' => Client::RegionList($em, $companyId),
  5370. //            'geographical_region_list' => Client::GeographicalRegionList($em, $companyId)
  5371.             )
  5372.         );
  5373.     }
  5374.     public function HolidayCalendarListAction(Request $request)
  5375.     {
  5376.         $q $this->getDoctrine()
  5377.             ->getRepository('ApplicationBundle:HolidayCalendar')
  5378.             ->findBy(
  5379.                 array(
  5380. //                'status' => GeneralConstant::ACTIVE,
  5381.                     'CompanyId' => $this->getLoggedUserCompanyId($request)
  5382. //                    'approved' =>  GeneralConstant::APPROVED,
  5383.                 )
  5384.             );
  5385.         $stage_list = array(
  5386.             => 'Pending',
  5387.             => 'Pending',
  5388.             => 'Complete',
  5389.             => 'Partial',
  5390.         );
  5391.         $data = [];
  5392.         foreach ($q as $entry) {
  5393.             $data[] = array(
  5394. //          'doc_date' => $entry->getSalesReplacementDate(),
  5395.                 'id' => $entry->getHolidayCalendarId(),
  5396.                 'title' => $entry->getHoliDayTitle(),
  5397.                 'approval_status' => GeneralConstant::$approvalStatus[$entry->getApproved()],
  5398. //          'stage' => $stage_list[$entry->getStage()]
  5399.             );
  5400.         }
  5401.         return $this->render('ApplicationBundle:pages/human_resource/list:holiday_calendar_list.html.twig',
  5402.             array(
  5403.                 'page_title' => 'Holiday Calendar List',
  5404.                 'data' => $data
  5405.             )
  5406.         );
  5407.     }
  5408.     public function PayrollPolicyListAction(Request $request)
  5409.     {
  5410.         $em $this->getDoctrine()->getManager();
  5411.         $allowed_ids = [];
  5412.         $companyId $this->getLoggedUserCompanyId($request);
  5413.         $listData HumanResource::GetDataForPayrollPolicyListAction($em$request->isMethod('POST') ? 'POST' 'GET'$request->request$companyId);
  5414.         if ($request->isMethod('POST')) {
  5415.             if ($request->query->has('dataTableQry')) {
  5416.                 return new JsonResponse(
  5417.                     $listData
  5418.                 );
  5419.             }
  5420.         }
  5421.         return $this->render('ApplicationBundle:pages/human_resource/list:payroll_policy_list.html.twig',
  5422. //         return $this->render('ApplicationBundle:pages/dashboard:test_pix_invent.html.twig',
  5423.             array(
  5424.                 'page_title' => 'Payroll Policy List',
  5425. //            'data' => SalesOrderM::GetClientList($em, [], $companyId),
  5426. //            'client_types' => Client::GetClientType($em, $companyId),
  5427. //            'region_list' => Client::RegionList($em, $companyId),
  5428. //            'geographical_region_list' => Client::GeographicalRegionList($em, $companyId)
  5429.             )
  5430.         );
  5431.     }
  5432.     public function payslipAction(Request $req$action 0$id 0)
  5433.     {
  5434.         $em $this->getDoctrine()->getManager();
  5435.         $attendanceSource HumanResourceConstant::$attendanceSources;
  5436.         if ($action === 'list') {
  5437.             $response HumanResource::twigDataForPayslipList($em);
  5438.             $approval_status GeneralConstant::$approvalAction;
  5439.             return $this->render(
  5440.                 'ApplicationBundle:pages/human_resource/list:payslip_list.html.twig',
  5441.                 [
  5442.                     'page_title' => 'Payslip List',
  5443.                     'reports' => $response,
  5444.                     'approval_status' => $approval_status
  5445.                 ]
  5446.             );
  5447.         }
  5448.         if ($action === 'view') {
  5449.             $response HumanResource::twigDataForPayslipViewAndPrint($em$req$id);
  5450.             return $this->render(
  5451.                 'ApplicationBundle:pages/human_resource/views:payslip_view.html.twig',
  5452.                 [
  5453.                     'page_title' => 'View Payslip',
  5454.                     'approval_data' => $response['approval_data'],
  5455.                     'payslip' => $response['payslip'],
  5456.                     'bankAccount' => $response['bankAccount'],
  5457.                     'tin' => $response['tin'],
  5458.                     'employeeCode' => $response['employeeCode'],
  5459.                     'earningValues' => $response['earningValues'],
  5460.                     'facilityValues' => $response['facilityValues'],
  5461.                     'deductionValues' => $response['deductionValues'],
  5462.                     'document_log' => $response['document_log'],
  5463.                     'approval_status' => $response['approval_status'],
  5464.                     'created_by' => $response['created_by'],
  5465.                     'updated_at' => $response['updated_at'],
  5466.                     'employeeId' => $response['employeeId'],
  5467.                     'totalAttendance' => $response['totalPresent'],
  5468.                     'leaveList' => HumanResourceConstant::$LeaveType,
  5469.                     'AttReportData' => $response['AttReportData'],
  5470. //                    'attendanceLog' => $response['attendanceLog'],
  5471.                     'attendanceSource' => $attendanceSource,
  5472.                     'auto_created' => 0,
  5473.                 ]
  5474.             );
  5475.         }
  5476.         if ($action === 'print') {
  5477.             $em $this->getDoctrine()->getManager();
  5478.             $company_data Company::getCompanyData($em1);
  5479.             $Authorizations System::getSignatureListForDocumentPrint($emarray_flip(GeneralConstant::$Entity_list)['Payslip'], $id);
  5480.             $response HumanResource::twigDataForPayslipViewAndPrint($em$req$id);
  5481.             return $this->render(
  5482.                 'ApplicationBundle:pages/human_resource/print:payslip_print.html.twig',
  5483.                 array(
  5484.                     'page_title' => 'Print Payslip',
  5485.                     'export' => 'pdf,print',
  5486.                     'payslip' => $response['payslip'],
  5487.                     'bankAccount' => $response['bankAccount'],
  5488.                     'tin' => $response['tin'],
  5489.                     'employeeCode' => $response['employeeCode'],
  5490.                     'earningValues' => $response['earningValues'],
  5491.                     'facilityValues' => $response['facilityValues'],
  5492.                     'deductionValues' => $response['deductionValues'],
  5493.                     'company_name' => $company_data->getName(),
  5494.                     'company_data' => $company_data,
  5495.                     'company_address' => $company_data->getAddress(),
  5496.                     'company_image' => $company_data->getImage(),
  5497.                     'Authorizations' => $Authorizations,
  5498.                     'totalAttendance' => $response['totalPresent'],
  5499.                     'leaveList' => HumanResourceConstant::$LeaveType,
  5500.                     'AttReportData' => $response['AttReportData'],
  5501.                     'attendanceSource' => $attendanceSource,
  5502.                     'red' => 0
  5503.                 )
  5504.             );
  5505.         }
  5506.         if ($req->isMethod('POST')) {
  5507.             $sigRes HumanResource::checkSignature($em$req);
  5508.             if ($sigRes['hasErr']) {
  5509.                 $msg $sigRes['msg'];
  5510.                 return new JsonResponse(['success' => false'msg' => $msg]);
  5511.             }
  5512.             HumanResource::storeDataForPayslip($em$req);
  5513.             return new JsonResponse(['success' => true]);
  5514.         }
  5515.     }
  5516.     public function applicantInfoAction(Request $request$id)
  5517.     {
  5518.         $em $this->getDoctrine()->getManager('company_group');
  5519.         $session $request->getSession();
  5520.         $consultantDetails $em->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
  5521.         $skillDetails $em->getRepository(EntitySkill::class)->findAll();
  5522.         $companyId $this->getLoggedUserCompanyId($request);
  5523.         $gender HumanResourceConstant::$sex;
  5524.         $blood HumanResourceConstant::$BloodGroup;
  5525.         $userId $session->get(UserConstants::USER_ID);
  5526.         $encData $request->query->has('ref') ? $request->query->get('ref') : '';
  5527.         $education = array(
  5528.             'instituteName' => $request->get('instituteName'),
  5529.             'courseOfStudy' => $request->get('courseOfStudy'),
  5530.             'courseStartDate' => $request->get('courseStartDate'),
  5531.             'courseEndDate' => $request->get('courseEndDate'),
  5532.             'result' => $request->get('result'),
  5533.             'grade' => $request->get('grade'),
  5534.             'degree' => $request->get('degree'),
  5535.         );
  5536.         $workExperience = array(
  5537.             'title' => $request->get('title'),
  5538.             'companyName' => $request->get('companyName'),
  5539.             'jobStartDate' => $request->get('jobStartDate'),
  5540.             'jobEndDate' => $request->get('jobEndDate'),
  5541.             'description' => $request->get('description'),
  5542.         );
  5543.         $certificate = array(
  5544.             'certificatename' => $request->get('certificatename'),
  5545.             'issuedDate' => $request->get('issuedDate'),
  5546.         );
  5547.         $courses = array(
  5548.             'courseName' => $request->get('courseName'),
  5549.             'date' => $request->get('date'),
  5550.             'duration' => $request->get('duration')
  5551.         );
  5552.         $languages = array(
  5553.             'languageName' => $request->get('languageName'),
  5554.             'writtenSkill' => $request->get('writtenSkill'),
  5555.             'verbalSkill' => $request->get('verbalSkill'),
  5556.         );
  5557.         if ($request->isMethod('POST')) {
  5558.             if ($consultantDetails)
  5559.                 $consultant $consultantDetails;
  5560.             else
  5561.                 $consultant = new EntityApplicantDetails();
  5562.             $consultant->setApplicationText($request->request->get('applicationText'));
  5563.             $consultant->setFirstname($request->request->get('firstname'));
  5564.             $consultant->setLastname($request->request->get('lastname'));
  5565.             $consultant->setIsImgLegal($request->request->get('is_img_legal'));
  5566.             $consultant->setNid($request->request->get('nid'));
  5567.             $consultant->setDob(new \DateTime($request->get('dob')));
  5568.             $consultant->setSex($request->request->get('sex'));
  5569.             $consultant->setFather($request->request->get('father'));
  5570.             $consultant->setMother($request->request->get('mother'));
  5571.             $consultant->setBlood($request->request->get('blood'));
  5572.             $consultant->setPhone($request->request->get('phone'));
  5573.             $consultant->setCountry($request->request->get('country'));
  5574.             $consultant->setPostalCode($request->request->get('postalCode'));
  5575.             $consultant->setCurrAddr($request->request->get('curr_addr'));
  5576.             $consultant->setSkill(json_encode($request->request->get('skill')));
  5577.             $consultant->setEmergencyContactNumber($request->request->get('emm_contact'));
  5578.             $consultant->setCurrentEmployment($request->request->get('currentEmployment'));
  5579.             $consultant->setTin($request->request->get('tin'));
  5580.             $consultant->setEducationData(json_encode($education));
  5581.             $consultant->setWorkExperienceData(json_encode($workExperience));
  5582.             $consultant->setCertificateData(json_encode($certificate));
  5583.             $consultant->setCoursesData(json_encode($courses));
  5584.             $consultant->setLanguagesData(json_encode($languages));
  5585.             $consultant->setWorkExperienceYear($request->request->get('workExperienceYear'));
  5586.             //$consultant->setApplyForConsultant(1);
  5587.             $em->persist($consultant);
  5588.             $em->flush();
  5589.             $path "";
  5590.             $defaultProductImage '';
  5591.             $uploadedFile null;
  5592.             $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/applicantCv/';
  5593.             $uploadedFile $request->files->get('docUpload');
  5594.             if ($uploadedFile != null) {
  5595.                 $fileName 'cv' $consultantDetails->getApplicantId() . '.' $uploadedFile->guessExtension();
  5596.                 $path $fileName;
  5597. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  5598.                 if (!file_exists($upl_dir)) {
  5599.                     mkdir($upl_dir0777true);
  5600.                 }
  5601.                 $uploadedFile->move($upl_dir$path);
  5602.                 $defaultProductImage 'uploads/applicantCv/' $path;
  5603.                 $consultant->setDocImage($defaultProductImage);
  5604.                 $em->flush();
  5605.             }
  5606.             $this->addFlash(
  5607.                 'success',
  5608.                 'Data Updated.'
  5609.             );
  5610.             if ($encData != '') {
  5611.                 $url $this->generateUrl(
  5612.                     'applicant_job_recruitment_view'
  5613.                 );
  5614.                 return $this->redirect($url '?auto_apply=1&encData=' $encData);
  5615.             }
  5616.             $url $this->generateUrl(
  5617.                 'job_recruitment_list_applicant'
  5618.             );
  5619.             return $this->redirect($url);
  5620.         }
  5621.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:applicant_info.html.twig', array(
  5622.             'page_title' => 'My Information ',
  5623.             'gender' => $gender,
  5624.             'blood' => $blood,
  5625.             'consultantDetails' => $consultantDetails,
  5626.             'education' => json_decode($consultantDetails->getEducationData(), true),
  5627.             'workExperience' => json_decode($consultantDetails->getWorkExperienceData(), true),
  5628.             'certificate' => json_decode($consultantDetails->getCertificateData(), true),
  5629.             'courses' => json_decode($consultantDetails->getCoursesData(), true),
  5630.             'languages' => json_decode($consultantDetails->getLanguagesData(), true),
  5631.             'skill' => json_decode($consultantDetails->getSkill(), true),
  5632.             'skillDetails' => $skillDetails
  5633.         ));
  5634. //        $em = $this->getDoctrine()->getManager('company_group');
  5635. //        $applicantRepo = $em->getRepository(EntityApplicantDetails::class);
  5636. //        $skillDetails = $em->getRepository(EntitySkill::class)->findAll();
  5637. //
  5638. //
  5639. //        if ($req->isMethod('POST')) {
  5640. //            $applicant = $applicantRepo->find($id);
  5641. //
  5642. //            if ($req->files->get('img')) {
  5643. //                $ImgName = HumanResource::StoreFiles($req->files->get('img'), 'Applicant');
  5644. //                $applicant->setImage($ImgName);
  5645. //            }
  5646. //
  5647. //            $applicant->setFirstname($req->request->get('firstname'));
  5648. //            $applicant->setLastname($req->request->get('lastname'));
  5649. //            $applicant->setIsImgLegal($req->request->get('is_img_legal'));
  5650. //            $applicant->setNid($req->request->get('nid'));
  5651. //            $applicant->setDob(HumanResource::StringToDate($req->request->get('dob')));
  5652. //            $applicant->setSex($req->request->get('sex'));
  5653. //            $applicant->setFather($req->request->get('father'));
  5654. //            $applicant->setMother($req->request->get('mother'));
  5655. //            $applicant->setSpouse($req->request->get('spouse'));
  5656. //            $applicant->setChild1($req->request->get('child_1'));
  5657. //            $applicant->setChild2($req->request->get('child_2'));
  5658. //            $applicant->setBlood($req->request->get('blood'));
  5659. //            $applicant->setPhone($req->request->get('phone'));
  5660. //            $applicant->setOAuthEmail($req->request->get('oauth_email'));
  5661. //            $applicant->setCurrAddr($req->request->get('curr_addr'));
  5662. //            $applicant->setPermAddr($req->request->get('perm_addr'));
  5663. //            $applicant->setEmmContact($req->request->get('emm_contact'));
  5664. //
  5665. //            $applicant->setInst1($req->request->get('inst1'));
  5666. //            $applicant->setYr1($req->request->get('yr1'));
  5667. //            $applicant->setDur1($req->request->get('dur1'));
  5668. //            $applicant->setInst2($req->request->get('inst2'));
  5669. //            $applicant->setYr2($req->request->get('yr2'));
  5670. //            $applicant->setDur2($req->request->get('dur2'));
  5671. //            $applicant->setInst3($req->request->get('inst3'));
  5672. //            $applicant->setYr3($req->request->get('yr3'));
  5673. //            $applicant->setDur3($req->request->get('dur3'));
  5674. //            $applicant->setEinst1($req->request->get('einst1'));
  5675. //            $applicant->setEyr1($req->request->get('eyr1'));
  5676. //            $applicant->setEdeg1($req->request->get('edeg1'));
  5677. //            $applicant->setEinst2($req->request->get('einst2'));
  5678. //            $applicant->setEyr2($req->request->get('eyr2'));
  5679. //            $applicant->setEdeg2($req->request->get('edeg2'));
  5680. //            $applicant->setEinst3($req->request->get('einst3'));
  5681. //            $applicant->setEyr3($req->request->get('eyr3'));
  5682. //            $applicant->setEdeg3($req->request->get('edeg3'));
  5683. //
  5684. //            $em->persist($applicant);
  5685. //            $em->flush();
  5686. //
  5687. //            return $this->render(
  5688. //                'ApplicationBundle:pages/human_resource/input_forms:applicant_info.html.twig',
  5689. //                [
  5690. //                    'page_title' => 'Applicant Info',
  5691. //                    'applicant_info' => $applicant,
  5692. //                    'blood' => HumanResourceConstant::$BloodGroup,
  5693. //                    'gender' => HumanResourceConstant::$sex,
  5694. //                    'skillDetails' => $skillDetails,
  5695. //                    'HasUpdateMode' => true,
  5696. //                ]
  5697. //            );
  5698. //        }
  5699. //
  5700. //        if ($id) {
  5701. //            $applicant = $applicantRepo->find($id);
  5702. //
  5703. //            return $this->render(
  5704. //                'ApplicationBundle:pages/human_resource/input_forms:applicant_info.html.twig',
  5705. //                [
  5706. //                    'page_title' => 'Applicant Info',
  5707. //                    'applicant_info' => $applicant,
  5708. //                    'blood' => HumanResourceConstant::$BloodGroup,
  5709. //                    'gender' => HumanResourceConstant::$sex,
  5710. //                    'skillDetails' => $skillDetails,
  5711. //                    'HasUpdateMode' => false,
  5712. //                ]
  5713. //            );
  5714. //        }
  5715. //
  5716. //        $google_client = new Google_Client();
  5717. //        $google_client->setClientId('916737688016-l2qfmb9p37cumudkaqpu8s7ndngq9una.apps.googleusercontent.com');
  5718. //        $google_client->setClientSecret('BEWpEBRvv3-hSoB4cGBrVB3z');
  5719. //        $google_client->setRedirectUri('http://localhost/applicant_info');
  5720. //        $google_client->addScope('email');
  5721. //        $google_client->addScope('profile');
  5722.     }
  5723.     public function applicantDashboardAction()
  5724.     {
  5725.         return new JsonResponse(['this is applicant dashboard']);
  5726.     }
  5727.     public function resignApplicationAction(Request $req$id)
  5728.     {
  5729.         $em $this->getDoctrine()->getManager();
  5730.         if ($req->request->has('xhrReq')) {
  5731.             $response HumanResource::HandelXhrForResignApplication($em$req);
  5732.             return new JsonResponse($response);
  5733.         }
  5734.         if ($req->isMethod('GET')) {
  5735.             $applicant $em->getRepository(EmployeeDetails::class)->findBy(['emp_status' => 1]);
  5736.             $resignReason HumanResourceConstant::$resignReason;
  5737.             return $this->render(
  5738.                 'ApplicationBundle:pages/human_resource/input_forms:resign_application.html.twig',
  5739.                 [
  5740.                     'page_title' => 'Resign Application',
  5741.                     'employeeIds' => $applicant,
  5742.                     'resignReasons' => $resignReason,
  5743.                     'HasUpdateMode' => false,
  5744.                 ]
  5745.             );
  5746.         }
  5747.         if ($req->isMethod('POST')) {
  5748.             $approveHash $req->request->get('approvalHash');
  5749.             $loginId $req->getSession()->get(UserConstants::USER_LOGIN_ID);
  5750.             $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  5751.             if ($isSignatureOk) {
  5752.                 $response HumanResource::storeResignApplicationData($em$req);
  5753.                 if ($response) {
  5754.                     return $this->redirectToRoute(
  5755.                         'view_resign_application',
  5756.                         array('id' => $response->getResignApplicationId()),
  5757.                         Response::HTTP_MOVED_PERMANENTLY
  5758.                     );
  5759.                 }
  5760.             } else {
  5761.                 $this->addFlash(
  5762.                     'error',
  5763.                     'Invalid Approval Hash!'
  5764.                 );
  5765.                 return $this->redirectToRoute('resign_application');
  5766.             }
  5767.         }
  5768.     }
  5769.     public function viewResignApplicationAction(Request $req$id 0)
  5770.     {
  5771.         $em $this->getDoctrine()->getManager();
  5772.         $response HumanResource::twigDataForResignApplicationView($em$req$id);
  5773.         return $this->render(
  5774.             'ApplicationBundle:pages/human_resource/views:resign_application_view.html.twig',
  5775.             [
  5776.                 'page_title' => 'View Resign Application',
  5777.                 'approval_data' => $response['approval_data'],
  5778.                 'application' => $response['application'],
  5779.                 'applicant' => $response['applicant'],
  5780.                 'document_log' => $response['document_log'],
  5781.                 'approval_status' => $response['approval_status'],
  5782.                 'created_by' => $response['created_by'],
  5783.                 'updated_at' => $response['updated_at'],
  5784.                 'auto_created' => 0,
  5785.             ]
  5786.         );
  5787.     }
  5788.     public function printResignApplicationAction(Request $req$id)
  5789.     {
  5790.         if ($id) {
  5791.             $em $this->getDoctrine()->getManager();
  5792.             $company_data Company::getCompanyData($em1);
  5793.             $authorizations System::getSignatureListForDocumentPrint($emarray_flip(GeneralConstant::$Entity_list)['ResignApplication'], $id);
  5794.             $response HumanResource::twigDataForResignApplicationView($em$req$id);
  5795.             return $this->render(
  5796.                 'ApplicationBundle:pages/human_resource/print:resign_application_print.html.twig',
  5797.                 array(
  5798.                     'page_title' => 'Print Resign Application',
  5799.                     'export' => 'pdf,print',
  5800.                     'company_name' => $company_data->getName(),
  5801.                     'company_data' => $company_data,
  5802.                     'company_address' => $company_data->getAddress(),
  5803.                     'company_image' => $company_data->getImage(),
  5804.                     'application' => $response['application'],
  5805.                     'applicant' => $response['applicant'],
  5806.                     'Authorizations' => $authorizations,
  5807.                     'red' => 0
  5808.                 )
  5809.             );
  5810.         }
  5811.         return new JsonResponse(array(
  5812.             'success' => false,
  5813.             'msg' => 'Wrong URL format! Please try with application ID'
  5814.         ));
  5815.     }
  5816.     public function listResignApplicationAction(Request $req)
  5817.     {
  5818.         $em $this->getDoctrine()->getManager();
  5819.         $response HumanResource::getResignApplicationList($em$req);
  5820.         return $this->render("ApplicationBundle:pages/human_resource/list:resign_application_list.html.twig", array(
  5821.             'page_title' => 'Resign Application List',
  5822.             'applications' => $response,
  5823.         ));
  5824.     }
  5825.     public function viewNocApprovalAction(Request $req$id)
  5826.     {
  5827.         $em $this->getDoctrine()->getManager();
  5828.         $response HumanResource::twigDataForNocView($em$req$id);
  5829.         return $this->render(
  5830.             'ApplicationBundle:pages/human_resource/views:noc_view.html.twig',
  5831.             [
  5832.                 'page_title' => 'View NOC',
  5833.                 'approval_data' => $response['approval_data'],
  5834.                 'noc_application' => $response['noc_application'],
  5835.                 'resign_application' => $response['resign_application'],
  5836.                 'applicant' => $response['applicant'],
  5837.                 'document_log' => $response['document_log'],
  5838.                 'approval_status' => $response['approval_status'],
  5839.                 'created_by' => $response['created_by'],
  5840.                 'updated_at' => $response['updated_at'],
  5841.                 'auto_created' => 0,
  5842.             ]
  5843.         );
  5844.     }
  5845.     public function printNocApprovalAction(Request $req$id)
  5846.     {
  5847.         $em $this->getDoctrine()->getManager();
  5848.         $company_data Company::getCompanyData($em1);
  5849.         $Authorizations System::getSignatureListForDocumentPrint($emarray_flip(GeneralConstant::$Entity_list)['NocApproval'], $id);
  5850.         $response HumanResource::twigDataForNocView($em$req$id);
  5851.         return $this->render(
  5852.             'ApplicationBundle:pages/human_resource/print:noc_print.html.twig',
  5853.             [
  5854.                 'page_title' => 'Print NOC',
  5855.                 'noc_application' => $response['noc_application'],
  5856.                 'resign_application' => $response['resign_application'],
  5857.                 'applicant' => $response['applicant'],
  5858.                 'export' => 'pdf,print',
  5859.                 'company_name' => $company_data->getName(),
  5860.                 'company_data' => $company_data,
  5861.                 'company_address' => $company_data->getAddress(),
  5862.                 'company_image' => $company_data->getImage(),
  5863.                 'Authorizations' => $Authorizations,
  5864.                 'red' => 0
  5865.             ]
  5866.         );
  5867.     }
  5868.     public function createHolidayAction(Request $request$id)
  5869.     {
  5870.         $em $this->getDoctrine()->getManager();
  5871.         $companyId $this->getLoggedUserCompanyId($request);
  5872.         if ($request->isMethod('POST')) {
  5873.             $entity_id array_flip(GeneralConstant::$Entity_list)['HolidayCalendar']; //change
  5874.             $dochash $request->request->get('doc_hash'); //change
  5875.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  5876.             $approveRole $request->request->get('approvalRole');
  5877.             $approveHash $request->request->get('approvalHash');
  5878.             if (!DocValidation::isInsertable(
  5879.                 $em,
  5880.                 $entity_id,
  5881.                 $dochash,
  5882.                 $loginId,
  5883.                 $approveRole,
  5884.                 $approveHash,
  5885.                 $id
  5886.             )
  5887.             ) {
  5888.                 $this->addFlash(
  5889.                     'error',
  5890.                     'Sorry Couldnot insert Data.'
  5891.                 );
  5892.             } else {
  5893.                 $funcname 'HolidayCalendar';
  5894.                 $doc_id $id;
  5895.                 DeleteDocument::$funcname($em$doc_id0);
  5896.                 if ($id != 0)
  5897.                     $HolidayCalender $em->getRepository(HolidayCalendar::class)->find($id);
  5898.                 else
  5899.                     $HolidayCalender = new HolidayCalendar;
  5900.                 $HolidayCalender->setDocumentHash($request->request->get('doc_hash'));
  5901.                 $HolidayCalender->setHoliDayTitle($request->request->get('holidayCalendarTitle'));
  5902.                 $HolidayCalender->setEmployeeIds(json_encode($request->request->get('employee')));
  5903.                 $HolidayCalender->setEmployeeTypeIds(json_encode($request->request->get('emp_status')));
  5904.                 $HolidayCalender->setDesignationIds(json_encode($request->request->get('desg', [])));
  5905.                 $HolidayCalender->setDepartmentIds(json_encode($request->request->get('dept', [])));
  5906.                 $HolidayCalender->setBranchIds(json_encode($request->request->get('branch', [])));
  5907.                 $HolidayCalender->setLevelSelectionStr($request->get('levelSelectionStr'''));
  5908.                 $HolidayCalender->setLevels(json_encode(HumanResource::getLevelsFromLevelSelectionStr($request->get('levelSelectionStr'''))));
  5909.                 $HolidayCalender->setCompanyId($companyId);
  5910.                 $HolidayCalender->setTypeHash('HD');
  5911.                 $HolidayCalender->setEditFlag(1); //editable usually
  5912.                 $HolidayCalender->setPrefixHash($request->request->get('prefix'));
  5913.                 $HolidayCalender->setAssocHash($request->request->get('assoc'));
  5914.                 $HolidayCalender->setNumberHash($request->request->get('number_hash'));
  5915.                 $HolidayCalender->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  5916.                 $HolidayCalender->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
  5917.                 $HolidayCalender->setAutocreated(0);
  5918. //
  5919. //        $arr = [
  5920. //            'date' =>$request->request->get('start_date'),
  5921. //            'title' => $request->request->get('title'),
  5922. //        ];
  5923. //
  5924. //        $HolidayCalender->setData(json_encode($arr));
  5925.                 $em->persist($HolidayCalender);
  5926.                 $em->flush();
  5927.                 $indHolidays = [];
  5928.                 if ($request->request->has('start_date'))
  5929.                     $indHolidays $request->request->get('start_date');
  5930.                 foreach ($indHolidays as $ind => $dateRangeStr) {
  5931.                     $currRow $request->request->get('row')[$ind];//string
  5932.                     $holidayTitle $request->request->get('title')[$ind];//string
  5933.                     $currStartDate $request->request->get('start_date')[$ind];//string
  5934.                     $currEndDate $request->request->get('end_date')[$ind];//string
  5935.                     $HolidayDate = new HolidayCalendarDates();
  5936.                     $HolidayDate->setHolidayCalendarId($HolidayCalender->getHolidayCalendarId());
  5937.                     $HolidayDate->setDateRange($currStartDate '-' $currEndDate);//string
  5938.                     $HolidayDate->setStartDate(new \DateTime($currStartDate));//date
  5939.                     $HolidayDate->setEndDate(new \DateTime($currEndDate ' 23:59:59'));//date
  5940.                     $HolidayDate->setHolidayTitle($holidayTitle);
  5941. //          $HolidayDate->setIsVariableEachYearFlag($request->request->get('is_variable_each_year',null));
  5942.                     $HolidayDate->setIsVariableEachYearFlag($request->request->get('is_variable_each_year_' $currRownull));
  5943.                     $HolidayDate->setAllDayFlag($request->request->get('all_day_flag_' $currRow1));
  5944.                     $em->persist($HolidayDate);
  5945.                     $em->flush();
  5946.                 }
  5947.                 $options = [];
  5948.                 $entity array_flip(GeneralConstant::$Entity_list)['HolidayCalendar'];
  5949.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  5950.                 $approveRole $request->request->get('approvalRole');
  5951.                 System::setApprovalInfo(
  5952.                     $em,
  5953.                     $options,
  5954.                     $entity,
  5955.                     $HolidayCalender->getHolidayCalendarId(),
  5956.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  5957.                 );
  5958.                 System::createEditSignatureHash(
  5959.                     $em,
  5960.                     $entity,
  5961.                     $HolidayCalender->getHolidayCalendarId(),
  5962.                     $loginId,
  5963.                     $approveRole,
  5964.                     $request->request->get('approvalHash')
  5965.                 );
  5966.                 $url $this->generateUrl(
  5967.                     'view_holiday_calendar'
  5968.                 );
  5969.                 return $this->redirect($url "/" $HolidayCalender->getHolidayCalendarId());
  5970.             }
  5971.         }
  5972.         $em $this->getDoctrine()->getManager();
  5973.         $branches $em->getRepository(Branch::class)->findAll();
  5974.         $employee $em->getRepository(Employee::class)->findAll();
  5975.         $departments $em->getRepository(SysDepartment::class)->findAll();
  5976.         $departmentPositions $em->getRepository(SysDepartmentPosition::class)->findAll();
  5977.         $EmploymentStatus HumanResourceConstant::$employeeType;
  5978.         $em $this->getDoctrine()->getManager();
  5979.         $extDocData = [];
  5980.         if ($id != 0)
  5981.             $extDocData $em->getRepository(HolidayCalendar::class)->find($id);
  5982.         return $this->render(
  5983.             'ApplicationBundle:pages/human_resource/input_forms:create_holiday.html.twig',
  5984.             [
  5985.                 'page_title' => 'Create Holiday',
  5986.                 'branches' => $branches,
  5987.                 'id' => $id,
  5988.                 'extDocData' => $extDocData,
  5989.                 'departments' => $departments,
  5990.                 'departmentPositions' => $departmentPositions,
  5991.                 'employeeStatus' => $EmploymentStatus,
  5992.                 'employeeIds' => $employee,
  5993.                 'holidayCalendarList' => $em->getRepository('ApplicationBundle:HolidayCalendar')
  5994.                     ->findBy(array())
  5995.             ]
  5996.         );
  5997.     }
  5998.     public function HolidayViewAction(Request $request$id)
  5999.     {
  6000.         $em $this->getDoctrine()->getManager();
  6001.         $HolidaysCalendar $em->getRepository(HolidayCalendar::class)->find($id);
  6002.         $holidayCalendarDetails $em->getRepository('ApplicationBundle:HolidayCalendarDates')
  6003.             ->findBy(array(
  6004.                 'holidayCalendarId' => $id
  6005.             ));
  6006.         $Approval_data System::checkIfApprovalExists(
  6007.             $em,
  6008.             array_flip(GeneralConstant::$Entity_list)['HolidayCalendar'],
  6009.             $id,
  6010.             $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  6011.         );
  6012.         return $this->render('ApplicationBundle:pages/human_resource/views:holidays_view.html.twig', array(
  6013.             'page_title' => 'View Holiday',
  6014.             'holidays' => $HolidaysCalendar,
  6015.             'holidayCalendarDetails' => $holidayCalendarDetails,
  6016.             'approval_status' => $HolidaysCalendar->getApproved(),
  6017.             'approval_data' => $Approval_data,
  6018.             'auto_created' => $HolidaysCalendar->getAutocreated(),
  6019.             'document_log' => $HolidaysCalendar->getAutocreated() == System::getDocumentLog(
  6020.                 $this->getDoctrine()->getManager(),
  6021.                 array_flip(GeneralConstant::$Entity_list)['HolidayCalendar'],
  6022.                 $id,
  6023.                 $HolidaysCalendar->getCreatedLoginId(),
  6024.                 $HolidaysCalendar->getEditedLoginId()
  6025.             ) : []
  6026.         ));
  6027.     }
  6028.     public function GetHolidayDetailsAction(Request $request$id)
  6029.     {
  6030.         $em $this->getDoctrine()->getManager();
  6031.         $holidayCalendar $em->getRepository('ApplicationBundle:HolidayCalendar')
  6032.             ->findOneBy(array(
  6033.                 'holidayCalendarId' => $id
  6034.             ));
  6035.         $holidayCalendarDetails $em->getRepository('ApplicationBundle:HolidayCalendarDates')
  6036.             ->findBy(array(
  6037.                 'holidayCalendarId' => $id
  6038.             ));
  6039.         $holidayList = [];
  6040.         foreach ($holidayCalendarDetails as $det) {
  6041.             $dateDet = array(
  6042.                 'title' => $det->getHolidayTitle(),
  6043.                 'startDate' => $det->getStartDate()->format('Y-m-d'),
  6044.                 'endDate' => $det->getEndDate()->format('Y-m-d'),
  6045.             );
  6046.             $holidayList[] = $dateDet;
  6047.         }
  6048.         return new JsonResponse(
  6049.             array(
  6050.                 'success' => true,
  6051.                 'holidayList' => $holidayList
  6052.             )
  6053.         );
  6054.     }
  6055.     public function GetHolidayListByEmployeeIdAction(Request $request$id)
  6056.     {
  6057.         $em $this->getDoctrine()->getManager();
  6058.         $options = [];
  6059.         $options['employeeId'] = $id;
  6060.         HumanResource::getFilteredHolidaysSingle($em$options);
  6061.         $holidayCalendar $em->getRepository('ApplicationBundle:HolidayCalendar')
  6062.             ->findOneBy(array(
  6063.                 'holidayCalendarId' => $id
  6064.             ));
  6065.         $holidayCalendarDetails $em->getRepository('ApplicationBundle:HolidayCalendarDates')
  6066.             ->findBy(array(
  6067.                 'holidayCalendarId' => $id
  6068.             ));
  6069.         $holidayList = [];
  6070.         foreach ($holidayCalendarDetails as $det) {
  6071.             $dateDet = array(
  6072.                 'title' => $det->getHolidayTitle(),
  6073.                 'startDate' => $det->getStartDate()->format('Y-m-d'),
  6074.                 'endDate' => $det->getEndDate()->format('Y-m-d'),
  6075.             );
  6076.             $holidayList[] = $dateDet;
  6077.         }
  6078.         return new JsonResponse(
  6079.             array(
  6080.                 'success' => true,
  6081.                 'holidayList' => $holidayList
  6082.             )
  6083.         );
  6084.     }
  6085.     public function createQuestionAction(Request $request)
  6086.     {
  6087.         $em $this->getDoctrine()->getManager();
  6088.         $em_goc $this->getDoctrine()->getManager('company_group');
  6089.         $companyId $this->getLoggedUserCompanyId($request);
  6090.         if ($request->isMethod('POST')) {
  6091.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6092.             $question = new Questionnaire();
  6093.             $question->setQuestionTitle($request->request->get('questionTitle'''));
  6094.             $question->setQuestionText($request->request->get('questionText'''));
  6095.             $question->setIsForPlanningItem($request->request->has('forPlanningItem') ? 0);
  6096.             $question->setIsForInterview($request->request->has('forInterview') ? 0);
  6097.             $question->setIsForMock($request->request->has('forMock') ? 0);
  6098.             $question->setIsForTraining($request->request->has('forTraining') ? 0);
  6099.             $question->setTaggedSkillHashes($request->request->get('skillHash'));
  6100.             $question->setCorrectAnswers(json_encode($request->request->get('correctAns')));
  6101.             $question->setCompanyId($companyId);
  6102.             $optionData = [];
  6103.             foreach ($request->request->get('optionText') as $key => $val) {
  6104.                 $option = array(
  6105.                     'index' => $request->request->get('optionIndex')[$key],
  6106.                     'text' => $val,
  6107.                 );
  6108.                 $optionData[] = $option;
  6109.             }
  6110.             $question->setOptions(json_encode($optionData));
  6111.             $question->setQuestionValueWeight(1);
  6112.             $question->setQuestionText($request->request->get('questionText'));
  6113.             $question->setUniqueHash('_NONE_');
  6114.             $question->setType($request->request->get('type'0));
  6115.             //$skill->setEditFlag(1); //editable usually
  6116.             $question->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  6117.             //$skill->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
  6118.             //$skill->setAutocreated(0);
  6119.             $em->persist($question);
  6120.             $em->flush();
  6121.             $questionId $question->getQuestionId();
  6122.             $file_path_list = [];
  6123.             if ($questionId != 0)
  6124.                 if (!empty($request->files)) {
  6125.                     MiscActions::RemoveFilesForEntityDoc($em_goc'Question'$questionId);
  6126.                     $storePath 'uploads/Questionnaire/';
  6127.                     $path "";
  6128.                     $file_path "";
  6129.                     $session $request->getSession();
  6130. //                    MiscActions::RemoveExpiredFiles($em_goc);
  6131.                     foreach ($request->files as $uploadedFileGG) {
  6132.                         //            if($uploadedFile->getImage())
  6133.                         //                var_dump($uploadedFile->getFile());
  6134.                         //                var_dump($uploadedFile);
  6135.                         $tempD $uploadedFileGG;
  6136.                         if (!is_array($uploadedFileGG)) {
  6137.                             $uploadedFileGG = array();
  6138.                             $uploadedFileGG[] = $tempD;
  6139.                         }
  6140.                         foreach ($uploadedFileGG as $uploadedFile) {
  6141.                             if ($uploadedFile != null) {
  6142.                                 $extension $uploadedFile->guessExtension();
  6143.                                 $size $uploadedFile->getSize();
  6144.                                 $fileName 'QUES_' $questionId '_' . (md5(uniqid())) . '.' $uploadedFile->guessExtension();
  6145.                                 $path $fileName;
  6146.                                 $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/' $storePath;
  6147.                                 if (!file_exists($upl_dir)) {
  6148.                                     mkdir($upl_dir0777true);
  6149.                                 }
  6150.                                 if (file_exists($upl_dir '' $path)) {
  6151.                                     chmod($upl_dir '' $path0755);
  6152.                                     unlink($upl_dir '' $path);
  6153.                                 }
  6154.                                 $file $uploadedFile->move($upl_dir$path);
  6155.                                 $expireNever 1;
  6156.                                 $expireTs 0;
  6157.                                 $EntityFile = new EntityFile();
  6158.                                 $EntityFile->setPath($this->container->getParameter('kernel.root_dir') . '/../web/' $storePath $path);
  6159.                                 $EntityFile->setMarker('_GEN_');
  6160.                                 $EntityFile->setExtension($extension);
  6161.                                 $EntityFile->setExpireTs($expireTs);
  6162.                                 $EntityFile->setSize($size);
  6163.                                 $EntityFile->setRelativePath($storePath $path);
  6164.                                 $EntityFile->setEntityName('Questionnaire');
  6165.                                 $EntityFile->setEntityBundle('ApplicationBundle');
  6166.                                 $EntityFile->setEntityId($questionId);
  6167.                                 $EntityFile->setEntityIdField('questionId');
  6168.                                 $EntityFile->setModifyFieldSetter('setFiles');
  6169.                                 $EntityFile->setDocIdForApplicant(0);
  6170.                                 $EntityFile->setUserId($session->get(UserConstants::USER_ID0));
  6171.                                 $EntityFile->setAppId($session->get(UserConstants::USER_APP_ID0));
  6172.                                 $EntityFile->setEmployeeId($session->get(UserConstants::USER_EMPLOYEE_ID0));
  6173.                                 $EntityFile->setUserType($session->get(UserConstants::USER_TYPE0));
  6174.                                 $em_goc->persist($EntityFile);
  6175.                                 $em_goc->flush();
  6176.                                 $EntityFileId $EntityFile->getId();
  6177.                             }
  6178.                             if ($path != "")
  6179.                                 $file_path_list[] = ($storePath $path);
  6180.                         }
  6181.                     }
  6182.                     $g_path $this->container->getParameter('kernel.root_dir') . '/../web/' $storePath $path;
  6183.                     $question->setFiles(implode(','$file_path_list));
  6184.                     $em->flush();
  6185.                 }
  6186.             if ($request->request->has('returnJson') || $request->query->has('returnJson')) {
  6187.                 if ($question)
  6188.                     return new JsonResponse(
  6189.                         array(
  6190.                             'id' => $questionId,
  6191.                             'value' => $questionId,
  6192.                             'question_id' => $questionId,
  6193.                             'text' => $question->getQuestionText(),
  6194.                             'question_text' => $question->getQuestionText(),
  6195.                             'question_title' => $question->getQuestionTitle(),
  6196.                             'files' => explode(','$question->getFiles()),
  6197.                             'options' => json_decode($question->getFiles(), true),
  6198.                             'answer_text' => '',
  6199.                             'success' => true
  6200.                         )
  6201.                     );
  6202.                 else
  6203.                     return new JsonResponse(
  6204.                         array(
  6205.                             'success' => false
  6206.                         )
  6207.                     );
  6208.             }
  6209.         }
  6210.         $skillDetails $em->getRepository(Skill::class)->findAll();
  6211.         $skillListObj = [];
  6212.         $skillListArray = [];
  6213.         foreach ($skillDetails as $skillDetail) {
  6214.             $dt = array(
  6215.                 'id' => $skillDetail->getSkillId(),
  6216.                 'name' => $skillDetail->getName(),
  6217.                 'hash' => $skillDetail->getUniqueHash(),
  6218.             );
  6219.             $skillListArray[] = $dt;
  6220.         }
  6221.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:createQuestion.html.twig', array(
  6222.             'page_title' => 'Create Question',
  6223.             'skiillDetails' => $skillDetails,
  6224.             'skillListArray' => $skillListArray,
  6225.         ));
  6226.     }
  6227.     public function createSkillAction(Request $request)
  6228.     {
  6229.         $em $this->getDoctrine()->getManager();
  6230.         $companyId $this->getLoggedUserCompanyId($request);
  6231.         if ($request->isMethod('POST')) {
  6232.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6233.             $skill = new Skill;
  6234.             $skill->setName($request->request->get('skillName'));
  6235.             $skill->setParentId($request->request->get('parentName'));
  6236.             $skill->setUniqueHash($request->request->get('uniqueHash'));
  6237.             $skill->setCompanyId($companyId);
  6238.             //$skill->setEditFlag(1); //editable usually
  6239.             $skill->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  6240.             //$skill->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
  6241.             //$skill->setAutocreated(0);
  6242.             $em->persist($skill);
  6243.             $em->flush();
  6244.         }
  6245.         $skillDetails $em->getRepository(Skill::class)->findAll();
  6246.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:createSkill.html.twig', array(
  6247.             'page_title' => 'Create Skill',
  6248.             'skiillDetails' => $skillDetails,
  6249.         ));
  6250.     }
  6251.     public function createEducationQualificationAction(Request $request)
  6252.     {
  6253.         $em $this->getDoctrine()->getManager();
  6254.         $companyId $this->getLoggedUserCompanyId($request);
  6255.         if ($request->isMethod('POST')) {
  6256.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6257.             $new = new EducationQualification;
  6258.             $new->setName($request->request->get('educationName'));
  6259.             $new->setParentId($request->request->get('parentName'));
  6260.             $new->setUniqueHash($request->request->get('uniqueHash'));
  6261.             $new->setCompanyId($companyId);
  6262.             //$skill->setEditFlag(1); //editable usually
  6263.             $new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  6264.             //$skill->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
  6265.             //$skill->setAutocreated(0);
  6266.             $em->persist($new);
  6267.             $em->flush();
  6268.         }
  6269.         $educationDetails $em->getRepository(EducationQualification::class)->findAll();
  6270.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_education.html.twig', array(
  6271.             'page_title' => 'Create Education',
  6272.             'educationDetails' => $educationDetails,
  6273.         ));
  6274.     }
  6275.     public function createEvaluationCategoryAction(Request $request$id 0)
  6276.     {
  6277.         $em $this->getDoctrine()->getManager();
  6278.         $companyId $this->getLoggedUserCompanyId($request);
  6279.         if ($request->isMethod('POST')) {
  6280.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6281.             $new = new EvaluationCategory;
  6282.             $new->setName($request->request->get('name'));
  6283.             $new->setBranch($request->request->get('branch'));
  6284.             $new->setSelectionType($request->request->get('selection_type'));
  6285.             $new->setEmployeeIds($request->request->get('selected_employeeIds'));
  6286.             $new->setEmployeeTypeIds($request->request->get('employee_types'));
  6287.             $new->setDesignationIds($request->request->get('designation'));
  6288.             $new->setDesignationIds($request->request->get('designation'));
  6289.             $new->setmark($request->request->get('mark'));
  6290.             $new->setSkills(json_encode($request->request->get('skill')));
  6291.             $new->setLevelSelectionStr($request->request->get('levelSelectionStr'));
  6292.             $new->setCompanyId($companyId);
  6293.             $new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  6294.             $em->persist($new);
  6295.             $em->flush();
  6296.         }
  6297.         $skill $em->getRepository(Skill::class)->findAll();
  6298.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  6299.         $employeeType HumanResourceConstant::$employeeType;
  6300.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  6301.         $branch $em->getRepository(Branch::class)->findAll();
  6302.         $departments $em->getRepository(SysDepartment::class)->findAll();
  6303.         $department = [];
  6304.         foreach ($departments as $entry) {
  6305.             $department[$entry->getDepartmentId()] = array(
  6306.                 'id' => $entry->getDepartmentId(),
  6307.                 'name' => $entry->getDepartmentName(),
  6308.             );
  6309.             return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_evaluation_category.html.twig', array(
  6310.                 'page_title' => 'Create Evaluation Category',
  6311.                 'employeeIds' => $employeeIds,
  6312.                 'employeeType' => $employeeType,
  6313.                 'Designation' => $Designation,
  6314.                 'branch' => $branch,
  6315.                 'department' => $department,
  6316.                 'skill' => $skill,
  6317.             ));
  6318.         }
  6319.     }
  6320.     public function createWorkplaceHarassmentAction(Request $request$id 0)
  6321.     {
  6322.         $em $this->getDoctrine()->getManager();
  6323.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  6324.         //$employeeType = HumanResourceConstant::$employeeType;
  6325.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  6326.         $branches $em->getRepository(Branch::class)->findAll();
  6327.         $departments $em->getRepository(SysDepartment::class)->findAll();
  6328.         $harassmentType HumanResourceConstant::$harrasmentType;
  6329.         $department = [];
  6330.         foreach ($departments as $entry) {
  6331.             $department[$entry->getDepartmentId()] = array(
  6332.                 'id' => $entry->getDepartmentId(),
  6333.                 'name' => $entry->getDepartmentName(),
  6334.             );
  6335.         }
  6336.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_workplace_harrasment.html.twig', array(
  6337.             'page_title' => 'Create Workplace Harrasment',
  6338.             'employeeIds' => $employeeIds,
  6339.             'branches' => $branches,
  6340.             'harassmentType' => $harassmentType,
  6341.             'departments' => $department,
  6342.             'designationIds' => $Designation
  6343.         ));
  6344.     }
  6345.     public function ViewHarasssmentComplainAction()
  6346.     {
  6347.         return $this->render('ApplicationBundle:pages/human_resource/views:view_harassment_compalin.html.twig', array(
  6348.             'page_title' => 'View Harassment Complain',
  6349.         ));
  6350.     }
  6351.     public function createWorkplaceViolenceAction(Request $request$id 0)
  6352.     {
  6353.         $em $this->getDoctrine()->getManager();
  6354.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  6355.         //$employeeType = HumanResourceConstant::$employeeType;
  6356.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  6357.         $branches $em->getRepository(Branch::class)->findAll();
  6358.         $departments $em->getRepository(SysDepartment::class)->findAll();
  6359.         $harassmentType HumanResourceConstant::$harrasmentType;
  6360.         $department = [];
  6361.         foreach ($departments as $entry) {
  6362.             $department[$entry->getDepartmentId()] = array(
  6363.                 'id' => $entry->getDepartmentId(),
  6364.                 'name' => $entry->getDepartmentName(),
  6365.             );
  6366.         }
  6367.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:register_workplace_complaint.html.twig', array(
  6368.             'page_title' => 'Register Complaint',
  6369.             'employeeIds' => $employeeIds,
  6370.             'branches' => $branches,
  6371.             'harassmentType' => $harassmentType,
  6372.             'departments' => $department,
  6373.             'designationIds' => $Designation
  6374.         ));
  6375.     }
  6376.     public function createBonusPolicyAction(Request $request$id 0)
  6377.     {
  6378.         $em $this->getDoctrine()->getManager();
  6379.         $companyId $this->getLoggedUserCompanyId($request);
  6380.         $extDocData = [];
  6381.         $extDetailsData = [];
  6382.         if ($request->isMethod('POST')) {
  6383.             //            Generic::debugMessage($_POST);
  6384.             $em $this->getDoctrine()->getManager();
  6385.             $entity_id array_flip(GeneralConstant::$Entity_list)['BonusPolicy']; //change
  6386.             $dochash $request->request->get('docHash'); //change
  6387.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6388.             $approveRole $request->request->get('approvalRole');
  6389.             $approveHash $request->request->get('approvalHash');
  6390.             if (!DocValidation::isInsertable(
  6391.                 $em,
  6392.                 $entity_id,
  6393.                 $dochash,
  6394.                 $loginId,
  6395.                 $approveRole,
  6396.                 $approveHash,
  6397.                 $id
  6398.             )
  6399.             ) {
  6400.                 $this->addFlash(
  6401.                     'error',
  6402.                     'Sorry Couldnot insert Data.'
  6403.                 );
  6404.             } else {
  6405.                 $funcname 'BonusPolicy';
  6406.                 DeleteDocument::$funcname($em$id0);
  6407.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6408.                 $docId HumanResource::createBonusPolicy($em$request$companyId$loginId0);
  6409.                 //now add Approval info
  6410.                 $approveRole $request->request->get('approvalRole');
  6411.                 $options = array(
  6412.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  6413.                     'notification_server' => $this->container->getParameter('notification_server'),
  6414.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  6415.                     'url' => $this->generateUrl(
  6416.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['BonusPolicy']]['entity_view_route_path_name']
  6417.                     )
  6418.                 );
  6419.                 System::setApprovalInfo(
  6420.                     $this->getDoctrine()->getManager(),
  6421.                     $options,
  6422.                     array_flip(GeneralConstant::$Entity_list)['BonusPolicy'],
  6423.                     $docId,
  6424.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  6425.                 );
  6426.                 System::createEditSignatureHash(
  6427.                     $this->getDoctrine()->getManager(),
  6428.                     array_flip(GeneralConstant::$Entity_list)['BonusPolicy'],
  6429.                     $docId,
  6430.                     $loginId,
  6431.                     $approveRole,
  6432.                     $request->request->get('approvalHash')
  6433.                 );
  6434.                 $doc_here $this->getDoctrine()
  6435.                     ->getRepository('ApplicationBundle:BonusPolicy')
  6436.                     ->findOneBy(
  6437.                         array(
  6438.                             'id' => $docId
  6439.                         )
  6440.                     );
  6441.                 //notify
  6442.                 $this->addFlash(
  6443.                     'success',
  6444.                     'Policy Successfully Updated.'
  6445.                 );
  6446.                 $url $this->generateUrl(
  6447.                     'view_bonus_policy'
  6448.                 );
  6449. //                System::AddNewNotification(
  6450. //                    $this->container->getParameter('notification_enabled'),
  6451. //                    $this->container->getParameter('notification_server'),
  6452. //                    $request->getSession()->get(UserConstants::USER_APP_ID),
  6453. //                    $request->getSession()->get(UserConstants::USER_COMPANY_ID),
  6454. //                    "Salary Segregation Policy : " . $doc_here->getDocumentHash() . " Has Been Created And is Under Processing",
  6455. //                    'pos',
  6456. //                    System::getPositionIdsByDepartment($em, GeneralConstant::HRM_DEPARTMENT),
  6457. //                    'success',
  6458. //                    //                    $url . "/" . $TransID,
  6459. //                    $url . "/" . $docId,
  6460. //                    "Journal"
  6461. //
  6462. //                );
  6463.                 return $this->redirect($url "/" $docId);
  6464.             }
  6465.         }
  6466.         //for edits
  6467.         if ($id == 0) {
  6468.         } else {
  6469.             $extDocData $em->getRepository('ApplicationBundle:BonusPolicy')->findOneBy(
  6470.                 array(
  6471.                     'id' => $id///material
  6472.                 )
  6473.             );
  6474.             //now if its not editable, redirect to view
  6475.             if ($extDocData) {
  6476.                 if ($extDocData->getEditFlag() != 1) {
  6477. //          $url = $this->generateUrl(
  6478. ////              'view_salary_segregation_policy'
  6479. //              'salary_segregation_policy'
  6480. //          );
  6481. //          return $this->redirect($url . "/" . $id);
  6482.                 } else {
  6483. //          $extVoucherDetailsData = Accounts::GetVoucherDataForEdit($em, $voucherId);
  6484. //          $extDetailsData = $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
  6485. //              array(
  6486. //                  'transactionId' => $id, ///material
  6487. //
  6488. //              )
  6489. //          );
  6490.                 }
  6491.             } else {
  6492.             }
  6493.         }
  6494.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  6495.         $employeeType HumanResourceConstant::$employeeType;
  6496.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  6497.         $branch $em->getRepository(Branch::class)->findAll();
  6498.         $departments $em->getRepository(SysDepartment::class)->findAll();
  6499.         $department = [];
  6500.         foreach ($departments as $entry) {
  6501.             $department[$entry->getDepartmentId()] = array(
  6502.                 'id' => $entry->getDepartmentId(),
  6503.                 'name' => $entry->getDepartmentName(),
  6504.             );
  6505.         }
  6506.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_bonus_policy.html.twig', array(
  6507.             'page_title' => 'Create Bonus Policy',
  6508.             'employeeIds' => $employeeIds,
  6509.             'employeeType' => $employeeType,
  6510.             'Designation' => $Designation,
  6511.             'branch' => $branch,
  6512.             'department' => $department,
  6513.         ));
  6514.     }
  6515.     public function BonusPolicyListAction()
  6516.     {
  6517.         $em $this->getDoctrine()->getManager();
  6518.         $bonusPolicy $em->getRepository(BonusPolicy::class)->findAll();
  6519.         return $this->render('ApplicationBundle:pages/human_resource/list:bonus_policy_list.html.twig', array(
  6520.             'page_title' => 'Increment Policy List',
  6521.             'bonusPolicy' => $bonusPolicy
  6522.         ));
  6523.     }
  6524.     public function createIncrementPolicyAction(Request $request$id 0)
  6525.     {
  6526.         $em $this->getDoctrine()->getManager();
  6527.         $companyId $this->getLoggedUserCompanyId($request);
  6528.         $extDocData = [];
  6529.         $extDetailsData = [];
  6530.         if ($request->isMethod('POST')) {
  6531.             //            Generic::debugMessage($_POST);
  6532.             $em $this->getDoctrine()->getManager();
  6533.             $entity_id array_flip(GeneralConstant::$Entity_list)['IncrementPolicy']; //change
  6534.             $dochash $request->request->get('docHash'); //change
  6535.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6536.             $approveRole $request->request->get('approvalRole');
  6537.             $approveHash $request->request->get('approvalHash');
  6538.             if (!DocValidation::isInsertable(
  6539.                 $em,
  6540.                 $entity_id,
  6541.                 $dochash,
  6542.                 $loginId,
  6543.                 $approveRole,
  6544.                 $approveHash,
  6545.                 $id
  6546.             )
  6547.             ) {
  6548.                 $this->addFlash(
  6549.                     'error',
  6550.                     'Sorry Couldnot insert Data.'
  6551.                 );
  6552.             } else {
  6553.                 $funcname 'IncrementPolicy';
  6554.                 DeleteDocument::$funcname($em$id0);
  6555.                 $docId HumanResource::createIncrementPolicy($em$request$companyId0);
  6556.                 //now add Approval info
  6557.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6558.                 $approveRole $request->request->get('approvalRole');
  6559.                 $options = array(
  6560.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  6561.                     'notification_server' => $this->container->getParameter('notification_server'),
  6562.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  6563.                     'url' => $this->generateUrl(
  6564.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['IncrementPolicy']]['view_increment_policy']
  6565.                     )
  6566.                 );
  6567.                 System::setApprovalInfo(
  6568.                     $this->getDoctrine()->getManager(),
  6569.                     $options,
  6570.                     array_flip(GeneralConstant::$Entity_list)['IncrementPolicy'],
  6571.                     $docId,
  6572.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID),
  6573.                     3    //journal voucher
  6574.                 );
  6575.                 System::createEditSignatureHash(
  6576.                     $this->getDoctrine()->getManager(),
  6577.                     array_flip(GeneralConstant::$Entity_list)['IncrementPolicy'],
  6578.                     $docId,
  6579.                     $loginId,
  6580.                     $approveRole,
  6581.                     $request->request->get('approvalHash')
  6582.                 );
  6583.                 $doc_here $this->getDoctrine()
  6584.                     ->getRepository('ApplicationBundle:IncrementPolicy')
  6585.                     ->findOneBy(
  6586.                         array(
  6587.                             'id' => $docId
  6588.                         )
  6589.                     );
  6590.                 //notify
  6591.                 $this->addFlash(
  6592.                     'success',
  6593.                     'Policy Successfully Updated.'
  6594.                 );
  6595.                 $url $this->generateUrl(
  6596.                     'view_increment_policy'
  6597.                 );
  6598. //                System::AddNewNotification(
  6599. //                    $this->container->getParameter('notification_enabled'),
  6600. //                    $this->container->getParameter('notification_server'),
  6601. //                    $request->getSession()->get(UserConstants::USER_APP_ID),
  6602. //                    $request->getSession()->get(UserConstants::USER_COMPANY_ID),
  6603. //                    "Salary Segregation Policy : " . $doc_here->getDocumentHash() . " Has Been Created And is Under Processing",
  6604. //                    'pos',
  6605. //                    System::getPositionIdsByDepartment($em, GeneralConstant::HRM_DEPARTMENT),
  6606. //                    'success',
  6607. //                    //                    $url . "/" . $TransID,
  6608. //                    $url . "/" . $docId,
  6609. //                    "Journal"
  6610. //
  6611. //                );
  6612.                 return $this->redirect($url "/" $docId);
  6613.             }
  6614.         }
  6615.         //for edits
  6616.         if ($id == 0) {
  6617.         } else {
  6618.             $extDocData $em->getRepository('ApplicationBundle:IncrementPolicy')->findOneBy(
  6619.                 array(
  6620.                     'id' => $id///material
  6621.                 )
  6622.             );
  6623.             //now if its not editable, redirect to view
  6624.             if ($extDocData) {
  6625.                 if ($extDocData->getEditFlag() != 1) {
  6626. //          $url = $this->generateUrl(
  6627. ////              'view_salary_segregation_policy'
  6628. //              'salary_segregation_policy'
  6629. //          );
  6630. //          return $this->redirect($url . "/" . $id);
  6631.                 } else {
  6632. //          $extVoucherDetailsData = Accounts::GetVoucherDataForEdit($em, $voucherId);
  6633. //          $extDetailsData = $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
  6634. //              array(
  6635. //                  'transactionId' => $id, ///material
  6636. //
  6637. //              )
  6638. //          );
  6639.                 }
  6640.             } else {
  6641.             }
  6642.         }
  6643.         //$em = $this->getDoctrine()->getManager();
  6644.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  6645.         $employeeType HumanResourceConstant::$employeeType;
  6646.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  6647.         $branch $em->getRepository(Branch::class)->findAll();
  6648.         $departments $em->getRepository(SysDepartment::class)->findAll();
  6649.         $department = [];
  6650.         foreach ($departments as $entry) {
  6651.             $department[$entry->getDepartmentId()] = array(
  6652.                 'id' => $entry->getDepartmentId(),
  6653.                 'name' => $entry->getDepartmentName(),
  6654.             );
  6655.         }
  6656.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_increment_policy.html.twig', array(
  6657.             'page_title' => 'Create Increment Policy',
  6658.             'employeeIds' => $employeeIds,
  6659.             'employeeType' => $employeeType,
  6660.             'Designation' => $Designation,
  6661.             'branch' => $branch,
  6662.             'department' => $department,
  6663.         ));
  6664.     }
  6665.     public function IncrementPolicyListAction()
  6666.     {
  6667.         $em $this->getDoctrine()->getManager();
  6668.         $incrementPolicy $em->getRepository(IncrementPolicy::class)->findAll();
  6669.         return $this->render('ApplicationBundle:pages/human_resource/list:increment_policy_list.html.twig', array(
  6670.             'page_title' => 'Increment Policy List',
  6671.             'incrementPolicy' => $incrementPolicy
  6672.         ));
  6673.     }
  6674.     public function ViewIncrementPolicyAction(Request $request$id)
  6675.     {
  6676.         $em $this->getDoctrine()->getManager();
  6677.         $incrementPolicy $em->getRepository(IncrementPolicy::class)->find($id);
  6678.         $Approval_data System::checkIfApprovalExists(
  6679.             $em,
  6680.             array_flip(GeneralConstant::$Entity_list)['IncrementPolicy'],
  6681.             $id,
  6682.             $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  6683.         );
  6684.         return $this->render('ApplicationBundle:pages/human_resource/views:view_increment_policy.html.twig', array(
  6685.             'page_title' => 'Increment Policy List',
  6686.             'incrementPolicy' => $incrementPolicy,
  6687.             'approval_status' => $incrementPolicy->getApproved(),
  6688.             'approval_data' => $Approval_data,
  6689.             'auto_created' => $incrementPolicy->getAutocreated(),
  6690.             'id' => $id,
  6691.             'document_log' => $incrementPolicy->getAutocreated() == System::getDocumentLog(
  6692.                 $this->getDoctrine()->getManager(),
  6693.                 array_flip(GeneralConstant::$Entity_list)['FundRequisition'],
  6694.                 $id,
  6695.                 $incrementPolicy->getCreatedLoginId(),
  6696.                 $incrementPolicy->getEditedLoginId()
  6697.             ) : []
  6698.         ));
  6699.     }
  6700.     public function createConsultancyTopicAction(Request $request$id 0)
  6701.     {
  6702.         $em $this->getDoctrine()->getManager();
  6703.         $companyId $this->getLoggedUserCompanyId($request);
  6704.         if ($request->isMethod('POST')) {
  6705.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6706.             $new = new ConsultancyTopic();
  6707.             $new->setTopicName($request->request->get('topicName'));
  6708.             $new->setParentTopicName($request->request->get('parentTopicName'));
  6709.             $new->setUniqueHash($request->request->get('uniqueHash'));
  6710.             $new->setCompanyId($companyId);
  6711.             $new->setTopicSlug($request->request->get('topicSlug'));
  6712.             $new->setTitle($request->request->get('title'));
  6713.             $new->setSubTitle($request->request->get('subTitle'));
  6714.             $new->setSummary($request->request->get('content'));
  6715.             $new->setVideo($request->request->get('video'));
  6716.             $new->setAuthor($request->request->get('author'));
  6717.             $new->setAuthorSummary($request->request->get('authorSummary'));
  6718.             $new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  6719. //            $arr = [
  6720. //                'requirement' => $request->request->get('requirement'),
  6721. //
  6722. //            ];
  6723. //            $new->setRequirementData(json_encode($arr));
  6724.             $em->persist($new);
  6725.             $em->flush();
  6726.         }
  6727. //            $data = [];
  6728. //            $em = $this->getDoctrine()->getManager();
  6729. //            $companyId = $this->getLoggedUserCompanyId($request);
  6730. //            if ($request->isMethod('POST')) {
  6731. //                $em = $this->getDoctrine()->getManager();
  6732. //                $entity_id = array_flip(GeneralConstant::$Entity_list)['ConsultancyTopic'];
  6733. //                //$dochash = $request->request->get('docHash');//change
  6734. //                $approveRole = $request->request->get('approvalRole');
  6735. //                $approveHash = $request->request->get('approvalHash');
  6736. //                $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6737. //                if (!DocValidation::isInsertable($em, $entity_id,
  6738. //                    $loginId, $approveRole, $approveHash, $id)
  6739. //                ) {
  6740. //                    $this->addFlash(
  6741. //                        'error',
  6742. //                        'Sorry Could not insert Data.'
  6743. //                    );
  6744. //                }  else {
  6745. //                    $data = $request->request;
  6746. //                    $docId = HumanResource::createConsultancyTopic($em, $loginId, $id, $data, $companyId);
  6747. ////                    now add Approval info
  6748. //
  6749. //                    $approveRole = $request->request->get('approvalRole');
  6750. //                    $options = array(
  6751. //                        'notification_enabled' => $this->container->getParameter('notification_enabled'),
  6752. //                        'notification_server' => $this->container->getParameter('notification_server'),
  6753. //                        'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  6754. ////                        'url' => $this->generateUrl(
  6755. ////                            GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['EmployeePerformanceEvolution']]
  6756. ////                            ['entity_view_route_path_name']
  6757. ////                        )
  6758. //                    );
  6759. //                    System::setApprovalInfo($this->getDoctrine()->getManager(), $options,
  6760. //                        array_flip(GeneralConstant::$Entity_list)['ConsultancyTopic'],
  6761. //                        $docId,
  6762. //                        $request->getSession()->get(UserConstants::USER_LOGIN_ID)    //journal voucher
  6763. //                    );
  6764. //                    System::createEditSignatureHash($this->getDoctrine()->getManager(), array_flip(GeneralConstant::$Entity_list)['ConsultancyTopic'],
  6765. //                        $docId,
  6766. //                        $loginId,
  6767. //                        $request->request->get('approvalHash'));
  6768. //                    $this->addFlash(
  6769. //                        'success',
  6770. //                        'New Consultancy Topic Added.'
  6771. //                    );
  6772. ////                    $url = $this->generateUrl(
  6773. ////                        'create_consultancy_topic'
  6774. ////                    );
  6775. //                    //return $this->redirect($url);
  6776. //
  6777. //                }
  6778. //            }
  6779.         $consultancyDetails $em->getRepository('ApplicationBundle:ConsultancyTopic')->findAll();
  6780.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_consultancy.html.twig', array(
  6781.             'page_title' => 'Consultancy Topic',
  6782.             'consultancyDetails' => $consultancyDetails,
  6783. //                'requirement' => json_decode($consultancyDetails->getRequirementData())
  6784.         ));
  6785.     }
  6786.     public function createTopicAction(Request $request$id 0)
  6787.     {
  6788.         $em $this->getDoctrine()->getManager('company_group');
  6789.         $companyId $this->getLoggedUserCompanyId($request);
  6790.         $documentQRY $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->findAll();
  6791.         $topicList $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findAll();
  6792.         $topic = [];
  6793.         $sessionName BuddybeeConstant::$sessionName;
  6794.         $document = [];
  6795.         foreach ($documentQRY as $d) {
  6796.             $document[$d->getId()] = array(
  6797.                 'id' => $d->getId(),
  6798.                 'documentName' => $d->getDocumentName(),
  6799.                 'text' => $d->getDocumentName(),
  6800.             );
  6801.         }
  6802.         $topicId $id;
  6803.         if ($topicId != 0)
  6804.             $topic $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
  6805.                 array(
  6806.                     'id' => $topicId
  6807.                 )
  6808.             );
  6809.         if ($request->isMethod('POST')) {
  6810.             if ($request->request->has('topicId'))
  6811.                 $topicId $request->request->get('topicId');
  6812. //            $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6813.             if ($topicId != 0)
  6814.                 $new $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
  6815.                     array(
  6816.                         'id' => $topicId
  6817.                     )
  6818.                 );
  6819.             else
  6820.                 $new = new EntityCreateTopic();
  6821.             $new->setTopicName($request->request->get('topicName'));
  6822.             $new->setParentTopicId($request->request->get('parentTopic'));
  6823.             if ($request->request->get('countryId') != '')
  6824.                 $new->setCountryId($request->request->get('countryId'));
  6825.             else if ($request->request->get('parentTopic') != '') {
  6826.                 $parentTopic $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
  6827.                     array(
  6828.                         'id' => $request->request->get('parentTopic')
  6829.                     )
  6830.                 );
  6831.                 if ($parentTopic)
  6832.                     $new->setCountryId($parentTopic->getCountryId());
  6833.             }
  6834.             $new->setTimeSlotMultipliers($request->request->get('timeSlotMultipliers'));
  6835.             $new->setOnlyBookableByAdmin($request->request->get('onlyBookableByAdmin'0));
  6836.             $new->setMeetingType($request->request->get('meetingType'0));
  6837.             $new->setConsultantCanUpload($request->request->get('consultantCanUpload'0));
  6838.             $new->setTopicMarker($request->request->get('topicMarker'));
  6839.             $new->setCoinMultiplierValue($request->request->get('coinMultiplierValue'1));
  6840.             $new->setMinLifetimeCoinsBalance($request->request->get('minLifetimeCoinsBalance'0));
  6841.             $new->setMapEmbedIframe($request->request->get('mapEmbedIframe'''));
  6842.             $new->setTopicSummary($request->request->get('topicSummary'));
  6843.             $new->setAddress($request->request->get('address'));
  6844.             $new->setLocationString($request->request->get('locationString'));
  6845.             $new->setLocationLat($request->request->get('locationLat'));
  6846.             $new->setLocationLong($request->request->get('locationLong'));
  6847.             $new->setUniversityRanking($request->request->get('universityRanking'));
  6848.             $new->setIsParent($request->request->get('isParent'));
  6849.             $new->setIsEvent($request->request->get('isEvent'));
  6850.             $new->setConsultancyEnabled($request->request->get('consultancyEnabled'0));
  6851.             $new->setEventExpired($request->request->get('eventExpired'0));
  6852.             $new->setEventDesc($request->request->get('eventDesc'0));
  6853.             $eventStartDate = new \DateTime($request->request->get('eventStartDate'));
  6854.             $eventEndDate = new \DateTime($request->request->get('eventStartDate'));
  6855.             $new->setEventStartDate($eventStartDate);
  6856.             $new->setEventStartDateTs($eventStartDate->format('U'));
  6857.             $new->setEventEndDate($eventEndDate);
  6858.             $new->setEventStartDateTs($eventEndDate->format('U'));
  6859.             $new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  6860.             $checkListStringArray = [];
  6861.             if ($request->request->has('checkList'))
  6862.                 foreach ($request->request->get('checkList') as $value) {
  6863.                     $checkListStringArray [] = explode(","$value);
  6864.                 }
  6865.             $docData = [];
  6866.             foreach ($request->request->get('document', []) as $key => $value)
  6867.                 $docData[] = [
  6868.                     'document' => $request->request->get('document')[$key],
  6869.                     'expDays' => $request->request->get('expDays')[$key],
  6870.                     'stage' => $request->request->get('stage')[$key],
  6871.                     'generalProcessingDays' => $request->request->get('generalProcessingDays')[$key],
  6872.                     'emergencyProcessingDays' => $request->request->get('emergencyProcessingDays')[$key],
  6873.                     'thresholdDaysOffset' => $request->request->get('thresholdDaysOffset')[$key],
  6874.                     'checklist' => explode(","$request->request->get('checkList')[$key])
  6875.                 ];
  6876.             $coursePlanData = [];
  6877.             foreach ($request->request->get('coursePlanSessionNo', []) as $key => $value)
  6878.                 if ($request->request->get('coursePlanSessionNo')[$key] != '' and $request->request->get('coursePlanSessionNo')[$key] != null) {
  6879.                     if (!isset($coursePlanData[$request->request->get('coursePlanSessionNo')[$key]]))
  6880.                         $coursePlanData[$request->request->get('coursePlanSessionNo')[$key]] = [];
  6881.                     $coursePlanData[$request->request->get('coursePlanSessionNo')[$key]][] = [
  6882.                         'sessionNo' => $request->request->get('coursePlanSessionNo')[$key],
  6883.                         'subject' => $request->request->get('coursePlanSubject')[$key],
  6884.                         'details' => $request->request->get('coursePlanDetails')[$key],
  6885.                         'optimumMin' => $request->request->get('coursePlanOptimumMin')[$key],
  6886.                     ];
  6887.                 }
  6888.             $routineData = [];
  6889.             foreach ($request->request->get('routine_sequence', []) as $key => $value) {
  6890.                 $routineData[] = [
  6891.                     'sequence' => $request->request->get('routine_sequence')[$key],
  6892.                     'topicId' => $request->request->get('routine_topic_id')[$key],
  6893.                     'topicName' => $request->request->get('routine_topic_name')[$key],
  6894.                     'meetingType' => $request->request->get('routine_topic_meeting_type')[$key],
  6895.                     'duration' => $request->request->get('routine_duration')[$key],
  6896.                     'offset' => $request->request->get('routine_offset')[$key],
  6897.                     'coins' => $request->request->get('routine_coins')[$key],
  6898.                     'nextSequenceStart' => $request->request->has('routine_next_sequence_start_' $value) ? 0,
  6899.                     'modifiable' => $request->request->has('routine_modifiable_' $value) ? 0,
  6900.                 ];
  6901.             }
  6902.             $sessionData = [];
  6903.             foreach ($request->request->get('sessionId', []) as $key => $value)
  6904.                 $sessionData[] = [
  6905.                     'sessionId' => $request->request->get('sessionId')[$key],
  6906.                     'sessionYear' => $request->request->get('year')[$key],
  6907.                     'threshold' => $request->request->get('threshold')[$key],
  6908.                     'sessionStart' => $request->request->get('sessionStart')[$key],
  6909.                     'applicationStartDate' => $request->request->get('applicationStartDate')[$key],
  6910.                 ];
  6911.             $coursesData = [];
  6912.             foreach ($request->request->get('courseName', []) as $key => $value)
  6913.                 $coursesData[] = [
  6914.                     'courseName' => $request->request->get('courseName')[$key],
  6915.                 ];
  6916.             $departmentData = [];
  6917.             foreach ($request->request->get('departmentName', []) as $key => $value)
  6918.                 $departmentData[] = [
  6919.                     'departmentName' => $request->request->get('departmentName')[$key],
  6920.                 ];
  6921.             $benefitsData = [];
  6922.             foreach ($request->request->get('benefit', []) as $key => $value)
  6923.                 $benefitsData[] = [
  6924.                     'benefit' => $request->request->get('benefit')[$key],
  6925.                 ];
  6926.             $new->setRoutineData(json_encode($routineData));
  6927.             $new->setDocumentData(json_encode($docData));
  6928.             $new->setCoursePlanData(json_encode($coursePlanData));
  6929.             $new->setSessionData(json_encode($sessionData));
  6930.             $new->setCourses(json_encode($coursesData));
  6931.             $new->setDepartments(json_encode($departmentData));
  6932.             $new->setBenefits(json_encode($benefitsData));
  6933.             $otherDataObj = [];
  6934.             foreach (BuddybeeConstant::$otherDataByHash as $ohash => $otherDataGroup)
  6935.                 foreach ($otherDataGroup as $otherData) {
  6936.                     $fieldExists $request->request->has($ohash '_' $otherData['field']);
  6937.                     if ($fieldExists) {
  6938.                         $fieldValue $request->request->get($ohash '_' $otherData['field'], '');
  6939.                         $otherDataObj[$ohash '_' $otherData['field']] = $fieldValue;
  6940.                     }
  6941.                 }
  6942.             $new->setOtherData(json_encode($otherDataObj));
  6943.             $new->setBenefits(json_encode($benefitsData));
  6944.             $em->persist($new);
  6945.             $em->flush();
  6946.             $path "";
  6947.             $defaultProductImage '';
  6948.             $uploadedFile null;
  6949.             $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/topicImage/';
  6950.             $uploadedFile $request->files->get('topicSummaryImage');
  6951.             if ($uploadedFile != null) {
  6952.                 $fileName 'TSI' $new->getId() . '.' $uploadedFile->guessExtension();
  6953.                 $path $fileName;
  6954. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  6955.                 if (!file_exists($upl_dir)) {
  6956.                     mkdir($upl_dir0777true);
  6957.                 }
  6958.                 $uploadedFile->move($upl_dir$path);
  6959.                 $defaultProductImage 'uploads/topicImage/' $path;
  6960.                 $new->setTopicSummaryImage($defaultProductImage);
  6961.                 $em->flush();
  6962.             }
  6963.             $path "";
  6964.             $defaultProductImage '';
  6965.             $uploadedFile null;
  6966.             $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/topicImage/';
  6967.             $uploadedFile $request->files->get('topicImage');
  6968.             if ($uploadedFile != null) {
  6969.                 $fileName 'TI' $new->getId() . '.' $uploadedFile->guessExtension();
  6970.                 $path $fileName;
  6971. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  6972.                 if (!file_exists($upl_dir)) {
  6973.                     mkdir($upl_dir0777true);
  6974.                 }
  6975.                 $uploadedFile->move($upl_dir$path);
  6976.                 $defaultProductImage 'uploads/topicImage/' $path;
  6977.                 $new->setTopicImage($defaultProductImage);
  6978.                 $em->flush();
  6979.             }
  6980.             $this->addFlash(
  6981.                 'success',
  6982.                 'Topic Added.'
  6983.             );
  6984.         }
  6985.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_topic.html.twig', array(
  6986.             'page_title' => 'Create Topic',
  6987.             'defaultCoursePlan' => BuddybeeConstant::$defaultCoursePlan,
  6988.             'coursePlanSessionTitle' => BuddybeeConstant::$coursePlanSessionTitle,
  6989.             'coursePlanSessionTitleShort' => BuddybeeConstant::$coursePlanSessionTitleShort,
  6990.             'document' => $document,
  6991.             'topic' => $topic,
  6992.             'otherDataByHash' => BuddybeeConstant::$otherDataByHash,
  6993.             'topicId' => $topicId,
  6994.             'topicList' => $topicList,
  6995.             'topicMarker' => BuddybeeConstant::$topicMarkup,
  6996.             'sessionName' => $sessionName,
  6997.         ));
  6998.     }
  6999.     public function ConsultancyRequirementSettingsAction(Request $request$id 0)
  7000.     {
  7001.         $em $this->getDoctrine()->getManager('company_group');
  7002.         $entityList $em->getRepository('CompanyGroupBundle:EntityCountryConsultantRequirements')->findAll();
  7003.         $documentQRY $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->findAll();
  7004.         $entity = [];
  7005.         $sessionName BuddybeeConstant::$sessionName;
  7006.         $document = [];
  7007.         foreach ($documentQRY as $d) {
  7008.             $document[$d->getId()] = array(
  7009.                 'id' => $d->getId(),
  7010.                 'documentName' => $d->getDocumentName(),
  7011.                 'text' => $d->getDocumentName(),
  7012.             );
  7013.         }
  7014.         $countryId $id;
  7015.         if ($countryId != 0)
  7016.             $entity $em->getRepository('CompanyGroupBundle:EntityCountryConsultantRequirements')->findOneBy(
  7017.                 array(
  7018.                     'countryId' => $countryId
  7019.                 )
  7020.             );
  7021.         if ($request->isMethod('POST')) {
  7022.             if ($request->request->has('countryId'))
  7023.                 $countryId $request->request->get('countryId');
  7024. //            $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7025.             if ($countryId != 0) {
  7026.                 $new $em->getRepository('CompanyGroupBundle:EntityCountryConsultantRequirements')->findOneBy(
  7027.                     array(
  7028.                         'countryId' => $countryId
  7029.                     )
  7030.                 );
  7031.                 if (!$new)
  7032.                     $new = new EntityCountryConsultantRequirements();
  7033.             } else
  7034.                 $new = new EntityCountryConsultantRequirements();
  7035.             $new->setCountryId($request->request->get('countryId'));
  7036.             $new->setContractLetterHtml($request->request->get('contractLetterHtml'));
  7037.             $new->setRequiredFields($request->request->get('requiredFields'));
  7038.             $new->setAllowedWorkingHoursPerDay($request->request->get('allowedWorkingHoursPerDay'));
  7039.             $new->setAllowedWorkingHoursPerMonth($request->request->get('allowedWorkingHoursPerMonth'));
  7040.             $new->setAllowedWorkingHoursPerWeek($request->request->get('allowedWorkingHoursPerWeek'));
  7041.             $new->setAllowedWorkingHoursPerYear($request->request->get('allowedWorkingHoursPerYear'));
  7042.             $new->setAllowedEarningPerDay($request->request->get('allowedEarningPerDay'));
  7043.             $new->setAllowedEarningPerMonth($request->request->get('allowedEarningPerMonth'));
  7044.             $new->setAllowedEarningPerWeek($request->request->get('allowedEarningPerWeek'));
  7045.             $new->setAllowedEarningPerYear($request->request->get('allowedEarningPerYear'));
  7046.             $new->setRevenuePercentagePerSession($request->request->get('revenuePercentagePerSession'));
  7047.             $docData = [];
  7048.             foreach ($request->request->get('document', []) as $key => $value)
  7049.                 $docData[] = [
  7050.                     'document' => $request->request->get('document')[$key],
  7051.                     'expDays' => $request->request->get('expDays')[$key],
  7052.                     'stage' => $request->request->get('stage')[$key],
  7053.                     'generalProcessingDays' => $request->request->get('generalProcessingDays')[$key],
  7054.                     'emergencyProcessingDays' => $request->request->get('emergencyProcessingDays')[$key],
  7055.                     'thresholdDaysOffset' => $request->request->get('thresholdDaysOffset')[$key],
  7056.                     'checklist' => explode(","$request->request->get('checkList')[$key])
  7057.                 ];
  7058.             $new->setDocumentList(json_encode($docData));
  7059.             $em->persist($new);
  7060.             $em->flush();
  7061.             $this->addFlash(
  7062.                 'success',
  7063.                 'Restriction Updated.'
  7064.             );
  7065.         }
  7066.         return $this->render('@Buddybee/pages/create_consultancy_requirements.html.twig', array(
  7067.             'page_title' => 'Create Requirements',
  7068.             'defaultCoursePlan' => BuddybeeConstant::$defaultCoursePlan,
  7069.             'coursePlanSessionTitle' => BuddybeeConstant::$coursePlanSessionTitle,
  7070.             'coursePlanSessionTitleShort' => BuddybeeConstant::$coursePlanSessionTitleShort,
  7071.             'document' => $document,
  7072.             'entity' => $entity,
  7073.             'otherDataByHash' => BuddybeeConstant::$otherDataByHash,
  7074.             'countryId' => $countryId,
  7075.             'entityList' => $entityList,
  7076.             'topicMarker' => BuddybeeConstant::$topicMarkup,
  7077.             'sessionName' => $sessionName,
  7078.         ));
  7079.     }
  7080.     public function PromoCodeSettingsAction(Request $request$id 0)
  7081.     {
  7082.         $em $this->getDoctrine()->getManager('company_group');
  7083.         $entityList $em->getRepository('CompanyGroupBundle:PromoCode')->findAll();
  7084.         $applicantList $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findAll();
  7085.         $promoCodeId $id;
  7086.         $entity = [];
  7087.         if ($promoCodeId != 0)
  7088.             $entity $em->getRepository('CompanyGroupBundle:PromoCode')->findOneBy(
  7089.                 array(
  7090.                     'id' => $promoCodeId
  7091.                 )
  7092.             );
  7093.         if ($request->isMethod('POST')) {
  7094.             if ($request->request->has('promoCodeId'))
  7095.                 $promoCodeId $request->request->get('promoCodeId');
  7096. //            $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7097.             if ($promoCodeId != 0) {
  7098.                 $new $em->getRepository('CompanyGroupBundle:PromoCode')->findOneBy(
  7099.                     array(
  7100.                         'id' => $promoCodeId
  7101.                     )
  7102.                 );
  7103.                 if (!$new)
  7104.                     $new = new PromoCode();
  7105.             } else
  7106.                 $new = new PromoCode();
  7107. //            $new->setCountryId($request->request->get('countryId'));
  7108.             $new->setCode($request->request->get('code'''));
  7109.             $new->setPromoType($request->request->get('promoType'1));
  7110.             $new->setPromoCodeType($request->request->get('promoCodeType'1));
  7111.             $new->setPromoValue($request->request->get('promoValue'0));
  7112.             $new->setPerpetual($request->request->get('perpetual'0));
  7113.             $new->setMaxDiscountAmount($request->request->get('maxDiscountAmount', -1));
  7114.             $new->setMaxCoinAddition($request->request->get('maxCoinAddition', -1));
  7115.             $new->setMinAmountForApplication($request->request->get('minAmountForApplication'0));
  7116.             $new->setMinCoinForApplication($request->request->get('minCoinForApplication'0));
  7117.             $new->setNextApplicationEachCoinCount($request->request->get('nextApplicationEachCoinCount', -1));
  7118.             $new->setMaxUseCount($request->request->get('maxUseCount', -1));
  7119.             $new->setMaxUseCountPerUser($request->request->get('maxUseCountPerUser', -1));
  7120.             $new->setUseCountBalance($request->request->get('useCountBalance', -1));
  7121.             $new->setReferralApplicantId($request->request->get('referralApplicantId'0));
  7122.             $new->setMaxReferralCommissionCount($request->request->get('maxReferralCommissionCount'0));
  7123.             $new->setReferralCommissionCountBalance($request->request->get('referralCommissionCountBalance'0));
  7124.             $new->setReferralCommissionType($request->request->get('referralCommissionType'1));
  7125.             $new->setReferralAmount($request->request->get('referralAmount'0));
  7126.             $startsAt = new \DateTime($request->request->get('startsAt'''));
  7127.             $expiresAt = new \DateTime($request->request->get('expiresAt'''));
  7128.             $new->setStartsAtTs($startsAt->format('U'));
  7129.             $new->setExpiresAtTs($expiresAt->format('U'));
  7130. //
  7131. //        startsAtTs:
  7132. //            type: integer
  7133. //            nullable: true
  7134. //        expiresAtTs:
  7135. //            type: integer
  7136. //            nullable: true
  7137.             $em->persist($new);
  7138.             $em->flush();
  7139.             $this->addFlash(
  7140.                 'success',
  7141.                 'Promo Code Updated.'
  7142.             );
  7143.         }
  7144.         return $this->render('@Buddybee/pages/buddybee_promo_code_settings.html.twig', array(
  7145.             'page_title' => 'Promo Codes',
  7146.             'entity' => $entity,
  7147.             'promoCodeId' => $promoCodeId,
  7148.             'entityList' => $entityList,
  7149.             'applicantList' => $applicantList,
  7150.         ));
  7151.     }
  7152.     public function createDocumentAction(Request $request$id 0)
  7153.     {
  7154.         $em $this->getDoctrine()->getManager('company_group');
  7155.         $companyId $this->getLoggedUserCompanyId($request);
  7156.         $document $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->findAll();
  7157.         $thisDoc = [];
  7158.         if ($id != 0)
  7159.             $thisDoc $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->findOneBy(
  7160.                 array(
  7161.                     'Id' => $id
  7162.                 )
  7163.             );
  7164.         if ($request->isMethod('POST')) {
  7165.             if ($id != 0)
  7166.                 $new $thisDoc;
  7167.             else
  7168.                 $new = new EntityCreateDocument();
  7169.             $new->setDocumentName($request->request->get('docName'));
  7170.             $new->setExpiryDays($request->request->get('expDays'));
  7171.             $new->setProcessingDays($request->request->get('processingDays'));
  7172.             $new->setEmergencyProcessingDays($request->request->get('emergencyProcessingDays'));
  7173.             $new->setDocVideo($request->request->get('docVideoLink'));
  7174.             $new->setRequiredDocument(json_encode($request->request->get('requiredDoc')));
  7175.             $new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  7176.             $arr = [
  7177.                 'checkListName' => $request->request->get('checkListName'),
  7178.             ];
  7179.             $new->setCheckList(json_encode($arr));
  7180.             $em->persist($new);
  7181.             $em->flush();
  7182.         }
  7183.         $this->addFlash(
  7184.             'Document Added',
  7185.             'Topic Added.'
  7186.         );
  7187.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_document.html.twig', array(
  7188.             'page_title' => 'Create Document',
  7189.             'document' => $document,
  7190.             'thisDoc' => $thisDoc
  7191.         ));
  7192.     }
  7193.     public function getIndividualDocumentAction(Request $request$id)
  7194.     {
  7195.         $em $this->getDoctrine()->getManager('company_group');
  7196.         if ($id == 0) {
  7197.             if ($request->request->has('documentId'))
  7198.                 $id $request->request->get('documentId');
  7199.         }
  7200.         $document $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->find($id);
  7201.         return new JsonResponse(
  7202.             array(
  7203.                 'success' => true,
  7204.                 'rowId' => $request->request->get('rowId'),
  7205.                 'expiryDays' => $document->getExpiryDays(),
  7206.                 'processingDays' => $document->getProcessingDays(),
  7207.                 'emergencyProcessing' => $document->getEmergencyProcessingDays(),
  7208.                 'checklist' => json_decode($document->getCheckList()),
  7209.             )
  7210.         );
  7211.     }
  7212.     public function createBlogAction(Request $request$id)
  7213.     {
  7214.         if (!$id) {
  7215.             if ($request->isMethod('POST')) {
  7216.                 $em $this->getDoctrine()->getManager('company_group');
  7217.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7218.                 $new = new EntityCreateBlog();
  7219.                 $new->setTopicId($request->request->get('topicId'));
  7220.                 $new->setTitle($request->request->get('title'));
  7221.                 $new->setSubtitle($request->request->get('subTitle'));
  7222.                 $new->setContent($request->request->get('content'));
  7223.                 $new->setVideoLink($request->request->get('videoLink'));
  7224.                 $new->setAuthorName($request->request->get('authorName'));
  7225.                 $new->setAuthorSummary($request->request->get('authorSummary'));
  7226.                 $new->setIsPrimaryBlog($request->request->get('checkPrimaryBlog'));
  7227.                 $em->persist($new);
  7228.                 $em->flush();
  7229.                 //$fileName = 'cv' . $consultantDetails->getApplicantId() . '.' . $uploadedFile->guessExtension();
  7230.                 $path "";
  7231.                 $defaultProductImage '';
  7232.                 $uploadedFile null;
  7233.                 $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/authorImage/';
  7234.                 $uploadedFile $request->files->get('authorImage');
  7235.                 if ($uploadedFile != null) {
  7236.                     $fileName 'authorImage' $new->getId() . '.' $uploadedFile->guessExtension();
  7237.                     $path $fileName;
  7238. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  7239.                     if (!file_exists($upl_dir)) {
  7240.                         mkdir($upl_dir0777true);
  7241.                     }
  7242.                     $uploadedFile->move($upl_dir$path);
  7243.                     $defaultProductImage 'uploads/authorImage/' $path;
  7244.                     $new->setAuthorImage($defaultProductImage);
  7245.                     $em->flush();
  7246.                 }
  7247.                 $path "";
  7248.                 $defaultProductImage '';
  7249.                 $uploadedFile null;
  7250.                 $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/mainImage/';
  7251.                 $uploadedFile $request->files->get('main_img');
  7252.                 if ($uploadedFile != null) {
  7253.                     $fileName 'mainImage' $new->getId() . '.' $uploadedFile->guessExtension();
  7254.                     $path $fileName;
  7255. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  7256.                     if (!file_exists($upl_dir)) {
  7257.                         mkdir($upl_dir0777true);
  7258.                     }
  7259.                     $uploadedFile->move($upl_dir$path);
  7260.                     $defaultProductImage 'uploads/mainImage/' $path;
  7261.                     $new->setMainImage($defaultProductImage);
  7262.                     $em->flush();
  7263.                 }
  7264.                 $topicDetails $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
  7265.                     array(
  7266.                         'id' => $request->request->get('topicId')
  7267.                     )
  7268.                 );
  7269.                 if ($new->getIsPrimaryBlog() == 1) {
  7270.                     if ($topicDetails)
  7271.                         $topic $topicDetails;
  7272.                     else
  7273.                         $topic = new EntityCreateTopic();
  7274.                     $topic->setPrimaryBlogId($new->getId());
  7275.                     $em->flush();
  7276.                 }
  7277.                 $this->addFlash(
  7278.                     'success',
  7279.                     'Blog Added.'
  7280.                 );
  7281.             } else {
  7282.                 $em $this->getDoctrine()->getManager('company_group');
  7283.                 $topic $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findAll();
  7284.                 $applicant $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findAll();
  7285.                 $blogs $em->getRepository('CompanyGroupBundle:EntityCreateBlog')->findAll();
  7286.                 $topicIds = [];
  7287.                 foreach ($blogs as $blog) {
  7288.                     $topicIds [] = $blog->getTopicId();
  7289.                 }
  7290. //                $topic = $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findBy(
  7291. //                    array(
  7292. //                        'id' => $topicIds
  7293. //                    )
  7294. //                );
  7295.                 return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_blog.html.twig', array(
  7296.                     'page_title' => 'Create Blog',
  7297.                     'topic' => $topic,
  7298.                     'applicant' => $applicant,
  7299.                     'blog' => $blogs,
  7300.                     'id' => $id,
  7301.                 ));
  7302.             }
  7303.         } else {
  7304.             if ($request->isMethod('GET')) {
  7305.                 $em $this->getDoctrine()->getManager('company_group');
  7306.                 $topic $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findAll();
  7307.                 $applicant $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findAll();
  7308.                 $blogs $em->getRepository('CompanyGroupBundle:EntityCreateBlog')->find($id);
  7309.                 return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_blog.html.twig', array(
  7310.                     'page_title' => 'Create Blog',
  7311.                     'topic' => $topic,
  7312.                     'applicant' => $applicant,
  7313.                     'blog' => $blogs,
  7314.                     'id' => $id,
  7315.                 ));
  7316.             } else {
  7317.                 $em $this->getDoctrine()->getManager('company_group');
  7318.                 $new = new EntityCreateBlog();
  7319.                 $new->setTopicId($request->request->get('topicId'));
  7320.                 $new->setTitle($request->request->get('title'));
  7321.                 $new->setSubtitle($request->request->get('subTitle'));
  7322.                 $new->setContent($request->request->get('content'));
  7323.                 $new->setVideoLink($request->request->get('videoLink'));
  7324.                 $new->setAuthorName($request->request->get('authorName'));
  7325.                 $new->setAuthorSummary($request->request->get('authorSummary'));
  7326.                 //$em->persist($new);
  7327.                 $em->flush();
  7328.                 $path "";
  7329.                 $defaultProductImage '';
  7330.                 $uploadedFile null;
  7331.                 $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/authorImage/';
  7332.                 $uploadedFile $request->files->get('authorImage');
  7333.                 if ($uploadedFile != null) {
  7334.                     $fileName 'authorImage' '.' $uploadedFile->guessExtension();
  7335.                     $path $fileName;
  7336. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  7337.                     if (!file_exists($upl_dir)) {
  7338.                         mkdir($upl_dir0777true);
  7339.                     }
  7340.                     $uploadedFile->move($upl_dir$path);
  7341.                     $defaultProductImage 'uploads/authorImage/' $path;
  7342.                     $new->setAuthorImage($defaultProductImage);
  7343.                     $em->flush();
  7344.                 }
  7345.                 $this->addFlash(
  7346.                     'success',
  7347.                     'Blog Updated.'
  7348.                 );
  7349.             }
  7350.         }
  7351.         return new JsonResponse(
  7352.             array(
  7353.                 'success' => true,
  7354.             )
  7355.         );
  7356. //        if ($request->isMethod('POST')) {
  7357. //            $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7358. //
  7359. //            $new = new EntityCreateBlog();
  7360. //
  7361. //            $new->setTopicId($request->request->get('topicId'));
  7362. //            $new->setTitle($request->request->get('title'));
  7363. //            $new->setSubtitle($request->request->get('subTitle'));
  7364. //            $new->setContent($request->request->get('content'));
  7365. //            $new->setVideoLink($request->request->get('videoLink'));
  7366. //            $new->setAuthorName($request->request->get('authorName'));
  7367. //            $new->setAuthorSummary($request->request->get('authorSummary'));
  7368. //
  7369. //            $em->persist($new);
  7370. //            $em->flush();
  7371. //
  7372. //
  7373. //            $path = "";
  7374. //            $defaultProductImage = '';
  7375. //            $uploadedFile = null;
  7376. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/authorImage/';
  7377. //            $uploadedFile=  $request->files->get('authorImage');
  7378. //
  7379. //            if ($uploadedFile != null) {
  7380. //
  7381. //                $fileName = 'authorImage' .'.' . $uploadedFile->guessExtension();
  7382. //                $path = $fileName;
  7383. ////            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  7384. //                if (!file_exists($upl_dir)) {
  7385. //                    mkdir($upl_dir, 0777, true);
  7386. //                }
  7387. //                $uploadedFile->move($upl_dir, $path);
  7388. //                $defaultProductImage = 'uploads/authorImage/' . $path;
  7389. //                $new->setAuthorImage($defaultProductImage);
  7390. //                $em->flush();
  7391. //
  7392. //            }
  7393. //            $this->addFlash(
  7394. //                'success',
  7395. //                'Blog Added.'
  7396. //            );
  7397. //        }
  7398. //        return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_blog.html.twig', array(
  7399. //            'page_title' => 'Create Blog',
  7400. //            'topic'=> $topic,
  7401. //            'applicant' => $applicant,
  7402. //            'blog' => $blogs
  7403. //        ));
  7404.     }
  7405.     public function applicantConsultancyAction()
  7406.     {
  7407.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:consultancy.html.twig', array(
  7408.             'page_title' => 'Consultancy',
  7409.         ));
  7410.     }
  7411.     public function viewConsultantDetailsAction(Request $request$id 0)
  7412.     {
  7413.         $gocEnabled 1;
  7414.         $currAppId 4;
  7415.         $honeybeeAppId 1;
  7416.         $buddybeeAppId 4;
  7417.         $em_goc $this->getDoctrine()->getManager('company_group');
  7418.         $em $this->getDoctrine()->getManager();
  7419.         $option = [];
  7420.         $option['appId'] = $currAppId//honeybee
  7421.         $option['departmentId'] = 18//consultancy
  7422.         $option['designationId'] = 50;
  7423. //        $dataToConnect = System::changeDoctrineManagerByAppId(
  7424. //            $this->getDoctrine()->getManager('company_group'),
  7425. //            $gocEnabled,
  7426. //            $currAppId
  7427. //        );
  7428. //        if (!empty($dataToConnect)) {
  7429. //            $connector = $this->container->get('application_connector');
  7430. //            $connector->resetConnection(
  7431. //                'default',
  7432. //                $dataToConnect['dbName'],
  7433. //                $dataToConnect['dbUser'],
  7434. //                $dataToConnect['dbPass'],
  7435. //                $dataToConnect['dbHost'],
  7436. //                $reset = true
  7437. //            );
  7438. //            $em = $this->getDoctrine()->getManager();
  7439. //        } else {
  7440. //            $currAppId = $honeybeeAppId;
  7441. //            $dataToConnectAgain = System::changeDoctrineManagerByAppId(
  7442. //                $this->getDoctrine()->getManager('company_group'),
  7443. //                $gocEnabled,
  7444. //                $currAppId
  7445. //            );
  7446. //            if (!empty($dataToConnectAgain)) {
  7447. //                $connector = $this->container->get('application_connector');
  7448. //                $connector->resetConnection(
  7449. //                    'default',
  7450. //                    $dataToConnect['dbName'],
  7451. //                    $dataToConnect['dbUser'],
  7452. //                    $dataToConnect['dbPass'],
  7453. //                    $dataToConnect['dbHost'],
  7454. //                    $reset = true
  7455. //                );
  7456. //                $em = $this->getDoctrine()->getManager();
  7457. //            }
  7458. //
  7459. //        }
  7460.         $consultantDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($id);
  7461.         $skill $em_goc->getRepository(EntitySkill::class)->findAll();
  7462.         $gender HumanResourceConstant::$sex;
  7463.         $blood HumanResourceConstant::$BloodGroup;
  7464.         $consultantLevel HumanResourceConstant::$consultantLevel;
  7465.         $companyId $this->getLoggedUserCompanyId($request);
  7466.         $designation $em->getRepository("ApplicationBundle:SysDepartmentPosition")->findAll();
  7467.         $departments $em->getRepository("ApplicationBundle:SysDepartment")->findAll();
  7468.         $companyData Company::getCompanyData($em$companyId);
  7469.         $currDate = new \DateTime();
  7470.         if ($request->isMethod('POST')) {
  7471.             //for consultant only
  7472.             $convertToConsultant HumanResource::convertToConsultant($em_goc$em$id$option$request->request);
  7473.             if ($request->request->get('confirmStatus'0) == 1) {
  7474.                 $bodyTemplate 'ApplicationBundle:email/templates:consultantApprovalEmail.html.twig';
  7475.                 $contractLetterHtml '';
  7476.                 $bodyData = array(
  7477.                     'name' => $consultantDetails->getFirstname() . ' ' $consultantDetails->getLastname(),
  7478.                     'companyData' => $companyData,
  7479.                     'contractLetterHtml' => $contractLetterHtml,
  7480.                     'commentText' => $request->request->get('commentText'),
  7481.                 );
  7482.                 $new_mail $this->get('mail_module');
  7483.                 $new_mail->sendMyMail(array(
  7484.                     'senderHash' => '_CUSTOM_',
  7485.                     'encryptionMethod' => 'ssl',
  7486.                     'userName' => 'management@buddybee.eu',
  7487.                     'fromAddress' => 'management@buddybee.eu',
  7488.                     'password' => 'Eco@0112',
  7489.                     'smtpServer' => 'smtp.hostinger.com',
  7490.                     'smtpPort' => '465',
  7491.                     'forwardToMailAddress' => $consultantDetails->getEmail(),
  7492.                     'subject' => 'Consultant Contract Letter Of ' $consultantDetails->getFirstName(),
  7493.                     'fileName' => '',
  7494.                     //'attachments' => $attachments,
  7495.                     'toAddress' => $consultantDetails->getEmail(),
  7496.                     'mailTemplate' => $bodyTemplate,
  7497.                     'templateData' => $bodyData,
  7498.                     'embedCompanyImage' => 1,
  7499.                     'companyId' => $companyId,
  7500.                     'companyImagePath' => ""
  7501.                 ));
  7502.             }
  7503.             if ($request->request->get('confirmStatus'0) == 0) {
  7504.                 $bodyTemplate 'ApplicationBundle:email/templates:consultantRejectionEmail.html.twig';
  7505.                 $contractLetterHtml '';
  7506.                 $bodyData = array(
  7507.                     'name' => $consultantDetails->getFirstname() . ' ' $consultantDetails->getLastname(),
  7508.                     'companyData' => $companyData,
  7509.                     'contractLetterHtml' => $contractLetterHtml,
  7510.                     'commentText' => $request->request->get('commentText'),
  7511.                 );
  7512.                 $new_mail $this->get('mail_module');
  7513.                 $new_mail->sendMyMail(array(
  7514.                     'senderHash' => '_CUSTOM_',
  7515.                     'encryptionMethod' => 'ssl',
  7516.                     'userName' => 'management@buddybee.eu',
  7517.                     'fromAddress' => 'management@buddybee.eu',
  7518.                     'password' => 'Eco@0112',
  7519.                     'smtpServer' => 'smtp.hostinger.com',
  7520.                     'smtpPort' => '465',
  7521.                     'forwardToMailAddress' => $consultantDetails->getEmail(),
  7522.                     'subject' => 'Rejection Letter Of ' $consultantDetails->getFirstName(),
  7523.                     'fileName' => '',
  7524.                     //'attachments' => $attachments,
  7525.                     'toAddress' => $consultantDetails->getEmail(),
  7526.                     'mailTemplate' => $bodyTemplate,
  7527.                     'templateData' => $bodyData,
  7528.                     'embedCompanyImage' => 1,
  7529.                     'companyId' => $companyId,
  7530.                     'companyImagePath' => ""
  7531.                 ));
  7532.             }
  7533.         }
  7534.         $docList MiscActions::GetDocumentDataForBuddybeeConsultantApply($em_goc,
  7535.             $id,
  7536.             $consultantDetails->getCurrentCountryId()
  7537.         );
  7538.         return $this->render('ApplicationBundle:pages/human_resource/views:viewConsultantDetails.html.twig', array(
  7539.             'page_title' => 'Consultant Details',
  7540.             'applicantId' => $id,
  7541.             'consultantDetails' => $consultantDetails,
  7542.             'education' => json_decode($consultantDetails->getEducationData(), true),
  7543.             'workExperience' => json_decode($consultantDetails->getWorkExperienceData(), true),
  7544.             'certificate' => json_decode($consultantDetails->getCertificateData(), true),
  7545.             'gender' => $gender,
  7546.             'blood' => $blood,
  7547.             'skill' => $skill,
  7548.             'docList' => $docList,
  7549.             'countryId' => $consultantDetails->getCurrentCountryId(),
  7550.             'consultantLevel' => $consultantLevel,
  7551.             'designation' => $designation,
  7552.             'department' => $departments
  7553.         ));
  7554.     }
  7555.     public function ApplicableEmployeSettingsAction()
  7556.     {
  7557.         $em $this->getDoctrine()->getManager();
  7558.         $employeeIds $em->getRepository(Employee::class)->findAll();
  7559.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:applicable_employee_settings.html.twig', array(
  7560.             'page_title' => 'Applicable Employee Settings',
  7561.             'employeeIds' => $employeeIds
  7562.         ));
  7563.     }
  7564.     public function GetApplicableSettingsForSingleEmployeeAction($id)
  7565.     {
  7566.         $em $this->getDoctrine()->getManager();
  7567.         $bankLists $em->getRepository(WorkHourPolicy::class)->findAll();
  7568.         if (json_decode($bankLists->getEmployeeIds()) == $id) {
  7569.             return new JsonResponse(
  7570.                 array(
  7571.                     'success' => true,
  7572.                     'msg' => 'employee found'
  7573.                 )
  7574.             );
  7575.         } else {
  7576.             return new JsonResponse(
  7577.                 array(
  7578.                     'success' => true,
  7579.                     'msg' => 'employee not found'
  7580.                 )
  7581.             );
  7582.         }
  7583.     }
  7584. //    public function  getEmployeeDataAction(){
  7585. //        $em = $this->getDoctrine()->getManager();
  7586. //        $emplyeeDetails =  $em->getRepository('ApplicationBundle:EmployeeDeatils')->findAll();
  7587. //        $days = HumanResourceConstant::$days;
  7588. //        $holidays = ;
  7589. //        $workHourPolicies = ;
  7590. //
  7591. //    }
  7592.     public function meetingSchedulingForTabAction()
  7593.     {
  7594.         $em $this->getDoctrine()->getManager();
  7595.         $date date('Y-m-d');
  7596.         $month date('m');
  7597.         $year date('Y');
  7598.         $monthName date("F"mktime(000$month));
  7599.         $totalDayOfMonth cal_days_in_month(CAL_GREGORIAN$month$year);
  7600.         $fromdt date('Y-m-01 'strtotime("First Day Of  $monthName $year"));
  7601. //        echo "Start Date : $fromdt" . "<br>";
  7602.         $todt date('Y-m-d 'strtotime("Last Day of $monthName $year"));
  7603. //        echo "End Date : $todt" . "<br>";
  7604.         $num_friday '';
  7605.         for ($i 0$i < ((strtotime($todt) - strtotime($fromdt)) / 86400); $i++) {
  7606.             if (date('l'strtotime($fromdt) + ($i 86400)) == 'Friday') {
  7607.                 $num_friday++;
  7608.             }
  7609.         }
  7610.         $num_saturday '';
  7611.         for ($i 0$i < ((strtotime($todt) - strtotime($fromdt)) / 86400); $i++) {
  7612.             if (date('l'strtotime($fromdt) + ($i 86400)) == 'Saturday') {
  7613.                 $num_saturday++;
  7614.             }
  7615.         }
  7616.         $totalWeekends $num_saturday $num_friday;
  7617.         $totalCompanyWorkingDay $totalDayOfMonth $totalWeekends;
  7618. //        $attendanceData=$em->getRepository('ApplicationBundle:EmployeeAttendanceLog')->findOneBy(
  7619. //            array(
  7620. //                'employeeId' => 3
  7621. //            )
  7622. //        );
  7623.         $DateRange = [];
  7624.         $holidayDates $em->getRepository('ApplicationBundle:HolidayCalendarDates')->findAll();
  7625.         foreach ($holidayDates as $holiday) {
  7626.             $holidaayData = array(
  7627.                 'startDate' => $holiday->getStartDate(),
  7628.                 'endDate' => $holiday->getEndDate(),
  7629.             );
  7630.             $DateRange $holidaayData;
  7631.         }
  7632.         $employeeDataDetail = [];
  7633.         $employeeDetail $em->getRepository('ApplicationBundle:EmployeeDetails')->findOneBy(
  7634.             array(
  7635.                 'id' => 3
  7636.             )
  7637.         );
  7638. //        foreach($employeeDetail as $employee){
  7639.         $employeeData = array(
  7640.             'firstName' => $employeeDetail->getFirstname(),
  7641.             'basic' => $employeeDetail->getEar1(),
  7642.             'dearness' => $employeeDetail->getEar2(),
  7643.             'houseRent' => $employeeDetail->getEar3(),
  7644.             'medical' => $employeeDetail->getEar4(),
  7645.             'leaveTravel' => $employeeDetail->getEar5(),
  7646.             'childEducation' => $employeeDetail->getEar6(),
  7647.             'totalEarning' => $employeeDetail->getEart(),
  7648.         );
  7649.         $employeeDataDetail $employeeData;
  7650. //        }
  7651.         $attendanceData $em->getRepository(EmployeeAttendanceLog::class);
  7652. //        $employeeId = $attendanceData->getEmployeeId();
  7653. //        $countId = count($employeeId);
  7654.         $totalPresent $attendanceData->createQueryBuilder('a')
  7655.             // Filter by some parameter if you want
  7656.             ->where('a.employeeId = 3')
  7657.             ->andWhere('a.isPresent = 1')
  7658.             ->select('a.isPresent')
  7659.             ->getQuery()
  7660.             ->getResult();
  7661. //        $countAt = 0;
  7662.         $count count($totalPresent);
  7663. //        $count = $countAt+$count;
  7664.         //get holiday
  7665.         $holidayStartDate $DateRange['startDate']->format('Y-m-d');
  7666.         $holidayEndDate $DateRange['endDate']->format('Y-m-d');
  7667.         $dates HumanResource::getBetweenDates($holidayStartDate$holidayEndDate);
  7668.         $dateCount count($dates);
  7669.         $totalOffDay $totalWeekends $dateCount;
  7670.         $totalCompanyWorkingDay $totalDayOfMonth $totalOffDay;
  7671.         $totalAbsent $totalCompanyWorkingDay $count;
  7672. //        foreach($dates as $compDate ){
  7673. //
  7674. //
  7675. //
  7676. //            if($date == $compDate){
  7677. //                echo $date;
  7678. //                echo $compDate;
  7679. //                echo "holiday" ;
  7680. //
  7681. //            }
  7682. //            else{
  7683. //                echo "no holiday" ;
  7684. //            }
  7685. //        }
  7686.         $twigData HumanResource::twigDataForWorkHourPolicy($em);
  7687.         return $this->render('ApplicationBundle:pages/human_resource/list:meeting_schedule_list_for_tab.html.twig', array(
  7688.             'page_title' => 'Meeting Schedule List',
  7689.             'date' => $date,
  7690.             'totalWeekends' => $totalWeekends,
  7691.             'totalCompanyWorkingDay' => $totalCompanyWorkingDay,
  7692. //            'attendanceData' => $attendanceData,
  7693. //            'employeeId' => $employeeId,
  7694.             'count' => $count,
  7695.             'totalAbsent' => $totalAbsent,
  7696.             'employeeDataDetail' => $employeeDataDetail,
  7697.             'holiday' => $DateRange,
  7698.             'holidayStartDate' => $holidayStartDate,
  7699.             'holidayEndDate' => $holidayEndDate,
  7700.             'holidayCount' => $dateCount,
  7701.             'totalOffDay' => $totalOffDay,
  7702.             'employeeIds' => $twigData['employeeIds'],
  7703.         ));
  7704.     }
  7705.     public function getEmployeeDataForDisburseAction($id)
  7706.     {
  7707.         $em $this->getDoctrine()->getManager();
  7708.         $employeeDetail $em->getRepository('ApplicationBundle:EmployeeDetails')->find($id);
  7709.         return new JsonResponse(
  7710.             array(
  7711.                 'success' => true,
  7712.                 'firstName' => $employeeDetail->getFirstName(),
  7713.             )
  7714.         );
  7715.     }
  7716.     public function BulkAttendanceAction(Request $request)
  7717.     {
  7718.         $em $this->getDoctrine()->getManager();
  7719.         $companyId $this->getLoggedUserCompanyId($request);
  7720.         if ($request->isMethod('POST')) {
  7721.             $attendance = [];
  7722.             foreach ($request->request->get('date') as $key => $val) {
  7723.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7724.                 $bulkAttendance=null;
  7725.                 if($request->request->get('attId')[$key]!=0)
  7726.                     $bulkAttendance $em->getRepository('ApplicationBundle:EmployeeAttendance')->findOneBy(array(
  7727.                         'id' => $request->request->get('attId')[$key],
  7728.                     ));
  7729.                 if(!$bulkAttendance)
  7730.                     $bulkAttendance = new EmployeeAttendance;
  7731.                 $theDate=new \DateTime($request->request->get('date')[$key]);
  7732.                 $bulkAttendance->setEmployeeId($request->request->get('employeeId'));
  7733.                 $bulkAttendance->setDate($theDate);
  7734.                 $bulkAttendance->setEntry(
  7735.                     ($request->request->get('startTimeTs')[$key] =='' ||
  7736.                         $request->request->get('startTimeTs')[$key]=='NaN' ||
  7737.                         $request->request->get('startTimeTs')[$key]==0) ?null:
  7738.                         new \DateTime('@'.$request->request->get('startTimeTs')[$key])
  7739.                 );
  7740.                 $bulkAttendance->setLastOut(($request->request->get('endTimeTs')[$key] =='' ||
  7741.                     $request->request->get('endTimeTs')[$key]=='NaN' ||
  7742.                     $request->request->get('endTimeTs')[$key]==0) ?null:
  7743.                     new \DateTime('@'.$request->request->get('endTimeTs')[$key]));
  7744.                 $bulkAttendance->setData(json_encode(
  7745.                     array(
  7746.                         "in"=>json_decode($request->request->get('entryDataIn')[$key],true),
  7747.                         "out"=>json_decode($request->request->get('entryDataOut')[$key],true)
  7748.                     )
  7749.                 ));
  7750. //                $bulkAttendance->setLastStartTime(new \DateTime($request->request->get('startDate')));
  7751. //                $bulkAttendance->setIsPresent(1);
  7752.                 $bulkAttendance->setLastStartTimeTs($request->request->get('startTimeTs')[$key]);
  7753.                 $bulkAttendance->setLastEndTimeTs($request->request->get('endTimeTs')[$key]);
  7754. //                $bulkAttendance->setTotalWorkHour($request->request->get('totalWorkHour')[$key]);
  7755.                 $em->persist($bulkAttendance);
  7756.                 $em->flush();
  7757.                 $bulkAttendanceLog $em->getRepository('ApplicationBundle:EmployeeAttendanceLog')->findOneBy(array(
  7758.                     'attendance_id' => $bulkAttendance->getId(),
  7759.                 ));
  7760.                 if(!$bulkAttendanceLog)
  7761.                     $bulkAttendanceLog = new EmployeeAttendanceLog;
  7762.                 $bulkAttendanceLog->setAttendanceId($bulkAttendance->getId());
  7763.                 $bulkAttendanceLog->setEmployeeId($request->request->get('employeeId'));
  7764.                 $bulkAttendanceLog->setLastStartTime(
  7765.                     ($request->request->get('startTimeTs')[$key] =='' ||
  7766.                         $request->request->get('startTimeTs')[$key]=='NaN' ||
  7767.                         $request->request->get('startTimeTs')[$key]==0) ?null:
  7768.                         new \DateTime('@'.$request->request->get('startTimeTs')[$key])
  7769.                 );
  7770.                 $bulkAttendanceLog->setLastEndTime(($request->request->get('endTimeTs')[$key] =='' ||
  7771.                     $request->request->get('endTimeTs')[$key]=='NaN' ||
  7772.                     $request->request->get('endTimeTs')[$key]==0) ?null:
  7773.                     new \DateTime('@'.$request->request->get('endTimeTs')[$key]));
  7774. //                $bulkAttendance->setLastStartTime(new \DateTime($request->request->get('startDate')));
  7775.                 $bulkAttendanceLog->setIsPresent(1);
  7776.                 $bulkAttendanceLog->setLastStartTimeTs($request->request->get('startTimeTs')[$key]);
  7777.                 $bulkAttendanceLog->setLastEndTimeTs($request->request->get('endTimeTs')[$key]);
  7778.                 $bulkAttendanceLog->setTotalWorkHour($request->request->get('totalWorkHour')[$key]);
  7779. //                $bulkAttendanceLog->setPositionArray(json_encode($request->request->get('locations')[$key]));
  7780.                 $em->persist($bulkAttendanceLog);
  7781.                 $em->flush();
  7782.             }
  7783.         }
  7784.         $startDate=$request->query->get('start_date','');
  7785.         $endDate=$request->query->get('end_date','');
  7786.         $employeeId=$request->query->get('employee_id',0);
  7787.         $existingData=[];
  7788.         $startDateTs=0;
  7789.         $endDateTs=0;
  7790.         $returnData=array(
  7791.             'page_title' => 'Bulk Attendance',
  7792.             'existingData' => $existingData,
  7793.             'startDateTs' =>  $startDateTs,
  7794.             'endDateTs' =>  $endDateTs,
  7795.         );
  7796.         if ($request->query->has('returnJson')) {
  7797.             if($startDate !='' && $endDate !='' && $employeeId!=0)
  7798.             {
  7799.                 $startDateDt=new \DateTime($startDate);
  7800.                 $endDateDt=new \DateTime($endDate);
  7801.                 $startDateTs=$startDateDt->format('U');
  7802.                 $endDateTs=$endDateDt->format('U');
  7803.                 $attendanceQuery $em->getRepository('ApplicationBundle:EmployeeAttendance')
  7804.                     ->createQueryBuilder('p')
  7805.                     ->where("p.employeeId = ".$employeeId)
  7806. //                ->andWhere("p.date => '" . ($startDateDt->format('Y-m-d'))."'")
  7807.                     ->andWhere("p.date <= :last" )
  7808.                     ->andWhere("p.date >= :start" )
  7809.                     ->setParameter('start'$startDateDt)
  7810.                     ->setParameter('last'$endDateDt);
  7811.                 $attendanceResults $attendanceQuery->getQuery()->getResult();
  7812.                 foreach($attendanceResults as $att)
  7813.                 {
  7814.                     $entryDateTime=null;
  7815.                     $outDateTime=null;
  7816.                     if($att->getEntry()) $entryDateTime=new \DateTime($att->getDate()->format('Y-m-d').' '.$att->getEntry()->format('H:i:00 +0000'));
  7817.                     if($att->getLastOut()) $outDateTime=new \DateTime($att->getDate()->format('Y-m-d').' '.$att->getLastOut()->format('H:i:00 +0000'));
  7818.                     $attData=array(
  7819.                         'id'=>$att->getId(),
  7820.                         'date_str'=>$att->getDate()->format('Y-m-d'),
  7821.                         'date_str_full'=>$att->getDate()->format('Y-m-d H:i:s'),
  7822.                         'in_time_full'=>$entryDateTime?$entryDateTime->format(DATE_RFC2822 ):'',
  7823.                         'date_ts'=>$att->getDate()->format('U'),
  7824.                         'in_time' => $entryDateTime?$entryDateTime->format('H:i:s'):'',
  7825.                         'in_time_ts' => $entryDateTime?$entryDateTime->format('U'):0,
  7826.                         'last_out_time' =>$outDateTime?$outDateTime->format('H:i:s'):'',
  7827.                         'last_out_time_ts' => $outDateTime?$outDateTime->format('U'):'',
  7828.                     );
  7829.                     $locations = [];
  7830.                     $locList = [];
  7831.                     $logHere $em->getRepository('ApplicationBundle:EmployeeAttendanceLog')->findOneBy(array(
  7832.                         'attendance_id' => $att->getId(),
  7833.                     ));
  7834.                     if ($logHere)
  7835.                         $locList json_decode($logHere->getPositionArray(), true);
  7836.                     if ($locList == null)
  7837.                         $locList = [];
  7838.                     $entry_data json_decode($att->getData(), true);
  7839.                     if ($entry_data == null$entry_data = [];
  7840.                     $lastLat 0;
  7841.                     $lastLng 0;
  7842.                     foreach ($locList as $lg) {
  7843.                         $dist 0;
  7844.                         if (isset($lg['lat'])) {
  7845.                             if ($lastLat == 0) {
  7846.                                 $lastLat $lg['lat'];
  7847.                                 $lastLng $lg['lng'];
  7848.                             }
  7849.                             $theta $lastLng $lg['lng'];
  7850.                             $dist sin(deg2rad($lastLat)) * sin(deg2rad($lg['lat'])) + cos(deg2rad($lastLat)) * cos(deg2rad($lg['lat'])) * cos(deg2rad($theta));
  7851.                             $dist acos($dist);
  7852.                             $dist rad2deg($dist);
  7853.                             $miles $dist 60 1.1515;
  7854.                             $dist $miles 1609.344;
  7855.                             if (abs($dist) > 1000) {
  7856.                                 $locations[] = array(
  7857.                                     'ts' => $lg['ts'],
  7858.                                     'lat' => $lg['lat'],
  7859.                                     'lng' => $lg['lng'],
  7860.                                 );
  7861.                                 $lastLat $lg['lat'];
  7862.                                 $lastLng $lg['lng'];
  7863.                             }
  7864.                         }
  7865.                     }
  7866.                     $attData['locations']=$locations;
  7867.                     $attData['entryData']=$entry_data;
  7868.                     $existingData[$att->getDate()->format('U')]=$attData;
  7869.                 }
  7870.             }
  7871.             $returnData=array(
  7872.                 'page_title' => 'Bulk Attendance',
  7873.                 'existingData' => $existingData,
  7874.                 'startDateTs' =>  $startDateTs,
  7875.                 'endDateTs' =>  $endDateTs,
  7876.             );
  7877.             return new JsonResponse($returnData);
  7878.         }
  7879.         else
  7880.             return $this->render('ApplicationBundle:pages/human_resource/attendance:bulk_attendance.html.twig'$returnData);
  7881.     }
  7882.     public function CreateAttendanceAmendmentAction(Request $request$id 0)
  7883.     {
  7884.         $em $this->getDoctrine()->getManager();
  7885.         $companyId $this->getLoggedUserCompanyId($request);
  7886.         $extDocData = [];
  7887.         if ($request->isMethod('POST') ) {
  7888.             $em $this->getDoctrine()->getManager();
  7889.             $entity_id array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment']; //change
  7890.             $dochash $request->request->get('docHash'); //change
  7891.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7892.             $approveRole $request->request->get('approvalRole');
  7893.             $approveHash $request->request->get('approvalHash');
  7894.             if ($dochash == '') {
  7895.                 $numberHash MiscActions::GetNumberHash($em'ATAM'$request->request->get('prefix_hash',$request->request->get('employeeId',0)), $request->request->get('assoc_hash',0), ''1);
  7896.                 $dochash 'ATAM' '/' $request->request->get('prefix_hash',$request->request->get('employeeId',0)) . '/' $request->request->get('assoc_hash',0) . '/' $numberHash;
  7897.             }
  7898.             else
  7899.                 $numberHash $request->request->get('number_hash');
  7900.             if (!DocValidation::isInsertable($em$entity_id$dochash,
  7901.                 $loginId$approveRole$approveHash$id)
  7902.             ) {
  7903.                 if ($request->request->has('returnJson')) {
  7904.                     return new JsonResponse(array(
  7905.                         'success' => false,
  7906.                         'documentHash' => 0,
  7907.                         'documentId' => 0,
  7908.                     ));
  7909.                 } else
  7910.                     $this->addFlash(
  7911.                         'error',
  7912.                         'Sorry Could not insert Data.'
  7913.                     );
  7914.             } else {
  7915.                 $funcname 'AttendanceAmendment';
  7916.                 $doc_id $id;
  7917.                 DeleteDocument::$funcname($em$doc_id0);
  7918.                 $attendanceAmendment = new AttendanceAmendment();
  7919.                 $attendanceAmendment->setDocumentHash($dochash);
  7920.                 $attendanceAmendment->setAttendanceAmendmentDate(new \DateTime($request->request->get('docDate','')));
  7921.                 $attendanceAmendment->setStartDate(new \DateTime($request->request->get('startDate','')));
  7922.                 $attendanceAmendment->setEndDate(new \DateTime($request->request->get('endDate','')));
  7923.                 $attendanceAmendment->setTypeHash('ATAM');
  7924.                 $attendanceAmendment->setPrefixHash($request->request->get('prefix_hash',0));
  7925.                 $attendanceAmendment->setAssocHash($request->request->get('assoc_hash',0));
  7926.                 $attendanceAmendment->setNumberHash($numberHash);
  7927.                 $attendanceAmendment->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  7928.                 $attendanceAmendment->setApproved(array_flip(GeneralConstant::$approvalStatus)['pending']);
  7929.                 $attendanceAmendment->setAutoCreated($request->request->get('fullApprove',0));
  7930.                 $attendanceAmendment->setEmployeeId($request->request->get('forcedEmployeeId',$request->request->get('employeeId',0)));
  7931. //                $attendanceAmendment->setAutocreated(0);
  7932.                 if ($request->request->has('dataArrayJson')) {
  7933.                     $attendanceAmendment->setData($request->request->get('dataArrayJson''[]'));
  7934.                 } else {
  7935.                     $arr = [
  7936.                     ];
  7937.                     //dump($arr);
  7938.                     foreach ($request->request->get('date',[]) as $key => $val) {
  7939.                         if($request->request->get('isChanged')[$key]==1) {
  7940.                             $dt = array(
  7941.                                 'enabled' => 1,
  7942.                                 'attId' => $request->request->get('attId')[$key],
  7943.                                 'note' => $request->request->get('note')[$key],
  7944.                                 'startTimeTs' => $request->request->get('startTimeTs')[$key],
  7945.                                 'endTimeTs' => $request->request->get('endTimeTs')[$key],
  7946.                                 'totalWorkHour' => $request->request->get('totalWorkHour')[$key],
  7947.                                 'entryDataIn' => json_decode($request->request->get('entryDataIn')[$key], true),
  7948.                                 'entryDataOut' => json_decode($request->request->get('entryDataOut')[$key], true),
  7949.                             );
  7950.                             $arr[$val] = $dt;
  7951.                         }
  7952.                     }
  7953.                     $attendanceAmendment->setData(json_encode($arr));
  7954.                 }
  7955.                 $em->persist($attendanceAmendment);
  7956.                 $em->flush();
  7957.                 $ID=$attendanceAmendment->getAttendanceAmendmentId();
  7958.                 //now add Approval info
  7959.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7960.                 $approveRole 1;  //created
  7961.                 $options = array(
  7962.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  7963.                     'notification_server' => $this->container->getParameter('notification_server'),
  7964.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  7965.                     'url' => $this->generateUrl(
  7966.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment']]
  7967.                         ['entity_view_route_path_name']
  7968.                     )
  7969.                 );
  7970.                 System::setApprovalInfo($this->getDoctrine()->getManager(), $options,
  7971.                     array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  7972.                     $ID,
  7973.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)    //journal voucher
  7974.                 );
  7975.                 if($request->request->get('fullApprove',0)==1)
  7976.                 {
  7977.                     DeleteDocument::AttendanceAmendment($em,$ID);
  7978.                 }
  7979.                 else {
  7980.                     System::createEditSignatureHash($this->getDoctrine()->getManager(), array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'], $ID,
  7981.                         $loginId,
  7982.                         $approveRole,
  7983.                         $request->request->get('approvalHash'));
  7984.                     $url $this->generateUrl(
  7985.                         'view_attendance_amendment'
  7986.                     );
  7987.                     if ($request->request->has('returnJson')) {
  7988.                         return new JsonResponse(array(
  7989.                             'success' => true,
  7990.                             'documentHash' => $dochash,
  7991.                             'documentId' => $ID,
  7992.                             'viewUrl' => $url "/" $ID,
  7993.                         ));
  7994.                     } else {
  7995.                         $this->addFlash(
  7996.                             'success',
  7997.                             'Attendance Amendment Note Added.'
  7998.                         );
  7999.                         return $this->redirect($url "/" $ID);
  8000.                     }
  8001.                 }
  8002.             }
  8003.         }
  8004.         if ($id == 0) {
  8005.         }
  8006.         else {
  8007.             $extDoc $em->getRepository('ApplicationBundle:AttendanceAmendment')->findOneBy(
  8008.                 array(
  8009.                     'salesOrderId' => $id///material
  8010.                 )
  8011.             );
  8012.             //now if its not editable, redirect to view
  8013.             if ($extDoc) {
  8014.                 if ($extDoc->getEditFlag() != 1) {
  8015.                     $url $this->generateUrl(
  8016.                         'view_attendance_amendment'
  8017.                     );
  8018.                     return $this->redirect($url "/" $id);
  8019.                 } else {
  8020.                     $extDocData $extDoc;
  8021.                 }
  8022.             } else {
  8023.             }
  8024.         }
  8025.         $startDate=$request->query->get('start_date','');
  8026.         $endDate=$request->query->get('end_date','');
  8027.         $employeeId=$request->query->get('employee_id',0);
  8028.         $existingData=[];
  8029.         $startDateTs=0;
  8030.         $endDateTs=0;
  8031.         $returnData=array(
  8032.             'page_title' => 'Attendance Amendment',
  8033.             'existingData' => $existingData,
  8034.             'startDateTs' =>  $startDateTs,
  8035.             'extDocData' =>  $extDocData,
  8036.             'endDateTs' =>  $endDateTs,
  8037.         );
  8038.         if ($request->query->has('returnJson')) {
  8039.             if($startDate !='' && $endDate !='' && $employeeId!=0)
  8040.             {
  8041.                 $startDateDt=new \DateTime($startDate);
  8042.                 $endDateDt=new \DateTime($endDate);
  8043.                 $startDateTs=$startDateDt->format('U');
  8044.                 $endDateTs=$endDateDt->format('U');
  8045.                 $attendanceQuery $em->getRepository('ApplicationBundle:EmployeeAttendance')
  8046.                     ->createQueryBuilder('p')
  8047.                     ->where("p.employeeId = ".$employeeId)
  8048. //                ->andWhere("p.date => '" . ($startDateDt->format('Y-m-d'))."'")
  8049.                     ->andWhere("p.date <= :last" )
  8050.                     ->andWhere("p.date >= :start" )
  8051.                     ->setParameter('start'$startDateDt)
  8052.                     ->setParameter('last'$endDateDt);
  8053.                 $attendanceResults $attendanceQuery->getQuery()->getResult();
  8054.                 foreach($attendanceResults as $att)
  8055.                 {
  8056.                     $entryDateTime=null;
  8057.                     $outDateTime=null;
  8058.                     if($att->getEntry()) $entryDateTime=new \DateTime($att->getDate()->format('Y-m-d').' '.$att->getEntry()->format('H:i:00 +0000'));
  8059.                     if($att->getLastOut()) $outDateTime=new \DateTime($att->getDate()->format('Y-m-d').' '.$att->getLastOut()->format('H:i:00 +0000'));
  8060.                     $attData=array(
  8061.                         'id'=>$att->getId(),
  8062.                         'date_str'=>$att->getDate()->format('Y-m-d'),
  8063.                         'date_str_full'=>$att->getDate()->format('Y-m-d H:i:s'),
  8064.                         'in_time_full'=>$entryDateTime?$entryDateTime->format(DATE_RFC2822 ):'',
  8065.                         'date_ts'=>$att->getDate()->format('U'),
  8066.                         'in_time' => $entryDateTime?$entryDateTime->format('H:i:s'):'',
  8067.                         'in_time_ts' => $entryDateTime?$entryDateTime->format('U'):0,
  8068.                         'last_out_time' =>$outDateTime?$outDateTime->format('H:i:s'):'',
  8069.                         'last_out_time_ts' => $outDateTime?$outDateTime->format('U'):'',
  8070.                     );
  8071.                     $locations = [];
  8072.                     $locList = [];
  8073.                     $logHere $em->getRepository('ApplicationBundle:EmployeeAttendanceLog')->findOneBy(array(
  8074.                         'attendance_id' => $att->getId(),
  8075.                     ));
  8076.                     if ($logHere)
  8077.                         $locList json_decode($logHere->getPositionArray(), true);
  8078.                     if ($locList == null)
  8079.                         $locList = [];
  8080.                     $entry_data json_decode($att->getData(), true);
  8081.                     if ($entry_data == null$entry_data = [];
  8082.                     $lastLat 0;
  8083.                     $lastLng 0;
  8084.                     foreach ($locList as $lg) {
  8085.                         $dist 0;
  8086.                         if (isset($lg['lat'])) {
  8087.                             if ($lastLat == 0) {
  8088.                                 $lastLat $lg['lat'];
  8089.                                 $lastLng $lg['lng'];
  8090.                             }
  8091.                             $theta $lastLng $lg['lng'];
  8092.                             $dist sin(deg2rad($lastLat)) * sin(deg2rad($lg['lat'])) + cos(deg2rad($lastLat)) * cos(deg2rad($lg['lat'])) * cos(deg2rad($theta));
  8093.                             $dist acos($dist);
  8094.                             $dist rad2deg($dist);
  8095.                             $miles $dist 60 1.1515;
  8096.                             $dist $miles 1609.344;
  8097.                             if (abs($dist) > 1000) {
  8098.                                 $locations[] = array(
  8099.                                     'ts' => $lg['ts'],
  8100.                                     'lat' => $lg['lat'],
  8101.                                     'lng' => $lg['lng'],
  8102.                                 );
  8103.                                 $lastLat $lg['lat'];
  8104.                                 $lastLng $lg['lng'];
  8105.                             }
  8106.                         }
  8107.                     }
  8108.                     $attData['locations']=$locations;
  8109.                     $attData['entryData']=$entry_data;
  8110.                     $existingData[$att->getDate()->format('U')]=$attData;
  8111.                 }
  8112.             }
  8113.             $returnData=array(
  8114.                 'page_title' => 'Attendance Amendment',
  8115.                 'existingData' => $existingData,
  8116.                 'startDateTs' =>  $startDateTs,
  8117.                 'extDocData' =>  $extDocData,
  8118.                 'endDateTs' =>  $endDateTs,
  8119.             );
  8120.             return new JsonResponse($returnData);
  8121.         }
  8122.         else
  8123.             return $this->render('ApplicationBundle:pages/human_resource/attendance:create_attendance_amendment.html.twig'$returnData);
  8124.     }
  8125.     public function AttendanceAmendmentListAction(Request $request)
  8126.     {
  8127.         $data = [];
  8128.         return $this->render('ApplicationBundle:pages/human_resource/list:attendance_amendment_list.html.twig',
  8129.             array(
  8130.                 'page_title' => 'Attendance Amendment List',
  8131.                 'data' => $data
  8132.             )
  8133.         );
  8134.     }
  8135.     public function ViewAttendanceAmendmentAction(Request $request$id)
  8136.     {
  8137.         $em $this->getDoctrine()->getManager();
  8138.         $dt HumanResource::GetAttendanceAmendmentDetails($em$id);
  8139.         return $this->render('ApplicationBundle:pages/human_resource/views:view_attendance_amendment.html.twig',
  8140.             array(
  8141.                 'page_title' => 'Attendance Amendment',
  8142.                 'data' => $dt,
  8143.                 'approval_data' => System::checkIfApprovalExists($emarray_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  8144.                     $id$request->getSession()->get(UserConstants::USER_LOGIN_ID)),
  8145.                 'document_log' => System::getDocumentLog($this->getDoctrine()->getManager(),
  8146.                     array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  8147.                     $id,
  8148.                     $dt['created_by'],
  8149.                     $dt['edited_by'])
  8150.             )
  8151.         );
  8152.     }
  8153.     public function PrintAttendanceAmendmentAction(Request $request$id)
  8154.     {
  8155.         $em $this->getDoctrine()->getManager();
  8156.         $dt HumanResource::GetAttendanceAmendmentDetails($em$id);
  8157.         $company_data Company::getCompanyData($em1);
  8158.         $document_mark = array(
  8159.             'original' => '/images/Original-Stamp-PNG-Picture.png',
  8160.             'copy' => ''
  8161.         );
  8162.         if ($request->query->has('pdf') && $this->get('knp_snappy.pdf')) {
  8163.             $html $this->renderView('@Inventory/pages/print/print_stock_received_note.html.twig',
  8164.                 array(
  8165.                     //full array here
  8166.                     'pdf' => true,
  8167.                     'page_title' => 'Stock Received Note',
  8168.                     'export' => 'pdf,print',
  8169.                     'data' => $dt,
  8170.                     'approval_data' => System::checkIfApprovalExists($emarray_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  8171.                         $id$request->getSession()->get(UserConstants::USER_LOGIN_ID)),
  8172.                     'document_log' => System::getDocumentLog($this->getDoctrine()->getManager(),
  8173.                         array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  8174.                         $id,
  8175.                         $dt['created_by'],
  8176.                         $dt['edited_by']),
  8177.                     'document_mark_image' => $document_mark['original'],
  8178.                     'company_name' => $company_data->getName(),
  8179.                     'company_data' => $company_data,
  8180.                     'company_address' => $company_data->getAddress(),
  8181.                     'company_image' => $company_data->getImage(),
  8182.                     'invoice_footer' => $company_data->getInvoiceFooter(),
  8183.                     'red' => 0
  8184.                 )
  8185.             );
  8186.             $pdf_response $this->get('knp_snappy.pdf')->getOutputFromHtml($html, array(
  8187. //                'orientation' => 'landscape',
  8188. //                'enable-javascript' => true,
  8189. //                'javascript-delay' => 1000,0
  8190.                 'no-stop-slow-scripts' => false,
  8191.                 'no-background' => false,
  8192.                 'lowquality' => false,
  8193.                 'encoding' => 'utf-8',
  8194. //            'images' => true,
  8195. //            'cookie' => array(),
  8196.                 'dpi' => 300,
  8197.                 'image-dpi' => 300,
  8198. //                'enable-external-links' => true,
  8199. //                'enable-internal-links' => true
  8200.             ));
  8201.             return new Response(
  8202.                 $pdf_response,
  8203.                 200,
  8204.                 array(
  8205.                     'Content-Type' => 'application/pdf',
  8206.                     'Content-Disposition' => 'attachment; filename="stock_received_note_' $id '.pdf"'
  8207.                 )
  8208.             );
  8209.         }
  8210.         return $this->render('ApplicationBundle:pages/human_resource/views:view_attendance_amendment.html.twig',
  8211.             array(
  8212.                 'page_title' => 'Attendance Amendment',
  8213.                 'data' => $dt,
  8214.                 'approval_data' => System::checkIfApprovalExists($emarray_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  8215.                     $id$request->getSession()->get(UserConstants::USER_LOGIN_ID)),
  8216.                 'document_log' => System::getDocumentLog($this->getDoctrine()->getManager(),
  8217.                     array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  8218.                     $id,
  8219.                     $dt['created_by'],
  8220.                     $dt['edited_by'])
  8221.             )
  8222.         );
  8223.     }
  8224.     public function createRoomAction(Request $request)
  8225.     {
  8226.         $em $this->getDoctrine()->getManager();
  8227.         $companyId $this->getLoggedUserCompanyId($request);
  8228.         if ($request->isMethod('POST')) {
  8229.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  8230.             $room = new Room;
  8231.             $room->setRoomNo($request->request->get('RoomNo'));
  8232.             //$room->setRoomName($request->request->get('RoomName'));
  8233.             $room->setBuilding($request->request->get('buildingName'));
  8234.             $room->setFloor($request->request->get('floor'));
  8235.             $room->setCapacity($request->request->get('capacity'));
  8236.             $room->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  8237.             $em->persist($room);
  8238.             $em->flush();
  8239.         }
  8240.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_room.html.twig', array(
  8241.             'page_title' => 'Add Room',
  8242.         ));
  8243.     }
  8244.     public function ExpenseTypeAction()
  8245.     {
  8246.         $expenseType HumanResourceConstant::$employeeExpenseAllowanceTypes;
  8247.         $expenseTypeArray = [];
  8248.         foreach ($expenseType as $k => $dt) {
  8249.             $dt['id'] = $k;
  8250.             $newSegs = [];
  8251.             foreach ($dt['segregations'] as $l => $s) {
  8252.                 $newOptions = [];
  8253.                 foreach ($s['options'] as $l2 => $s2) {
  8254.                     $s3 = array(
  8255.                         'value' => $l2,
  8256.                         'text' => $s2,
  8257.                     );
  8258.                     $newOptions[] = $s3;
  8259.                 }
  8260.                 $s['options'] = $newOptions;
  8261.                 if (is_string($s['defaultVal'])) $s['defaultVal'] = [$s['defaultVal']];
  8262.                 $newSegs[] = $s;
  8263.             }
  8264.             $dt['segregations'] = $newSegs;
  8265.             $expenseTypeArray[] = $dt;
  8266.         }
  8267.         return new JsonResponse(
  8268.             array(
  8269.                 'success' => true,
  8270.                 'expenseType' => $expenseType,
  8271.                 'expenseTypeArray' => $expenseTypeArray,
  8272.             )
  8273.         );
  8274.     }
  8275.     public function DemoDataTableAction()
  8276.     {
  8277.         return $this->render('ApplicationBundle:pages/human_resource/list:demo_data_table.html.twig', array(
  8278.             'page_title' => 'Add Room',
  8279.         ));
  8280.     }
  8281.     public function workEnrtyAction(Request $request)
  8282.     {
  8283. //        $em = $this->getDoctrine()->getManager();
  8284. //        $companyId = $this->getLoggedUserCompanyId($request);
  8285. //        if ($request->isMethod('POST')) {
  8286. //            $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  8287. //            $labour = new Labour();
  8288. //            $labour->setLabourName($request->request->get('labourName'));
  8289. //            $labour->setNidNumber($request->request->get('nidNumber'));
  8290. //            $em->persist($labour);
  8291. //            $em->flush();
  8292. //            $this->addFlash(
  8293. //                'success',
  8294. //                'Labour Added'
  8295. //            );
  8296. //        }
  8297.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:work_entry.html.twig', array(
  8298.             'page_title' => 'Work Entry',
  8299.         ));
  8300.     }
  8301.     public function ViewContractLetterAction(Request  $request$id)
  8302.     {
  8303.         $em $this->getDoctrine()->getManager();
  8304.         $employeeDetail $em->getRepository('ApplicationBundle:EmployeeDetails')->find($id);
  8305. //        $employeeData = [];
  8306. //        foreach ($employeeDetails as $employeeDetail) {
  8307. //            $data = array(
  8308. //                'firstName' => $employeeDetail->getNid(),
  8309. //
  8310. //
  8311. //
  8312. //            );
  8313. //
  8314. //
  8315. //            $employeeData[] = $data;
  8316. //        }
  8317.         return $this->render('ApplicationBundle:pages/human_resource/views:viewContractLetter.html.twig', array(
  8318.             'page_title' => 'Contract Letter',
  8319.             'employeeDetail' => $employeeDetail
  8320.         ));
  8321.     }
  8322.     public function getAttendanceReportForEmployeeAction(Request $request){
  8323.         $em $this->getDoctrine()->getManager();
  8324.         $session $request->getSession();
  8325.         $fromDateRow = (new \DateTime($request->get('start_date','')));
  8326. //        $fromDate = $fromDateRow->format("M d, Y");
  8327.         $toDateRow = (new \DateTime($request->get('end_date',$fromDateRow) . ' 23:59:59'));
  8328. //        $toDate = $toDateRow->format("M d, Y");
  8329. //        $startDate = "2025-02-13";
  8330. //        $endDate = "2025-02-16";
  8331.         $userId $session->get(UserConstants::USER_ID);
  8332.         $attendanceDetails $em->getRepository('ApplicationBundle:EmployeeAttendance')->createQueryBuilder('A')
  8333. //            ->select('A.createdAt','A.data')
  8334.             ->where('A.sysId = :userId')
  8335.             ->andWhere('A.createdAt >=  :startDate')
  8336.             ->andWhere('A.createdAt <=  :endDate')
  8337.             ->setParameter('userId'$userId)
  8338.             ->setParameter('startDate'$fromDateRow)
  8339.             ->setParameter('endDate'$toDateRow)
  8340.             ->getQuery()
  8341.             ->getResult();
  8342.         $attendance = [];
  8343.         $dt = [];
  8344.         foreach ($attendanceDetails as $data){
  8345.             $in_out_data=json_decode($data->getData(),true);
  8346.             $new_in_data=[];
  8347.             $elapsed_data=[];
  8348.             $new_out_data=[];
  8349.             if($in_out_data==null$in_out_data=[];
  8350.             if(isset($in_out_data['in']))
  8351.             {
  8352.                 foreach($in_out_data['in'] as $ind=>$g)
  8353.                 {
  8354.                     if(!isset($elapsed_data[$ind]))
  8355.                     {
  8356.                         $elapsed_data[$ind]=0;
  8357.                     }
  8358.                     $the_time=new \DateTime($data->getDate()->format('Y-m-d ').$g.' +0000');
  8359.                     $new_in_data[]=$the_time->format('U');
  8360.                 }
  8361.             }
  8362.             if(isset($in_out_data['out']))
  8363.             {
  8364.                 foreach($in_out_data['out'] as $ind=>$g)
  8365.                 {
  8366.                     if(!isset($elapsed_data[$ind]))
  8367.                     {
  8368.                         $elapsed_data[$ind]=0;
  8369.                     }
  8370.                     $the_time=new \DateTime($data->getDate()->format('Y-m-d ').$g.' +0000');
  8371.                     $new_out_data[]=$the_time->format('U');
  8372.                     if(isset($new_in_data[$ind]))
  8373.                     {
  8374.                         $elapsed_data[$ind]=$new_out_data[$ind]-$new_in_data[$ind];
  8375.                     }
  8376.                 }
  8377.             }
  8378.             $list = array(
  8379.                 'date' =>$data->getDate()->format('F d Y'),
  8380.                 'attendanceData' => [
  8381.                     'in'=> $new_in_data,
  8382.                     'out'=> $new_out_data,
  8383.                     'elapsedSec'=> $elapsed_data,
  8384.                 ]
  8385.             );
  8386.             $dt[] = $list;
  8387.         }
  8388.         $count count($attendance);
  8389. //        for ($i=0;$i < $count; $i++){
  8390. //            $dt[] = $attendance[$i]['date'];
  8391. //            $dt[] = ($attendance[$i]['attendanceData']);
  8392. //        }
  8393. ////        $decodeData = json_decode($dt, true);
  8394. //
  8395. //        $work_hours = [];
  8396. //
  8397. //        foreach ($dt as $index => $entry) {
  8398. //            $in_times = $entry['in'];
  8399. //            $out_times = $entry['out'];
  8400. //
  8401. //
  8402. //            $count = min(count($in_times), count($out_times));
  8403. //
  8404. //            for ($i = 0; $i < $count; $i++) {
  8405. //                $time_in = new DateTime($in_times[$i]);
  8406. //                $time_out = new DateTime($out_times[$i]);
  8407. //
  8408. //
  8409. //                $interval = $time_in->diff($time_out);
  8410. //                $total_hours = $interval->format('%h');
  8411. //                $total_minutes = $interval->format('%i');
  8412. //
  8413. //
  8414. //                $work_hours[] = [
  8415. ////                    "set" => $index + 1,
  8416. //                    "in" => $in_times[$i],
  8417. //                    "out" => $out_times[$i],
  8418. //                    "worked" => "$total_hours hours, $total_minutes minutes"
  8419. //                ];
  8420. //            }
  8421. //        }
  8422. //
  8423. ////        foreach ($work_hours as $work) {
  8424. ////           return new  JsonResponse(
  8425. ////               array(
  8426. ////                   'in'=>$work['in'],
  8427. ////                   'out' => $work['out'],
  8428. ////                   'hour' => $work['worked']
  8429. ////               )
  8430. ////           ) ;
  8431. //////            echo "Set {$work['set']} - IN: {$work['in']} - OUT: {$work['out']} => Worked: {$work['worked']}\n";
  8432. ////        }
  8433.         return new JsonResponse($dt);
  8434.     }
  8435.     public function getTotalWorkHourAction(Request $request)
  8436.     {
  8437.         $em $this->getDoctrine()->getManager();
  8438.         $currentDate = new \DateTime(date('y-m-d'));
  8439.         $session $request->getSession();
  8440.         $employeeId $session->get(UserConstants::USER_EMPLOYEE_ID);
  8441.         $planningItemId $session->get(UserConstants::USER_CURRENT_PLANNING_ITEM_ID);
  8442.         $attendanceData $em->getRepository('ApplicationBundle:EmployeeAttendance');
  8443.         $currentStatus HumanResource::getCurrentStatusFromDb($attendanceData$employeeId$currentDate);
  8444.         $planningItemDetails$em->getRepository(PlanningItem::class)->createQueryBuilder('p')
  8445.             ->select('p.itemAlias')
  8446.             ->where('p.id = :planningItemId')
  8447.             ->setParameter('planningItemId'$planningItemId)
  8448.             ->getQuery()
  8449.             ->getResult();
  8450.         // Check if "data" key exists and contains "in" times
  8451.         if (empty($currentStatus["data"]["in"])) {
  8452.             return new JsonResponse([
  8453. //                'message' => 'No attendance data available',
  8454.                 'currentStatus' => $currentStatus,
  8455.                 'totalWorkingTime' => '00:00:00'
  8456.             ]);
  8457.         }
  8458.         $totalSeconds 0;
  8459.         for ($i 0$i count($currentStatus["data"]["in"]); $i++) {
  8460.             $inTime $currentStatus["data"]["in"][$i];
  8461.             // Check if "out" time exists for this "in" time
  8462.             if (!isset($currentStatus["data"]["out"][$i])) {
  8463.                 continue; // Skip this entry if there is no out time
  8464.             }
  8465.             $outTime $currentStatus["data"]["out"][$i];
  8466.             // Calculate the difference
  8467.             $totalSeconds += ($outTime $inTime);
  8468.         }
  8469.         // If no valid time pairs were found, return 00:00:00
  8470. //        if ($totalSeconds == 0) {
  8471. //            return new JsonResponse([
  8472. //                'message' => 'No complete in-out records found',
  8473. //                'totalWorkingTime' => '00:00:00'
  8474. //            ]);
  8475. //        }
  8476.         // Convert total seconds to hours, minutes, and seconds
  8477.         $hours floor($totalSeconds 3600);
  8478.         $minutes floor(($totalSeconds 3600) / 60);
  8479.         $seconds $totalSeconds 60;
  8480.         $totalWorkingTime sprintf("%02d:%02d:%02d"$hours$minutes$seconds);
  8481.         return new JsonResponse([
  8482.             'taskName'=> isset($planningItemDetails[0]) ? $planningItemDetails[0]['itemAlias'] : '',
  8483.             'currentStatus' => $currentStatus,
  8484.             'totalWorkingTime' => $totalWorkingTime
  8485.         ]);
  8486.     }
  8487. //    public function getEmployeeDataAction(Request $request)
  8488. //    {
  8489. //        $em = $this->getDoctrine()->getManager();
  8490. //        $session = $request->getSession();
  8491. //        $employeeId = $session->get(UserConstants::USER_EMPLOYEE_ID);
  8492. //
  8493. //
  8494. //        $employeeDetails = $em->getRepository('ApplicationBundle:EmployeeDetails')->createQueryBuilder('E')
  8495. //            ->select('E.firstname', 'E.lastname', 'E.nid', 'E.tin','E.image', 'P.positionName')
  8496. //            ->addSelect('A.current_balance')
  8497. //            ->leftJoin('ApplicationBundle:SysDepartmentPosition', 'P', 'WITH', 'E.desg = P.positionId')
  8498. //            ->leftJoin('ApplicationBundle:Employee', 'EMP', 'WITH', 'EMP.employeeId = E.id')
  8499. //            ->leftJoin('ApplicationBundle:AccAccountsHead', 'A', 'WITH', 'EMP.accountsHeadId = A.accountsHeadId')
  8500. //            ->where('E.id = :employeeId')
  8501. //            ->setParameter('employeeId', $employeeId)
  8502. //            ->getQuery()
  8503. //            ->getResult();
  8504. //
  8505. //        return new JsonResponse($employeeDetails[0]);
  8506. //    }
  8507. //    public function getEmployeeDataAction(Request $request)
  8508. //    {
  8509. //        $em = $this->getDoctrine()->getManager();
  8510. //        $session = $request->getSession();
  8511. //        $employeeId = $session->get(UserConstants::USER_EMPLOYEE_ID);
  8512. //        $image = $session->get(UserConstants::USER_IMAGE);
  8513. //        $absoluteUrl = $this->generateUrl('dashboard', [], UrlGenerator::ABSOLUTE_URL);
  8514. //
  8515. //        $employeeDetails = $em->getRepository('ApplicationBundle:EmployeeDetails')->createQueryBuilder('E')
  8516. //            ->select('E.firstname', 'E.lastname', 'E.nid', 'E.tin', 'E.image', 'P.positionName')
  8517. //            ->addSelect('A.current_balance')
  8518. //            ->leftJoin('ApplicationBundle:SysDepartmentPosition', 'P', 'WITH', 'E.desg = P.positionId')
  8519. //            ->leftJoin('ApplicationBundle:Employee', 'EMP', 'WITH', 'EMP.employeeId = E.id')
  8520. //            ->leftJoin('ApplicationBundle:AccAccountsHead', 'A', 'WITH', 'EMP.accountsHeadId = A.accountsHeadId')
  8521. //            ->where('E.id = :employeeId')
  8522. //            ->setParameter('employeeId', $employeeId)
  8523. //            ->getQuery()
  8524. //            ->getResult();
  8525. //
  8526. //        // If image is null or empty, assign empty string
  8527. //        if (empty($employeeDetails['image'])) {
  8528. //            $employeeDetails['image'] =  $image;
  8529. //        }
  8530. //
  8531. //        return new JsonResponse($employeeDetails);
  8532. //    }
  8533.     public function getEmployeeDataAction(Request $request)
  8534.     {
  8535.         $em $this->getDoctrine()->getManager();
  8536.         $session $request->getSession();
  8537.         $employeeId $session->get(UserConstants::USER_EMPLOYEE_ID);
  8538.         $image $session->get(UserConstants::USER_IMAGE);
  8539.         $absoluteUrl $this->generateUrl('dashboard', [], UrlGenerator::ABSOLUTE_URL);
  8540.         $userImage $session->get(UserConstants::USER_IMAGE);
  8541.         $employeeDetails $em->getRepository('ApplicationBundle:EmployeeDetails')->createQueryBuilder('E')
  8542.             ->select('E.firstname''E.lastname''E.nid''E.tin''E.image''P.positionName')
  8543.             ->addSelect('A.current_balance')
  8544.             ->leftJoin('ApplicationBundle:SysDepartmentPosition''P''WITH''E.desg = P.positionId')
  8545.             ->leftJoin('ApplicationBundle:Employee''EMP''WITH''EMP.employeeId = E.id')
  8546.             ->leftJoin('ApplicationBundle:AccAccountsHead''A''WITH''EMP.accountsHeadId = A.accountsHeadId')
  8547.             ->where('E.id = :employeeId')
  8548.             ->setParameter('employeeId'$employeeId)
  8549.             ->getQuery()
  8550.             ->getOneOrNullResult(\Doctrine\ORM\Query::HYDRATE_ARRAY); // Only one employee expected
  8551.         if (!$employeeDetails) {
  8552.             return new JsonResponse(['error' => 'Employee not found'], 404);
  8553.         }
  8554.         // If image is missing, fallback to session image
  8555.         if (empty($employeeDetails['image'])) {
  8556.             $employeeDetails['image'] = $image;
  8557.         }
  8558.         // If image is still available, prefix it with absolute URL
  8559.         if (!empty($employeeDetails['image'])) {
  8560.             $employeeDetails['image_url'] = $absoluteUrl '' $userImage;
  8561.         } else {
  8562.             $employeeDetails['image_url'] = ''// no image
  8563.         }
  8564.         return new JsonResponse($employeeDetails);
  8565.     }
  8566.     public function updateEmployeeDataForAppAction(Request $request)
  8567.     {
  8568.         $em $this->getDoctrine()->getManager();
  8569.         $session $request->getSession();
  8570.         $employeeId $session->get(UserConstants::USER_EMPLOYEE_ID);
  8571.         $employeeDetails $em->getRepository('ApplicationBundle:EmployeeDetails')->find($employeeId);
  8572.         if ($request->isMethod('POST')) {
  8573.             $firstname $request->request->get('firstname');
  8574.             $lastname $request->request->get('lastname');
  8575.             $nid $request->request->get('nid');
  8576.             $tin $request->request->get('tin');
  8577.             if ($firstname !== null) {
  8578.                 $employeeDetails->setFirstName($firstname);
  8579.             }
  8580.             if ($lastname !== null) {
  8581.                 $employeeDetails->setLastName($lastname);
  8582.             }
  8583.             if ($nid !== null) {
  8584.                 $employeeDetails->setNid($nid);
  8585.             }
  8586.             if ($tin !== null) {
  8587.                 $employeeDetails->setTin($tin);
  8588.             }
  8589.             $em->flush();
  8590.             return new JsonResponse(['success' => true]);
  8591.         }
  8592.         return new JsonResponse(['success' => false'message' => 'Invalid request method']);
  8593.     }
  8594. //    public function updateEmployeeDataForAppAction(Request $request){
  8595. //        $em = $this->getDoctrine()->getManager();
  8596. //        $session = $request->getSession();
  8597. //        $employeeId = $session->get(UserConstants::USER_EMPLOYEE_ID);
  8598. //        $employeeDetails = $em->getRepository('ApplicationBundle:EmployeeDetails')->find($employeeId);
  8599. //
  8600. //        if ($request->isMethod('POST')) {
  8601. //            $employeeDetails->setFirstName(($request->request->get('firstname',$employeeDetails->getFirstName())));
  8602. //            $employeeDetails->setLastName($request->request->get('lastname',$employeeDetails->getLastName()));
  8603. //            $employeeDetails->setNid($request->request->get('nid'),$employeeDetails->getNid());
  8604. //            $employeeDetails->setTin($request->request->get('tin'),$employeeDetails->getTin());
  8605. //
  8606. //            $em->flush(); //
  8607. //
  8608. //            return new JsonResponse(['success' => true]);
  8609. //        }
  8610. //
  8611. //
  8612. //    }
  8613.     public function leaveApplicationListForAppAction(Request $request)
  8614.     {
  8615.         $em $this->getDoctrine()->getManager();
  8616.         $session $request->getSession();
  8617.         $employeeId $session->get(UserConstants::USER_EMPLOYEE_ID);
  8618.         $leaveType HumanResourceConstant::$LeaveType;
  8619.         $approvalStatus GeneralConstant::$approvalAction;
  8620.         $leaveCategory HumanResourceConstant::$leavCategory;
  8621.         // Get page and limit from request (default: page=1, limit=10)
  8622.         $page max((int)$request->query->get('page'1), 1);
  8623.         $limit max((int)$request->query->get('limit'10), 1);
  8624.         $offset = ($page 1) * $limit;
  8625.         // Get total count
  8626.         $total $em->getRepository('ApplicationBundle:EmployeeLeaveApplication')
  8627.             ->createQueryBuilder('L')
  8628.             ->select('COUNT(L.employeeLeaveApplicationId)')
  8629.             ->where('L.employeeId = :employeeId')
  8630.             ->setParameter('employeeId'$employeeId)
  8631.             ->getQuery()
  8632.             ->getSingleScalarResult();
  8633.         // Get paginated results
  8634.         $leaveRecords $em->getRepository('ApplicationBundle:EmployeeLeaveApplication')
  8635.             ->createQueryBuilder('L')
  8636.             ->select(
  8637.                 'L.documentHash',
  8638.                 'L.employeeLeaveApplicationId',
  8639.                 'L.leaveStartDate',
  8640.                 'L.leaveEndDate',
  8641.                 'L.leaveTypeId',
  8642.                 'L.leaveCategory',
  8643.                 'L.approved',
  8644.                 'L.createdAt',
  8645.                 'L.alternateDate',
  8646.                 'L.leaveComment',
  8647.                 'L.createdAt',
  8648.                 'L.approved_by'
  8649.             )
  8650.             ->where('L.employeeId = :employeeId')
  8651.             ->setParameter('employeeId'$employeeId)
  8652.             ->setFirstResult($offset)
  8653.             ->setMaxResults($limit)
  8654.             ->getQuery()
  8655.             ->getResult();
  8656.         // Format the results
  8657.         $formattedData = [];
  8658.         foreach ($leaveRecords as $leave) {
  8659.             $formattedData[] = [
  8660.                 'documentHash' => $leave['documentHash'],
  8661.                 'employeeLeaveApplicationId' => $leave['employeeLeaveApplicationId'],
  8662.                 'leaveStartDate' => $leave['leaveStartDate'] ? $leave['leaveStartDate']->getTimestamp() : 0,
  8663.                 'leaveEndDate' => $leave['leaveEndDate'] ? $leave['leaveEndDate']->getTimestamp() : 0,
  8664.                 'leaveType' => $leaveType[$leave['leaveTypeId']] ?? 'Unknown',
  8665.                 'leaveCategory' => $leaveCategory[$leave['leaveCategory']] ?? 'Unknown',
  8666.                 'approved' => $approvalStatus[$leave['approved']] ?? 'Unknown',
  8667.                 'createdAt' => $leave['createdAt'] ? $leave['createdAt']->getTimestamp() : 0,
  8668.                 'alternateDate' => $leave['alternateDate'] ? $leave['alternateDate']->getTimestamp() : 0,
  8669.                 'note' => $leave['leaveComment'] ? $leave['leaveComment'] : '',
  8670.                 'appliedOn' => $leave['createdAt'] ? $leave['createdAt']->getTimestamp() : 0,
  8671.                 'approvedBy' => $leave['approved_by'] ? $leave['approved_by'] : 'automatically approved',
  8672.             ];
  8673.         }
  8674.         // Final response with pagination meta
  8675.         return new JsonResponse([
  8676.             'CurrentPage' => $page,
  8677.             'limit' => $limit,
  8678.             'total' => (int)$total,
  8679.             'data' => $formattedData,
  8680.         ]);
  8681.     }
  8682.     public function PublicProfilePageAction(Request $request){
  8683.         return new JsonResponse(['success' => true]);
  8684.     }
  8685.     public function leaveSettingsAction(Request $request)
  8686.     {
  8687.         $em $this->getDoctrine()->getManager();
  8688.         if ($request->isMethod('POST')) {
  8689.             $ids $request->request->get('id', []);
  8690.             $leaveTitles $request->request->get('leaveTitle', []);
  8691.             $carryForwardTypes $request->request->get('carryForwardType', []);
  8692.             $carryForwardQtys $request->request->get('number', []);
  8693.             $totalLeaves $request->request->get('totalLeave', []);
  8694.             $resetFreqTypes $request->request->get('resetFrequencyType', []);
  8695.             $resetFreqQtys $request->request->get('resetFrequencyQty', []);
  8696.             $additionConditions $request->request->get('additionCondition', []);
  8697.             $additionDurations $request->request->get('additionConditionDuration', []);
  8698.             for ($i 0$i count($leaveTitles); $i++) {
  8699.                 if (
  8700.                     isset(
  8701.                         $carryForwardTypes[$i],
  8702.                         $carryForwardQtys[$i],
  8703.                         $totalLeaves[$i],
  8704.                         $resetFreqTypes[$i],
  8705.                         $resetFreqQtys[$i],
  8706.                         $additionConditions[$i],
  8707.                         $additionDurations[$i]
  8708.                     )
  8709.                 ) {
  8710.                     $id $ids[$i] ?? null;
  8711.                     $leaveSetting null;
  8712.                     if ($id) {
  8713.                         $leaveSetting $em->getRepository('ApplicationBundle:LeaveSettings')->find($id);
  8714.                     }
  8715.                     if (!$leaveSetting) {
  8716.                         $leaveSetting = new LeaveSettings();
  8717.                     }
  8718.                     $leaveSetting->setLeaveTitle($leaveTitles[$i]);
  8719.                     $leaveSetting->setCarryForwardType((int)$carryForwardTypes[$i]);
  8720.                     $leaveSetting->setCarryForwardQty((int)$carryForwardQtys[$i]);
  8721.                     $leaveSetting->setTotalLeave((int)$totalLeaves[$i]);
  8722.                     $leaveSetting->setResetFrequencyType((int)$resetFreqTypes[$i]);
  8723.                     $leaveSetting->setResetFrequencyQty((int)$resetFreqQtys[$i]);
  8724.                     $leaveSetting->setAdditionCondition((int)$additionConditions[$i]);
  8725.                     $leaveSetting->setAdditionConditionDuration((int)$additionDurations[$i]);
  8726.                     $em->persist($leaveSetting);
  8727.                 }
  8728.             }
  8729.             $em->flush();
  8730.             $this->addFlash('success''Leave settings saved successfully!');
  8731.             return $this->redirectToRoute('leave_settings_list');
  8732.         }
  8733.         $defaultLeaveType HumanResourceConstant::$defaultLeaveType;
  8734.         $savedLeaveSettings $em->getRepository('ApplicationBundle:LeaveSettings')->findAll();
  8735.         $useDefaultLeave count($savedLeaveSettings) === 0;
  8736.         $leaveSettings array_map(function ($setting) {
  8737.             return [
  8738.                 'id' => $setting->getId(),
  8739.                 'leaveTitle' => $setting->getLeaveTitle(),
  8740.                 'carryForwardType' => $setting->getCarryForwardType(),
  8741.                 'carryForwardQty' => $setting->getCarryForwardQty(),
  8742.                 'totalLeave' => $setting->getTotalLeave(),
  8743.                 'resetFrequencyType' => $setting->getResetFrequencyType(),
  8744.                 'resetFrequencyQty' => $setting->getResetFrequencyQty(),
  8745.                 'additionCondition' => $setting->getAdditionCondition(),
  8746.                 'additionConditionDuration' => $setting->getAdditionConditionDuration(),
  8747.             ];
  8748.         }, $savedLeaveSettings);
  8749.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:leave_settings.html.twig', [
  8750.             'page_title' => 'Leave Settings',
  8751.             'defaultLeaveType' => $defaultLeaveType,
  8752.             'leaveSettings' => $leaveSettings,
  8753.             'useDefaultLeave' => $useDefaultLeave,
  8754.         ]);
  8755.     }
  8756.     public function leavePolicyListAction()
  8757.     {
  8758.             return $this->render("ApplicationBundle:pages/human_resource/list:leaveApplicationSettingsList.html.twig", array(
  8759.                 'page_title' => 'Leave PolicyList',
  8760.             ));
  8761.     }
  8762. }