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.             } else if ($paymentGatewayFromInvoice == 'bkash') {
  819.                 $studentDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($gatewayInvoice->getBillToId());
  820.                 $baseUrl = ($sandBoxMode == 1) ? 'https://tokenized.sandbox.bka.sh/v1.2.0-beta' 'https://tokenized.pay.bka.sh/v1.2.0-beta';
  821.                 $username_value = ($sandBoxMode == 1) ? 'sandboxTokenizedUser02' '01891962953';
  822.                 $password_value = ($sandBoxMode == 1) ? 'sandboxTokenizedUser02@12345' ',a&kPV4deq&';
  823.                 $app_key_value = ($sandBoxMode == 1) ? '4f6o0cjiki2rfm34kfdadl1eqq' '2ueVHdwz5gH3nxx7xn8wotlztc';
  824.                 $app_secret_value = ($sandBoxMode == 1) ? '2is7hdktrekvrbljjh44ll3d9l1dtjo4pasmjvs5vl5qr3fug4b' '49Ay3h3wWJMBFD7WF5CassyLrtA1jt6ONhspqjqFx5hTjhqh5dHU';
  825.                 $request_data = array(
  826.                     'app_key' => $app_key_value,
  827.                     'app_secret' => $app_secret_value
  828.                 );
  829.                 $url curl_init($baseUrl '/tokenized/checkout/token/grant');
  830.                 $request_data_json json_encode($request_data);
  831.                 $header = array(
  832.                     'Content-Type:application/json',
  833.                     'username:' $username_value,
  834.                     'password:' $password_value
  835.                 );
  836.                 curl_setopt($urlCURLOPT_HTTPHEADER$header);
  837.                 curl_setopt($urlCURLOPT_CUSTOMREQUEST"POST");
  838.                 curl_setopt($urlCURLOPT_RETURNTRANSFERtrue);
  839.                 curl_setopt($urlCURLOPT_POSTFIELDS$request_data_json);
  840.                 curl_setopt($urlCURLOPT_FOLLOWLOCATION1);
  841.                 curl_setopt($urlCURLOPT_IPRESOLVECURL_IPRESOLVE_V4);
  842.                 $tokenData json_decode(curl_exec($url), true);
  843.                 curl_close($url);
  844.                 $id_token $tokenData['id_token'];
  845.                 $goToBkashPage 0;
  846.                 if ($tokenData['statusCode'] == '0000') {
  847.                     $auth $id_token;
  848.                     $requestbody = array(
  849.                         "mode" => "0011",
  850. //                        "payerReference" => "01723888888",
  851.                         "payerReference" => $invoiceDate->format('U'),
  852.                         "callbackURL" => $this->generateUrl(
  853.                             'bkash_callback', [], UrlGenerator::ABSOLUTE_URL
  854.                         ),
  855. //                    "merchantAssociationInfo" => "MI05MID54RF09123456One",
  856.                         "amount" => number_format($gatewayInvoice->getGateWayBillamount(), 2'.'''),
  857.                         "currency" => "BDT",
  858.                         "intent" => "sale",
  859.                         "merchantInvoiceNumber" => $invoiceId
  860.                     );
  861.                     $url curl_init($baseUrl '/tokenized/checkout/create');
  862.                     $requestbodyJson json_encode($requestbody);
  863.                     $header = array(
  864.                         'Content-Type:application/json',
  865.                         'Authorization:' $auth,
  866.                         'X-APP-Key:' $app_key_value
  867.                     );
  868.                     curl_setopt($urlCURLOPT_HTTPHEADER$header);
  869.                     curl_setopt($urlCURLOPT_CUSTOMREQUEST"POST");
  870.                     curl_setopt($urlCURLOPT_RETURNTRANSFERtrue);
  871.                     curl_setopt($urlCURLOPT_POSTFIELDS$requestbodyJson);
  872.                     curl_setopt($urlCURLOPT_FOLLOWLOCATION1);
  873.                     curl_setopt($urlCURLOPT_IPRESOLVECURL_IPRESOLVE_V4);
  874.                     $resultdata curl_exec($url);
  875. //                    curl_close($url);
  876. //                    echo $resultdata;
  877.                     $obj json_decode($resultdatatrue);
  878.                     $goToBkashPage 1;
  879.                     $justNow = new \DateTime();
  880.                     $justNow->modify('+' $tokenData['expires_in'] . ' second');
  881.                     $gatewayInvoice->setGatewayIdTokenExpireTs($justNow->format('U'));
  882.                     $gatewayInvoice->setGatewayIdToken($tokenData['id_token']);
  883.                     $gatewayInvoice->setGatewayPaymentId($obj['paymentID']);
  884.                     $gatewayInvoice->setGatewayIdRefreshToken($tokenData['refresh_token']);
  885.                     $em->flush();
  886.                     $output = [
  887. //                        'redirectUrl' => $obj['bkashURL'],
  888.                         'paymentGateway' => $paymentGatewayFromInvoice,
  889.                         'proceedToCheckout' => $goToBkashPage,
  890.                         'tokenData' => $tokenData,
  891.                         'obj' => $obj,
  892.                         'id_token' => $tokenData['id_token'],
  893.                         'data' => [
  894.                             'amount' => $gatewayInvoice->getGateWayBillamount(), //transaction amount
  895. //                            'payment_type' => 'VISA', //no need to change
  896.                             'currency' => strtoupper($currencyForGateway),  //currenct will be USD/BDT
  897.                             'tran_id' => $gatewayInvoice->getDocumentHash(), //transaction id must be unique from your end
  898.                             'cus_name' => $studentDetails->getFirstname() . ' ' $studentDetails->getLastName(),  //customer name
  899.                             'cus_email' => $studentDetails->getEmail(), //customer email address
  900.                             'cus_add1' => $studentDetails->getCurrAddr(),  //customer address
  901.                             'cus_add2' => $studentDetails->getCurrAddrCity(), //customer address
  902.                             'cus_city' => $studentDetails->getCurrAddrCity(),  //customer city
  903.                             'cus_state' => $studentDetails->getCurrAddrState(),  //state
  904.                             'cus_postcode' => $studentDetails->getCurrAddrZip(), //postcode or zipcode
  905.                             'cus_country' => 'Bangladesh',  //country
  906.                             'cus_phone' => ($studentDetails->getPhone() == null || $studentDetails->getPhone() == '') ? '+8801911706483' $studentDetails->getPhone(), //customer phone number
  907.                             'cus_fax' => '',  //fax
  908.                             'ship_name' => ''//ship name
  909.                             'ship_add1' => '',  //ship address
  910.                             'ship_add2' => '',
  911.                             'ship_city' => '',
  912.                             'ship_state' => '',
  913.                             'ship_postcode' => '',
  914.                             'ship_country' => 'Bangladesh',
  915.                             'desc' => $productDescStr,
  916.                         ]
  917.                     ];
  918.                     return new JsonResponse($output);
  919.                 }
  920. //                $fields = array(
  921. //
  922. //                    "mode" => "0011",
  923. //                    "payerReference" => "01723888888",
  924. //                    "callbackURL" => $this->generateUrl(
  925. //                        'payment_gateway_success',
  926. //                        ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  927. //                            'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
  928. //                        ))), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  929. //                    ),
  930. //                    "merchantAssociationInfo" => "MI05MID54RF09123456One",
  931. //                    "amount" => 1*number_format($gatewayInvoice->getGateWayBillamount(),2,'.',''),,
  932. //                    "currency" => "BDT",
  933. //                    "intent" => "sale",
  934. //                    "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)
  935. //
  936. //                );
  937. //                $fields = array(
  938. ////                    'store_id' => 'aamarpaytest', //store id will be aamarpay,  contact integration@aamarpay.com for test/live id
  939. //                    'store_id' => $sandBoxMode == 1 ? 'aamarpaytest' : 'buddybee', //store id will be aamarpay,  contact integration@aamarpay.com for test/live id
  940. //                    'amount' => 1*number_format($gatewayInvoice->getGateWayBillamount(),2,'.',''),, //transaction amount
  941. //                    'payment_type' => 'VISA', //no need to change
  942. //                    'currency' => strtoupper($currencyForGateway),  //currenct will be USD/BDT
  943. //                    '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
  944. //                    'cus_name' => $studentDetails->getFirstname() . ' ' . $studentDetails->getLastName(),  //customer name
  945. //                    'cus_email' => $studentDetails->getEmail(), //customer email address
  946. //                    'cus_add1' => $studentDetails->getCurrAddr(),  //customer address
  947. //                    'cus_add2' => $studentDetails->getCurrAddrCity(), //customer address
  948. //                    'cus_city' => $studentDetails->getCurrAddrCity(),  //customer city
  949. //                    'cus_state' => $studentDetails->getCurrAddrState(),  //state
  950. //                    'cus_postcode' => $studentDetails->getCurrAddrZip(), //postcode or zipcode
  951. //                    'cus_country' => 'Bangladesh',  //country
  952. //                    'cus_phone' => ($studentDetails->getPhone() == null || $studentDetails->getPhone() == '') ? ' + 8801911706483' : $studentDetails->getPhone(), //customer phone number
  953. //                    'cus_fax' => '',  //fax
  954. //                    'ship_name' => '', //ship name
  955. //                    'ship_add1' => '',  //ship address
  956. //                    'ship_add2' => '',
  957. //                    'ship_city' => '',
  958. //                    'ship_state' => '',
  959. //                    'ship_postcode' => '',
  960. //                    'ship_country' => 'Bangladesh',
  961. //                    'desc' => $productDescStr,
  962. //                    'success_url' => $this->generateUrl(
  963. //                        'payment_gateway_success',
  964. //                        ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  965. //                            'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
  966. //                        ))), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  967. //                    ),
  968. //                    'fail_url' => $this->generateUrl(
  969. //                        'payment_gateway_cancel', ['invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  970. //                    ),
  971. //                    'cancel_url' => $this->generateUrl(
  972. //                        'payment_gateway_cancel', ['invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  973. //                    ),
  974. ////                    'opt_a' => 'Reshad',  //optional paramter
  975. ////                    'opt_b' => 'Akil',
  976. ////                    'opt_c' => 'Liza',
  977. ////                    'opt_d' => 'Sohel',
  978. ////                    'signature_key' => 'dbb74894e82415a2f7ff0ec3a97e4183',  //sandbox
  979. //                    'signature_key' => $sandBoxMode == 1 ? 'dbb74894e82415a2f7ff0ec3a97e4183' : 'b7304a40e21fe15af3be9a948307f524'  //live
  980. //
  981. //                ); //signature key will provided aamarpay, contact integration@aamarpay.com for test/live signature key
  982. //
  983. //                $fields_string = http_build_query($fields);
  984. //
  985. //                $ch = curl_init();
  986. //                curl_setopt($ch, CURLOPT_VERBOSE, true);
  987. //                curl_setopt($ch, CURLOPT_URL, $url);
  988. //
  989. //                curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
  990. //                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  991. //                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  992. //                $url_forward = str_replace('"', '', stripslashes(curl_exec($ch)));
  993. //                curl_close($ch);
  994. //                $this->redirect_to_merchant($url_forward);
  995.             } else if ($paymentGatewayFromInvoice == 'onsite_pos' || $paymentGatewayFromInvoice == 'onsite_cash' || $paymentGatewayFromInvoice == 'onsite_bkash') {
  996.                 $meetingId 0;
  997.                 if ($gatewayInvoice->getId() != 0) {
  998.                     if ($gatewayInvoice->getDueAmount() <= 0) {
  999.                         $retData Buddybee::ProcessEntityInvoice($em_goc$gatewayInvoice->getId(), ['stage' => BuddybeeConstant::ENTITY_INVOICE_STAGE_COMPLETED], false,
  1000.                             $this->container->getParameter('notification_enabled'),
  1001.                             $this->container->getParameter('notification_server')
  1002.                         );
  1003.                         $meetingId $retData['meetingId'];
  1004.                     }
  1005.                     if (GeneralConstant::EMAIL_ENABLED == 1) {
  1006.                         $billerDetails = [];
  1007.                         $billToDetails = [];
  1008.                         $invoice $gatewayInvoice;
  1009.                         if ($invoice) {
  1010.                             $billerDetails $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
  1011.                                 ->findOneBy(
  1012.                                     array(
  1013.                                         'applicantId' => $invoice->getBillerId(),
  1014.                                     )
  1015.                                 );
  1016.                             $billToDetails $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
  1017.                                 ->findOneBy(
  1018.                                     array(
  1019.                                         'applicantId' => $invoice->getBillToId(),
  1020.                                     )
  1021.                                 );
  1022.                         }
  1023.                         $bodyTemplate 'ApplicationBundle:email/templates:buddybeeInvoiceEmail.html.twig';
  1024.                         $bodyData = array(
  1025.                             'page_title' => 'Invoice',
  1026. //            'studentDetails' => $student,
  1027.                             'billerDetails' => $billerDetails,
  1028.                             'billToDetails' => $billToDetails,
  1029.                             'invoice' => $invoice,
  1030.                             'currencyList' => BuddybeeConstant::$currency_List,
  1031.                             'currencyListByMarker' => BuddybeeConstant::$currency_List_by_marker,
  1032.                         );
  1033.                         $attachments = [];
  1034.                         $forwardToMailAddress $billToDetails->getOAuthEmail();
  1035. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  1036.                         $new_mail $this->get('mail_module');
  1037.                         $new_mail->sendMyMail(array(
  1038.                             'senderHash' => '_CUSTOM_',
  1039.                             //                        'senderHash'=>'_CUSTOM_',
  1040.                             'forwardToMailAddress' => $forwardToMailAddress,
  1041.                             '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 ',
  1042. //                        'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
  1043.                             'attachments' => $attachments,
  1044.                             'toAddress' => $forwardToMailAddress,
  1045.                             'fromAddress' => 'no-reply@buddybee.eu',
  1046.                             'userName' => 'no-reply@buddybee.eu',
  1047.                             'password' => 'Honeybee@0112',
  1048.                             'smtpServer' => 'smtp.hostinger.com',
  1049.                             'smtpPort' => 465,
  1050. //                            'emailBody' => $bodyHtml,
  1051.                             'mailTemplate' => $bodyTemplate,
  1052.                             'templateData' => $bodyData,
  1053.                             'embedCompanyImage' => 0,
  1054.                             'companyId' => 0,
  1055.                             'companyImagePath' => ''
  1056. //                        'embedCompanyImage' => 1,
  1057. //                        'companyId' => $companyId,
  1058. //                        'companyImagePath' => $company_data->getImage()
  1059.                         ));
  1060.                     }
  1061.                 }
  1062.                 MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  1063.                 if ($meetingId != 0) {
  1064.                     $url $this->generateUrl(
  1065.                         'consultancy_session'
  1066.                     );
  1067.                     $output = [
  1068.                         'proceedToCheckout' => 0,
  1069.                         'invoiceId' => $gatewayInvoice->getId(),
  1070.                         'meetingId' => $meetingId,
  1071.                         'redirectUrl' => $url '/' $meetingId
  1072.                     ];
  1073.                 } else {
  1074.                     $url $this->generateUrl(
  1075.                         'buddybee_dashboard'
  1076.                     );
  1077.                     $output = [
  1078.                         'proceedToCheckout' => 0,
  1079.                         'invoiceId' => $gatewayInvoice->getId(),
  1080.                         'meetingId' => $meetingId,
  1081.                         'redirectUrl' => $url
  1082.                     ];
  1083.                 }
  1084.                 return new JsonResponse($output);
  1085.             }
  1086.         }
  1087.         $output = [
  1088.             'clientSecret' => 0,
  1089.             'id' => 0,
  1090.             'proceedToCheckout' => 0
  1091.         ];
  1092.         return new JsonResponse($output);
  1093. //        return $this->render('ApplicationBundle:pages/stripe:checkout.html.twig', array(
  1094. //            'page_title' => 'Checkout',
  1095. ////            'stripe' => $stripe,
  1096. //            'stripe' => null,
  1097. ////            'PaymentIntent' => $paymentIntent,
  1098. //
  1099. ////            'consultantDetail' => $consultantDetail,
  1100. ////            'consultantDetails'=> $consultantDetails,
  1101. ////
  1102. ////            'meetingSession' => $meetingSession,
  1103. ////            'packageDetails' => json_decode($meetingSession->getPcakageDetails(),true),
  1104. ////            'packageName' => json_decode($meetingSession->getPackageName(),true),
  1105. ////            'pay' => $payableAmount,
  1106. ////            'balance' => $currStudentBal
  1107. //        ));
  1108.     }
  1109.     public function AddEmployeeAction(Request $data$id 0)
  1110.     {
  1111.         $em $this->getDoctrine()->getManager();
  1112.         $skills $em->getRepository(Skill::class)->findAll();
  1113.         $session $data->getSession();
  1114.         $ownOnly 0;
  1115. //        $session=$data->getSession()->get(UserConstants::USER_LOGIN_ID);
  1116.         $consultancyLevel HumanResourceConstant::$consultantLevel;
  1117.         $systemType $this->container->hasParameter('system_type') ? $this->container->getParameter('system_type') : '_ERP_';
  1118.         $banks $em->getRepository(BankList::class)->findAll();
  1119.         $bankListObj = [];
  1120.         foreach ($banks as $bank) {
  1121.             $bankListObj[$bank->getBankId()] = $bank->getName();
  1122.         }
  1123.         if ($id === "my") {
  1124. //            return $this->redirectToRoute('permission_denied_page');
  1125. //            return new JsonResponse([$id]);
  1126.             $id $session->get(UserConstants::USER_EMPLOYEE_ID);
  1127.             $ownOnly 1;
  1128.             if ($id == || $id == null) {
  1129.                 return $this->redirectToRoute('permission_denied_page');
  1130.             }
  1131.         }
  1132.         if ($id) {
  1133.             if ($data->isMethod('GET')) {
  1134.                 $Employee $this->getDoctrine()->getRepository(EmployeeDetails::class)->find($id);
  1135.                 if (!$Employee) {
  1136.                     $this->addFlash(
  1137.                         'error',
  1138.                         'Invalid User ID!'
  1139.                     );
  1140.                     return $this->redirectToRoute('add_employee');
  1141.                 } else {
  1142.                     $EmployeeRes HumanResource::TwigDataForAddEmployee($em$id);
  1143.                     $Employee $EmployeeRes['employee'];
  1144.                     $EmployeeMain $EmployeeRes['employeeMain'];
  1145.                     $sysUserId $EmployeeRes['sysId'];
  1146.                     $existingSysUser $sysUserId $em->getRepository('ApplicationBundle:SysUser')->find($sysUserId) : [];
  1147.                     $regionIdsArray json_decode($EmployeeMain->getRegionIds(), true) ?: [];
  1148.                     $regionLeaderFlagsArray json_decode($EmployeeMain->getRegionLeaderFlags(), true) ?: [];
  1149.                     $existingRegionAssociations = [];
  1150.                     if (!empty($regionIdsArray)) {
  1151.                         $regionRepo $this->getDoctrine()->getRepository('ApplicationBundle:Region');
  1152.                         $regions $regionRepo->findBy(['id' => $regionIdsArray]);
  1153.                         $regionMap = [];
  1154.                         foreach ($regions as $region) {
  1155.                             $regionMap[$region->getId()] = $region;
  1156.                         }
  1157.                         foreach ($regionIdsArray as $index => $regionId) {
  1158.                             if (!isset($regionMap[$regionId])) continue;
  1159.                             $region $regionMap[$regionId];
  1160.                             $existingRegionAssociations[] = [
  1161.                                 'regionLevelId' => $region->getRegionLevelId(),
  1162.                                 'regionId' => $region->getId(),
  1163.                                 'isLeader' => isset($regionLeaderFlagsArray[$index]) ? (int)$regionLeaderFlagsArray[$index] : 0
  1164.                             ];
  1165.                         }
  1166.                     }
  1167.                     $TwigData HumanResource::TwigDataForAddEmployee($em0);
  1168.                     return $this->render(
  1169.                         'ApplicationBundle:pages/human_resource/input_forms:add_employee.html.twig',
  1170.                         array(
  1171.                             'page_title' => 'Update Employee',
  1172.                             'ownOnly' => $ownOnly,
  1173.                             'branches' => $TwigData['branches'],
  1174.                             'bankListObj' => $bankListObj,
  1175.                             'heads' => Accounts::getLedgerHeadsWithParents($em),
  1176.                             'departments' => $TwigData['departments'],
  1177.                             'departmentPositions' => $TwigData['departmentPositions'],
  1178.                             'regions' => $TwigData['regions'],
  1179.                             'supervisors' => $TwigData['supervisors'],
  1180.                             'sysUsers' => $TwigData['sysUser'],
  1181.                             'EmploymentStatus' => $TwigData['EmploymentStatus'],
  1182.                             'sex' => $TwigData['sex'],
  1183.                             'BloodGroup' => $TwigData['BloodGroup'],
  1184.                             'days' => $TwigData['days'],
  1185.                             'employeeMain' => $EmployeeMain,
  1186.                             'employee' => $Employee,
  1187.                             'skills' => $skills,
  1188.                             'existingSysUser' => $existingSysUser,
  1189.                             'id' => $id,
  1190.                             'default_route' => $EmployeeRes['defaultRoute'],
  1191.                             'user_type' => $EmployeeRes['userType'],
  1192.                             'user_type_data' => HumanResourceConstant::$userType,
  1193.                             'AccountTypes' => $TwigData['AccountType'],
  1194.                             'weekends' => explode(','$Employee->getWeeklyHoliday()),
  1195.                             'consultancyLevel' => $consultancyLevel,
  1196.                             'module_data_array' => $TwigData['module_data_array'],
  1197.                             'HasUpdateMode' => true,
  1198.                             'brand_list' => Inventory::GetBrandList($em$this->getLoggedUserCompanyId($data)),
  1199.                             'branch_list' => Client::BranchList($this->getDoctrine()->getManager(), $this->getLoggedUserCompanyId($data)),
  1200.                             'region_data' => Client::RegionList($this->getDoctrine()->getManager(), $this->getLoggedUserCompanyId($data)),
  1201.                             'leaveData' => $EmployeeRes['leaveData'],
  1202.                             'positions' => $EmployeeRes['positions'],
  1203.                             'existing_region_associations' => $existingRegionAssociations
  1204.                         )
  1205.                     );
  1206.                 }
  1207.             } else {
  1208.                 $approveHash $data->request->get('approvalHash');
  1209.                 $loginId $data->getSession()->get(UserConstants::USER_LOGIN_ID);
  1210.                 $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  1211.                 $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Users/';
  1212.                 $image $data->files->get('img');
  1213.                 $profileImage $this->uploadImage($image$data);
  1214.                 $path '';
  1215.                 if ($isSignatureOk) {
  1216.                     $CompanyId $this->getLoggedUserCompanyId($data);
  1217.                     $isSuccess HumanResource::StoreDataForAddEmployee($em$data$id$CompanyId$profileImage);
  1218.                     if ($isSuccess) {
  1219.                         // $EmployeeDetails = $em->getRepository(EmployeeDetails::class)->find($id);
  1220.                         $Employee $em->getRepository(Employee::class)->find($id);
  1221.                         $EmployeeDetails $em->getRepository(EmployeeDetails::class)->findOneBy(
  1222.                             array(
  1223.                                 'id' => $id
  1224.                             )
  1225.                         );
  1226.                         $sysUserId $isSuccess->getUserId();
  1227.                         $message $this->get('user_module')->updateUser(
  1228.                             $sysUserId,
  1229.                             $data->request->get('firstname') . " " $data->request->get('lastname'),
  1230.                             $data->request->has('email') ? $data->request->get('email') : '_UNCHANGED_',
  1231.                             $data->request->has('username') ? $data->request->get('username') : '_UNCHANGED_',
  1232.                             $data->request->get('password'),
  1233.                             1,
  1234.                             $data->request->get('user_type''_UNCHANGED_'),
  1235.                             $data->request->get('supervisor'),
  1236.                             $data->request->get('default_route'),
  1237.                             $data->request->get('branch'),
  1238.                             $data->request->has('access_module') ? 0,
  1239.                             $data->getSession()->get(UserConstants::USER_LOGIN_ID),
  1240.                             $data->request->get('global_user_id'null),
  1241.                             $profileImage,
  1242.                             $upl_dir
  1243.                         );
  1244.                         if (isset($message[0]) && $message[0] === 'success') {
  1245.                             if ($systemType == '_CENTRAL_') {
  1246.                             } else {
  1247.                                 $em_goc $this->getDoctrine()->getManager('company_group');
  1248.                                 $em_goc->getConnection()->connect();
  1249.                                 $connected $em_goc->getConnection()->isConnected();
  1250.                                 $gocDataList = [];
  1251.                                 $gocDataListByAppId = [];
  1252.                                 $retDataDebug = array();
  1253.                                 $appIds $message[3]->getUserAppId();
  1254.                                 $userIds $message[3]->getUserId();
  1255.                                 if ($connected) {
  1256.                                     $findByQuery = array(
  1257.                                         'active' => 1
  1258.                                     );
  1259.                                     if ($appIds !== '_UNSET_')
  1260.                                         $findByQuery['appId'] = $appIds;
  1261.                                     $gocList $this->getDoctrine()->getManager('company_group')
  1262.                                         ->getRepository("CompanyGroupBundle:CompanyGroup")
  1263.                                         ->findBy($findByQuery);
  1264.                                     foreach ($gocList as $entry) {
  1265.                                         $d = array(
  1266.                                             'name' => $entry->getName(),
  1267.                                             'id' => $entry->getId(),
  1268.                                             'image' => $entry->getImage(),
  1269.                                             'companyGroupHash' => $entry->getCompanyGroupHash(),
  1270.                                             'dbName' => $entry->getDbName(),
  1271.                                             'dbUser' => $entry->getDbUser(),
  1272.                                             'dbPass' => $entry->getDbPass(),
  1273.                                             'dbHost' => $entry->getDbHost(),
  1274.                                             'appId' => $entry->getAppId(),
  1275.                                             'companyRemaining' => $entry->getCompanyRemaining(),
  1276.                                             'companyAllowed' => $entry->getCompanyAllowed(),
  1277.                                         );
  1278.                                         $gocDataList[$entry->getId()] = $d;
  1279.                                         $gocDataListByAppId[$entry->getAppId()] = $d;
  1280.                                     }
  1281.                                     $debugCount 0;
  1282.                                     foreach ($gocDataList as $gocId => $entry) {
  1283. //                    if($debugCount>0)
  1284. //                        continue;
  1285.                                         $skipSend 1;
  1286.                                         $connector $this->container->get('application_connector');
  1287.                                         $connector->resetConnection(
  1288.                                             'default',
  1289.                                             $gocDataList[$gocId]['dbName'],
  1290.                                             $gocDataList[$gocId]['dbUser'],
  1291.                                             $gocDataList[$gocId]['dbPass'],
  1292.                                             $gocDataList[$gocId]['dbHost'],
  1293.                                             $reset true);
  1294.                                         $em $this->getDoctrine()->getManager();
  1295.                                         if ($userIds !== '_UNSET_')
  1296.                                             $users $this->getDoctrine()
  1297.                                                 ->getRepository('ApplicationBundle:SysUser')
  1298.                                                 ->findBy(
  1299.                                                     array(
  1300.                                                         'userId' => $userIds
  1301.                                                     )
  1302.                                                 );
  1303.                                         else
  1304.                                             $users $this->getDoctrine()
  1305.                                                 ->getRepository('ApplicationBundle:SysUser')
  1306.                                                 ->findBy(
  1307.                                                     array()
  1308.                                                 );
  1309.                                         $output '';
  1310.                                         $userData = array();
  1311.                                         $userFiles = array();
  1312.                                         foreach ($users as $user) {
  1313.                                             $file $this->container->getParameter('kernel.root_dir') . '/../web/' $user->getImage(); //<-- Path could be relative
  1314. //                            $output=$file;
  1315.                                             if ($user->getImage() != '' && $user->getImage() != null && file_exists($file)) {
  1316. //                        $file = new \CURLFile($this->container->getParameter('kernel.root_dir') . '/../web/uploads/CompanyImage/' . $company->getImage()); //<-- Path could be relative
  1317.                                                 $mime mime_content_type($file);
  1318.                                                 $info pathinfo($file);
  1319.                                                 $name $info['basename'];
  1320.                                                 if (strpos($mime'image') !== false) {
  1321.                                                     $output = new \CURLFile($file$mime$name);
  1322.                                                 }
  1323.                                                 $skipSend 0;
  1324.                                                 $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = $output;
  1325.                                             } else {
  1326. //                                    unlink($this->container->getParameter('kernel.root_dir') . '/../web'. $centralUser->getImage());
  1327.                                                 $user->setImage(null);
  1328.                                                 $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = 'pika';
  1329.                                                 $em->flush();
  1330.                                             }
  1331.                                             $getters array_filter(get_class_methods($user), function ($method) {
  1332.                                                 return 'get' === substr($method03);
  1333.                                             });
  1334.                                             $userDataSingle = array(//                                'file'=>$output
  1335.                                             );
  1336.                                             foreach ($getters as $getter) {
  1337.                                                 if ($getter == 'getCreatedAt' || $getter == 'getUpdatedAt' || $getter == 'getImage')
  1338.                                                     continue;
  1339. //                                if(is_string($user->{$getter}())|| is_numeric($user->{$getter}()))
  1340. //                                {
  1341. //                                    $userDataSingle[$getter]= $user->{$getter}();
  1342. //                                }
  1343.                                                 if ($user->{$getter}() instanceof \DateTime) {
  1344.                                                     $ggtd $user->{$getter}();
  1345.                                                     $userDataSingle[$getter] = $ggtd->format('Y-m-d');
  1346.                                                 } else
  1347.                                                     $userDataSingle[$getter] = $user->{$getter}();
  1348.                                             }
  1349.                                             $employeeGetters = array(
  1350.                                                 'getFirstname''getLastname''getImage''getIsImgLegal''getNid''getDob''getSex''getReligion''getFather',
  1351.                                                 'getMother''getSpouse''getChild1''getChild2''getBlood''getPhone''getOfficailPhone''getCurrAddr',
  1352.                                                 'getCurrAddrLat''getCurrAddrLng''getPermAddr''getEmmContact''getUsername''getEmail''getPassword',
  1353.                                                 'getUserId''getJoiningDate''getEmpValidTill''getEmpStatus''getEmpType''getEmpCode''getEmpLabel''getTin',
  1354.                                                 'getTinValidTill''getMedIns''getMedInsValidTill''getDocs''getNocApproval''getInst1''getYr1''getDur1',
  1355.                                                 'getInst2''getYr2''getDur2''getInst3''getYr3''getDur3''getEinst1''getEyr1''getEdeg1''getEinst2',
  1356.                                                 'getEyr2''getEdeg2''getEinst3''getEyr3''getEdeg3''getBankAcc''getBankAccType''getBankAccValidFrom',
  1357.                                                 'getBankAccValidTo''getRoutingCode''getSwiftCode''getEar1''getEar2''getEar3''getEar4''getEar5''getEar6',
  1358.                                                 'getEart''getDed1''getDed2''getDed3''getDed4''getDedt''getPayable''getHandCash''getBankTransfer',
  1359.                                                 'getSecDep''getSecDepSpan''getSecDepRemMon''getSecDepRemAmount''getSlQty''getSlTkn''getSlFreq''getMlQty',
  1360.                                                 'getMlTkn''getMlFreq''getElQty''getElTkn''getElFreq''getClQty''getClTkn''getClFreq''getLevt',
  1361.                                                 'getWeeklyHoliday''getFiles''getSupervisor''getDept''getDesg''getBranch''getDivision''getCreatedAt',
  1362.                                                 'getUpdatedAt''getEmployeeLevel''getSkill''getProbationaryPeriod''getDocBookedFlag''getTimeStampOfForm',
  1363.                                                 'getIsConsultant''getConsultantLevel''getApplicationText''getCurrentEmployment''getEmergencyContactNumber',
  1364.                                                 'getPostalCode''getCountry''getEducationData''getWorkExperienceData''getCertificateData''getLanguagesData',
  1365.                                                 'getBeneficiaryName''getBankName''getBranchName''getClockedIn'
  1366.                                             );
  1367.                                             foreach ($employeeGetters as $getter) {
  1368.                                                 if (!method_exists($EmployeeDetails$getter)) continue;
  1369.                                                 try {
  1370.                                                     $value $EmployeeDetails->{$getter}();
  1371.                                                     if ($value instanceof \DateTime) {
  1372.                                                         $userDataSingle[$getter] = $value->format('Y-m-d');
  1373.                                                     } elseif (is_object($value)) {
  1374.                                                         continue; // skip non-scalar objects
  1375.                                                     } else {
  1376.                                                         $userDataSingle[$getter] = $value;
  1377.                                                     }
  1378.                                                 } catch (\Exception $e) {
  1379.                                                     continue;
  1380.                                                 }
  1381.                                             }
  1382. //                                            $userDataSingle['getNid']=$EmployeeDetails->getNid();
  1383. //                                            $userDataSingle['getDob']=$EmployeeDetails->getDob();
  1384. //                                            $userDataSingle['getSex']=$EmployeeDetails->getSex();
  1385. //                                            $userDataSingle['getCurrAddr'] = $EmployeeDetails->getCurrAddr();
  1386.                                             $userData[] = $userDataSingle;
  1387.                                         }
  1388.                                         $retDataDebug[$debugCount] = array(
  1389.                                             'skipSend' => $skipSend
  1390.                                         );
  1391. //                    if ($skipSend == 0)
  1392.                                         {
  1393.                                             $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/SyncUserToCentralUser';
  1394.                                             $userFiles['userData'] = json_encode($userData);
  1395.                                             $curl curl_init();
  1396.                                             curl_setopt_array($curl, array(
  1397.                                                 CURLOPT_RETURNTRANSFER => 1,
  1398.                                                 CURLOPT_POST => 1,
  1399.                                                 CURLOPT_URL => $urlToCall,
  1400.                                                 CURLOPT_CONNECTTIMEOUT => 10,
  1401.                                                 CURLOPT_SSL_VERIFYPEER => false,
  1402.                                                 CURLOPT_SSL_VERIFYHOST => false,
  1403. //                            CURLOPT_SAFE_UPLOAD => false,
  1404.                                                 CURLOPT_HTTPHEADER => array(//                                "Accept: multipart/form-data",
  1405.                                                 ),
  1406.                                                 //                        CURLOPT_USERAGENT => 'InnoPM',
  1407. //                            CURLOPT_POSTFIELDS => array(
  1408. //                                'userData'=>json_encode($userData),
  1409. //                                'userFiles'=>$userFiles
  1410. //                            ),
  1411.                                                 CURLOPT_POSTFIELDS => $userFiles
  1412.                                             ));
  1413.                                             $retData curl_exec($curl);
  1414.                                             $errData curl_error($curl);
  1415.                                             curl_close($curl);
  1416.                                             $retDataObj json_decode($retDatatrue);
  1417.                                             $retDataDebug[$debugCount] = $retDataObj;
  1418.                                             if (isset($retDataObj['globalIdsData']))
  1419.                                                 foreach ($retDataObj['globalIdsData'] as $app_id => $usrList) {
  1420.                                                     $connector $this->container->get('application_connector');
  1421.                                                     $connector->resetConnection(
  1422.                                                         'default',
  1423.                                                         $gocDataListByAppId[$app_id]['dbName'],
  1424.                                                         $gocDataListByAppId[$app_id]['dbUser'],
  1425.                                                         $gocDataListByAppId[$app_id]['dbPass'],
  1426.                                                         $gocDataListByAppId[$app_id]['dbHost'],
  1427.                                                         $reset true);
  1428.                                                     $em $this->getDoctrine()->getManager();
  1429.                                                     foreach ($usrList as $sys_id => $globaldata) {
  1430.                                                         $user $this->getDoctrine()
  1431.                                                             ->getRepository('ApplicationBundle:SysUser')
  1432.                                                             ->findOneBy(
  1433.                                                                 array(
  1434.                                                                     'userId' => $sys_id
  1435.                                                                 )
  1436.                                                             );
  1437.                                                         if ($user) {
  1438.                                                             $user->setGlobalId($globaldata['gid']);
  1439.                                                             $em->flush();
  1440.                                                         }
  1441.                                                     }
  1442.                                                 }
  1443.                                         }
  1444.                                         $debugCount++;
  1445.                                     }
  1446.                                 }
  1447. //                    return new JsonResponse($retDataDebug);
  1448.                             }
  1449.                         } else {
  1450.                             $errorMsg $message['message'] ?? 'Unknown error occurred.';
  1451.                             $this->addFlash('error'$errorMsg);
  1452.                             return $this->redirectToRoute('add_employee');
  1453.                         }
  1454.                         // $SysUserRepo = $em->getRepository(SysUser::class);
  1455.                         // $SysUser = $SysUserRepo->findOneBy(array(
  1456.                         //   'email' => $data->request->get('email')
  1457.                         // ));
  1458.                         // $isSuccess->setUserId($SysUser->getUserId());
  1459.                         // $em->persist($isSuccess);
  1460.                         // $em->flush();
  1461.                         // $companyData = $message[2];
  1462.                         // $emailmessage = (new \Swift_Message('Update to Entity'))
  1463.                         //   ->setFrom('registration@entity.innobd.com')
  1464.                         //   ->setTo($data->request->get('email'))
  1465.                         //   ->setBody(
  1466.                         //     $this->renderView(
  1467.                         //       'ApplicationBundle:email/user:registration.html.twig',
  1468.                         //       array(
  1469.                         //         'name' => $data->request->get('name'),
  1470.                         //         'companyData' => $companyData,
  1471.                         //         'userName' => $data->request->get('email'),
  1472.                         //         'password' => $data->request->get('password'),
  1473.                         //       )
  1474.                         //     ),
  1475.                         //     'text/html'
  1476.                         //   );
  1477.                         // $this->get('mailer')->send($emailmessage);
  1478.                         $userType $data->getSession()->get(UserConstants::USER_TYPE);
  1479.                         $redirctUrl $this->generateUrl('employee_list', [], UrlGenerator::ABSOLUTE_URL);
  1480.                         if ($userType == 1) {
  1481.                             $redirctUrl $this->generateUrl('employee_list', [], UrlGenerator::ABSOLUTE_URL);
  1482.                         } else {
  1483.                             $redirctUrl $this->generateUrl('edit_employee', [], UrlGenerator::ABSOLUTE_URL) . '/my';
  1484.                         }
  1485.                         return new JsonResponse(array(
  1486.                             'employeeId' => $Employee->getEmployeeId(),
  1487.                             'redirectToNew' => 0,
  1488.                             'success' => true,
  1489.                             'redirectUrl' => $redirctUrl,
  1490.                         ));
  1491.                     }
  1492.                 } else {
  1493.                     $this->addFlash(
  1494.                         'error',
  1495.                         'Invalid Approval Hash!'
  1496.                     );
  1497.                     return $this->redirectToRoute('add_employee');
  1498.                 }
  1499.             }
  1500.         } else {
  1501.             if ($data->isMethod('GET')) {
  1502.                 $TwigData HumanResource::TwigDataForAddEmployee($em0);
  1503.                 $existingRegionAssociations = [];
  1504.                 return $this->render(
  1505.                     'ApplicationBundle:pages/human_resource/input_forms:add_employee.html.twig',
  1506.                     array(
  1507.                         'page_title' => 'Add Employee',
  1508.                         'ownOnly' => $ownOnly,
  1509.                         'heads' => Accounts::getLedgerHeadsWithParents($em),
  1510.                         'bankListObj' => $bankListObj,
  1511.                         'branches' => $TwigData['branches'],
  1512.                         'departments' => $TwigData['departments'],
  1513.                         'departmentPositions' => $TwigData['departmentPositions'],
  1514.                         'regions' => $TwigData['regions'],
  1515.                         'supervisors' => $TwigData['supervisors'],
  1516.                         'sysUsers' => $TwigData['sysUser'],
  1517.                         'EmploymentStatus' => $TwigData['EmploymentStatus'],
  1518.                         'sex' => $TwigData['sex'],
  1519.                         'skills' => $skills,
  1520.                         'consultancyLevel' => $consultancyLevel,
  1521.                         'existingSysUser' => null,
  1522.                         'BloodGroup' => $TwigData['BloodGroup'],
  1523.                         'days' => $TwigData['days'],
  1524.                         'AccountTypes' => $TwigData['AccountType'],
  1525.                         'module_data_array' => $TwigData['module_data_array'],
  1526.                         'user_type_data' => HumanResourceConstant::$userType,
  1527.                         'HasUpdateMode' => false,
  1528.                         'brand_list' => Inventory::GetBrandList($em$this->getLoggedUserCompanyId($data)),
  1529.                         'employee' => [],
  1530.                         'positions' => $TwigData['positions'],
  1531.                         'existing_region_associations' => $existingRegionAssociations ?? [],
  1532.                         'branch_list' => Client::BranchList($this->getDoctrine()->getManager(), $this->getLoggedUserCompanyId($data)),
  1533.                         'region_data' => Client::RegionList($this->getDoctrine()->getManager(), $this->getLoggedUserCompanyId($data)),
  1534.                     )
  1535.                 );
  1536.             } else {
  1537.                 $approveHash $data->request->get('approvalHash');
  1538.                 $loginId $data->getSession()->get(UserConstants::USER_LOGIN_ID);
  1539.                 $CompanyId $this->getLoggedUserCompanyId($data);
  1540.                 $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  1541.                 $isSuccess HumanResource::StoreDataForAddEmployee($em$datafalse$CompanyId);
  1542.                 $Employee $isSuccess;
  1543.                 $EmployeeDetails $em->getRepository(EmployeeDetails::class)->findOneBy(
  1544.                     array(
  1545.                         'id' => $id
  1546.                     )
  1547.                 );
  1548.                 $isUserExist $em->getRepository(EmployeeDetails::class)
  1549.                     ->findOneBy(array('email' => $data->request->get('email')));
  1550.                 if ($isSignatureOk) {
  1551.                     if ($isUserExist) {
  1552.                         if ($isSuccess) {
  1553.                             $message $this->get('user_module')->addNewUser(
  1554.                                 $data->request->get('firstname') . " " $data->request->get('lastname'),
  1555.                                 $data->request->get('email'),
  1556.                                 $data->request->get('username'),
  1557.                                 $data->request->get('password'),
  1558.                                 $data->request->get('desg'),
  1559.                                 $this->getLoggedUserLoginId($data),
  1560.                                 $data->request->get('company'),
  1561.                                 $data->request->get('user_type'),
  1562.                                 $data->request->get('companyIdList'),
  1563.                                 $data->request->get('branch'),
  1564.                                 $data->request->get('supervisor'),
  1565.                                 $data->request->get('default_route'),
  1566.                                 $data->request->has('access_module') ? 0,
  1567.                                 "",
  1568.                                 $data->files->get('img'), ''00,
  1569.                                 ''''''0''0$data->request->get('global_user_id'null)
  1570.                             );
  1571.                             if ($message[0] == 'success') {
  1572.                                 $Employee->setUserId($message[3]->getUserId());
  1573.                                 $em->persist($Employee);
  1574.                                 if ($EmployeeDetails) {
  1575.                                     $EmployeeDetails->setUserId($message[3]->getUserId());
  1576.                                     $em->persist($EmployeeDetails);
  1577.                                 }
  1578.                                 $em->flush();
  1579.                                 if ($systemType == '_CENTRAL_') {
  1580.                                 } else {
  1581.                                     $em_goc $this->getDoctrine()->getManager('company_group');
  1582.                                     $em_goc->getConnection()->connect();
  1583.                                     $connected $em_goc->getConnection()->isConnected();
  1584.                                     $gocDataList = [];
  1585.                                     $gocDataListByAppId = [];
  1586.                                     $retDataDebug = array();
  1587.                                     $appIds $message[2]->getAppId();
  1588.                                     $userIds $message[3]->getUserId();
  1589.                                     if ($connected) {
  1590.                                         $findByQuery = array(
  1591.                                             'active' => 1
  1592.                                         );
  1593.                                         if ($appIds !== '_UNSET_')
  1594.                                             $findByQuery['appId'] = $appIds;
  1595.                                         $gocList $this->getDoctrine()->getManager('company_group')
  1596.                                             ->getRepository("CompanyGroupBundle:CompanyGroup")
  1597.                                             ->findBy($findByQuery);
  1598.                                         foreach ($gocList as $entry) {
  1599.                                             $d = array(
  1600.                                                 'name' => $entry->getName(),
  1601.                                                 'id' => $entry->getId(),
  1602.                                                 'image' => $entry->getImage(),
  1603.                                                 'companyGroupHash' => $entry->getCompanyGroupHash(),
  1604.                                                 'dbName' => $entry->getDbName(),
  1605.                                                 'dbUser' => $entry->getDbUser(),
  1606.                                                 'dbPass' => $entry->getDbPass(),
  1607.                                                 'dbHost' => $entry->getDbHost(),
  1608.                                                 'appId' => $entry->getAppId(),
  1609.                                                 'companyRemaining' => $entry->getCompanyRemaining(),
  1610.                                                 'companyAllowed' => $entry->getCompanyAllowed(),
  1611.                                             );
  1612.                                             $gocDataList[$entry->getId()] = $d;
  1613.                                             $gocDataListByAppId[$entry->getAppId()] = $d;
  1614.                                         }
  1615.                                         $debugCount 0;
  1616.                                         foreach ($gocDataList as $gocId => $entry) {
  1617.                                             $skipSend 1;
  1618.                                             $connector $this->container->get('application_connector');
  1619.                                             $connector->resetConnection(
  1620.                                                 'default',
  1621.                                                 $gocDataList[$gocId]['dbName'],
  1622.                                                 $gocDataList[$gocId]['dbUser'],
  1623.                                                 $gocDataList[$gocId]['dbPass'],
  1624.                                                 $gocDataList[$gocId]['dbHost'],
  1625.                                                 $reset true);
  1626.                                             $em $this->getDoctrine()->getManager();
  1627.                                             if ($userIds !== '_UNSET_')
  1628.                                                 $users $this->getDoctrine()
  1629.                                                     ->getRepository('ApplicationBundle:SysUser')
  1630.                                                     ->findBy(
  1631.                                                         array(
  1632.                                                             'userId' => $userIds
  1633.                                                         )
  1634.                                                     );
  1635.                                             else
  1636.                                                 $users $this->getDoctrine()
  1637.                                                     ->getRepository('ApplicationBundle:SysUser')
  1638.                                                     ->findBy(
  1639.                                                         array()
  1640.                                                     );
  1641.                                             $output '';
  1642.                                             $userData = array();
  1643.                                             $userFiles = array();
  1644.                                             foreach ($users as $user) {
  1645.                                                 $file $this->container->getParameter('kernel.root_dir') . '/../web/' $user->getImage();
  1646.                                                 if ($user->getImage() != '' && $user->getImage() != null && file_exists($file)) {
  1647.                                                     $mime mime_content_type($file);
  1648.                                                     $info pathinfo($file);
  1649.                                                     $name $info['basename'];
  1650.                                                     if (strpos($mime'image') !== false) {
  1651.                                                         $output = new \CURLFile($file$mime$name);
  1652.                                                     }
  1653.                                                     $skipSend 0;
  1654.                                                     $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = $output;
  1655.                                                 } else {
  1656.                                                     $user->setImage(null);
  1657.                                                     $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = 'pika';
  1658.                                                     $em->flush();
  1659.                                                 }
  1660.                                                 $getters array_filter(get_class_methods($user), function ($method) {
  1661.                                                     return 'get' === substr($method03);
  1662.                                                 });
  1663.                                                 $userDataSingle = array();
  1664.                                                 foreach ($getters as $getter) {
  1665.                                                     if ($getter == 'getCreatedAt' || $getter == 'getUpdatedAt' || $getter == 'getImage')
  1666.                                                         continue;
  1667. //                                if(is_string($user->{$getter}())|| is_numeric($user->{$getter}()))
  1668. //                                {
  1669. //                                    $userDataSingle[$getter]= $user->{$getter}();
  1670. //                                }
  1671.                                                     if ($user->{$getter}() instanceof \DateTime) {
  1672.                                                         $ggtd $user->{$getter}();
  1673.                                                         $userDataSingle[$getter] = $ggtd->format('Y-m-d');
  1674.                                                     } else
  1675.                                                         $userDataSingle[$getter] = $user->{$getter}();
  1676.                                                 }
  1677.                                                 $employeeGetters = array(
  1678.                                                     'getFirstname''getLastname''getImage''getIsImgLegal''getNid''getDob''getSex''getReligion''getFather',
  1679.                                                     'getMother''getSpouse''getChild1''getChild2''getBlood''getPhone''getOfficailPhone''getCurrAddr',
  1680.                                                     'getCurrAddrLat''getCurrAddrLng''getPermAddr''getEmmContact''getUsername''getEmail''getPassword',
  1681.                                                     'getUserId''getJoiningDate''getEmpValidTill''getEmpStatus''getEmpType''getEmpCode''getEmpLabel''getTin',
  1682.                                                     'getTinValidTill''getMedIns''getMedInsValidTill''getDocs''getNocApproval''getInst1''getYr1''getDur1',
  1683.                                                     'getInst2''getYr2''getDur2''getInst3''getYr3''getDur3''getEinst1''getEyr1''getEdeg1''getEinst2',
  1684.                                                     'getEyr2''getEdeg2''getEinst3''getEyr3''getEdeg3''getBankAcc''getBankAccType''getBankAccValidFrom',
  1685.                                                     'getBankAccValidTo''getRoutingCode''getSwiftCode''getEar1''getEar2''getEar3''getEar4''getEar5''getEar6',
  1686.                                                     'getEart''getDed1''getDed2''getDed3''getDed4''getDedt''getPayable''getHandCash''getBankTransfer',
  1687.                                                     'getSecDep''getSecDepSpan''getSecDepRemMon''getSecDepRemAmount''getSlQty''getSlTkn''getSlFreq''getMlQty',
  1688.                                                     'getMlTkn''getMlFreq''getElQty''getElTkn''getElFreq''getClQty''getClTkn''getClFreq''getLevt',
  1689.                                                     'getWeeklyHoliday''getFiles''getSupervisor''getDept''getDesg''getBranch''getDivision''getCreatedAt',
  1690.                                                     'getUpdatedAt''getEmployeeLevel''getSkill''getProbationaryPeriod''getDocBookedFlag''getTimeStampOfForm',
  1691.                                                     'getIsConsultant''getConsultantLevel''getApplicationText''getCurrentEmployment''getEmergencyContactNumber',
  1692.                                                     'getPostalCode''getCountry''getEducationData''getWorkExperienceData''getCertificateData''getLanguagesData',
  1693.                                                     'getBeneficiaryName''getBankName''getBranchName''getClockedIn'
  1694.                                                 );
  1695.                                                 foreach ($employeeGetters as $getter) {
  1696.                                                     if (!method_exists($EmployeeDetails$getter)) continue;
  1697.                                                     try {
  1698.                                                         $value $EmployeeDetails->{$getter}();
  1699.                                                         if ($value instanceof \DateTime) {
  1700.                                                             $userDataSingle[$getter] = $value->format('Y-m-d');
  1701.                                                         } elseif (is_object($value)) {
  1702.                                                             continue; // skip non-scalar objects
  1703.                                                         } else {
  1704.                                                             $userDataSingle[$getter] = $value;
  1705.                                                         }
  1706.                                                     } catch (\Exception $e) {
  1707.                                                         continue;
  1708.                                                     }
  1709.                                                 }
  1710. //                                                    $userDataSingle['getNid']=$Employee->getNid();
  1711. //                                                    $userDataSingle['getCurrAddr'] = $Employee->getCurrAddr();
  1712.                                                 $userData[] = $userDataSingle;
  1713.                                             }
  1714.                                             $retDataDebug[$debugCount] = array(
  1715.                                                 'skipSend' => $skipSend
  1716.                                             );
  1717.                                             {
  1718.                                                 $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/SyncUserToCentralUser';
  1719.                                                 $userFiles['userData'] = json_encode($userData);
  1720.                                                 $curl curl_init();
  1721.                                                 curl_setopt_array($curl, array(
  1722.                                                     CURLOPT_RETURNTRANSFER => 1,
  1723.                                                     CURLOPT_POST => 1,
  1724.                                                     CURLOPT_URL => $urlToCall,
  1725.                                                     CURLOPT_CONNECTTIMEOUT => 10,
  1726.                                                     CURLOPT_SSL_VERIFYPEER => false,
  1727.                                                     CURLOPT_SSL_VERIFYHOST => false,
  1728. //                            CURLOPT_SAFE_UPLOAD => false,
  1729.                                                     CURLOPT_HTTPHEADER => array(//                                "Accept: multipart/form-data",
  1730.                                                     ),
  1731.                                                     //                        CURLOPT_USERAGENT => 'InnoPM',
  1732. //                            CURLOPT_POSTFIELDS => array(
  1733. //                                'userData'=>json_encode($userData),
  1734. //                                'userFiles'=>$userFiles
  1735. //                            ),
  1736.                                                     CURLOPT_POSTFIELDS => $userFiles
  1737.                                                 ));
  1738.                                                 $retData curl_exec($curl);
  1739.                                                 $errData curl_error($curl);
  1740.                                                 curl_close($curl);
  1741.                                                 $response = [];
  1742.                                                 if ($errData) {
  1743.                                                     $response['status'] = 'error';
  1744.                                                     $response['message'] = 'cURL Error: ' $errData;
  1745.                                                 } else {
  1746.                                                     $retDataObj json_decode($retDatatrue);
  1747.                                                     if (!$retDataObj) {
  1748.                                                         $response['status'] = 'error';
  1749.                                                         $response['message'] = 'Invalid response from central server';
  1750.                                                         $response['raw_response'] = $retData;
  1751.                                                     } else {
  1752.                                                         $response['status'] = 'success';
  1753.                                                         $response['data'] = $retDataObj;
  1754.                                                     }
  1755.                                                 }
  1756. // Return JSON response
  1757. //                                                    return new JsonResponse($response);
  1758.                                                 $retDataDebug[$debugCount] = $retDataObj;
  1759.                                                 if (isset($retDataObj['globalIdsData']))
  1760.                                                     foreach ($retDataObj['globalIdsData'] as $app_id => $usrList) {
  1761.                                                         $connector $this->container->get('application_connector');
  1762.                                                         $connector->resetConnection(
  1763.                                                             'default',
  1764.                                                             $gocDataListByAppId[$app_id]['dbName'],
  1765.                                                             $gocDataListByAppId[$app_id]['dbUser'],
  1766.                                                             $gocDataListByAppId[$app_id]['dbPass'],
  1767.                                                             $gocDataListByAppId[$app_id]['dbHost'],
  1768.                                                             $reset true);
  1769.                                                         $em $this->getDoctrine()->getManager();
  1770.                                                         foreach ($usrList as $sys_id => $globaldata) {
  1771.                                                             $user $this->getDoctrine()
  1772.                                                                 ->getRepository('ApplicationBundle:SysUser')
  1773.                                                                 ->findOneBy(
  1774.                                                                     array(
  1775.                                                                         'userId' => $sys_id
  1776.                                                                     )
  1777.                                                                 );
  1778.                                                             if ($user) {
  1779.                                                                 $user->setGlobalId($globaldata['gid']);
  1780.                                                                 $em->persist($user);
  1781.                                                                 $em->flush();
  1782.                                                             }
  1783.                                                         }
  1784.                                                     }
  1785.                                             }
  1786.                                             $debugCount++;
  1787.                                         }
  1788.                                     }
  1789. //                    return new JsonResponse($retDataDebug);
  1790.                                 }
  1791.                             } else if ($message[0] == 'error') {
  1792.                                 $this->addFlash(
  1793.                                     'error',
  1794.                                     'Invalid Approval Hash!'
  1795.                                 );
  1796.                             }
  1797. //                                    if($message[0]=='success'){
  1798. //                                        $SysUserRepo = $em->getRepository('ApplicationBundle:SysUser');
  1799. //                                        $SysUser = $SysUserRepo->findOneBy([
  1800. //                                            'email' => $data->request->get('email')
  1801. //                                        ]);
  1802. //
  1803. //                                        if ($SysUser === null) {
  1804. //                                            throw new \Exception("User with email " . $data->request->get('email') . " not found.");
  1805. //                                        }
  1806. //
  1807. //                                        $isSuccess->setUserId($SysUser->getUserId());
  1808. //                                        $em->persist($isSuccess);
  1809. //                                        $em->flush();
  1810. //                                    }
  1811.                             $companyData $message[2];
  1812.                             if ($message[0] == 'success' && GeneralConstant::EMAIL_ENABLED == 1) {
  1813.                                 $bodyHtml '';
  1814.                                 $bodyTemplate 'ApplicationBundle:email/user:registration.html.twig';
  1815.                                 $bodyData = array(
  1816.                                     'name' => $data->request->get('name'),
  1817.                                     'companyData' => $companyData,
  1818.                                     'userName' => $data->request->get('username'),
  1819.                                     'password' => $data->request->get('password'),
  1820.                                 );
  1821.                                 $attachments = [];
  1822.                                 $new_mail $this->get('mail_module');
  1823.                                 $new_mail->sendMyMail(array(
  1824.                                     'senderHash' => '_CUSTOM_',
  1825.                                     //                        'senderHash'=>'_CUSTOM_',
  1826.                                     'forwardToMailAddress' => $data->request->get('email'),
  1827.                                     'fromAddress' => 'no-reply@ourhoneybee.eu',
  1828.                                     'userName' => 'no-reply@ourhoneybee.eu',
  1829.                                     'password' => 'Honeybee@0112',
  1830.                                     'smtpServer' => 'smtp.hostinger.com',
  1831.                                     'smtpPort' => 465,
  1832.                                     'subject' => 'User Registration on HoneyBee Ecosystem under Entity ' $companyData->getName(),
  1833.                                     'fileName' => '',
  1834.                                     'attachments' => $attachments,
  1835.                                     'toAddress' => $data->request->get('email'),
  1836.                                     'mailTemplate' => $bodyTemplate,
  1837.                                     'templateData' => $bodyData,
  1838.                                     'embedCompanyImage' => 1,
  1839.                                     'companyId' => $data->request->get('company'),
  1840.                                     'companyImagePath' => $companyData->getImage()
  1841.                                 ));
  1842.                             }
  1843.                         }
  1844.                         $this->addFlash(
  1845.                             'success',
  1846.                             'New Employee Successfully Added!'
  1847.                         );
  1848.                         $userType $data->getSession()->get(UserConstants::USER_TYPE);
  1849.                         $redirctUrl $this->generateUrl('employee_list', [], UrlGenerator::ABSOLUTE_URL);
  1850.                         if ($userType == 1) {
  1851.                             $redirctUrl $this->generateUrl('employee_list', [], UrlGenerator::ABSOLUTE_URL);
  1852.                         } else {
  1853.                             $redirctUrl $this->generateUrl('add_employee', [], UrlGenerator::ABSOLUTE_URL);
  1854.                         }
  1855.                         return new JsonResponse(array(
  1856.                             'employeeId' => $Employee->getEmployeeId(),
  1857.                             'redirectToNew' => 1,
  1858.                             'success' => true,
  1859.                             'redirectUrl' => $redirctUrl,
  1860.                         ));
  1861. //                        return $this->redirectToRoute('add_employee');
  1862.                     } else {
  1863. //                        $requiredFields = [
  1864. //                            'email', 'username', 'password', 'firstname', 'lastname', 'nid', 'dob',
  1865. //                            'sex', 'blood', 'phone', 'perm_addr', 'dept', 'desg', 'branch',
  1866. //                            'emp_type', 'tin'
  1867. //                        ];
  1868. //
  1869. //                        $missingFields = [];
  1870. //
  1871. //                        foreach ($requiredFields as $field) {
  1872. //                            if (!$data->request->get($field)) {
  1873. //                                $missingFields[] = $field;
  1874. //                            }
  1875. //                        }
  1876. //                        if (!empty($missingFields)) {
  1877. //                            $this->addFlash('error', 'Missing fields: ' . implode(', ', $missingFields));
  1878. //                            return $this->redirectToRoute('add_employee');
  1879. //                        }
  1880. //                        $password = $data->request->get('password');
  1881. //                        $passwordPattern = '/^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[\W_]).{8,}$/';
  1882. //                        if (!preg_match($passwordPattern, $password)) {
  1883. //                            $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));
  1884. //                            return $this->redirectToRoute('add_employee');
  1885. //                        }
  1886.                         $CompanyId $this->getLoggedUserCompanyId($data);
  1887.                         $isSuccess HumanResource::StoreDataForAddEmployee($em$datafalse$CompanyId);
  1888.                         if ($isSuccess) {
  1889.                             if ($data->request->has('send_appointment')) {
  1890.                                 $email $data->request->get('email');
  1891.                                 $bodyHtml '';
  1892.                                 $bodyTemplate 'ApplicationBundle:email/general:appointment_letter_test.html.twig';
  1893.                                 $bodyData = [];
  1894.                                 $attachments = [];
  1895.                                 $forwardToMailAddress $email;
  1896.                                 $new_mail $this->get('mail_module');
  1897.                                 $new_mail->sendMyMail(array(
  1898.                                     'senderHash' => '_CUSTOM_',
  1899.                                     'forwardToMailAddress' => $forwardToMailAddress,
  1900.                                     'subject' => 'Appointment Letter',
  1901.                                     'attachments' => $attachments,
  1902.                                     'toAddress' => $forwardToMailAddress,
  1903.                                     'fromAddress' => 'no-reply@ourhoneybee.eu',
  1904.                                     'userName' => 'no-reply@ourhoneybee.eu',
  1905.                                     'password' => 'Honeybee@0112',
  1906.                                     'smtpServer' => 'smtp.hostinger.com',
  1907.                                     'smtpPort' => 465,
  1908.                                     'emailBody' => $bodyHtml,
  1909.                                     'mailTemplate' => $bodyTemplate,
  1910.                                     'templateData' => $bodyData,
  1911.                                 ));
  1912.                             }
  1913.                             // Mailer function
  1914.                             if ($data->get("send_mail") && empty($data->get('sys_user'))) {
  1915.                                 $message $this->get('user_module')->addNewUser(
  1916.                                     $data->request->get('firstname') . " " $data->request->get('lastname'),
  1917.                                     $data->request->get('email'),
  1918.                                     $data->request->get('username'),
  1919.                                     $data->request->get('password'),
  1920.                                     $data->request->get('desg'),
  1921.                                     $this->getLoggedUserLoginId($data),
  1922.                                     $data->request->get('company'),
  1923.                                     $data->request->get('user_type'),
  1924.                                     $data->request->get('companyIdList'),
  1925.                                     $data->request->get('branch'),
  1926.                                     $data->request->get('supervisor'),
  1927.                                     $data->request->get('default_route'),
  1928.                                     $data->request->has('access_module') ? 0
  1929.                                 );
  1930.                                 if ($message[0] == 'success') {
  1931.                                     if ($systemType == '_CENTRAL_') {
  1932.                                     } else {
  1933.                                         $em_goc $this->getDoctrine()->getManager('company_group');
  1934.                                         $em_goc->getConnection()->connect();
  1935.                                         $connected $em_goc->getConnection()->isConnected();
  1936.                                         $gocDataList = [];
  1937.                                         $gocDataListByAppId = [];
  1938.                                         $retDataDebug = array();
  1939.                                         $appIds $message[2]->getAppId();
  1940.                                         $userIds $message[3]->getUserId();
  1941.                                         if ($connected) {
  1942.                                             $findByQuery = array(
  1943.                                                 'active' => 1
  1944.                                             );
  1945.                                             if ($appIds !== '_UNSET_')
  1946.                                                 $findByQuery['appId'] = $appIds;
  1947.                                             $gocList $this->getDoctrine()->getManager('company_group')
  1948.                                                 ->getRepository("CompanyGroupBundle:CompanyGroup")
  1949.                                                 ->findBy($findByQuery);
  1950.                                             foreach ($gocList as $entry) {
  1951.                                                 $d = array(
  1952.                                                     'name' => $entry->getName(),
  1953.                                                     'id' => $entry->getId(),
  1954.                                                     'image' => $entry->getImage(),
  1955.                                                     'companyGroupHash' => $entry->getCompanyGroupHash(),
  1956.                                                     'dbName' => $entry->getDbName(),
  1957.                                                     'dbUser' => $entry->getDbUser(),
  1958.                                                     'dbPass' => $entry->getDbPass(),
  1959.                                                     'dbHost' => $entry->getDbHost(),
  1960.                                                     'appId' => $entry->getAppId(),
  1961.                                                     'companyRemaining' => $entry->getCompanyRemaining(),
  1962.                                                     'companyAllowed' => $entry->getCompanyAllowed(),
  1963.                                                 );
  1964.                                                 $gocDataList[$entry->getId()] = $d;
  1965.                                                 $gocDataListByAppId[$entry->getAppId()] = $d;
  1966.                                             }
  1967.                                             $debugCount 0;
  1968.                                             foreach ($gocDataList as $gocId => $entry) {
  1969.                                                 $skipSend 1;
  1970.                                                 $connector $this->container->get('application_connector');
  1971.                                                 $connector->resetConnection(
  1972.                                                     'default',
  1973.                                                     $gocDataList[$gocId]['dbName'],
  1974.                                                     $gocDataList[$gocId]['dbUser'],
  1975.                                                     $gocDataList[$gocId]['dbPass'],
  1976.                                                     $gocDataList[$gocId]['dbHost'],
  1977.                                                     $reset true);
  1978.                                                 $em $this->getDoctrine()->getManager();
  1979.                                                 if ($userIds !== '_UNSET_')
  1980.                                                     $users $this->getDoctrine()
  1981.                                                         ->getRepository('ApplicationBundle:SysUser')
  1982.                                                         ->findBy(
  1983.                                                             array(
  1984.                                                                 'userId' => $userIds
  1985.                                                             )
  1986.                                                         );
  1987.                                                 else
  1988.                                                     $users $this->getDoctrine()
  1989.                                                         ->getRepository('ApplicationBundle:SysUser')
  1990.                                                         ->findBy(
  1991.                                                             array()
  1992.                                                         );
  1993.                                                 $output '';
  1994.                                                 $userData = array();
  1995.                                                 $userFiles = array();
  1996.                                                 foreach ($users as $user) {
  1997.                                                     $file $this->container->getParameter('kernel.root_dir') . '/../web/' $user->getImage();
  1998.                                                     if ($user->getImage() != '' && $user->getImage() != null && file_exists($file)) {
  1999.                                                         $mime mime_content_type($file);
  2000.                                                         $info pathinfo($file);
  2001.                                                         $name $info['basename'];
  2002.                                                         if (strpos($mime'image') !== false) {
  2003.                                                             $output = new \CURLFile($file$mime$name);
  2004.                                                         }
  2005.                                                         $skipSend 0;
  2006.                                                         $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = $output;
  2007.                                                     } else {
  2008.                                                         $user->setImage(null);
  2009.                                                         $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = 'pika';
  2010.                                                         $em->flush();
  2011.                                                     }
  2012.                                                     $getters array_filter(get_class_methods($user), function ($method) {
  2013.                                                         return 'get' === substr($method03);
  2014.                                                     });
  2015.                                                     $userDataSingle = array();
  2016.                                                     foreach ($getters as $getter) {
  2017.                                                         if ($getter == 'getCreatedAt' || $getter == 'getUpdatedAt' || $getter == 'getImage')
  2018.                                                             continue;
  2019. //                                if(is_string($user->{$getter}())|| is_numeric($user->{$getter}()))
  2020. //                                {
  2021. //                                    $userDataSingle[$getter]= $user->{$getter}();
  2022. //                                }
  2023.                                                         if ($user->{$getter}() instanceof \DateTime) {
  2024.                                                             $ggtd $user->{$getter}();
  2025.                                                             $userDataSingle[$getter] = $ggtd->format('Y-m-d');
  2026.                                                         } else
  2027.                                                             $userDataSingle[$getter] = $user->{$getter}();
  2028.                                                     }
  2029. //                                                    $userDataSingle['getNid']=$Employee->getNid();
  2030. //                                                    $userDataSingle['getCurrAddr'] = $Employee->getCurrAddr();
  2031.                                                     $userData[] = $userDataSingle;
  2032.                                                 }
  2033.                                                 $retDataDebug[$debugCount] = array(
  2034.                                                     'skipSend' => $skipSend
  2035.                                                 );
  2036.                                                 {
  2037.                                                     $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/SyncUserToCentralUser';
  2038.                                                     $userFiles['userData'] = json_encode($userData);
  2039.                                                     $curl curl_init();
  2040.                                                     curl_setopt_array($curl, array(
  2041.                                                         CURLOPT_RETURNTRANSFER => 1,
  2042.                                                         CURLOPT_POST => 1,
  2043.                                                         CURLOPT_URL => $urlToCall,
  2044.                                                         CURLOPT_CONNECTTIMEOUT => 10,
  2045.                                                         CURLOPT_SSL_VERIFYPEER => false,
  2046.                                                         CURLOPT_SSL_VERIFYHOST => false,
  2047. //                            CURLOPT_SAFE_UPLOAD => false,
  2048.                                                         CURLOPT_HTTPHEADER => array(//                                "Accept: multipart/form-data",
  2049.                                                         ),
  2050.                                                         //                        CURLOPT_USERAGENT => 'InnoPM',
  2051. //                            CURLOPT_POSTFIELDS => array(
  2052. //                                'userData'=>json_encode($userData),
  2053. //                                'userFiles'=>$userFiles
  2054. //                            ),
  2055.                                                         CURLOPT_POSTFIELDS => $userFiles
  2056.                                                     ));
  2057.                                                     $retData curl_exec($curl);
  2058.                                                     $errData curl_error($curl);
  2059.                                                     curl_close($curl);
  2060.                                                     $response = [];
  2061.                                                     if ($errData) {
  2062.                                                         $response['status'] = 'error';
  2063.                                                         $response['message'] = 'cURL Error: ' $errData;
  2064.                                                     } else {
  2065.                                                         $retDataObj json_decode($retDatatrue);
  2066.                                                         if (!$retDataObj) {
  2067.                                                             $response['status'] = 'error';
  2068.                                                             $response['message'] = 'Invalid response from central server';
  2069.                                                             $response['raw_response'] = $retData;
  2070.                                                         } else {
  2071.                                                             $response['status'] = 'success';
  2072.                                                             $response['data'] = $retDataObj;
  2073.                                                         }
  2074.                                                     }
  2075. // Return JSON response
  2076. //                                                    return new JsonResponse($response);
  2077.                                                     $retDataDebug[$debugCount] = $retDataObj;
  2078.                                                     if (isset($retDataObj['globalIdsData']))
  2079.                                                         foreach ($retDataObj['globalIdsData'] as $app_id => $usrList) {
  2080.                                                             $connector $this->container->get('application_connector');
  2081.                                                             $connector->resetConnection(
  2082.                                                                 'default',
  2083.                                                                 $gocDataListByAppId[$app_id]['dbName'],
  2084.                                                                 $gocDataListByAppId[$app_id]['dbUser'],
  2085.                                                                 $gocDataListByAppId[$app_id]['dbPass'],
  2086.                                                                 $gocDataListByAppId[$app_id]['dbHost'],
  2087.                                                                 $reset true);
  2088.                                                             $em $this->getDoctrine()->getManager();
  2089.                                                             foreach ($usrList as $sys_id => $globaldata) {
  2090.                                                                 $user $this->getDoctrine()
  2091.                                                                     ->getRepository('ApplicationBundle:SysUser')
  2092.                                                                     ->findOneBy(
  2093.                                                                         array(
  2094.                                                                             'userId' => $sys_id
  2095.                                                                         )
  2096.                                                                     );
  2097.                                                                 if ($user) {
  2098.                                                                     $user->setGlobalId($globaldata['gid']);
  2099.                                                                     $em->persist($user);
  2100.                                                                     $em->flush();
  2101.                                                                 }
  2102.                                                             }
  2103.                                                         }
  2104.                                                 }
  2105.                                                 $debugCount++;
  2106.                                             }
  2107.                                         }
  2108. //                    return new JsonResponse($retDataDebug);
  2109.                                     }
  2110.                                 }
  2111.                                 $SysUserRepo $em->getRepository(SysUser::class);
  2112.                                 $SysUser $SysUserRepo->findOneBy(array(
  2113.                                     'email' => $data->request->get('email')
  2114.                                 ));
  2115.                                 $isSuccess->setUserId($SysUser->getUserId());
  2116.                                 $em->persist($isSuccess);
  2117.                                 $em->flush();
  2118.                                 $companyData $message[2];
  2119.                                 if ($message[0] == 'success' && GeneralConstant::EMAIL_ENABLED == 1) {
  2120.                                     $bodyHtml '';
  2121.                                     $bodyTemplate 'ApplicationBundle:email/user:registration.html.twig';
  2122.                                     $bodyData = array(
  2123.                                         'name' => $data->request->get('name'),
  2124.                                         'companyData' => $companyData,
  2125.                                         'userName' => $data->request->get('username'),
  2126.                                         'password' => $data->request->get('password'),
  2127.                                     );
  2128.                                     $attachments = [];
  2129. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  2130.                                     $new_mail $this->get('mail_module');
  2131.                                     $new_mail->sendMyMail(array(
  2132.                                         'senderHash' => '_CUSTOM_',
  2133.                                         //                        'senderHash'=>'_CUSTOM_',
  2134.                                         'forwardToMailAddress' => $data->request->get('email'),
  2135.                                         'subject' => 'User Registration on HoneyBee Ecosystem under Entity ' $companyData->getName(),
  2136.                                         'fileName' => '',
  2137.                                         'attachments' => $attachments,
  2138.                                         'toAddress' => $data->request->get('email'),
  2139.                                         'fromAddress' => 'no-reply@ourhoneybee.eu',
  2140.                                         'userName' => 'no-reply@ourhoneybee.eu',
  2141.                                         'password' => 'Y41dh8g0112',
  2142.                                         'smtpServer' => 'smtp.hostinger.com',
  2143.                                         'smtpPort' => 465,
  2144. //                        'fromAddress'=>'sales@entity.innobd.com',
  2145. //                        'userName'=>'sales@entity.innobd.com',
  2146. //                        'password'=>'Y41dh8g0112',
  2147. //                        'smtpServer'=>'smtp.hostinger.com',
  2148. //                        'smtpPort'=>587,
  2149. //                        'emailBody'=>$bodyHtml,
  2150.                                         'mailTemplate' => $bodyTemplate,
  2151.                                         'templateData' => $bodyData,
  2152.                                         'embedCompanyImage' => 1,
  2153.                                         'companyId' => $data->request->get('company'),
  2154.                                         'companyImagePath' => $companyData->getImage()
  2155.                                     ));
  2156. //                  $emailmessage = (new \Swift_Message('Registration to Entity'))
  2157. //                    ->setFrom('registration@entity.innobd.com')
  2158. //                    ->setTo($data->request->get('email'))
  2159. //                    ->setBody(
  2160. //                      $this->renderView(
  2161. //                        'ApplicationBundle:email/user:registration.html.twig',
  2162. //                        array(
  2163. //                          'name' => $data->request->get('name'),
  2164. //                          'companyData' => $companyData,
  2165. //                          'userName' => $data->request->get('email'),
  2166. //                          'password' => $data->request->get('password'),
  2167. //                        )
  2168. //                      ),
  2169. //                      'text/html'
  2170. //                    );
  2171. //                  $this->get('mailer')->send($emailmessage);
  2172.                                 }
  2173.                             }
  2174.                             // End Mailer function
  2175.                             $this->addFlash(
  2176.                                 'success',
  2177.                                 'New Employee Successfully Added!'
  2178.                             );
  2179.                             $userType HumanResourceConstant::$userType;
  2180.                             if ($userType == 1) {
  2181.                                 return $this->redirectToRoute('employee_list');
  2182.                             } else {
  2183.                                 return $this->redirectToRoute('edit_employee');
  2184.                             }
  2185.                         } else {
  2186.                             $this->addFlash(
  2187.                                 'error',
  2188.                                 'Something Went Wrong!'
  2189.                             );
  2190.                             $userType HumanResourceConstant::$userType;
  2191.                             if ($userType == 1) {
  2192.                                 return $this->redirectToRoute('employee_list');
  2193.                             } else {
  2194.                                 return $this->redirectToRoute('edit_employee');
  2195.                             }
  2196.                         }
  2197.                     }
  2198.                 } else {
  2199.                     $this->addFlash(
  2200.                         'error',
  2201.                         'Invalid Approval Hash!'
  2202.                     );
  2203.                     return $this->redirectToRoute('add_employee');
  2204.                 }
  2205.             }
  2206.         }
  2207.     }
  2208.     public function AddNewEmployeeAction(Request $request$id)
  2209.     {
  2210.         $em $this->getDoctrine()->getManager();
  2211.         $systemType $this->container->hasParameter('system_type') ? $this->container->getParameter('system_type') : '_ERP_';
  2212.         $approveHash $request->request->get('approvalHash');
  2213.         $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  2214.         $CompanyId $this->getLoggedUserCompanyId($request);
  2215.         $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  2216.         $employee HumanResource::StoreDataForAddEmployee($em$requestfalse$CompanyId);
  2217.         $isUserExist $em->getRepository(EmployeeDetails::class);
  2218.         if ($isSignatureOk) {
  2219.             if ($isUserExist) {
  2220.                 if ($employee) {
  2221.                     $message $this->get('user_module')->addNewUser(
  2222.                         $request->request->get('firstname') . " " $request->request->get('lastname'),
  2223.                         $request->request->get('email'),
  2224.                         $request->request->get('username'),
  2225.                         $request->request->get('password'),
  2226.                         $request->request->get('desg'),
  2227.                         $request->getLoggedUserLoginId($request),
  2228.                         $request->request->get('company'),
  2229.                         $request->request->get('user_type'),
  2230.                         $request->request->get('companyIdList'),
  2231.                         $request->request->get('branch'),
  2232.                         $request->request->get('supervisor'),
  2233.                         $request->request->get('default_route'),
  2234.                         $request->request->has('access_module') ? 0
  2235.                     );
  2236.                     if ($message[0] == 'success') {
  2237.                         $employee->setUserId($message[3]->getUserId());
  2238.                         $em->flush();
  2239.                         if ($systemType == '_CENTRAL_') {
  2240.                         } else {
  2241.                             $em_goc $this->getDoctrine()->getManager('company_group');
  2242.                             $em_goc->getConnection()->connect();
  2243.                             $connected $em_goc->getConnection()->isConnected();
  2244.                             $gocDataList = [];
  2245.                             $gocDataListByAppId = [];
  2246.                             $retDataDebug = array();
  2247.                             $appIds $message[2]->getAppId();
  2248.                             $userIds $message[3]->getUserId();
  2249.                             if ($connected) {
  2250.                                 $findByQuery = array(
  2251.                                     'active' => 1
  2252.                                 );
  2253.                                 if ($appIds !== '_UNSET_')
  2254.                                     $findByQuery['appId'] = $appIds;
  2255.                                 $gocList $this->getDoctrine()->getManager('company_group')
  2256.                                     ->getRepository("CompanyGroupBundle:CompanyGroup")
  2257.                                     ->findBy($findByQuery);
  2258.                                 foreach ($gocList as $entry) {
  2259.                                     $d = array(
  2260.                                         'name' => $entry->getName(),
  2261.                                         'id' => $entry->getId(),
  2262.                                         'image' => $entry->getImage(),
  2263.                                         'companyGroupHash' => $entry->getCompanyGroupHash(),
  2264.                                         'dbName' => $entry->getDbName(),
  2265.                                         'dbUser' => $entry->getDbUser(),
  2266.                                         'dbPass' => $entry->getDbPass(),
  2267.                                         'dbHost' => $entry->getDbHost(),
  2268.                                         'appId' => $entry->getAppId(),
  2269.                                         'companyRemaining' => $entry->getCompanyRemaining(),
  2270.                                         'companyAllowed' => $entry->getCompanyAllowed(),
  2271.                                     );
  2272.                                     $gocDataList[$entry->getId()] = $d;
  2273.                                     $gocDataListByAppId[$entry->getAppId()] = $d;
  2274.                                 }
  2275.                                 $debugCount 0;
  2276.                                 foreach ($gocDataList as $gocId => $entry) {
  2277.                                     $skipSend 1;
  2278.                                     $connector $this->container->get('application_connector');
  2279.                                     $connector->resetConnection(
  2280.                                         'default',
  2281.                                         $gocDataList[$gocId]['dbName'],
  2282.                                         $gocDataList[$gocId]['dbUser'],
  2283.                                         $gocDataList[$gocId]['dbPass'],
  2284.                                         $gocDataList[$gocId]['dbHost'],
  2285.                                         $reset true);
  2286.                                     $em $this->getDoctrine()->getManager();
  2287.                                     if ($userIds !== '_UNSET_')
  2288.                                         $users $this->getDoctrine()
  2289.                                             ->getRepository('ApplicationBundle:SysUser')
  2290.                                             ->findBy(
  2291.                                                 array(
  2292.                                                     'userId' => $userIds
  2293.                                                 )
  2294.                                             );
  2295.                                     else
  2296.                                         $users $this->getDoctrine()
  2297.                                             ->getRepository('ApplicationBundle:SysUser')
  2298.                                             ->findBy(
  2299.                                                 array()
  2300.                                             );
  2301.                                     $output '';
  2302.                                     $userData = array();
  2303.                                     $userFiles = array();
  2304.                                     foreach ($users as $user) {
  2305.                                         $file $this->container->getParameter('kernel.root_dir') . '/../web/' $user->getImage();
  2306.                                         if ($user->getImage() != '' && $user->getImage() != null && file_exists($file)) {
  2307.                                             $mime mime_content_type($file);
  2308.                                             $info pathinfo($file);
  2309.                                             $name $info['basename'];
  2310.                                             if (strpos($mime'image') !== false) {
  2311.                                                 $output = new \CURLFile($file$mime$name);
  2312.                                             }
  2313.                                             $skipSend 0;
  2314.                                             $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = $output;
  2315.                                         } else {
  2316.                                             $user->setImage(null);
  2317.                                             $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = 'pika';
  2318.                                             $em->flush();
  2319.                                         }
  2320.                                         $getters array_filter(get_class_methods($user), function ($method) {
  2321.                                             return 'get' === substr($method03);
  2322.                                         });
  2323.                                         $userDataSingle = array();
  2324.                                         foreach ($getters as $getter) {
  2325.                                             if ($getter == 'getCreatedAt' || $getter == 'getUpdatedAt' || $getter == 'getImage')
  2326.                                                 continue;
  2327. //                                if(is_string($user->{$getter}())|| is_numeric($user->{$getter}()))
  2328. //                                {
  2329. //                                    $userDataSingle[$getter]= $user->{$getter}();
  2330. //                                }
  2331.                                             if ($user->{$getter}() instanceof \DateTime) {
  2332.                                                 $ggtd $user->{$getter}();
  2333.                                                 $userDataSingle[$getter] = $ggtd->format('Y-m-d');
  2334.                                             } else
  2335.                                                 $userDataSingle[$getter] = $user->{$getter}();
  2336.                                         }
  2337. //                                                    $userDataSingle['getNid']=$Employee->getNid();
  2338. //                                                    $userDataSingle['getCurrAddr'] = $Employee->getCurrAddr();
  2339.                                         $userData[] = $userDataSingle;
  2340.                                     }
  2341.                                     $retDataDebug[$debugCount] = array(
  2342.                                         'skipSend' => $skipSend
  2343.                                     );
  2344.                                     {
  2345.                                         $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/SyncUserToCentralUser';
  2346.                                         $userFiles['userData'] = json_encode($userData);
  2347.                                         $curl curl_init();
  2348.                                         curl_setopt_array($curl, array(
  2349.                                             CURLOPT_RETURNTRANSFER => 1,
  2350.                                             CURLOPT_POST => 1,
  2351.                                             CURLOPT_URL => $urlToCall,
  2352.                                             CURLOPT_CONNECTTIMEOUT => 10,
  2353.                                             CURLOPT_SSL_VERIFYPEER => false,
  2354.                                             CURLOPT_SSL_VERIFYHOST => false,
  2355. //                            CURLOPT_SAFE_UPLOAD => false,
  2356.                                             CURLOPT_HTTPHEADER => array(//                                "Accept: multipart/form-data",
  2357.                                             ),
  2358.                                             //                        CURLOPT_USERAGENT => 'InnoPM',
  2359. //                            CURLOPT_POSTFIELDS => array(
  2360. //                                'userData'=>json_encode($userData),
  2361. //                                'userFiles'=>$userFiles
  2362. //                            ),
  2363.                                             CURLOPT_POSTFIELDS => $userFiles
  2364.                                         ));
  2365.                                         $retData curl_exec($curl);
  2366.                                         $errData curl_error($curl);
  2367.                                         curl_close($curl);
  2368.                                         $response = [];
  2369.                                         if ($errData) {
  2370.                                             $response['status'] = 'error';
  2371.                                             $response['message'] = 'cURL Error: ' $errData;
  2372.                                         } else {
  2373.                                             $retDataObj json_decode($retDatatrue);
  2374.                                             if (!$retDataObj) {
  2375.                                                 $response['status'] = 'error';
  2376.                                                 $response['message'] = 'Invalid response from central server';
  2377.                                                 $response['raw_response'] = $retData;
  2378.                                             } else {
  2379.                                                 $response['status'] = 'success';
  2380.                                                 $response['data'] = $retDataObj;
  2381.                                             }
  2382.                                         }
  2383. // Return JSON response
  2384. //                                                    return new JsonResponse($response);
  2385.                                         $retDataDebug[$debugCount] = $retDataObj;
  2386.                                         if (isset($retDataObj['globalIdsData']))
  2387.                                             foreach ($retDataObj['globalIdsData'] as $app_id => $usrList) {
  2388.                                                 $connector $this->container->get('application_connector');
  2389.                                                 $connector->resetConnection(
  2390.                                                     'default',
  2391.                                                     $gocDataListByAppId[$app_id]['dbName'],
  2392.                                                     $gocDataListByAppId[$app_id]['dbUser'],
  2393.                                                     $gocDataListByAppId[$app_id]['dbPass'],
  2394.                                                     $gocDataListByAppId[$app_id]['dbHost'],
  2395.                                                     $reset true);
  2396.                                                 $em $this->getDoctrine()->getManager();
  2397.                                                 foreach ($usrList as $sys_id => $globaldata) {
  2398.                                                     $user $this->getDoctrine()
  2399.                                                         ->getRepository('ApplicationBundle:SysUser')
  2400.                                                         ->findOneBy(
  2401.                                                             array(
  2402.                                                                 'userId' => $sys_id
  2403.                                                             )
  2404.                                                         );
  2405.                                                     if ($user) {
  2406.                                                         $user->setGlobalId($globaldata['gid']);
  2407.                                                         $em->persist($user);
  2408.                                                         $em->flush();
  2409.                                                     }
  2410.                                                 }
  2411.                                             }
  2412.                                     }
  2413.                                     $debugCount++;
  2414.                                 }
  2415.                             }
  2416. //                    return new JsonResponse($retDataDebug);
  2417.                         }
  2418.                     }
  2419. //                                    if($message[0]=='success'){
  2420. //                                        $SysUserRepo = $em->getRepository('ApplicationBundle:SysUser');
  2421. //                                        $SysUser = $SysUserRepo->findOneBy([
  2422. //                                            'email' => $data->request->get('email')
  2423. //                                        ]);
  2424. //
  2425. //                                        if ($SysUser === null) {
  2426. //                                            throw new \Exception("User with email " . $data->request->get('email') . " not found.");
  2427. //                                        }
  2428. //
  2429. //                                        $isSuccess->setUserId($SysUser->getUserId());
  2430. //                                        $em->persist($isSuccess);
  2431. //                                        $em->flush();
  2432. //                                    }
  2433.                     $companyData $message[2];
  2434.                     if ($message[0] == 'success' && GeneralConstant::EMAIL_ENABLED == 1) {
  2435.                         $bodyHtml '';
  2436.                         $bodyTemplate 'ApplicationBundle:email/user:registration.html.twig';
  2437.                         $bodyData = array(
  2438.                             'name' => $request->request->get('name'),
  2439.                             'companyData' => $companyData,
  2440.                             'userName' => $request->request->get('username'),
  2441.                             'password' => $request->request->get('password'),
  2442.                         );
  2443.                         $attachments = [];
  2444.                         $new_mail $this->get('mail_module');
  2445.                         $new_mail->sendMyMail(array(
  2446.                             'senderHash' => '_CUSTOM_',
  2447.                             //                        'senderHash'=>'_CUSTOM_',
  2448.                             'forwardToMailAddress' => $request->request->get('email'),
  2449.                             'fromAddress' => 'no-reply@ourhoneybee.eu',
  2450.                             'userName' => 'no-reply@ourhoneybee.eu',
  2451.                             'password' => 'Honeybee@0112',
  2452.                             'smtpServer' => 'smtp.hostinger.com',
  2453.                             'smtpPort' => 465,
  2454.                             'subject' => 'User Registration on HoneyBee Ecosystem under Entity ' $companyData->getName(),
  2455.                             'fileName' => '',
  2456.                             'attachments' => $attachments,
  2457.                             'toAddress' => $request->request->get('email'),
  2458.                             'mailTemplate' => $bodyTemplate,
  2459.                             'templateData' => $bodyData,
  2460.                             'embedCompanyImage' => 1,
  2461.                             'companyId' => $request->request->get('company'),
  2462.                             'companyImagePath' => $companyData->getImage()
  2463.                         ));
  2464.                     }
  2465.                 }
  2466.                 $this->addFlash(
  2467.                     'success',
  2468.                     'New Employee Successfully Added!'
  2469.                 );
  2470.                 return $this->redirectToRoute('add_employee');
  2471.             } else {
  2472. //                        $requiredFields = [
  2473. //                            'email', 'username', 'password', 'firstname', 'lastname', 'nid', 'dob',
  2474. //                            'sex', 'blood', 'phone', 'perm_addr', 'dept', 'desg', 'branch',
  2475. //                            'emp_type', 'tin'
  2476. //                        ];
  2477. //
  2478. //                        $missingFields = [];
  2479. //
  2480. //                        foreach ($requiredFields as $field) {
  2481. //                            if (!$data->request->get($field)) {
  2482. //                                $missingFields[] = $field;
  2483. //                            }
  2484. //                        }
  2485. //                        if (!empty($missingFields)) {
  2486. //                            $this->addFlash('error', 'Missing fields: ' . implode(', ', $missingFields));
  2487. //                            return $this->redirectToRoute('add_employee');
  2488. //                        }
  2489. //                        $password = $data->request->get('password');
  2490. //                        $passwordPattern = '/^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[\W_]).{8,}$/';
  2491. //                        if (!preg_match($passwordPattern, $password)) {
  2492. //                            $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));
  2493. //                            return $this->redirectToRoute('add_employee');
  2494. //                        }
  2495.                 $CompanyId $this->getLoggedUserCompanyId($request);
  2496.                 $isSuccess HumanResource::StoreDataForAddEmployee($em$requestfalse$CompanyId);
  2497.                 if ($isSuccess) {
  2498.                     if ($request->request->has('send_appointment')) {
  2499.                         $email $request->request->get('email');
  2500.                         $bodyHtml '';
  2501.                         $bodyTemplate 'ApplicationBundle:email/general:appointment_letter_test.html.twig';
  2502.                         $bodyData = [];
  2503.                         $attachments = [];
  2504.                         $forwardToMailAddress $email;
  2505.                         $new_mail $this->get('mail_module');
  2506.                         $new_mail->sendMyMail(array(
  2507.                             'senderHash' => '_CUSTOM_',
  2508.                             'forwardToMailAddress' => $forwardToMailAddress,
  2509.                             'subject' => 'Appointment Letter',
  2510.                             'attachments' => $attachments,
  2511.                             'toAddress' => $forwardToMailAddress,
  2512.                             'fromAddress' => 'no-reply@ourhoneybee.eu',
  2513.                             'userName' => 'no-reply@ourhoneybee.eu',
  2514.                             'password' => 'Honeybee@0112',
  2515.                             'smtpServer' => 'smtp.hostinger.com',
  2516.                             'smtpPort' => 465,
  2517.                             'emailBody' => $bodyHtml,
  2518.                             'mailTemplate' => $bodyTemplate,
  2519.                             'templateData' => $bodyData,
  2520.                         ));
  2521.                     }
  2522.                     // Mailer function
  2523.                     if ($request->get("send_mail") && empty($request->get('sys_user'))) {
  2524.                         $message $this->get('user_module')->addNewUser(
  2525.                             $request->request->get('firstname') . " " $request->request->get('lastname'),
  2526.                             $request->request->get('email'),
  2527.                             $request->request->get('username'),
  2528.                             $request->request->get('password'),
  2529.                             $request->request->get('desg'),
  2530.                             $request->getLoggedUserLoginId($request),
  2531.                             $request->request->get('company'),
  2532.                             $request->request->get('user_type'),
  2533.                             $request->request->get('companyIdList'),
  2534.                             $request->request->get('branch'),
  2535.                             $request->request->get('supervisor'),
  2536.                             $request->request->get('default_route'),
  2537.                             $request->request->has('access_module') ? 0
  2538.                         );
  2539.                         if ($message[0] == 'success') {
  2540.                             if ($systemType == '_CENTRAL_') {
  2541.                             } else {
  2542.                                 $em_goc $this->getDoctrine()->getManager('company_group');
  2543.                                 $em_goc->getConnection()->connect();
  2544.                                 $connected $em_goc->getConnection()->isConnected();
  2545.                                 $gocDataList = [];
  2546.                                 $gocDataListByAppId = [];
  2547.                                 $retDataDebug = array();
  2548.                                 $appIds $message[2]->getAppId();
  2549.                                 $userIds $message[3]->getUserId();
  2550.                                 if ($connected) {
  2551.                                     $findByQuery = array(
  2552.                                         'active' => 1
  2553.                                     );
  2554.                                     if ($appIds !== '_UNSET_')
  2555.                                         $findByQuery['appId'] = $appIds;
  2556.                                     $gocList $this->getDoctrine()->getManager('company_group')
  2557.                                         ->getRepository("CompanyGroupBundle:CompanyGroup")
  2558.                                         ->findBy($findByQuery);
  2559.                                     foreach ($gocList as $entry) {
  2560.                                         $d = array(
  2561.                                             'name' => $entry->getName(),
  2562.                                             'id' => $entry->getId(),
  2563.                                             'image' => $entry->getImage(),
  2564.                                             'companyGroupHash' => $entry->getCompanyGroupHash(),
  2565.                                             'dbName' => $entry->getDbName(),
  2566.                                             'dbUser' => $entry->getDbUser(),
  2567.                                             'dbPass' => $entry->getDbPass(),
  2568.                                             'dbHost' => $entry->getDbHost(),
  2569.                                             'appId' => $entry->getAppId(),
  2570.                                             'companyRemaining' => $entry->getCompanyRemaining(),
  2571.                                             'companyAllowed' => $entry->getCompanyAllowed(),
  2572.                                         );
  2573.                                         $gocDataList[$entry->getId()] = $d;
  2574.                                         $gocDataListByAppId[$entry->getAppId()] = $d;
  2575.                                     }
  2576.                                     $debugCount 0;
  2577.                                     foreach ($gocDataList as $gocId => $entry) {
  2578.                                         $skipSend 1;
  2579.                                         $connector $this->container->get('application_connector');
  2580.                                         $connector->resetConnection(
  2581.                                             'default',
  2582.                                             $gocDataList[$gocId]['dbName'],
  2583.                                             $gocDataList[$gocId]['dbUser'],
  2584.                                             $gocDataList[$gocId]['dbPass'],
  2585.                                             $gocDataList[$gocId]['dbHost'],
  2586.                                             $reset true);
  2587.                                         $em $this->getDoctrine()->getManager();
  2588.                                         if ($userIds !== '_UNSET_')
  2589.                                             $users $this->getDoctrine()
  2590.                                                 ->getRepository('ApplicationBundle:SysUser')
  2591.                                                 ->findBy(
  2592.                                                     array(
  2593.                                                         'userId' => $userIds
  2594.                                                     )
  2595.                                                 );
  2596.                                         else
  2597.                                             $users $this->getDoctrine()
  2598.                                                 ->getRepository('ApplicationBundle:SysUser')
  2599.                                                 ->findBy(
  2600.                                                     array()
  2601.                                                 );
  2602.                                         $output '';
  2603.                                         $userData = array();
  2604.                                         $userFiles = array();
  2605.                                         foreach ($users as $user) {
  2606.                                             $file $this->container->getParameter('kernel.root_dir') . '/../web/' $user->getImage();
  2607.                                             if ($user->getImage() != '' && $user->getImage() != null && file_exists($file)) {
  2608.                                                 $mime mime_content_type($file);
  2609.                                                 $info pathinfo($file);
  2610.                                                 $name $info['basename'];
  2611.                                                 if (strpos($mime'image') !== false) {
  2612.                                                     $output = new \CURLFile($file$mime$name);
  2613.                                                 }
  2614.                                                 $skipSend 0;
  2615.                                                 $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = $output;
  2616.                                             } else {
  2617.                                                 $user->setImage(null);
  2618.                                                 $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = 'pika';
  2619.                                                 $em->flush();
  2620.                                             }
  2621.                                             $getters array_filter(get_class_methods($user), function ($method) {
  2622.                                                 return 'get' === substr($method03);
  2623.                                             });
  2624.                                             $userDataSingle = array();
  2625.                                             foreach ($getters as $getter) {
  2626.                                                 if ($getter == 'getCreatedAt' || $getter == 'getUpdatedAt' || $getter == 'getImage')
  2627.                                                     continue;
  2628. //                                if(is_string($user->{$getter}())|| is_numeric($user->{$getter}()))
  2629. //                                {
  2630. //                                    $userDataSingle[$getter]= $user->{$getter}();
  2631. //                                }
  2632.                                                 if ($user->{$getter}() instanceof \DateTime) {
  2633.                                                     $ggtd $user->{$getter}();
  2634.                                                     $userDataSingle[$getter] = $ggtd->format('Y-m-d');
  2635.                                                 } else
  2636.                                                     $userDataSingle[$getter] = $user->{$getter}();
  2637.                                             }
  2638. //                                                    $userDataSingle['getNid']=$Employee->getNid();
  2639. //                                                    $userDataSingle['getCurrAddr'] = $Employee->getCurrAddr();
  2640.                                             $userData[] = $userDataSingle;
  2641.                                         }
  2642.                                         $retDataDebug[$debugCount] = array(
  2643.                                             'skipSend' => $skipSend
  2644.                                         );
  2645.                                         {
  2646.                                             $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/SyncUserToCentralUser';
  2647.                                             $userFiles['userData'] = json_encode($userData);
  2648.                                             $curl curl_init();
  2649.                                             curl_setopt_array($curl, array(
  2650.                                                 CURLOPT_RETURNTRANSFER => 1,
  2651.                                                 CURLOPT_POST => 1,
  2652.                                                 CURLOPT_URL => $urlToCall,
  2653.                                                 CURLOPT_CONNECTTIMEOUT => 10,
  2654.                                                 CURLOPT_SSL_VERIFYPEER => false,
  2655.                                                 CURLOPT_SSL_VERIFYHOST => false,
  2656. //                            CURLOPT_SAFE_UPLOAD => false,
  2657.                                                 CURLOPT_HTTPHEADER => array(//                                "Accept: multipart/form-data",
  2658.                                                 ),
  2659.                                                 //                        CURLOPT_USERAGENT => 'InnoPM',
  2660. //                            CURLOPT_POSTFIELDS => array(
  2661. //                                'userData'=>json_encode($userData),
  2662. //                                'userFiles'=>$userFiles
  2663. //                            ),
  2664.                                                 CURLOPT_POSTFIELDS => $userFiles
  2665.                                             ));
  2666.                                             $retData curl_exec($curl);
  2667.                                             $errData curl_error($curl);
  2668.                                             curl_close($curl);
  2669.                                             $response = [];
  2670.                                             if ($errData) {
  2671.                                                 $response['status'] = 'error';
  2672.                                                 $response['message'] = 'cURL Error: ' $errData;
  2673.                                             } else {
  2674.                                                 $retDataObj json_decode($retDatatrue);
  2675.                                                 if (!$retDataObj) {
  2676.                                                     $response['status'] = 'error';
  2677.                                                     $response['message'] = 'Invalid response from central server';
  2678.                                                     $response['raw_response'] = $retData;
  2679.                                                 } else {
  2680.                                                     $response['status'] = 'success';
  2681.                                                     $response['data'] = $retDataObj;
  2682.                                                 }
  2683.                                             }
  2684. // Return JSON response
  2685. //                                                    return new JsonResponse($response);
  2686.                                             $retDataDebug[$debugCount] = $retDataObj;
  2687.                                             if (isset($retDataObj['globalIdsData']))
  2688.                                                 foreach ($retDataObj['globalIdsData'] as $app_id => $usrList) {
  2689.                                                     $connector $this->container->get('application_connector');
  2690.                                                     $connector->resetConnection(
  2691.                                                         'default',
  2692.                                                         $gocDataListByAppId[$app_id]['dbName'],
  2693.                                                         $gocDataListByAppId[$app_id]['dbUser'],
  2694.                                                         $gocDataListByAppId[$app_id]['dbPass'],
  2695.                                                         $gocDataListByAppId[$app_id]['dbHost'],
  2696.                                                         $reset true);
  2697.                                                     $em $this->getDoctrine()->getManager();
  2698.                                                     foreach ($usrList as $sys_id => $globaldata) {
  2699.                                                         $user $this->getDoctrine()
  2700.                                                             ->getRepository('ApplicationBundle:SysUser')
  2701.                                                             ->findOneBy(
  2702.                                                                 array(
  2703.                                                                     'userId' => $sys_id
  2704.                                                                 )
  2705.                                                             );
  2706.                                                         if ($user) {
  2707.                                                             $user->setGlobalId($globaldata['gid']);
  2708.                                                             $em->persist($user);
  2709.                                                             $em->flush();
  2710.                                                         }
  2711.                                                     }
  2712.                                                 }
  2713.                                         }
  2714.                                         $debugCount++;
  2715.                                     }
  2716.                                 }
  2717. //                    return new JsonResponse($retDataDebug);
  2718.                             }
  2719.                         }
  2720.                         $SysUserRepo $em->getRepository(SysUser::class);
  2721.                         $SysUser $SysUserRepo->findOneBy(array(
  2722.                             'email' => $request->request->get('email')
  2723.                         ));
  2724.                         $isSuccess->setUserId($SysUser->getUserId());
  2725.                         $em->persist($isSuccess);
  2726.                         $em->flush();
  2727.                         $companyData $message[2];
  2728.                         if ($message[0] == 'success' && GeneralConstant::EMAIL_ENABLED == 1) {
  2729.                             $bodyHtml '';
  2730.                             $bodyTemplate 'ApplicationBundle:email/user:registration.html.twig';
  2731.                             $bodyData = array(
  2732.                                 'name' => $request->request->get('name'),
  2733.                                 'companyData' => $companyData,
  2734.                                 'userName' => $request->request->get('username'),
  2735.                                 'password' => $request->request->get('password'),
  2736.                             );
  2737.                             $attachments = [];
  2738. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  2739.                             $new_mail $this->get('mail_module');
  2740.                             $new_mail->sendMyMail(array(
  2741.                                 'senderHash' => '_CUSTOM_',
  2742.                                 //                        'senderHash'=>'_CUSTOM_',
  2743.                                 'forwardToMailAddress' => $request->request->get('email'),
  2744.                                 'subject' => 'User Registration on HoneyBee Ecosystem under Entity ' $companyData->getName(),
  2745.                                 'fileName' => '',
  2746.                                 'attachments' => $attachments,
  2747.                                 'toAddress' => $request->request->get('email'),
  2748.                                 'fromAddress' => 'no-reply@ourhoneybee.eu',
  2749.                                 'userName' => 'no-reply@ourhoneybee.eu',
  2750.                                 'password' => 'Y41dh8g0112',
  2751.                                 'smtpServer' => 'smtp.hostinger.com',
  2752.                                 'smtpPort' => 465,
  2753. //                        'fromAddress'=>'sales@entity.innobd.com',
  2754. //                        'userName'=>'sales@entity.innobd.com',
  2755. //                        'password'=>'Y41dh8g0112',
  2756. //                        'smtpServer'=>'smtp.hostinger.com',
  2757. //                        'smtpPort'=>587,
  2758. //                        'emailBody'=>$bodyHtml,
  2759.                                 'mailTemplate' => $bodyTemplate,
  2760.                                 'templateData' => $bodyData,
  2761.                                 'embedCompanyImage' => 1,
  2762.                                 'companyId' => $request->request->get('company'),
  2763.                                 'companyImagePath' => $companyData->getImage()
  2764.                             ));
  2765. //                  $emailmessage = (new \Swift_Message('Registration to Entity'))
  2766. //                    ->setFrom('registration@entity.innobd.com')
  2767. //                    ->setTo($data->request->get('email'))
  2768. //                    ->setBody(
  2769. //                      $this->renderView(
  2770. //                        'ApplicationBundle:email/user:registration.html.twig',
  2771. //                        array(
  2772. //                          'name' => $data->request->get('name'),
  2773. //                          'companyData' => $companyData,
  2774. //                          'userName' => $data->request->get('email'),
  2775. //                          'password' => $data->request->get('password'),
  2776. //                        )
  2777. //                      ),
  2778. //                      'text/html'
  2779. //                    );
  2780. //                  $this->get('mailer')->send($emailmessage);
  2781.                         }
  2782.                     }
  2783.                     // End Mailer function
  2784.                     $this->addFlash(
  2785.                         'success',
  2786.                         'New Employee Successfully Added!'
  2787.                     );
  2788.                     return $this->redirectToRoute('employee_list');
  2789.                 } else {
  2790.                     $this->addFlash(
  2791.                         'error',
  2792.                         'Something Went Wrong!'
  2793.                     );
  2794.                     return $this->redirectToRoute('add_employee');
  2795.                 }
  2796.             }
  2797.         } else {
  2798.             $this->addFlash(
  2799.                 'error',
  2800.                 'Invalid Approval Hash!'
  2801.             );
  2802.             return $this->redirectToRoute('add_employee');
  2803.         }
  2804.     }
  2805.     public function UpdateEmployeeAction(Request $request$id)
  2806.     {
  2807.     }
  2808.     private function uploadImage($image$request)
  2809.     {
  2810.         $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Users/';
  2811.         $profileImage '';
  2812.         if ($image != null) {
  2813.             $fileName $request->request->get('firstname') . '.' $request->request->get('global_user_id') . '.' $image->guessExtension();
  2814.             $path $fileName;
  2815.             if (!file_exists($upl_dir)) {
  2816.                 mkdir($upl_dir0777true);
  2817.             }
  2818.             $image->move($upl_dir$path);
  2819.             $profileImage 'uploads/Users/' $path;
  2820.         }
  2821.         return $profileImage;
  2822.     }
  2823.     public function OnboardEmployeeAction(Request $request)
  2824.     {
  2825.         $systemType $this->container->hasParameter('system_type') ? $this->container->getParameter('system_type') : '_ERP_';
  2826.         $email $request->request->get('email');
  2827.         $applicantId $request->request->get('applicant_id');
  2828.         $em $this->getDoctrine()->getManager();
  2829.         $session $request->getSession();
  2830.         $companyId $session->get('userCompanyId');
  2831.         $appId $session->get('userAppId');
  2832.         $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/get_applicant_data_central';
  2833.         $applicantFiles = [
  2834.             'email' => $email,
  2835.             'applicantId' => $applicantId
  2836.         ];
  2837.         $entityToken $em->getRepository('ApplicationBundle:EntityTokenStorage')
  2838.             ->findOneBy(['userId' => $applicantId]);
  2839.         $curl curl_init();
  2840.         curl_setopt_array($curl, array(
  2841.             CURLOPT_RETURNTRANSFER => 1,
  2842.             CURLOPT_POST => 1,
  2843.             CURLOPT_URL => $urlToCall,
  2844.             CURLOPT_CONNECTTIMEOUT => 10,
  2845.             CURLOPT_SSL_VERIFYPEER => false,
  2846.             CURLOPT_SSL_VERIFYHOST => false,
  2847.             CURLOPT_HTTPHEADER => array(),
  2848.             CURLOPT_POSTFIELDS => $applicantFiles
  2849.         ));
  2850.         $retData curl_exec($curl);
  2851.         $errData curl_error($curl);
  2852.         curl_close($curl);
  2853.         $retDataObj json_decode($retDatatrue);
  2854.         if (!isset($retDataObj['status']) || $retDataObj['status'] !== 'success') {
  2855.             return new JsonResponse([
  2856.                 'status' => 'error',
  2857.                 'message' => 'Failed to get applicant data from central server',
  2858.                 'response' => $retDataObj
  2859.             ]);
  2860.         }
  2861.         $centralData $retDataObj['centralData'];
  2862.         $em $this->getDoctrine()->getManager();
  2863.         $sysUser = new SysUser();
  2864.         $sysUser->setGlobalId($centralData['globalId'] ?? '');
  2865.         $sysUser->setUsername($centralData['username'] ?? '');
  2866.         $sysUser->setEmail($centralData['email'] ?? '');
  2867.         $sysUser->setName($centralData['firstname'] ?? '');
  2868.         $sysUser->setUserType(1);
  2869.         $sysUser->setUserAppId($appId);
  2870.         $sysUser->setUserCompanyId($companyId);
  2871.         $sysUser->setStatus(1);
  2872.         $sysUser->setDefaultRoute('sales_dashboard');
  2873.         $em->persist($sysUser);
  2874.         $em->flush();
  2875.         $employee $em->getRepository('ApplicationBundle:Employee')
  2876.             ->findOneBy(
  2877.                 array(
  2878.                     'userId' => $sysUser->getUserId(),
  2879.                 )
  2880.             );
  2881.         if (!$employee) {
  2882.             $employee = new Employee();
  2883.             if ($sysUser->getUserId()) {
  2884.                 $employee->setEmail($sysUser->getEmail());
  2885.                 $employee->setFirstName($sysUser->getUsername());
  2886.                 $employee->setLastName($sysUser->getName());
  2887.                 $employee->setCompanyId($sysUser->getUserCompanyId());
  2888.                 $employee->setStatus(1);
  2889.                 $employee->setUserId($sysUser->getUserId());
  2890.                 $em->persist($employee);
  2891.                 $em->flush();
  2892.             } else {
  2893.                 return new JsonResponse([
  2894.                     'status' => 'error',
  2895.                     'message' => 'Missing employee data',
  2896.                 ]);
  2897.             }
  2898.         }
  2899.         $employeeDetails $em->getRepository('ApplicationBundle:EmployeeDetails')
  2900.             ->findOneBy([
  2901.                 'userId' => $sysUser->getUserId(),
  2902.             ]);
  2903.         if (!$employeeDetails) {
  2904.             $employeeDetails = new EmployeeDetails();
  2905.             if ($sysUser->getUserId() && $employee->getEmployeeId()) {
  2906.                 $employeeDetails->setId($employee->getEmployeeId());
  2907.                 $employeeDetails->setEmail($sysUser->getEmail());
  2908.                 $employeeDetails->setFirstName($sysUser->getUsername());
  2909.                 $employeeDetails->setLastName($sysUser->getName());
  2910.                 $employeeDetails->setUsername($sysUser->getUsername());
  2911.                 $employeeDetails->setUserId($sysUser->getUserId());
  2912.                 $employeeDetails->setEmpStatus(1);
  2913.                 $em->persist($employeeDetails);
  2914.                 $em->flush();
  2915.             } else {
  2916.                 return new JsonResponse([
  2917.                     'status' => 'error',
  2918.                     'message' => 'Missing employee details data',
  2919.                 ]);
  2920.             }
  2921.         }
  2922.         $company $em->getRepository('ApplicationBundle:Company')->find($companyId);
  2923.         $companyName $company $company->getName() : '';
  2924.         $currentAccessList $session->get('userAccessList', []);
  2925.         $newAccess = [
  2926.             'userType' => 1,
  2927.             'userTypeName' => 'Admin',
  2928.             'globalId' => $sysUser->getGlobalId(),
  2929.             'serverId' => 1,
  2930.             'serverUrl' => $request->getSchemeAndHttpHost(),
  2931.             'serverPort' => 80,
  2932.             'systemType' => $systemType,
  2933.             'companyId' => $companyId,
  2934.             'appId' => $appId,
  2935.             'companyLogoUrl' => '/uploads/CompanyImage/company_image' $appId '.png',
  2936.             'companyName' => $companyName,
  2937.             'authenticationStr' => base64_encode(bin2hex(random_bytes(32))),
  2938.             'userCompanyList' => [],
  2939.         ];
  2940.         $exists false;
  2941.         foreach ($currentAccessList as $access) {
  2942.             if ($access['companyId'] == $companyId && $access['appId'] == $appId) {
  2943.                 $exists true;
  2944.                 break;
  2945.             }
  2946.         }
  2947.         if (!$exists) {
  2948.             $currentAccessList[] = $newAccess;
  2949.             $session->set('userAccessList'$currentAccessList);
  2950.         }
  2951.         if ($entityToken) {
  2952.             $entityToken->setSessionData($currentAccessList);
  2953.             $entityToken->setUpdatedAt(new \DateTime());
  2954.             $em->persist($entityToken);
  2955.             $em->flush();
  2956.             return new JsonResponse([
  2957.                 'status' => 'success',
  2958.                 'message' => 'Token session updated successfully'
  2959.             ]);
  2960.         }
  2961.         return new JsonResponse([
  2962.             'status' => 'success',
  2963.             'message' => 'User onboarded successfully',
  2964.             'redirectUlr' => 'dashboard'
  2965.         ]);
  2966.     }
  2967.     public function DecodeQrAction(Request $request)
  2968.     {
  2969.         $applicantId $request->request->get('applicant_id');
  2970.         $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/get_applicant_data_central';
  2971.         $applicantFiles = [
  2972.             'applicantId' => $applicantId
  2973.         ];
  2974.         $curl curl_init();
  2975.         curl_setopt_array($curl, array(
  2976.             CURLOPT_RETURNTRANSFER => 1,
  2977.             CURLOPT_POST => 1,
  2978.             CURLOPT_URL => $urlToCall,
  2979.             CURLOPT_CONNECTTIMEOUT => 10,
  2980.             CURLOPT_SSL_VERIFYPEER => false,
  2981.             CURLOPT_SSL_VERIFYHOST => false,
  2982.             CURLOPT_HTTPHEADER => array(),
  2983.             CURLOPT_POSTFIELDS => $applicantFiles
  2984.         ));
  2985.         $retData curl_exec($curl);
  2986.         $errData curl_error($curl);
  2987.         curl_close($curl);
  2988.         $retDataObj json_decode($retDatatrue);
  2989.         return new JsonResponse($retDataObj['centralData']);
  2990.     }
  2991.     public function GetApplicantDataForErpAction(Request $request)
  2992.     {
  2993.         $applicantId $request->request->get('applicantId');
  2994.         if (!$applicantId) {
  2995.             return new JsonResponse([
  2996.                 'status' => 'error',
  2997.                 'message' => 'Missing applicantId in request.'
  2998.             ]);
  2999.         }
  3000.         $em_goc $this->getDoctrine()->getManager('company_group');
  3001.         $entityApplicant $em_goc->getRepository("CompanyGroupBundle:EntityApplicantDetails")
  3002.             ->findOneBy(['applicantId' => $applicantId]);
  3003.         if (!$entityApplicant) {
  3004.             return new JsonResponse([
  3005.                 'status' => 'error',
  3006.                 'message' => 'Applicant not found.'
  3007.             ]);
  3008.         }
  3009.         return new JsonResponse([
  3010.             'status' => 'success',
  3011.             'centralData' => [
  3012.                 'globalId' => $entityApplicant->getApplicantId(),
  3013.                 'username' => $entityApplicant->getUsername(),
  3014.                 'email' => $entityApplicant->getEmail(),
  3015.                 'firstname' => $entityApplicant->getFirstname(),
  3016.                 'lastname' => $entityApplicant->getLastname(),
  3017.                 'image' => $entityApplicant->getImage(),
  3018.                 'phone' => $entityApplicant->getPhone(),
  3019.                 'address' => $entityApplicant->getPermAddr()
  3020.             ]
  3021.         ]);
  3022.     }
  3023.     public function EmployeeListAction(Request $data)
  3024.     {
  3025.         $em $this->getDoctrine()->getManager();
  3026.         if ($data->isMethod('GET')) {
  3027.             return $this->render("ApplicationBundle:pages/human_resource/list:list_employee.html.twig", array(
  3028.                 'page_title' => 'Employee List',
  3029.             ));
  3030.         }
  3031.     }
  3032.     public function OrganizationChartAction()
  3033.     {
  3034.         $em $this->getDoctrine()->getManager();
  3035.         $Reponse HumanResource::TwigDataForOrgChart($em);
  3036.         return $this->render('ApplicationBundle:pages/human_resource/views:org_chart.html.twig', array(
  3037.             'page_title' => 'Organization Chart',
  3038.             'supervisors' => $Reponse['TreantJsData'],
  3039.             'alluser' => $Reponse['TreantJsInitUser']
  3040.         ));
  3041.     }
  3042.     public function EmployeeListSelectizeAjaxAction(Request $request$str '_EMPTY_')
  3043.     {
  3044.         $em $this->getDoctrine()->getManager();
  3045.         $companyId $this->getLoggedUserCompanyId($request);
  3046.         $company_data Company::getCompanyData($em$companyId);
  3047.         $data = [];
  3048.         $html '';
  3049.         $qryStrs explode(' '$str);
  3050.         $qryStrAddedForSpacedName "";
  3051.         if ($str == '_EMPTY_') {
  3052.             $query "SELECT *
  3053. from  employee  order by employee_id asc limit 10";
  3054.         } else {
  3055.             foreach ($qryStrs as $qryStr) {
  3056.                 $qryStrAddedForSpacedName .= "or first_name like '%$qryStr%' or last_name like '%$qryStr%' ";
  3057.             }
  3058.             $query "SELECT  *
  3059. 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";
  3060.         }
  3061.         $stmt $em->getConnection()->prepare($query);
  3062.         $stmt->execute();
  3063.         $res $stmt->fetchAll();
  3064. //    if(!empty($res)) {
  3065.         foreach ($res as $i => $r) {
  3066.             $res[$i]['id_padded'] = str_pad($r['employee_id'], 8'0'STR_PAD_LEFT);
  3067.         }
  3068. //    }
  3069.         return new JsonResponse(
  3070.             array(
  3071.                 'success' => true,
  3072.                 'data' => $res,
  3073.             )
  3074.         );
  3075.     }
  3076.     public function AttendanceAction(Request $data$remoteVerify 0)
  3077.     {
  3078.         $em $this->getDoctrine()->getManager();
  3079.         $em_goc $this->getDoctrine()->getManager('company_group');
  3080.         $workHourPolicy $em->getRepository('ApplicationBundle:WorkHourPolicy')->findAll();
  3081.         $options = array(
  3082.             'notification_enabled' => $this->container->getParameter('notification_enabled'),
  3083.             'notification_server' => $this->container->getParameter('notification_server'),
  3084.         );
  3085.         if ($data->get('DataTable')) {
  3086.             $response HumanResource::HandelAjaxRequestForManualAttendance($em$data);
  3087.             return new JsonResponse($response);
  3088.         }
  3089.         if ($data->request->get('getAttendanceStatus')) {
  3090.             $response HumanResource::getAttendanceStatus($em$data);
  3091.             return new JsonResponse($response);
  3092.         }
  3093.         $session $data->getSession();
  3094. //        if ($session->get('devAdminMode', 0) != 1 && $data->get('returnJson', 0) == 0)
  3095. //            return $this->redirectToRoute('permission_denied_page');
  3096.         // Auto attendance
  3097.         if ($data->get('autoAttendance') && $data->request->has('position_array')) {
  3098. //            $empId = $data->query->get('id');
  3099.             $empId $data->request->get('id'$session->get(UserConstants::USER_EMPLOYEE_ID));
  3100.             $positionsArray $data->request->get('position_array', []);
  3101.             if (is_string($positionsArray)) $positionsArray json_decode($positionsArraytrue);
  3102.             if ($positionsArray == null$positionsArray = [];
  3103.             $dataByAttId = [];
  3104.             $workPlaceType '_UNSET_';
  3105.             foreach ($positionsArray as $d) {
  3106.                 $sysUserId 0;
  3107.                 $userId 0;
  3108.                 $empId 0;
  3109.                 $dtTs 0;
  3110.                 $timeZoneStr '+0000';
  3111. //                $timeZoneStr = '+0600';
  3112.                 $token '_unset_';
  3113.                 if (isset($d['token'])) $token $d['token'];
  3114.                 if (isset($d['employeeId'])) $empId $d['employeeId'];
  3115.                 if (isset($d['userId'])) $userId $d['userId'];
  3116.                 if (isset($d['sysUserId'])) $sysUserId $d['sysUserId'];
  3117.                 if (isset($d['tsMilSec'])) {
  3118.                     $dtTs ceil(($d['tsMilSec']) / 1000);
  3119.                 }
  3120.                 if ($token != '_unset_') {
  3121.                     $sessionData MiscActions::GetSessionDataFromToken($em_goc$token)['sessionData'];
  3122.                     if (isset($sessionData[UserConstants::USER_EMPLOYEE_ID]))
  3123.                         $empId $sessionData[UserConstants::USER_EMPLOYEE_ID];
  3124.                 }
  3125.                 if ($sysUserId == 0)
  3126.                     $sysUserId $userId;
  3127.                 if ($sysUserId == 0)
  3128.                     $sysUserId $em->getRepository(Employee::class)
  3129.                         ->findOneBy(['employeeId' => $empId])->getUserId();
  3130.                 if ($dtTs == 0) {
  3131.                     $currTsTime = new \DateTime();
  3132.                     $dtTs $currTsTime->format('U');
  3133.                 } else {
  3134.                     $currTsTime = new \DateTime('@' $dtTs);
  3135.                 }
  3136.                 $currTsTime->setTimezone(new \DateTimeZone('UTC'));
  3137.                 $attDate = new \DateTime($currTsTime->format('Y-m-d') . ' 00:00:00' $timeZoneStr);
  3138.                 $EmployeeAttendance $this->getDoctrine()
  3139.                     ->getRepository(EmployeeAttendance::class)
  3140.                     ->findOneBy(array('employeeId' => $empId'date' => $attDate));
  3141.                 if (!$EmployeeAttendance)
  3142.                     $EmployeeAttendance = new EmployeeAttendance;
  3143.                 $attendanceInfo HumanResource::StoreAttendance($em$empId$sysUserId$data$EmployeeAttendance$attDate$dtTs$timeZoneStr$d['markerId']);
  3144.                 if ($d['markerId'] == HumanResourceConstant::ATTENDANCE_MARKER_CLOCK_IN) {
  3145.                     if ($empId == 24)
  3146.                         $workPlaceType '_HYBRID_';
  3147.                     else
  3148.                         $workPlaceType '_STATIC_';
  3149.                 }
  3150.                 if (!isset($dataByAttId[$attendanceInfo->getId()]))
  3151.                     $dataByAttId[$attendanceInfo->getId()] = array(
  3152.                         'attendanceInfo' => $attendanceInfo,
  3153.                         'empId' => $empId,
  3154.                         'lat' => 0,
  3155.                         'lng' => 0,
  3156.                         'address' => 0,
  3157.                         'sysUserId' => $sysUserId,
  3158.                         'companyId' => $data->getSession()->get(UserConstants::USER_COMPANY_ID),
  3159.                         'appId' => $data->getSession()->get(UserConstants::USER_APP_ID),
  3160.                         'positionArray' => []
  3161.                     );
  3162.                 $posData = array(
  3163.                     'ts' => $dtTs,
  3164.                     'lat' => $d['lat'],
  3165.                     'lng' => $d['lng'],
  3166.                     'marker' => $d['markerId'],
  3167.                     'src' => 2,
  3168.                 );
  3169.                 $posDataArray = array(
  3170.                     $dtTs,
  3171.                     $d['lat'],
  3172.                     $d['lng'],
  3173.                     $d['markerId'],
  3174.                     2
  3175.                 );
  3176.                 $dataByAttId[$attendanceInfo->getId()]['markerId'] = $d['markerId'];
  3177.                 //this markerId will be calclulted and modified to check if user is in our out of office/workplace later
  3178.                 $dataByAttId[$attendanceInfo->getId()]['attendanceInfo'] = $attendanceInfo;
  3179.                 $dataByAttId[$attendanceInfo->getId()]['positionArray'][] = $posData;
  3180.                 $dataByAttId[$attendanceInfo->getId()]['lat'] = $d['lat'];  //for last lat lng etc
  3181.                 $dataByAttId[$attendanceInfo->getId()]['lng'] = $d['lng'];  //for last lat lng etc
  3182.                 if (isset($d['address']))
  3183.                     $dataByAttId[$attendanceInfo->getId()]['address'] = $d['address'];  //for last lat lng etc
  3184. //                $dataByAttId[$attendanceInfo->getId()]['positionArray'][]=$posDataArray;
  3185.             }
  3186.             $response = array(
  3187.                 'success' => true,
  3188.             );
  3189.             foreach ($dataByAttId as $attInfoId => $d) {
  3190.                 $response HumanResource::setAttendanceLogFlutterApp($em,
  3191.                     $d['empId'],
  3192.                     $d['sysUserId'],
  3193.                     $d['companyId'],
  3194.                     $d['appId'],
  3195.                     $data,
  3196.                     $d['attendanceInfo'],
  3197.                     $options,
  3198.                     $d['positionArray'],
  3199.                     $d['lat'],
  3200.                     $d['lng'],
  3201.                     $d['address'],
  3202.                     $d['markerId']
  3203.                 );
  3204.             }
  3205.             if ($data->request->get('requestFromMobile')) {
  3206.                 $today = new \DateTime(date('y-m-d'));
  3207.                 $repository $this->getDoctrine()->getRepository(EmployeeAttendance::class);
  3208.                 $ActivitiesTemplate HumanResource::getCurrentStatusFromDb($repository$empId$today);
  3209.                 return new JsonResponse(array(
  3210.                     'success' => $response['success'] == true true false,
  3211.                     'msg' => $response['success'] == true 'Employee activities successfully updated.' 'Action Failed',
  3212.                     'workPlaceType' => $workPlaceType,
  3213.                     'data' => $ActivitiesTemplate
  3214.                 ));
  3215.             }
  3216.             return new JsonResponse(
  3217.                 array(
  3218.                     'success' => true,
  3219.                     'msg' => 'Employee activities successfully updated.',
  3220.                     'workPlaceType' => $workPlaceType,
  3221.                 )
  3222.             );
  3223.         } else if ($data->get('autoAttendance')) {
  3224.             $sysUserId 0;
  3225.             $userId 0;
  3226.             $empId 0;
  3227.             $dtTs 0;
  3228. //            $timeZoneStr = '+0600';
  3229.             $timeZoneStr '+0000';
  3230.             if ($data->request->get('requestFromMobile')) {
  3231.                 $empId $data->request->get('employeeId');
  3232.                 $userId $data->request->get('userId'0);
  3233.                 $sysUserId $data->request->get('id'0);
  3234. //        $empId = $em->getRepository(Employee::class)
  3235. //            ->findOneBy(['userId' => $userId])->getEmployeeId();
  3236.             } else {
  3237.                 $empId $data->request->get('employeeId'0);
  3238.                 $sysUserId $data->request->get('userId'0);
  3239.             }
  3240.             $dtTs $data->request->get('timeTs'0);
  3241.             if ($sysUserId == 0)
  3242.                 $sysUserId $userId;
  3243.             if ($sysUserId == 0)
  3244.                 $sysUserId $em->getRepository(Employee::class)
  3245.                     ->findOneBy(['employeeId' => $empId])->getUserId();
  3246.             if ($dtTs == 0) {
  3247.                 $currTsTime = new \DateTime();
  3248.                 $dtTs $currTsTime->format('U');
  3249.             } else {
  3250.                 $currTsTime = new \DateTime('@' $dtTs);
  3251.             }
  3252.             if ($sysUserId == 0)
  3253.                 $sysUserId $userId;
  3254.             if ($sysUserId == 0)
  3255.                 $sysUserId $em->getRepository(Employee::class)
  3256.                     ->findOneBy(['employeeId' => $empId])->getUserId();
  3257.             $today = new \DateTime(date('y-m-d'));
  3258.             $currTsTime->setTimezone(new \DateTimeZone('UTC'));
  3259.             $attDate = new \DateTime($currTsTime->format('Y-m-d') . ' 00:00:00' $timeZoneStr);
  3260.             $EmployeeAttendance $this->getDoctrine()
  3261.                 ->getRepository(EmployeeAttendance::class)
  3262.                 ->findOneBy(array('employeeId' => $empId'date' => $attDate));
  3263.             if (!$EmployeeAttendance)
  3264.                 $EmployeeAttendance = new EmployeeAttendance;
  3265. //            return new JsonResponse(["success" => true, "data" => $ActivitiesTemplate]);
  3266. //            $attendanceInfo = HumanResource::StoreAttendance($em, $empId, $sysUserId, $data, $EmployeeAttendance, $customTime);
  3267.             $attendanceInfo HumanResource::StoreAttendance($em$empId$sysUserId$data$EmployeeAttendance$attDate$dtTs$timeZoneStrHumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED);
  3268.             if (!isset($dataByAttId[$attendanceInfo->getId()]))
  3269.                 $dataByAttId[$attendanceInfo->getId()] = array(
  3270.                     'attendanceInfo' => $attendanceInfo,
  3271.                     'empId' => $empId,
  3272.                     'lat' => 0,
  3273.                     'lng' => 0,
  3274.                     'address' => 0,
  3275.                     'sysUserId' => $sysUserId,
  3276.                     'companyId' => $data->getSession()->get(UserConstants::USER_COMPANY_ID),
  3277.                     'appId' => $data->getSession()->get(UserConstants::USER_APP_ID),
  3278.                     'positionArray' => []
  3279.                 );
  3280.             $posData = array(
  3281.                 'ts' => $dtTs,
  3282.                 'lat' => 0,
  3283.                 'lng' => 0,
  3284.                 'marker' => HumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED,
  3285.                 'src' => 1,
  3286.             );
  3287.             $posDataArray = array(
  3288.                 $dtTs,
  3289.                 0,
  3290.                 0,
  3291.                 HumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED,
  3292.                 1
  3293.             );
  3294.             $dataByAttId[$attendanceInfo->getId()]['markerId'] = HumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED;
  3295.             //this markerId will be calclulted and modified to check if user is in our out of office/workplace later
  3296.             $dataByAttId[$attendanceInfo->getId()]['attendanceInfo'] = $attendanceInfo;
  3297.             $dataByAttId[$attendanceInfo->getId()]['positionArray'][] = $posData;
  3298.             $dataByAttId[$attendanceInfo->getId()]['lat'] = 0;  //for last lat lng etc
  3299.             $dataByAttId[$attendanceInfo->getId()]['lng'] = 0;  //for last lat lng etc
  3300.             if (isset($d['address']))
  3301.                 $dataByAttId[$attendanceInfo->getId()]['address'] = '';  //for last lat lng etc
  3302.             $response = array(
  3303.                 'success' => true
  3304.             );
  3305.             foreach ($dataByAttId as $attInfoId => $d) {
  3306.                 $response HumanResource::setAttendanceLogFlutterApp($em,
  3307.                     $d['empId'],
  3308.                     $d['sysUserId'],
  3309.                     $d['companyId'],
  3310.                     $d['appId'],
  3311.                     $data,
  3312.                     $d['attendanceInfo'],
  3313.                     $options,
  3314.                     $d['positionArray'],
  3315.                     $d['lat'],
  3316.                     $d['lng'],
  3317.                     $d['address'],
  3318.                     $d['markerId']
  3319.                 );
  3320.             }
  3321.             if ($data->request->get('requestFromMobile')) {
  3322.                 return new JsonResponse(array(
  3323.                     'success' => $response['success'] == true true false,
  3324.                     'msg' => $response['success'] == true 'Employee activities successfully updated.' 'Action Failed',
  3325.                 ));
  3326.             }
  3327.             return new JsonResponse(
  3328.                 array(
  3329.                     'success' => true,
  3330.                     'dtTs' => $dtTs,
  3331.                     'attDate' => $attDate->format(DATE_RFC822),
  3332.                     'currTsTime' => $currTsTime->format(DATE_RFC822),
  3333.                     'msg' => 'Employee activities successfully updated.',
  3334.                 )
  3335.             );
  3336. //
  3337. //
  3338. //            $response = HumanResource::setAttendanceLog($em, $empId, $sysUserId,
  3339. //                $data->getSession()->get(UserConstants::USER_COMPANY_ID),
  3340. //                $data->getSession()->get(UserConstants::USER_APP_ID),
  3341. //                $data, $attendanceInfo, $options);
  3342. //
  3343. //            if ($data->request->get('requestFromMobile')) {
  3344. //                return new JsonResponse($response);
  3345. //            }
  3346. //
  3347. //            return new JsonResponse(
  3348. //                array(
  3349. //                    'success' => true,
  3350. //                    'msg' => 'Employee activities successfully updated.'
  3351. //                )
  3352. //            );
  3353.             // }
  3354.             // else {
  3355.             //   return new JsonResponse(
  3356.             //     array(
  3357.             //       'success' => false,
  3358.             //       'msg' => "Invalid employee ID"
  3359.             //     )
  3360.             //   );
  3361.             // }
  3362.         } else {
  3363.             if ($data->get('manualAttendance')) {
  3364.                 return $this->render(
  3365.                     'ApplicationBundle:pages/human_resource/input_forms:manual_attendance.html.twig',
  3366.                     array(
  3367.                         'page_title' => 'Manual Attendance',
  3368.                         'workPolicy' => $workHourPolicy,
  3369. //                        'workTime' => json_decode($workHourPolicy->getRepeatationData()),
  3370. //                        'workTime' => json_decode($workHourPolicy->getRepeatationData()),
  3371. //                        'workTime' => json_decode($workHourPolicy->getEmployeeTypeIds(),true),
  3372.                     )
  3373.                 );
  3374.             }
  3375.             // Show all matching employee list during ajax request
  3376.             // Show current location according to id
  3377.             if ($data->get('getCurrLocById')) {
  3378.                 $Id $data->get("id");
  3379.                 $options = array(
  3380.                     'employeeId' => $Id,
  3381.                     'entityDbaseName' => 'work_hour_policy',
  3382.                     'entityDbaseIdField' => 'id',
  3383.                     'entityDbaseEmployeeIdsField' => 'employeeIds',
  3384.                     'entityDesignationIdsField' => 'designationIds',
  3385.                     'entityDepartmentIdsField' => 'departmentIds',
  3386.                     'entityEmployeeTypeIdsField' => 'employee_types',
  3387.                     'limit' => 1,
  3388.                     'single' => 1,
  3389.                 );
  3390.                 $workHourPolicyData HumanResource::getApplicableSettingsDataForEmployee($em$options);
  3391.                 $today = new \DateTime(date('y-m-d'));
  3392.                 $repository $this->getDoctrine()->getRepository(EmployeeAttendance::class);
  3393.                 $ActivitiesTemplate HumanResource::getActivitiesTemplate($repository$Id$today);
  3394.                 return new JsonResponse(["success" => true"workHourPolicyData" => $workHourPolicyData"template" => $ActivitiesTemplate]);
  3395.             }
  3396.         }
  3397.     }
  3398.     public function getCurrentStatusAction($id)
  3399.     {
  3400.         $today = new \DateTime(date('y-m-d'));
  3401.         $repository $this->getDoctrine()->getRepository(EmployeeAttendance::class);
  3402.         $ActivitiesTemplate HumanResource::getCurrentStatusFromDb($repository$id$today);
  3403.         return new JsonResponse(["success" => true"data" => $ActivitiesTemplate]);
  3404.     }
  3405.     public function CurrentAttendanceAction(Request $data)
  3406.     {
  3407.         $em $this->getDoctrine()->getManager();
  3408.         $options = array(
  3409.             'notification_enabled' => $this->container->getParameter('notification_enabled'),
  3410.             'notification_server' => $this->container->getParameter('notification_server'),
  3411.         );
  3412.         if ($data->get('DataTable')) {
  3413.             $response HumanResource::HandelAjaxRequestForManualAttendance($em$data);
  3414.             return new JsonResponse($response);
  3415.         }
  3416.         if ($data->request->get('getAttendanceStatus')) {
  3417.             $response HumanResource::getAttendanceStatus($em$data);
  3418.             return new JsonResponse($response);
  3419.         }
  3420.         // Auto attendance
  3421.         if ($data->get('autoAttendance')) {
  3422.             $empId $data->query->get('id');
  3423.             $sysUserId 0;
  3424.             if ($data->get('requestFromMobile')) {
  3425.                 $sysUserId $data->request->get('id');
  3426.                 $empId $em->getRepository(Employee::class)
  3427.                     ->findOneBy(['userId' => $sysUserId])->getEmployeeId();
  3428.             } else {
  3429.                 $sysUserId $em->getRepository(Employee::class)
  3430.                     ->findOneBy(['employeeId' => $empId])->getUserId();
  3431.             }
  3432.             $customTime $data->get('time');
  3433.             $today = new \DateTime(date('y-m-d'));
  3434.             $EmployeeAttendance $this->getDoctrine()
  3435.                 ->getRepository(EmployeeAttendance::class)
  3436.                 ->findOneBy(array('employeeId' => $empId'date' => $today));
  3437.             if (!$EmployeeAttendance)
  3438.                 $EmployeeAttendance = new EmployeeAttendance;
  3439.             $attendanceInfo HumanResource::StoreAttendance($em$empId$sysUserId$data$EmployeeAttendance$customTime);
  3440.             $response HumanResource::setAttendanceLog($em$empId$sysUserId,
  3441.                 $data->getSession()->get(UserConstants::USER_COMPANY_ID),
  3442.                 $data->getSession()->get(UserConstants::USER_APP_ID),
  3443.                 $data$attendanceInfo$options);
  3444.             if ($data->get('requestFromMobile')) {
  3445.                 return new JsonResponse([$response]);
  3446.             }
  3447.             return new JsonResponse(
  3448.                 array(
  3449.                     'success' => true,
  3450.                     'msg' => 'Employee activities successfully updated.'
  3451.                 )
  3452.             );
  3453.             // }
  3454.             // else {
  3455.             //   return new JsonResponse(
  3456.             //     array(
  3457.             //       'success' => false,
  3458.             //       'msg' => "Invalid employee ID"
  3459.             //     )
  3460.             //   );
  3461.             // }
  3462.         } else {
  3463.             if ($data->get('manualAttendance')) {
  3464.                 return $this->render(
  3465.                     'ApplicationBundle:pages/human_resource/report:current_attendance.html.twig',
  3466.                     array(
  3467.                         'page_title' => 'Current Attendance Status',
  3468.                     )
  3469.                 );
  3470.             }
  3471.             // Show all matching employee list during ajax request
  3472.             // Show current location according to id
  3473.             if ($data->get('getCurrLocById')) {
  3474.                 $Id $data->get("id");
  3475.                 $today = new \DateTime(date('y-m-d'));
  3476.                 $repository $this->getDoctrine()->getRepository(EmployeeAttendance::class);
  3477.                 $ActivitiesTemplate HumanResource::getActivitiesTemplate($repository$Id$today);
  3478.                 return new JsonResponse(["success" => true"template" => $ActivitiesTemplate]);
  3479.             }
  3480.         }
  3481.     }
  3482.     public function EmployeeLeaveAction(Request $data$id 0)
  3483.     {
  3484.         $em $this->getDoctrine()->getManager();
  3485.         $request $data;
  3486.         if (!$id) {
  3487.             if ($data->isMethod('GET')) {
  3488.                 $EmpID $data->query->get('id');
  3489.                 $LeaveType $data->query->get('leaveType');
  3490.                 if ($data->query->has('id') && $data->query->has('leaveType')) {
  3491.                     $response HumanResource::HandelAjaxRequestForLeaveApp($em$EmpID$LeaveType);
  3492.                     return new JsonResponse($response);
  3493.                 }
  3494.                 if ($data->query->has('id')) {
  3495.                     $Response HumanResource::HandelAjaxRequestForLeaveApp($em$EmpID);
  3496.                     return new JsonResponse($Response);
  3497.                 }
  3498.                 $TemplateData HumanResource::TwigDataForLeaveApp($emFalse);
  3499.                 return $this->render(
  3500.                     'ApplicationBundle:pages/human_resource/input_forms:employee_leave.html.twig',
  3501.                     array(
  3502.                         'page_title' => $TemplateData['Title'],
  3503.                         'EmployeeList' => $TemplateData['EmployeeList'],
  3504.                         'DesignationList' => $TemplateData['DesignationList'],
  3505.                         'HasUpdateMode' => false
  3506.                     )
  3507.                 );
  3508.             } else {
  3509.                 $CompanyId $this->getLoggedUserCompanyId($data);
  3510.                 $Response HumanResource::StoreDataForLeaveApplication($em$id$datafalse$CompanyId);
  3511.                 if ($Response['HasErr']) {
  3512.                     $this->addFlash('error'$Response['msg']);
  3513.                     if ($data->request->has('returnJson')) {
  3514.                         return new JsonResponse(array(
  3515.                             'success' => false,
  3516.                             'errorStr' => $Response['msg'],
  3517.                         ));
  3518.                     } else {
  3519.                         return $this->redirectToRoute('employee_leave');
  3520.                     }
  3521.                 }
  3522.                 $applicationId $Response['applicationId'];
  3523.                 $em_goc $this->getDoctrine()->getManager('company_group');
  3524.                 $file_path_list = [];
  3525.                 if ($applicationId != 0) {
  3526.                     if (!empty($request->files)) {
  3527.                         MiscActions::RemoveFilesForEntityDoc($em_goc'EmployeeLeaveApplication'$applicationId);
  3528.                         $storePath 'uploads/LeaveDoc/';
  3529.                         $path "";
  3530.                         $file_path "";
  3531.                         $session $request->getSession();
  3532.                         MiscActions::RemoveExpiredFiles($em_goc);
  3533.                         foreach ($request->files as $uploadedFileGG) {
  3534.                             //            if($uploadedFile->getImage())
  3535.                             //                var_dump($uploadedFile->getFile());
  3536.                             //                var_dump($uploadedFile);
  3537.                             $tempD $uploadedFileGG;
  3538.                             if (!is_array($uploadedFileGG)) {
  3539.                                 $uploadedFileGG = array();
  3540.                                 $uploadedFileGG[] = $tempD;
  3541.                             }
  3542.                             foreach ($uploadedFileGG as $uploadedFile) {
  3543.                                 if ($uploadedFile != null) {
  3544.                                     $extension $uploadedFile->guessExtension();
  3545.                                     $size $uploadedFile->getSize();
  3546.                                     $fileName 'LDOC_' $applicationId '_' . (md5(uniqid())) . '.' $uploadedFile->guessExtension();
  3547.                                     $path $fileName;
  3548.                                     $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/' $storePath;
  3549.                                     if (!file_exists($upl_dir)) {
  3550.                                         mkdir($upl_dir0777true);
  3551.                                     }
  3552.                                     if (file_exists($upl_dir '' $path)) {
  3553.                                         chmod($upl_dir '' $path0755);
  3554.                                         unlink($upl_dir '' $path);
  3555.                                     }
  3556.                                     $file $uploadedFile->move($upl_dir$path);
  3557.                                     $expireNever 1;
  3558.                                     $expireTs 0;
  3559.                                     $EntityFile = new EntityFile();
  3560.                                     $EntityFile->setPath($this->container->getParameter('kernel.root_dir') . '/../web/' $storePath $path);
  3561.                                     $EntityFile->setMarker('_GEN_');
  3562.                                     $EntityFile->setExtension($extension);
  3563.                                     $EntityFile->setExpireTs($expireTs);
  3564.                                     $EntityFile->setSize($size);
  3565.                                     $EntityFile->setRelativePath($storePath $path);
  3566.                                     $EntityFile->setEntityName('EmployeeLeaveApplication');
  3567.                                     $EntityFile->setEntityBundle('EmployeeLeaveApplication');
  3568.                                     $EntityFile->setEntityId($applicationId);
  3569.                                     $EntityFile->setEntityIdField('employeeLeaveApplicationId');
  3570.                                     $EntityFile->setModifyFieldSetter('setFiles');
  3571.                                     $EntityFile->setDocIdForApplicant(0);
  3572.                                     $EntityFile->setUserId($session->get(UserConstants::USER_ID0));
  3573.                                     $EntityFile->setAppId($session->get(UserConstants::USER_APP_ID0));
  3574.                                     $EntityFile->setEmployeeId($session->get(UserConstants::USER_EMPLOYEE_ID0));
  3575.                                     $EntityFile->setUserType($session->get(UserConstants::USER_TYPE0));
  3576.                                     $em_goc->persist($EntityFile);
  3577.                                     $em_goc->flush();
  3578.                                     $EntityFileId $EntityFile->getId();
  3579.                                 }
  3580.                                 if ($path != "")
  3581.                                     $file_path_list[] = ($storePath $path);
  3582.                             }
  3583.                         }
  3584.                         $g_path $this->container->getParameter('kernel.root_dir') . '/../web/' $storePath $path;
  3585.                         $v $em->getRepository('ApplicationBundle:EmployeeLeaveApplication')->findOneBy(array(
  3586.                             'employeeLeaveApplicationId' => $applicationId,
  3587.                         ));
  3588.                         if ($v) {
  3589.                             $v->setFiles(implode(','$file_path_list));
  3590.                             $em->flush();
  3591.                         } else {
  3592.                         }
  3593.                     }
  3594.                 }
  3595.                 // $this->addFlash('success', 'Application submitted successfully!');
  3596.                 // return $this->redirectToRoute('leave_application_list');
  3597.                 if ($data->request->has('returnJson')) {
  3598.                     return new JsonResponse(array(
  3599.                         'success' => true,
  3600.                     ));
  3601.                 } else {
  3602.                     return $this->redirectToRoute('view_employee_leave_application', array('id' => $applicationId));
  3603.                 }
  3604.             }
  3605.         } else {
  3606.             if ($data->isMethod('GET')) {
  3607.                 $ApplicationRepo $em->getRepository(EmployeeLeaveApplication::class);
  3608.                 $OldData $ApplicationRepo->find(array('employeeLeaveApplicationId' => $id));
  3609.                 $TemplateData HumanResource::TwigDataForLeaveApp($em$OldData);
  3610.                 return $this->render(
  3611.                     'ApplicationBundle:pages/human_resource/input_forms:employee_leave.html.twig',
  3612.                     array(
  3613.                         'page_title' => $TemplateData['Title'],
  3614.                         'EmployeeList' => $TemplateData['EmployeeList'],
  3615.                         'DesignationList' => $TemplateData['DesignationList'],
  3616.                         'OldData' => $TemplateData['OldData'],
  3617.                         'AvailableLeave' => $TemplateData['AvailableLeave'],
  3618.                         'HasUpdateMode' => true
  3619.                     )
  3620.                 );
  3621.             } else {
  3622.                 $CompanyId $this->getLoggedUserCompanyId($data);
  3623.                 $Response HumanResource::StoreDataForLeaveApplication($em$id$datatrue$CompanyId);
  3624.                 if ($Response['HasErr']) {
  3625.                     $this->addFlash('error'$Response['msg']);
  3626.                     return $this->redirectToRoute('employee_leave');
  3627.                 }
  3628.                 $this->addFlash('success'"Application updated successfully!");
  3629.                 return $this->redirectToRoute('leave_application_list');
  3630.             }
  3631.         }
  3632.     }
  3633.     public function ViewLeaveApplicationAction(Request $request$id)
  3634.     {
  3635.         $em $this->getDoctrine()->getManager();
  3636.         if ($id) {
  3637.             $TwigData HumanResource::TwigDataForViewLeaveApplication($em$request$id);
  3638.             if ($TwigData['HasErr']) {
  3639.                 return new JsonResponse(array(
  3640.                     'success' => false,
  3641.                     'msg' => $TwigData['Msg']
  3642.                 ));
  3643.             }
  3644.             return $this->render(
  3645.                 'ApplicationBundle:pages/human_resource/views:leave_application_view.html.twig',
  3646.                 array(
  3647.                     'page_title' => 'View Leave Application',
  3648.                     'Applicant' => $TwigData['Applicant'],
  3649.                     'Application' => $TwigData['Application'],
  3650.                     'LeaveType' => $TwigData['LeaveType'],
  3651.                     'leaveDataArray' => $TwigData['leaveDataArray'],
  3652.                     'LeaveCategory' => $TwigData['LeaveCategory'],
  3653.                     'FrwdEmp' => $TwigData['FrwdEmp'],
  3654.                     'ApplicantDesg' => $TwigData['ApplicantDesg'],
  3655.                     'approval_status' => $TwigData['approval_status'],
  3656.                     'approval_data' => $TwigData['approval_data'],
  3657.                     'document_log' => $TwigData['document_log'],
  3658.                     'auto_created' => 0,
  3659.                 )
  3660.             );
  3661.         }
  3662.         return new JsonResponse(array(
  3663.             'success' => false,
  3664.             'msg' => 'Wrong URL format! Please try with application ID'
  3665.         ));
  3666.     }
  3667.     public function PrintLeaveApplicationAction(Request $request$id)
  3668.     {
  3669.         if ($id) {
  3670.             $em $this->getDoctrine()->getManager();
  3671.             $company_data Company::getCompanyData($em1);
  3672.             $Application $em->getRepository(EmployeeLeaveApplication::class)->find($id);
  3673.             $Authorizations System::getSignatureListForDocumentPrint($emarray_flip(GeneralConstant::$Entity_list)['EmployeeLeaveApplication'], $id);
  3674.             $ApplicationCategory $Application->getLeaveCategory();
  3675.             $ApplicationType '';
  3676.             if (($ApplicationCategory != && $ApplicationCategory != 2))
  3677.                 if (isset($leaveDataArray[$Application->getLeaveTypeId() - 1]))
  3678.                     $ApplicationType $leaveDataArray[$Application->getLeaveTypeId() - 1]['name'];
  3679.             $Applicant $em->getRepository(EmployeeDetails::class)
  3680.                 ->find($Application->getEmployeeId());
  3681.             return $this->render(
  3682.                 'ApplicationBundle:pages/human_resource/print:leave_application_print.html.twig',
  3683.                 array(
  3684.                     'page_title' => 'Print Leave Application',
  3685.                     'export' => 'pdf,print',
  3686.                     'company_name' => $company_data->getName(),
  3687.                     'company_data' => $company_data,
  3688.                     'company_address' => $company_data->getAddress(),
  3689.                     'company_image' => $company_data->getImage(),
  3690.                     'Application' => $Application,
  3691.                     'Applicant' => $Applicant,
  3692.                     'Authorizations' => $Authorizations,
  3693.                     'ApplicationType' => $ApplicationType,
  3694.                     'ApplicationCategory' => $ApplicationCategory,
  3695.                     'red' => 0
  3696.                 )
  3697.             );
  3698.         }
  3699.         return new JsonResponse(array(
  3700.             'success' => false,
  3701.             'msg' => 'Wrong URL format! Please try with application ID'
  3702.         ));
  3703.     }
  3704.     public function LeaveApplicationListAction(Request $request)
  3705.     {
  3706.         $em $this->getDoctrine()->getManager();
  3707.         $response HumanResource::GetEmployeeLeaveApplicationList($em$request);
  3708.         if ($request->isMethod('GET')) {
  3709.             return $this->render("ApplicationBundle:pages/human_resource/list:leave_application_list.html.twig", array(
  3710.                 'page_title' => 'Leave Application List',
  3711.                 'application_data' => $response,
  3712.             ));
  3713.         }
  3714.     }
  3715.     public function PayrollPolicySettingsAction(Request $request$id)
  3716.     {
  3717.         $em $this->getDoctrine()->getManager();
  3718.         $CompanyId $this->getLoggedUserCompanyId($request);
  3719.         if ($id) {
  3720.             if ($request->isMethod('GET')) {
  3721.                 $Row $em->getRepository(PayrollPolicy::class)->find($id);
  3722.                 if (!$Row) {
  3723.                     $this->addFlash('error''Invalid Payroll Policy Id');
  3724.                     return $this->redirectToRoute('payroll_policy_settings');
  3725.                 }
  3726.                 $TwigData HumanResource::GetPayrollPolicyTwigData($em);
  3727.                 $OldData HumanResource::GetPayrollPolicyTwigData($em$id);
  3728.                 return $this->render('ApplicationBundle:pages/human_resource/input_forms:payroll_policy_settings.html.twig', array(
  3729.                     'page_title' => 'Update Payroll Policy Settings',
  3730.                     'EmployeeIds' => $TwigData['EmployeeIds'],
  3731.                     'EmployeeType' => $TwigData['EmployeeType'],
  3732.                     'department' => $TwigData['department'],
  3733.                     'Designation' => $TwigData['Designation'],
  3734.                     'WorkingDays' => $TwigData['WorkingDays'],
  3735.                     'OldData' => $OldData['Row'],
  3736.                     'earningAspects' => HumanResourceConstant::$earningAspectsForPayrollPolicy,
  3737.                     'leaveTypes' => HumanResourceConstant::$LeaveTypeForPayrollPolicy,
  3738.                     'leaveTypesArray' => HumanResourceConstant::$LeaveTypeArrayForPayrollPolicy,
  3739.                     'deductionAspects' => HumanResourceConstant::$deductionAspects,
  3740.                     'deductionCondition' => json_decode($Row->getDeductionCondition(), true),
  3741.                     'HasUpdateMode' => true,
  3742.                 ));
  3743.             } else {
  3744.                 $Response HumanResource::StorePayrollPolicyData($em$id$CompanyId$request);
  3745.                 if ($Response['HasErr']) {
  3746.                     $this->addFlash('error'$Response['msg']);
  3747.                     return $this->redirectToRoute('payroll_policy_settings');
  3748.                 }
  3749.                 return $this->redirectToRoute('payroll_policy_settings');
  3750. //        if ($Response['isSuccess']) {
  3751. //          return new JsonResponse(array('success' => true, 'msg' => 'don\'t forget to redirect'));
  3752. //        }
  3753. //        return new JsonResponse(array('success' => false, 'msg' => 'Sorry something went wrong'));
  3754.             }
  3755.         } else {
  3756.             if ($request->isMethod('GET')) {
  3757.                 if ($request->query->get('GetDocHash')) {
  3758.                     $Dochash HumanResource::GenerateDocHashForPayrollSettings($em$request);
  3759.                     return new JsonResponse($Dochash);
  3760.                 }
  3761.                 $TwigData HumanResource::GetPayrollPolicyTwigData($em);
  3762.                 return $this->render(
  3763.                     'ApplicationBundle:pages/human_resource/input_forms:payroll_policy_settings.html.twig',
  3764.                     array(
  3765.                         'page_title' => 'Create Payroll Policy Settings',
  3766.                         'EmployeeIds' => $TwigData['EmployeeIds'],
  3767.                         'EmployeeType' => $TwigData['EmployeeType'],
  3768.                         'WorkingDays' => $TwigData['WorkingDays'],
  3769.                         'Designation' => $TwigData['Designation'],
  3770.                         'department' => $TwigData['department'],
  3771.                         'earningAspects' => HumanResourceConstant::$earningAspectsForPayrollPolicy,
  3772.                         'leaveTypes' => HumanResourceConstant::$LeaveTypeForPayrollPolicy,
  3773.                         'leaveTypesArray' => HumanResourceConstant::$LeaveTypeArrayForPayrollPolicy,
  3774.                         'deductionAspects' => HumanResourceConstant::$deductionAspects,
  3775.                         'HasUpdateMode' => false
  3776.                     )
  3777.                 );
  3778.             } else {
  3779.                 $Response HumanResource::StorePayrollPolicyData($em$id$CompanyId$request);
  3780.                 if ($Response['HasErr']) {
  3781.                     $this->addFlash('error'$Response['msg']);
  3782.                     return $this->redirectToRoute('payroll_policy_settings');
  3783.                 }
  3784.                 return $this->redirectToRoute('payroll_policy_settings');
  3785. //        return new JsonResponse(array("success" => true, 'msg' => 'Dont forget to redirect!'));
  3786.             }
  3787.         }
  3788.     }
  3789.     public function AttendanceReportAction(Request $request$apiKey 'impose')
  3790.     {
  3791.         $em $this->getDoctrine()->getManager();
  3792.         $attendanceSource HumanResourceConstant::$attendanceSources;
  3793.         $routeName $request->attributes->get('_route');
  3794.         if ($routeName == 'app_get_attendendance_data') {
  3795.             $ReportData HumanResource::GenerateAttendanceReport($em$request$request->get('considerCurrTsIfNoOut'1));
  3796.             $newReports = [];
  3797.             foreach ($ReportData['Reports'] as $gg) {
  3798.                 foreach ($gg as $d) {
  3799.                     $newReports[] = $d;
  3800. //                if(!isset($newReports[$d['id']]))
  3801. //                    $newReports[$d['id']]=array();
  3802. //                    $newReports[$d['id']][]=$d;
  3803.                 }
  3804.             }
  3805.             return new JsonResponse (array(
  3806.                 'attendanceSource' => $attendanceSource,
  3807. //                'Reports' => $ReportData['Reports'],
  3808.                 'Reports' => $newReports,
  3809.                 'from_date' => $ReportData['from_date'],
  3810.                 'to_date' => $ReportData['to_date'],
  3811.                 'report_for' => $ReportData['generated_for'],
  3812.                 'attendance' => $ReportData['attendance'],
  3813.             ));
  3814.         } else {
  3815.             $EmployeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  3816.             $Departments $em->getRepository(SysDepartment::class)->findAll();
  3817.             if ($request->isMethod('GET')) {
  3818.                 return $this->render('ApplicationBundle:pages/human_resource/report:attendance_report.html.twig', array(
  3819.                     'page_title' => 'Attendance Report',
  3820.                     'employes' => $EmployeeIds,
  3821.                     'departments' => $Departments,
  3822.                     'isMethodGet' => true,
  3823.                     'from_date' => '',
  3824.                     'to_date' => '',
  3825.                     'report_for' => '',
  3826.                     'attendance' => [],
  3827.                     'Reports' => [],
  3828.                     'qry' => ''
  3829.                 ));
  3830.             }
  3831.             $ReportData HumanResource::GenerateAttendanceReport($em$request$request->request->get('considerCurrTsIfNoOut'0));
  3832.             if ($request->request->get('returnJson'0) == 1) {
  3833.                 return new JsonResponse($ReportData);
  3834.             }
  3835.             $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') : []));
  3836.             return $this->render('ApplicationBundle:pages/human_resource/report:attendance_report.html.twig', array(
  3837.                 'page_title' => 'Attendance Report',
  3838.                 'isMethodGet' => false,
  3839.                 'departments' => $Departments,
  3840.                 'employes' => $EmployeeIds,
  3841.                 'attendanceSource' => $attendanceSource,
  3842.                 'Reports' => $ReportData['Reports'],
  3843.                 'from_date' => $ReportData['from_date'],
  3844.                 'to_date' => $ReportData['to_date'],
  3845.                 'report_for' => $ReportData['generated_for'],
  3846.                 'attendance' => $ReportData['attendance'],
  3847.                 'qry' => $Qry
  3848.             ));
  3849.         }
  3850.     }
  3851.     public function PrintAttendanceReportAction(Request $request)
  3852.     {
  3853.         $em $this->getDoctrine()->getManager();
  3854.         $company_data Company::getCompanyData($em1);
  3855.         $ReportData HumanResource::GenerateAttendanceReport($em$request);
  3856.         return $this->render(
  3857.             'ApplicationBundle:pages/human_resource/print:print_attendance_report.html.twig',
  3858.             array(
  3859.                 'page_title' => 'Print Attendance Report',
  3860.                 'export' => 'pdf,print',
  3861.                 'company_name' => $company_data->getName(),
  3862.                 'company_data' => $company_data,
  3863.                 'company_address' => $company_data->getAddress(),
  3864.                 'company_image' => $company_data->getImage(),
  3865.                 'Reports' => $ReportData['Reports'],
  3866.                 'from_date' => $ReportData['from_date'],
  3867.                 'to_date' => $ReportData['to_date'],
  3868.                 'report_for' => $ReportData['generated_for'],
  3869.                 'attendance' => $ReportData['attendance'],
  3870.                 'red' => 0
  3871.             )
  3872.         );
  3873.     }
  3874.     public function SalaryReportAction(Request $request)
  3875.     {
  3876.         $em $this->getDoctrine()->getManager();
  3877.         $startDate $request->get('salary_start_date''');
  3878.         $endDate $request->get('salary_till_date''');
  3879.         $segregationType $request->get('segregationType'1);
  3880.         $filterBranchIds $request->get('branchIds', []);
  3881.         $filterBankIds $request->get('bankIds', []);
  3882.         $approvalFilterTypes $request->get('approvalFilterTypes', []);
  3883.         $filterDepartmentIds $request->get('departmentIds', []);
  3884.         $filterEmployeeIds $request->get('employeeIds', []);
  3885.         $Departments $em->getRepository(SysDepartment::class)->findAll();
  3886.         $attendance $em->getRepository(EmployeeAttendanceLog::class)->findAll();
  3887.         $banks $em->getRepository(BankList::class)->findAll();
  3888.         $branches $em->getRepository(Branch::class)->findAll();
  3889.         $SalaryReports HumanResource::GenerateSalaryReport($em$request);
  3890. //        dump($SalaryReports);
  3891.         $Qry "salary_till_date=" $endDate '&' "departmentIds=" implode(','$filterDepartmentIds) . '&' "employeeIds=" implode(','$filterEmployeeIds) .
  3892.             '&' "salary_start_date=" $startDate .
  3893.             '&' "segregationType=" $segregationType .
  3894.             '&' "branchIds=" implode(','$filterBranchIds) .
  3895.             '&' "bankIds=" implode(','$filterBankIds);
  3896. //        if ($request->get('returnJson', 0) == 1) {
  3897.         if ($request->get('returnJson'0) == 1) {
  3898.             return new JsonResponse(array(
  3899.                 'SalaryReports' => $SalaryReports,
  3900.             ));
  3901.         } else {
  3902.             return $this->render('ApplicationBundle:pages/human_resource/report:salary_report.html.twig', array(
  3903.                 'page_title' => 'Salary Report',
  3904.                 'departments' => $Departments,
  3905.                 'branches' => $branches,
  3906.                 'banks' => $banks,
  3907.                 'approvalFilterTypes' => $approvalFilterTypes,
  3908.                 'salaryInfo' => $SalaryReports,
  3909.                 'SalaryReports' => $SalaryReports,
  3910.                 'for_month' => '',
  3911.                 'from_date' => $startDate,
  3912.                 'to_date' => $endDate,
  3913.                 'Qry' => $Qry,
  3914.                 'isMethodGet' => false,
  3915.                 'startDate' => $startDate,
  3916.                 'endDate' => $endDate,
  3917.                 'segregationType' => $segregationType,
  3918.                 'filterBranchIds' => $filterBranchIds,
  3919.                 'filterBankIds' => $filterBankIds,
  3920.                 'filterDepartmentIds' => $filterDepartmentIds,
  3921.                 'filterEmployeeIds' => $filterEmployeeIds,
  3922.             ));
  3923.         }
  3924.     }
  3925.     public function DisburseSalaryAction(Request $request)
  3926.     {
  3927.         $em $this->getDoctrine()->getManager();
  3928.         $EmployeeIds $em->getRepository(EmployeeDetails::class)->findBy(
  3929.             array(
  3930.                 'emp_status' => 1
  3931.             )
  3932.         );
  3933.         $startDate $request->get('salary_start_date''');
  3934.         $endDate $request->get('salary_till_date''');
  3935.         $filterType $request->get('filterType'1);
  3936.         $filterBranchIds $request->get('branchIds', []);
  3937.         $filterBankIds $request->get('bankIds', []);
  3938.         $filterDepartmentIds $request->get('departmentIds', []);
  3939.         $filterEmployeeIds $request->get('employeeIds', []);
  3940.         $Departments $em->getRepository(SysDepartment::class)->findAll();
  3941.         $attendance $em->getRepository(EmployeeAttendanceLog::class)->findAll();
  3942.         $banks $em->getRepository(BankList::class)->findAll();
  3943.         $branches $em->getRepository(Branch::class)->findAll();
  3944.         if ($request->isMethod('GET')) {
  3945.             return $this->render('ApplicationBundle:pages/human_resource/report:disburse_salary.html.twig', array(
  3946.                 'page_title' => 'Disburse Salary',
  3947.                 'EmployeeIds' => $EmployeeIds,
  3948.                 'departments' => $Departments,
  3949.                 'attendance' => $attendance,
  3950.                 'branches' => $branches,
  3951.                 'banks' => $banks,
  3952.                 'SalaryReports' => [],
  3953.                 'from_date' => '',
  3954.                 'to_date' => '',
  3955.                 'Qry' => '',
  3956.                 'isMethodGet' => true,
  3957.                 'filterType' => $filterType,
  3958.                 'startDate' => $startDate,
  3959.                 'endDate' => $endDate,
  3960.                 'filterBranchIds' => $filterBranchIds,
  3961.                 'filterBankIds' => $filterBankIds,
  3962.                 'filterDepartmentIds' => $filterDepartmentIds,
  3963.                 'filterEmployeeIds' => $filterEmployeeIds,
  3964.             ));
  3965.         }
  3966.         $SalaryReports HumanResource::BasicDeduction($em$request);
  3967. //        $SalaryReportsNew = HumanResource::calculateSalary($em,
  3968. //            array(
  3969. //                'startDate' => $request->get('salary_start_date', ''),
  3970. //                'endDate' => $request->get('salary_end_date', ''),
  3971. //                'timeZone' => $request->get('time_zone', '+0600'),
  3972. //                'employeeIds' => $request->get('employeeIds', []),
  3973. //                'departmentIds' => $request->get('department', []),
  3974. //                'allFlag' => $request->get('show_all', 0),
  3975. //
  3976. //            )
  3977. //        );
  3978.         $Qry "salary_till_date=" $endDate '&' "departmentIds=" implode(','$filterDepartmentIds) . '&' "employeeIds=" implode(','$filterEmployeeIds) .
  3979.             '&' "salary_start_date=" $startDate .
  3980.             '&' "filterType=" $filterType .
  3981.             '&' "branchIds=" implode(','$filterBranchIds) .
  3982.             '&' "bankIds=" implode(','$filterBankIds);
  3983. //        if ($request->get('returnJson', 0) == 1) {
  3984.         if ($request->get('returnJson'0) == 1) {
  3985.             return new JsonResponse(array(
  3986.                 'SalaryReports' => $SalaryReports,
  3987.             ));
  3988.         } else {
  3989.             return $this->render('ApplicationBundle:pages/human_resource/report:disburse_salary.html.twig', array(
  3990.                 'page_title' => 'Disburse Salary',
  3991.                 'EmployeeIds' => $EmployeeIds,
  3992.                 'departments' => $Departments,
  3993.                 'branches' => $branches,
  3994.                 'banks' => $banks,
  3995.                 'SalaryReports' => $SalaryReports,
  3996.                 'for_month' => $SalaryReports[0]['for_month'],
  3997.                 'from_date' => $SalaryReports[0]['from_date'],
  3998.                 'to_date' => $SalaryReports[0]['to_date'],
  3999.                 'Qry' => $Qry,
  4000.                 'isMethodGet' => false,
  4001.                 'startDate' => $startDate,
  4002.                 'endDate' => $endDate,
  4003.                 'filterType' => $filterType,
  4004.                 'filterBranchIds' => $filterBranchIds,
  4005.                 'filterBankIds' => $filterBankIds,
  4006.                 'filterDepartmentIds' => $filterDepartmentIds,
  4007.                 'filterEmployeeIds' => $filterEmployeeIds,
  4008.             ));
  4009.         }
  4010.     }
  4011.     public function PrintDisburseSalaryAction(Request $Req)
  4012.     {
  4013.         $em $this->getDoctrine()->getManager();
  4014.         $company_data Company::getCompanyData($em1);
  4015.         $SalaryReports HumanResource::BasicDeduction($em$Req);
  4016.         return $this->render(
  4017.             'ApplicationBundle:pages/human_resource/print:print_disburse_salary.html.twig',
  4018.             array(
  4019.                 'page_title' => 'Print Disburse Salary',
  4020.                 'export' => 'pdf,print',
  4021.                 'company_name' => $company_data->getName(),
  4022.                 'company_data' => $company_data,
  4023.                 'company_address' => $company_data->getAddress(),
  4024.                 'company_image' => $company_data->getImage(),
  4025.                 'SalaryReports' => $SalaryReports,
  4026.                 'for_month' => $SalaryReports[0]['for_month'],
  4027.                 'from_date' => $SalaryReports[0]['from_date'],
  4028.                 'to_date' => $SalaryReports[0]['to_date'],
  4029.                 'red' => 0
  4030.             )
  4031.         );
  4032.     }
  4033.     public function createJobRecruitmentAction(Request $request$id 0)
  4034.     {
  4035.         $data = [];
  4036.         $em_goc $this->getDoctrine()->getManager('company_group');
  4037.         $skillDetails $em_goc->getRepository(EntitySkill::class)->findAll();
  4038.         $em $this->getDoctrine()->getManager();
  4039.         $companyId $this->getLoggedUserCompanyId($request);
  4040.         if ($request->isMethod('POST')) {
  4041.             $em $this->getDoctrine()->getManager();
  4042.             $entity_id array_flip(GeneralConstant::$Entity_list)['JobRecruitment']; //change
  4043.             $dochash $request->request->get('docHash'); //change
  4044.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  4045.             $approveRole $request->request->get('approvalRole');
  4046.             $approveHash $request->request->get('approvalHash');
  4047.             if (!DocValidation::isInsertable($em$entity_id$dochash,
  4048.                 $loginId$approveRole$approveHash$id)
  4049.             ) {
  4050.                 $this->addFlash(
  4051.                     'error',
  4052.                     'Sorry Could not insert Data.'
  4053.                 );
  4054.             } else {
  4055.                 $data $request->request;
  4056.                 $docId HumanResource::createJobRecruitment($em$loginId$id$data$companyId);
  4057.                 //now add Approval info
  4058.                 $approveRole $request->request->get('approvalRole');
  4059.                 $options = array(
  4060.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  4061.                     'notification_server' => $this->container->getParameter('notification_server'),
  4062.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  4063.                     'url' => $this->generateUrl(
  4064.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['JobRecruitment']]
  4065.                         ['entity_view_route_path_name']
  4066.                     )
  4067.                 );
  4068.                 System::setApprovalInfo($this->getDoctrine()->getManager(), $options,
  4069.                     array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  4070.                     $docId,
  4071.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)    //journal voucher
  4072.                 );
  4073.                 System::createEditSignatureHash($this->getDoctrine()->getManager(), array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  4074.                     $docId,
  4075.                     $loginId,
  4076.                     $approveRole,
  4077.                     $request->request->get('approvalHash'));
  4078.                 $this->addFlash(
  4079.                     'success',
  4080.                     'New Recruitment Document Added.'
  4081.                 );
  4082.                 $url $this->generateUrl(
  4083.                     'view_job_recruitment'
  4084.                 );
  4085.                 return $this->redirect($url "/" $docId);
  4086.             }
  4087.         }
  4088.         if ($id == 0) {
  4089.         } else {
  4090.             $extDoc $em->getRepository('ApplicationBundle:JobRecruitment')->findOneBy(
  4091.                 array(
  4092.                     'jobRecruitmentId' => $id///material
  4093.                 )
  4094.             );
  4095.             //now if its not editable, redirect to view
  4096.             if ($extDoc) {
  4097.                 if ($extDoc->getEditFlag() != 1) {
  4098.                     $url $this->generateUrl(
  4099.                         'view_job_recruitment'
  4100.                     );
  4101.                     return $this->redirect($url "/" $id);
  4102.                 }
  4103.             }
  4104.         }
  4105.         $jobType HumanResourceConstant::$employeeType;
  4106.         //$skillDetails = $em->getRepository(Skill::class)->findAll();
  4107.         $educationDetails $em->getRepository('ApplicationBundle:EducationQualification')->findAll();
  4108.         $employeeIds $em->getRepository('ApplicationBundle:Employee')->findAll();
  4109.         $location HumanResourceConstant::$location;
  4110.         $salaryPer HumanResourceConstant::$salaryPer;
  4111.         $workExperience HumanResourceConstant::$workExperience;
  4112.         $jobOpeningStatus HumanResourceConstant::$jobOpeningStatus;
  4113.         $compatibility HumanResourceConstant::$compatibility;
  4114.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_new_job_post.html.twig', [
  4115.             'page_title' => 'Create New Job Post',
  4116.             'jobType' => $jobType,
  4117.             'skillDetails' => $skillDetails,
  4118.             'educationDetails' => $educationDetails,
  4119.             'employeeIds' => $employeeIds,
  4120.             'location' => $location,
  4121.             'salaryPer' => $salaryPer,
  4122.             'workExperience' => $workExperience,
  4123.             'jobOpeningStatus' => $jobOpeningStatus,
  4124.             'compatibility' => $compatibility
  4125.         ]);
  4126.     }
  4127.     public function viewApplicantInfoAction(Request $request$id)
  4128.     {
  4129.         $em $this->getDoctrine()->getManager('company_group');
  4130.         //$session = $request->getSession();
  4131.         $consultantDetails $em->getRepository(EntityApplicantDetails::class)->find($id);
  4132.         $skillDetails $em->getRepository('CompanyGroupBundle:EntitySkill')->findAll();
  4133.         //$companyId = $this->getLoggedUserCompanyId($request);
  4134.         $gender HumanResourceConstant::$sex;
  4135.         $blood HumanResourceConstant::$BloodGroup;
  4136.         //$userId = $session->get(UserConstants::USER_ID);
  4137.         return $this->render('ApplicationBundle:pages/human_resource/views:view_applicant_info.html.twig', [
  4138.             'page_title' => 'Applicant Information',
  4139.             'gender' => $gender,
  4140.             'blood' => $blood,
  4141.             'consultantDetails' => $consultantDetails,
  4142.             'education' => json_decode($consultantDetails->getEducationData(), true),
  4143.             'workExperience' => json_decode($consultantDetails->getWorkExperienceData(), true),
  4144.             'certificate' => json_decode($consultantDetails->getCertificateData(), true),
  4145.             'courses' => json_decode($consultantDetails->getCoursesData(), true),
  4146.             'languages' => json_decode($consultantDetails->getLanguagesData(), true),
  4147.             'skillDetails' => $skillDetails
  4148.         ]);
  4149.     }
  4150.     public function ListJobRecruitmentAction()
  4151.     {
  4152.         $em $this->getDoctrine()->getManager();
  4153.         $jobRecruitmentList = [];
  4154.         $jobRecruitments $em->getRepository('ApplicationBundle:JobRecruitment')->findAll();
  4155.         foreach ($jobRecruitments as $jobRecruitment) {
  4156.             $jobData = array(
  4157.                 'jobRecruitmentId' => $jobRecruitment->getJobRecruitmentId(),
  4158.                 'title' => $jobRecruitment->getTitle(),
  4159.                 'date' => $jobRecruitment->getDate(),
  4160.                 'jobOpeningStatus' => $jobRecruitment->getJobOpeningStatus(),
  4161.                 'applicationOpeningDate' => $jobRecruitment->getApplicationOpeningDate(),
  4162.                 'applicationClosingDate' => $jobRecruitment->getApplicationClosingDate(),
  4163.             );
  4164.             $jobRecruitmentList[] = $jobData;
  4165.         }
  4166.         return $this->render('ApplicationBundle:pages/human_resource/list:job_recruitment_list.html.twig', [
  4167.             'page_title' => 'Job RecruitmentAction List',
  4168.             'jobRecruitments' => $jobRecruitmentList
  4169.         ]);
  4170.     }
  4171.     public function ViewJobRecruitmentAction(Request $request$id 0)
  4172.     {
  4173.         $em_goc $this->getDoctrine()->getManager('company_group');
  4174.         $skillDetails $em_goc->getRepository('CompanyGroupBundle:EntitySkill')->findAll();
  4175.         $em $this->getDoctrine()->getManager();
  4176.         $companyId $this->getLoggedUserCompanyId($request);
  4177.         $company_data Company::getCompanyData($em$companyId);
  4178. //        return new JsonResponse($encryptedDataArray);
  4179.         $location HumanResourceConstant::$location;
  4180.         $salaryPer HumanResourceConstant::$salaryPer;
  4181.         $workExperience HumanResourceConstant::$workExperience;
  4182.         $jobOpeningStatus HumanResourceConstant::$jobOpeningStatus;
  4183.         $compatibility HumanResourceConstant::$compatibility;
  4184.         $jobType HumanResourceConstant::$employeeType;
  4185.         $educationDetail $em->getRepository(EducationQualification::class)->findAll();
  4186.         $jobRecruitments $em->getRepository('ApplicationBundle:JobRecruitment')->find($id);
  4187.         $em_goc $this->getDoctrine()->getManager('company_group');
  4188.         $applicantApplicationList $em_goc->getRepository("CompanyGroupBundle:EntityApplicantApplicationList")->findBy(
  4189.             array(
  4190.                 'jobPostId' => $id,
  4191.                 'CompanyId' => $companyId,
  4192.                 'appId' => $company_data->getAppId()
  4193.             )
  4194.         );
  4195.         $applicantIdList = [];
  4196.         foreach ($applicantApplicationList as $dt) {
  4197.             $applicantIdList[] = $dt->getApplicantId();
  4198.         }
  4199.         $applicantList ApplicantM::getApplicantList($em_goc$applicantIdList);
  4200.         $Approval_data = [
  4201.             'exists' => 0,
  4202.             'approvalId' => 0,
  4203.             'roleType' => 0,
  4204.             'required' => 0,
  4205.             'acted' => 0,
  4206.             'entity' => array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  4207.             'entityId' => $id,
  4208.         ];
  4209.         if (in_array($request->getSession()->get(UserConstants::USER_TYPE), [125]))
  4210.             $Approval_data System::checkIfApprovalExists(
  4211.                 $em,
  4212.                 array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  4213.                 $id,
  4214.                 $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  4215.             );
  4216.         return $this->render('ApplicationBundle:pages/human_resource/views:view_job_recruitment.html.twig', [
  4217.             'page_title' => 'View Job RecruitmentAction',
  4218.             'jobRecruitments' => $jobRecruitments,
  4219.             'applicantApplicationList' => $applicantApplicationList,
  4220.             'applicantList' => $applicantList,
  4221. //            'encryptedData' => $encryptedData,
  4222.             'skills' => json_decode($jobRecruitments->getskills()),
  4223.             'skillDetails' => $skillDetails,
  4224.             'education' => json_decode($jobRecruitments->getEducations()),
  4225.             'educationDetails' => $educationDetail,
  4226.             'location' => $location,
  4227.             'salaryPer' => $salaryPer,
  4228.             'workExperience' => $workExperience,
  4229.             'jobType' => $jobType,
  4230.             'compatibility' => $compatibility,
  4231.             'approval_status' => $jobRecruitments->getApproved(),
  4232.             'jobOpeningStatus' => $jobOpeningStatus,
  4233.             'approval_data' => $Approval_data,
  4234.             'auto_created' => $jobRecruitments->getAutocreated(),
  4235.             'document_log' => $jobRecruitments->getAutocreated() == System::getDocumentLog(
  4236.                 $em,
  4237.                 array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  4238.                 $id,
  4239.                 $jobRecruitments->getCreatedLoginId(),
  4240.                 $jobRecruitments->getEditedLoginId()
  4241.             ) : []
  4242.         ]);
  4243.     }
  4244.     public function ViewApplicantScheduleAction(Request $request$id 0)
  4245.     {
  4246.         $em $this->getDoctrine()->getManager();
  4247.         $companyId $this->getLoggedUserCompanyId($request);
  4248.         $company_data Company::getCompanyData($em$companyId);
  4249.         $em_goc $this->getDoctrine()->getManager('company_group');
  4250.         $applicantApplicationList $em_goc->getRepository("CompanyGroupBundle:EntityApplicantApplicationList")->findBy(
  4251.             array(
  4252.                 'jobPostId' => $id,
  4253.                 'CompanyId' => $companyId,
  4254.                 'appId' => $company_data->getAppId()
  4255.             )
  4256.         );
  4257.         $applicantIdList = [];
  4258.         foreach ($applicantApplicationList as $dt) {
  4259.             $applicantIdList[] = $dt->getApplicantId();
  4260.         }
  4261.         $applicantList ApplicantM::getApplicantList($em_goc$applicantIdList);
  4262.         return $this->render('ApplicationBundle:pages/human_resource/views:view_applicant_scheduled.html.twig', [
  4263.             'page_title' => 'View Applicant Scheduled',
  4264.             'applicantApplicationList' => $applicantApplicationList,
  4265.             'applicantList' => $applicantList,
  4266.         ]);
  4267.     }
  4268.     public function ViewApplicantReportAction(Request $request$id 0)
  4269.     {
  4270.         $em $this->getDoctrine()->getManager();
  4271.         $companyId $this->getLoggedUserCompanyId($request);
  4272.         $company_data Company::getCompanyData($em$companyId);
  4273.         $em_goc $this->getDoctrine()->getManager('company_group');
  4274.         $applicantApplicationList $em_goc->getRepository("CompanyGroupBundle:EntityApplicantApplicationList")->findBy(
  4275.             array(
  4276.                 'jobPostId' => $id,
  4277.                 'CompanyId' => $companyId,
  4278.                 'appId' => $company_data->getAppId()
  4279.             )
  4280.         );
  4281.         $applicantIdList = [];
  4282.         foreach ($applicantApplicationList as $dt) {
  4283.             $applicantIdList[] = $dt->getApplicantId();
  4284.         }
  4285.         $applicantList ApplicantM::getApplicantList($em_goc$applicantIdList);
  4286.         return $this->render('ApplicationBundle:pages/human_resource/views:view_applicant_report.html.twig', [
  4287.             'page_title' => 'View Applicant Report',
  4288.             'applicantApplicationList' => $applicantApplicationList,
  4289.             'applicantList' => $applicantList,
  4290.         ]);
  4291.     }
  4292.     public function createEmployeePerformanceEvaluationAction(Request $request$id 0)
  4293.     {
  4294.         $data = [];
  4295.         $em $this->getDoctrine()->getManager();
  4296.         $companyId $this->getLoggedUserCompanyId($request);
  4297.         if ($request->isMethod('POST')) {
  4298.             $em $this->getDoctrine()->getManager();
  4299.             $entity_id array_flip(GeneralConstant::$Entity_list)['EmployeePerformanceEvolution']; //change
  4300.             $dochash $request->request->get('docHash'); //change
  4301.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  4302.             $approveRole $request->request->get('approvalRole');
  4303.             $approveHash $request->request->get('approvalHash');
  4304.             if (!DocValidation::isInsertable($em$entity_id$dochash,
  4305.                 $loginId$approveRole$approveHash$id)
  4306.             ) {
  4307.                 $this->addFlash(
  4308.                     'error',
  4309.                     'Sorry Could not insert Data.'
  4310.                 );
  4311.             } else {
  4312.                 $data $request->request;
  4313.                 $docId HumanResource::createEmployeePerformanceEvaluation($em$loginId$id$data$companyId);
  4314.                 //now add Approval info
  4315.                 $approveRole $request->request->get('approvalRole');
  4316.                 $options = array(
  4317.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  4318.                     'notification_server' => $this->container->getParameter('notification_server'),
  4319.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  4320.                     'url' => $this->generateUrl(
  4321.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['EmployeePerformanceEvolution']]
  4322.                         ['entity_view_route_path_name']
  4323.                     )
  4324.                 );
  4325.                 System::setApprovalInfo($this->getDoctrine()->getManager(), $options,
  4326.                     array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  4327.                     $docId,
  4328.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)    //journal voucher
  4329.                 );
  4330.                 System::createEditSignatureHash($this->getDoctrine()->getManager(), array_flip(GeneralConstant::$Entity_list)['EmployeePerformanceEvolution'],
  4331.                     $docId,
  4332.                     $loginId,
  4333.                     $approveRole,
  4334.                     $request->request->get('approvalHash'));
  4335.                 $this->addFlash(
  4336.                     'success',
  4337.                     'New Recruitment Document Added.'
  4338.                 );
  4339.                 $url $this->generateUrl(
  4340.                     'view_employee_performance_evolution'
  4341.                 );
  4342.                 return $this->redirect($url "/" $docId);
  4343.             }
  4344.         }
  4345.         $skill $em->getRepository(Skill::class)->findAll();
  4346.         $educationDetail $em->getRepository(EducationQualification::class)->findAll();
  4347.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  4348.         $employeeType HumanResourceConstant::$employeeType;
  4349.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  4350.         $branch $em->getRepository(Branch::class)->findAll();
  4351.         $departments $em->getRepository(SysDepartment::class)->findAll();
  4352.         $department = [];
  4353.         foreach ($departments as $entry) {
  4354.             $department[$entry->getDepartmentId()] = array(
  4355.                 'id' => $entry->getDepartmentId(),
  4356.                 'name' => $entry->getDepartmentName(),
  4357.             );
  4358.         }
  4359.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:employee_performance_evolution.html.twig',
  4360.             array(
  4361.                 'page_title' => 'Create Employee Performance Evaluation',
  4362.                 'employeeIds' => $employeeIds,
  4363.                 'employeeType' => $employeeType,
  4364.                 'Designation' => $Designation,
  4365.                 'branch' => $branch,
  4366.                 'department' => $department,
  4367.                 'skill' => $skill,
  4368.                 'educationDetail' => $educationDetail
  4369.             )
  4370.         );
  4371.     }
  4372.     public function ViewIndividualReviewAction()
  4373.     {
  4374.         return $this->render('ApplicationBundle:pages/human_resource/views:individual_review.html.twig',
  4375.             array(
  4376.                 'page_title' => 'Individual Performance View',
  4377.             )
  4378.         );
  4379.     }
  4380.     public function EmployeeListBySkillPerformanceAction()
  4381.     {
  4382.         $em $this->getDoctrine()->getManager();
  4383.         $employee $em->getRepository('ApplicationBundle:EmployeeDetails')->findAll();
  4384.         $skill $em->getRepository('ApplicationBundle:Skill')->findAll();
  4385.         return $this->render('ApplicationBundle:pages/human_resource/list:employee_performance_evolution_list.html.twig',
  4386.             array(
  4387.                 'page_title' => 'Employee Skill & Performance',
  4388.                 'employee' => $employee,
  4389.                 //'employeeSkill' => json_decode($employee->getSkill(),true),
  4390.                 'skill' => $skill,
  4391.             )
  4392.         );
  4393.     }
  4394.     public function setWorkPlaceAction(Request $req)
  4395.     {
  4396.         $em $this->getDoctrine()->getManager();
  4397.         $companyId $this->getLoggedUserCompanyId($req);
  4398.         $docHash '';
  4399.         if ($req->request->has('XHRreq')) {
  4400.             $docHash HumanResource::HandelXHRreqForEmpWorkplace($em$req);
  4401.             return new JsonResponse([$docHash]);
  4402.         }
  4403.         if ($req->isMethod('GET')) {
  4404.             $TwigData HumanResource::TwigDataForEmployeeWorkplace($em);
  4405.             return $this->render(
  4406.                 'ApplicationBundle:pages/human_resource/input_forms:update_workplace.html.twig',
  4407.                 [
  4408.                     'page_title' => 'Set Workplace',
  4409.                     'employeeIds' => $TwigData['employeeIds']
  4410.                 ]
  4411.             );
  4412.         }
  4413.         if ($req->isMethod('POST')) {
  4414.             $approveHash $req->request->get('approvalHash');
  4415.             $loginId $req->getSession()->get(UserConstants::USER_LOGIN_ID);
  4416.             $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  4417.             if ($isSignatureOk) {
  4418.                 $isSuccess HumanResource::CreateOrUpdateForEmpWorkplace($em$req$companyIdfalse$docHash);
  4419.                 if ($isSuccess) {
  4420.                     $this->addFlash(
  4421.                         'success',
  4422.                         'Workplace set!'
  4423.                     );
  4424.                     return $this->redirectToRoute('set_workplace');
  4425.                 }
  4426.             } else {
  4427.                 $this->addFlash(
  4428.                     'error',
  4429.                     'Invalid Approval Hash!'
  4430.                 );
  4431.                 return $this->redirectToRoute('set_workplace');
  4432.             }
  4433.         }
  4434.     }
  4435.     public function setWorkPlaceForAppAction(Request $req)
  4436.     {
  4437.         $em $this->getDoctrine()->getManager();
  4438.         $companyId $this->getLoggedUserCompanyId($req);
  4439.         $docHash HumanResource::HandelXHRreqForEmpWorkplace($em$req);
  4440.         if ($req->isMethod('GET')) {
  4441.             $TwigData HumanResource::TwigDataForEmployeeWorkplace($em);
  4442.             return $this->render(
  4443.                 'ApplicationBundle:pages/human_resource/input_forms:update_workplace.html.twig',
  4444.                 [
  4445.                     'page_title' => 'Set Workplace',
  4446.                     'employeeIds' => $TwigData['employeeIds']
  4447.                 ]
  4448.             );
  4449.         }
  4450.         if ($req->isMethod('POST')) {
  4451.             $approveHash $req->request->get('approvalHash');
  4452.             $loginId $req->getSession()->get(UserConstants::USER_LOGIN_ID);
  4453.             $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  4454.             if ($isSignatureOk) {
  4455.                 $isSuccess HumanResource::CreateOrUpdateForEmpWorkplace($em$req$companyIdfalse$docHash);
  4456.                 if ($isSuccess) {
  4457.                     $this->addFlash(
  4458.                         'success',
  4459.                         'Workplace set!'
  4460.                     );
  4461. //                    return $this->redirectToRoute('set_workplace');
  4462.                     return new JsonResponse(array(
  4463.                         "success" => true
  4464.                     ));
  4465.                 }
  4466.             } else {
  4467.                 $this->addFlash(
  4468.                     'error',
  4469.                     'Invalid Approval Hash!'
  4470.                 );
  4471. //                return $this->redirectToRoute('set_workplace');
  4472.             }
  4473.         }
  4474.     }
  4475.     public function ViewMeetingAction(Request $req$action 0$id 0)
  4476.     {
  4477.         $em $this->getDoctrine()->getManager();
  4478.         $companyId $this->getLoggedUserCompanyId($req);
  4479.         if ($req->request->has('XHRreq')) {
  4480.             return new JsonResponse([HumanResource::HandelXHRreqForMeetingScheduling($em$req)]);
  4481.         }
  4482.         if ($action === 'view') {
  4483.             $response HumanResource::TwigDataForScheduledMeetingView($em$req$id);
  4484.             return $this->render(
  4485.                 'ApplicationBundle:pages/human_resource/views:scheduled_meeting_view.html.twig',
  4486.                 [
  4487.                     'page_title' => 'View Scheduled Meeting',
  4488.                     'duration' => $response['duration'],
  4489.                     'appId' => $response['appId'],
  4490.                     'publicView' => 0,
  4491.                     'meeting_data' => $response['meeting_data'],
  4492.                     'agenda_list' => $response['agenda_list'],
  4493.                     'id' => $req->query->get('view_meeting'),
  4494.                     'approval_data' => $response['approval_data'],
  4495.                     'document_log' => $response['document_log'],
  4496.                     'approval_status' => $response['approval_status'],
  4497.                     'created_by' => $response['created_by'],
  4498.                     'updated_at' => $response['updated_at'],
  4499.                     'auto_created' => 0,
  4500.                 ]
  4501.             );
  4502.         }
  4503.         if ($action === 'print') {
  4504.             $response HumanResource::TwigDataForScheduledMeetingView($em$req$id);
  4505. //      $id = $req->query->get('print_meeting');
  4506.             $em $this->getDoctrine()->getManager();
  4507.             $company_data Company::getCompanyData($em1);
  4508.             $Authorizations System::getSignatureListForDocumentPrint($emarray_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'], $id);
  4509.             return $this->render(
  4510.                 'ApplicationBundle:pages/human_resource/print:scheduled_meeting_print.html.twig',
  4511.                 array(
  4512.                     'page_title' => 'View Scheduled Meeting',
  4513.                     'duration' => $response['duration'],
  4514.                     'meeting_data' => $response['meeting_data'],
  4515.                     'agenda_list' => $response['agenda_list'],
  4516.                     'export' => 'pdf,print',
  4517.                     'company_name' => $company_data->getName(),
  4518.                     'company_data' => $company_data,
  4519.                     'company_address' => $company_data->getAddress(),
  4520.                     'company_image' => $company_data->getImage(),
  4521.                     'Authorizations' => $Authorizations,
  4522.                     'red' => 0
  4523.                 )
  4524.             );
  4525.         }
  4526.     }
  4527.     public function UpdateMeetingMinutesAction(Request $req$action 0$id 0)
  4528.     {
  4529.         $em $this->getDoctrine()->getManager();
  4530.         $companyId $this->getLoggedUserCompanyId($req);
  4531.         $scheduleId $req->request->get('scheduleId');
  4532.         $minuteText $req->request->get('minuteText');
  4533.         $agendaKey $req->request->get('key');
  4534.         $scheduledMeeting $em->getRepository(ScheduledMeeting::class)
  4535.             ->find($scheduleId);
  4536.         $agendaList json_decode($scheduledMeeting->getAgendaList(), true);
  4537.         foreach ($agendaList as $key => $item) {
  4538.             if ($key == $agendaKey)
  4539.                 $agendaList[$key]['minutes'] = $minuteText;
  4540.         }
  4541.         $scheduledMeeting->setAgendaList(json_encode($agendaList));
  4542.         $em->flush();
  4543.         return new JsonResponse(array(
  4544.             'success' => true
  4545.         ));
  4546.     }
  4547.     public function SendMeetingUpdatesAction(Request $req$action 0$id 0)
  4548.     {
  4549.         $em $this->getDoctrine()->getManager();
  4550.         $companyId $this->getLoggedUserCompanyId($req);
  4551.         $session $req->getSession();
  4552.         $companyData Company::getCompanyData($em$companyId);
  4553.         $scheduleId $req->request->get('scheduleId');
  4554.         $minuteText $req->request->get('minuteText');
  4555.         $agendaKey $req->request->get('key');
  4556.         $scheduledMeeting $em->getRepository(ScheduledMeeting::class)
  4557.             ->find($scheduleId);
  4558.         $sendEmailInvitationTo json_decode($scheduledMeeting->getAllParticipantsNameEmail(), true);
  4559.         if ($sendEmailInvitationTo == null)
  4560.             $sendEmailInvitationTo = [];
  4561.         $agendaList json_decode($scheduledMeeting->getAgendaList(), true);
  4562.         if ($agendaList == null)
  4563.             $agendaList = [];
  4564.         $EmployeeList HumanResource::GetEmployeeList($em, []);
  4565.         $meetingType MeetingSchedulingConstant::$meetingType[$scheduledMeeting->getMeetingType()];
  4566.         foreach ($sendEmailInvitationTo as $key => $email) {
  4567.             $name ucWords(str_replace("_"" "$key));
  4568.             $bodyHtml '';
  4569.             $bodyTemplate 'ApplicationBundle:email/meeting_scheduling:scheduled_meeting_update.html.twig';
  4570.             $bodyData = array(
  4571.                 'name' => $name,
  4572.                 'gocId' => $session->get(UserConstants::USER_GOC_ID),
  4573.                 'appId' => $session->get(UserConstants::USER_APP_ID),
  4574.                 'email' => $email,
  4575.                 'meetingData' => $scheduledMeeting,
  4576.                 'meeting_type' => $meetingType,
  4577.                 'agenda_list' => $agendaList,
  4578.                 'companyData' => $companyData,
  4579.                 'employeeList' => $EmployeeList,
  4580.             );
  4581.             $attachments = [];
  4582.             $new_mail $this->get('mail_module');
  4583.             $new_mail->sendMyMail(array(
  4584.                 'senderHash' => '_MEETING_',
  4585.                 'forwardToMailAddress' => $email,
  4586.                 'subject' => "Meeting Updates Arranged By - " $companyData->getName() . " on " $scheduledMeeting->getTitle() . ". ",
  4587.                 'fileName' => '',
  4588.                 'attachments' => $attachments,
  4589.                 'toAddress' => $email,
  4590.                 'mailTemplate' => $bodyTemplate,
  4591.                 'templateData' => $bodyData,
  4592.                 'embedCompanyImage' => 1,
  4593.                 'companyId' => $companyId,
  4594.                 'companyImagePath' => $companyData->getImage()
  4595.             ));
  4596.         }
  4597.         return new JsonResponse(array(
  4598.             'success' => true
  4599.         ));
  4600.     }
  4601.     public function meetingSchedulingAction(Request $req$action 0)
  4602.     {
  4603.         $em $this->getDoctrine()->getManager();
  4604.         $companyId $this->getLoggedUserCompanyId($req);
  4605.         $session $req->getSession();
  4606.         if ($req->request->has('XHRreq')) {
  4607.             return new JsonResponse([HumanResource::HandelXHRreqForMeetingScheduling($em$req)]);
  4608.         }
  4609.         if ($action === 'list') {
  4610.             $response HumanResource::TwigDataForScheduledMeetingList($em, [0null]);
  4611.             return $this->render(
  4612.                 'ApplicationBundle:pages/human_resource/list:scheduled_meeting_list.html.twig',
  4613.                 [
  4614.                     'page_title' => 'Scheduled Meeting List',
  4615.                     'list' => $response
  4616.                 ]
  4617.             );
  4618.         }
  4619.         if ($req->isMethod('GET')) {
  4620.             $response HumanResource::twigDataForMeetingScheduling($em);
  4621.             return $this->render(
  4622.                 'ApplicationBundle:pages/human_resource/input_forms:meeting_scheduling.html.twig',
  4623.                 [
  4624.                     'page_title' => 'Schedule a Meeting',
  4625.                     'employeeIds' => $response['employeeIds'],
  4626.                     'branches' => $response['branches'],
  4627.                     'asset' => $response['asset'],
  4628.                     'rooms' => $response['rooms'],
  4629.                     'sales_orders' => $response['salesOrders'],
  4630.                     'purchase_orders' => $response['purchaseOrders'],
  4631.                     'meeting_types' => $response['meetingType'],
  4632.                 ]
  4633.             );
  4634.         }
  4635.         if ($req->isMethod('POST')) {
  4636.             $approveHash $req->request->get('approvalHash');
  4637.             $approveRole $req->request->get('approvalRole');
  4638.             $loginId $req->getSession()->get(UserConstants::USER_LOGIN_ID);
  4639.             $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  4640.             $companyData Company::getCompanyData($em$companyId);
  4641.             if ($isSignatureOk) {
  4642.                 $isSuccess HumanResource::createOrUpdateDataForMeetingScheduling($em$req);
  4643.                 if ($isSuccess) {
  4644.                     $options = array(
  4645.                         'notification_enabled' => $this->container->getParameter('notification_enabled'),
  4646.                         'notification_server' => $this->container->getParameter('notification_server'),
  4647.                         'appId' => $req->getSession()->get(UserConstants::USER_APP_ID),
  4648.                         'url' => $this->generateUrl(
  4649.                             GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting']]['entity_view_route_path_name']
  4650.                         )
  4651.                     );
  4652.                     $meetingId $isSuccess[1];
  4653.                     System::setApprovalInfo(
  4654.                         $this->getDoctrine()->getManager(),
  4655.                         $options,
  4656.                         array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'],
  4657.                         $meetingId,
  4658.                         $req->getSession()->get(UserConstants::USER_LOGIN_ID),
  4659.                         0//normal meeting
  4660.                         0,
  4661.                         $this->get('mail_module')
  4662.                     );
  4663.                     System::createEditSignatureHash(
  4664.                         $this->getDoctrine()->getManager(),
  4665.                         array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'],
  4666.                         $meetingId,
  4667.                         $loginId,
  4668.                         $approveRole,
  4669.                         $req->request->get('approvalHash')
  4670.                     );
  4671.                     $url $this->generateUrl(
  4672.                         'view_scheduled_meeting'
  4673.                     );
  4674.                     return $this->redirect($url "/" $meetingId);
  4675.                 } else {
  4676.                     return new JsonResponse(array(
  4677.                         'success' => false
  4678.                     ));
  4679.                 }
  4680.             } else {
  4681.                 $this->addFlash(
  4682.                     'error',
  4683.                     'Invalid Approval Hash!'
  4684.                 );
  4685.                 return $this->redirectToRoute('meeting_scheduling');
  4686.             }
  4687.         }
  4688.         return $this->redirectToRoute('meeting_scheduling');
  4689.     }
  4690.     public function CreateTrainingScheduleAction(Request $req$action 0)
  4691.     {
  4692.         $em $this->getDoctrine()->getManager();
  4693.         $companyId $this->getLoggedUserCompanyId($req);
  4694.         $session $req->getSession();
  4695.         if ($req->request->has('XHRreq')) {
  4696.             return new JsonResponse([HumanResource::HandelXHRreqForMeetingScheduling($em$req)]);
  4697.         }
  4698.         if ($action === 'list') {
  4699.             $response HumanResource::TwigDataForScheduledMeetingList($em, [1]);
  4700.             return $this->render(
  4701.                 'ApplicationBundle:pages/human_resource/list:scheduled_meeting_list.html.twig',
  4702.                 [
  4703.                     'page_title' => 'Training Schedule List',
  4704.                     'list' => $response
  4705.                 ]
  4706.             );
  4707.         }
  4708.         if ($req->isMethod('GET')) {
  4709.         }
  4710.         if ($req->isMethod('POST')) {
  4711.             $approveHash $req->request->get('approvalHash');
  4712.             $approveRole $req->request->get('approvalRole');
  4713.             $loginId $req->getSession()->get(UserConstants::USER_LOGIN_ID);
  4714.             $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  4715.             $companyData Company::getCompanyData($em$companyId);
  4716.             if ($isSignatureOk) {
  4717.                 $isSuccess HumanResource::createOrUpdateDataForMeetingScheduling($em$req);
  4718.                 if ($isSuccess) {
  4719.                     $options = array(
  4720.                         'notification_enabled' => $this->container->getParameter('notification_enabled'),
  4721.                         'notification_server' => $this->container->getParameter('notification_server'),
  4722.                         'appId' => $req->getSession()->get(UserConstants::USER_APP_ID),
  4723.                         'url' => $this->generateUrl(
  4724.                             GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting']]['entity_view_route_path_name']
  4725.                         )
  4726.                     );
  4727.                     $meetingId $isSuccess[1];
  4728.                     System::setApprovalInfo(
  4729.                         $this->getDoctrine()->getManager(),
  4730.                         $options,
  4731.                         array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'],
  4732.                         $meetingId,
  4733.                         $req->getSession()->get(UserConstants::USER_LOGIN_ID),
  4734.                         '',
  4735.                         0,
  4736.                         $this->get('mail_module')
  4737.                     );
  4738.                     System::createEditSignatureHash(
  4739.                         $this->getDoctrine()->getManager(),
  4740.                         array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'],
  4741.                         $meetingId,
  4742.                         $loginId,
  4743.                         $approveRole,
  4744.                         $req->request->get('approvalHash')
  4745.                     );
  4746.                     $url $this->generateUrl(
  4747.                         'view_scheduled_meeting'
  4748.                     );
  4749.                     return $this->redirect($url "/" $meetingId);
  4750.                 } else {
  4751.                     return new JsonResponse(array(
  4752.                         'success' => false
  4753.                     ));
  4754.                 }
  4755.             } else {
  4756.                 $this->addFlash(
  4757.                     'error',
  4758.                     'Invalid Approval Hash!'
  4759.                 );
  4760.                 return $this->redirectToRoute('create_training_schedule');
  4761.             }
  4762.         }
  4763.         $response HumanResource::twigDataForTrainingScheduling($em);
  4764.         return $this->render(
  4765.             'ApplicationBundle:pages/human_resource/input_forms:create_training_schedule.html.twig',
  4766.             [
  4767.                 'page_title' => 'Schedule a Training',
  4768.                 'employeeIds' => $response['employeeIds'],
  4769.                 'branches' => $response['branches'],
  4770.                 'asset' => $response['asset'],
  4771.                 'rooms' => $response['rooms'],
  4772.                 'courseList' => $response['courseList'],
  4773.                 'sales_orders' => $response['salesOrders'],
  4774.                 'purchase_orders' => $response['purchaseOrders'],
  4775.                 'meeting_types' => $response['meetingType'],
  4776.                 'skillList' => $response['skillList'],
  4777.             ]
  4778.         );
  4779.     }
  4780.     public function ScheduledTrainingListAction(Request $req$action 0)
  4781.     {
  4782.         $em $this->getDoctrine()->getManager();
  4783.         $companyId $this->getLoggedUserCompanyId($req);
  4784.         $session $req->getSession();
  4785.         $response HumanResource::TwigDataForScheduledMeetingList($em, [1]);
  4786.         return $this->render(
  4787.             'ApplicationBundle:pages/human_resource/list:scheduled_training_list.html.twig',
  4788.             [
  4789.                 'page_title' => 'Scheduled Trainings ',
  4790.                 'list' => $response
  4791.             ]
  4792.         );
  4793.     }
  4794.     public function ScheduledInterviewListAction(Request $req$action 0)
  4795.     {
  4796.         $em $this->getDoctrine()->getManager();
  4797.         $companyId $this->getLoggedUserCompanyId($req);
  4798.         $session $req->getSession();
  4799.         $response HumanResource::TwigDataForScheduledMeetingList($em, [2]);
  4800.         return $this->render(
  4801.             'ApplicationBundle:pages/human_resource/list:scheduled_interview_list.html.twig',
  4802.             [
  4803.                 'page_title' => 'Scheduled Interviews ',
  4804.                 'list' => $response
  4805.             ]
  4806.         );
  4807.     }
  4808.     public function GetFilteredQuestionsAction(Request $request$search '')
  4809.     {
  4810.         $em $this->getDoctrine()->getManager();
  4811.         $companyId $this->getLoggedUserCompanyId($request);
  4812.         if ($search == '' || $search == '_EMPTY_')
  4813.             $Query "SELECT  * FROM questionnaire WHERE 1 limit 10;";
  4814.         else
  4815.             $Query "SELECT  * FROM questionnaire WHERE question_text like '%$search%'  limit 10;";
  4816.         $stmt $em->getConnection()->prepare($Query);
  4817.         $stmt->execute();
  4818.         $queryResult $stmt->fetchAll();
  4819.         $parent_head_ids = [];
  4820.         $queryResultIndexed = [];
  4821.         foreach ($queryResult as $dt) {
  4822.             $queryResultIndexed[$dt['question_id']] = $dt;
  4823.         }
  4824.         return new JsonResponse(array(
  4825.             'data' => $queryResult,
  4826.             'queryResultIndexed' => $queryResultIndexed,
  4827.         ));
  4828.     }
  4829.     public function CreateTrainingCourseAction(Request $request$id 0)
  4830.     {
  4831.         $em $this->getDoctrine()->getManager();
  4832.         $companyId $this->getLoggedUserCompanyId($request);
  4833.         $skills $em->getRepository('ApplicationBundle:Skill')->findAll();
  4834.         $courses $em->getRepository('ApplicationBundle:TrainingCourse')->findAll();
  4835.         if ($request->isMethod('POST')) {
  4836.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  4837.             $skill = new TrainingCourse;
  4838.             $skill->setTitle($request->request->get('name'));
  4839.             $skill->setCourseHash($request->request->get('coursehash'));
  4840.             $skill->setTrainingMaterialText($request->request->get('overview'));
  4841.             $skill->setTaggedSkillHashes(json_encode($request->request->get('skill')));
  4842.             $skill->setCompanyId($companyId);
  4843.             //$skill->setEditFlag(1); //editable usually
  4844.             $skill->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  4845.             //$skill->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
  4846.             //$skill->setAutocreated(0);
  4847.             $em->persist($skill);
  4848.             $em->flush();
  4849.         }
  4850.         return $this->render(
  4851.             'ApplicationBundle:pages/human_resource/input_forms:create_training_course.html.twig',
  4852.             [
  4853.                 'page_title' => 'Create Training Course',
  4854.                 'skills' => $skills,
  4855.                 'courses' => $courses
  4856.             ]
  4857.         );
  4858.     }
  4859.     public function CreateEmployeeExpenseAllowanceSettingsAction(Request $request$id 0)
  4860.     {
  4861.         $em $this->getDoctrine()->getManager();
  4862.         $companyId $this->getLoggedUserCompanyId($request);
  4863.         $extDocData = [];
  4864.         $extDetailsData = [];
  4865.         if ($request->isMethod('POST')) {
  4866.             //            Generic::debugMessage($_POST);
  4867.             $em $this->getDoctrine()->getManager();
  4868.             $entity_id array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings']; //change
  4869.             $dochash $request->request->get('docHash'); //change
  4870.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  4871.             $approveRole $request->request->get('approvalRole');
  4872.             $approveHash $request->request->get('approvalHash');
  4873.             if (!DocValidation::isInsertable(
  4874.                 $em,
  4875.                 $entity_id,
  4876.                 $dochash,
  4877.                 $loginId,
  4878.                 $approveRole,
  4879.                 $approveHash,
  4880.                 $id
  4881.             )
  4882.             ) {
  4883.                 $this->addFlash(
  4884.                     'error',
  4885.                     'Sorry Could not insert Data.'
  4886.                 );
  4887.             } else {
  4888.                 $funcname 'EmployeeExpenseAllowanceSettings';
  4889.                 DeleteDocument::$funcname($em$id0);
  4890.                 $docId HumanResource::CreateSalarySegregationPolicy($em$request$companyId0);
  4891.                 //now add Approval info
  4892.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  4893.                 $approveRole $request->request->get('approvalRole');
  4894.                 $options = array(
  4895.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  4896.                     'notification_server' => $this->container->getParameter('notification_server'),
  4897.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  4898.                     'url' => $this->generateUrl(
  4899.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings']]['entity_view_route_path_name']
  4900.                     )
  4901.                 );
  4902.                 System::setApprovalInfo(
  4903.                     $this->getDoctrine()->getManager(),
  4904.                     $options,
  4905.                     array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings'],
  4906.                     $docId,
  4907.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  4908.                 );
  4909.                 System::createEditSignatureHash(
  4910.                     $this->getDoctrine()->getManager(),
  4911.                     array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings'],
  4912.                     $docId,
  4913.                     $loginId,
  4914.                     $approveRole,
  4915.                     $request->request->get('approvalHash')
  4916.                 );
  4917.                 $doc_here $this->getDoctrine()
  4918.                     ->getRepository('ApplicationBundle:EmployeeExpenseAllowanceSettings')
  4919.                     ->findOneBy(
  4920.                         array(
  4921.                             'id' => $docId
  4922.                         )
  4923.                     );
  4924.                 //notify
  4925.                 $this->addFlash(
  4926.                     'success',
  4927.                     'Settings Successfully Updated.'
  4928.                 );
  4929.                 $url $this->generateUrl(
  4930.                     GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings']]['entity_view_route_path_name']
  4931.                 );
  4932.                 System::AddNewNotification(
  4933.                     $this->container->getParameter('notification_enabled'),
  4934.                     $this->container->getParameter('notification_server'),
  4935.                     $request->getSession()->get(UserConstants::USER_APP_ID),
  4936.                     $request->getSession()->get(UserConstants::USER_COMPANY_ID),
  4937.                     "Salary Segregation Policy : " $doc_here->getDocumentHash() . " Has Been Created And is Under Processing",
  4938.                     'pos',
  4939.                     System::getPositionIdsByDepartment($emGeneralConstant::HRM_DEPARTMENT),
  4940.                     'success',
  4941.                     //                    $url . "/" . $TransID,
  4942.                     $url "/" $docId,
  4943.                     "Journal"
  4944.                 );
  4945.                 return $this->redirect($url "/" $docId);
  4946.             }
  4947.         }
  4948.         //for edits
  4949.         if ($id == 0) {
  4950.         } else {
  4951.             $extDocData $em->getRepository('ApplicationBundle:EmployeeExpenseAllowanceSettings')->findOneBy(
  4952.                 array(
  4953.                     'id' => $id///material
  4954.                 )
  4955.             );
  4956.             //now if its not editable, redirect to view
  4957.             if ($extDocData) {
  4958.                 if ($extDocData->getEditFlag() != 1) {
  4959. //          $url = $this->generateUrl(
  4960. ////              'view_salary_segregation_policy'
  4961. //              'salary_segregation_policy'
  4962. //          );
  4963. //          return $this->redirect($url . "/" . $id);
  4964.                 } else {
  4965. //          $extVoucherDetailsData = Accounts::GetVoucherDataForEdit($em, $voucherId);
  4966. //          $extDetailsData = $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
  4967. //              array(
  4968. //                  'transactionId' => $id, ///material
  4969. //
  4970. //              )
  4971. //          );
  4972.                 }
  4973.             } else {
  4974.             }
  4975.         }
  4976.         $employeeIds $em->getRepository("ApplicationBundle:Employee")->findAll();
  4977.         $employeeType HumanResourceConstant::$employeeType;
  4978.         $employeeExpenseAllowanceTypes HumanResourceConstant::$employeeExpenseAllowanceTypes;
  4979.         $Designation $em->getRepository("ApplicationBundle:SysDepartmentPosition")->findAll();
  4980.         $branch $em->getRepository("ApplicationBundle:Branch")->findAll();
  4981.         $departments $em->getRepository("ApplicationBundle:SysDepartment")->findAll();
  4982.         $department = [];
  4983.         foreach ($departments as $entry) {
  4984.             $department[$entry->getDepartmentId()] = array(
  4985.                 'id' => $entry->getDepartmentId(),
  4986.                 'name' => $entry->getDepartmentName(),
  4987.             );
  4988.         }
  4989.         return $this->render(
  4990.             'ApplicationBundle:pages/human_resource/input_forms:create_employee_expense_allowance_settings.html.twig',
  4991.             [
  4992.                 'page_title' => 'Employee Expense Allowance Settings',
  4993.                 'employeeIds' => $employeeIds,
  4994.                 'extId' => $id,
  4995.                 'extDocData' => $extDocData,
  4996.                 'employeeType' => $employeeType,
  4997.                 'employeeExpenseAllowanceTypes' => $employeeExpenseAllowanceTypes,
  4998.                 'Designation' => $Designation,
  4999.                 'branch' => $branch,
  5000.                 'department' => $department,
  5001.             ]
  5002.         );
  5003.     }
  5004.     public function EmployeeExpenseAllowanceSettingsListAction(Request $request)
  5005.     {
  5006.         $em $this->getDoctrine()->getManager();
  5007.         $allowed_ids = [];
  5008.         $companyId $this->getLoggedUserCompanyId($request);
  5009.         $listData HumanResource::GetDataForEmployeeExpenseAllowanceSettingsListAction($em$request->isMethod('POST') ? 'POST' 'GET'$request->request$companyId);
  5010.         if ($request->isMethod('POST')) {
  5011.             if ($request->query->has('dataTableQry')) {
  5012.                 return new JsonResponse(
  5013.                     $listData
  5014.                 );
  5015.             }
  5016.         }
  5017.         return $this->render('ApplicationBundle:pages/human_resource/list:employee_expense_allowance_settings_list.html.twig',
  5018. //         return $this->render('ApplicationBundle:pages/dashboard:test_pix_invent.html.twig',
  5019.             array(
  5020.                 'page_title' => 'Expense Allowance Settings List',
  5021. //            'data' => SalesOrderM::GetClientList($em, [], $companyId),
  5022. //            'client_types' => Client::GetClientType($em, $companyId),
  5023. //            'region_list' => Client::RegionList($em, $companyId),
  5024. //            'geographical_region_list' => Client::GeographicalRegionList($em, $companyId)
  5025.             )
  5026.         );
  5027.     }
  5028.     public function salarySegAction(Request $request$id 0)
  5029.     {
  5030.         $em $this->getDoctrine()->getManager();
  5031.         $companyId $this->getLoggedUserCompanyId($request);
  5032.         $extDocData = [];
  5033.         $extDetailsData = [];
  5034.         if ($request->isMethod('POST')) {
  5035.             //            Generic::debugMessage($_POST);
  5036.             $em $this->getDoctrine()->getManager();
  5037.             $entity_id array_flip(GeneralConstant::$Entity_list)['SalarySegregationPolicy']; //change
  5038.             $dochash $request->request->get('docHash'); //change
  5039.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  5040.             $approveRole $request->request->get('approvalRole');
  5041.             $approveHash $request->request->get('approvalHash');
  5042.             if (!DocValidation::isInsertable(
  5043.                 $em,
  5044.                 $entity_id,
  5045.                 $dochash,
  5046.                 $loginId,
  5047.                 $approveRole,
  5048.                 $approveHash,
  5049.                 $id
  5050.             )
  5051.             ) {
  5052.                 $this->addFlash(
  5053.                     'error',
  5054.                     'Sorry Couldnot insert Data.'
  5055.                 );
  5056.             } else {
  5057.                 $funcname 'SalarySegregationPolicy';
  5058.                 DeleteDocument::$funcname($em$id0);
  5059.                 $docId HumanResource::CreateSalarySegregationPolicy($em$request$companyId0);
  5060.                 //now add Approval info
  5061.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  5062.                 $approveRole $request->request->get('approvalRole');
  5063.                 $options = array(
  5064.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  5065.                     'notification_server' => $this->container->getParameter('notification_server'),
  5066.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  5067.                     'url' => $this->generateUrl(
  5068.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['SalarySegregationPolicy']]['entity_view_route_path_name']
  5069.                     )
  5070.                 );
  5071.                 System::setApprovalInfo(
  5072.                     $this->getDoctrine()->getManager(),
  5073.                     $options,
  5074.                     array_flip(GeneralConstant::$Entity_list)['SalarySegregationPolicy'],
  5075.                     $docId,
  5076.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID),
  5077.                     3    //journal voucher
  5078.                 );
  5079.                 System::createEditSignatureHash(
  5080.                     $this->getDoctrine()->getManager(),
  5081.                     array_flip(GeneralConstant::$Entity_list)['SalarySegregationPolicy'],
  5082.                     $docId,
  5083.                     $loginId,
  5084.                     $approveRole,
  5085.                     $request->request->get('approvalHash')
  5086.                 );
  5087.                 $doc_here $this->getDoctrine()
  5088.                     ->getRepository('ApplicationBundle:SalarySegregationPolicy')
  5089.                     ->findOneBy(
  5090.                         array(
  5091.                             'id' => $docId
  5092.                         )
  5093.                     );
  5094.                 //notify
  5095.                 $this->addFlash(
  5096.                     'success',
  5097.                     'Policy Successfully Updated.'
  5098.                 );
  5099.                 $url $this->generateUrl(
  5100.                     'salary_segregation_policy'
  5101.                 );
  5102.                 System::AddNewNotification(
  5103.                     $this->container->getParameter('notification_enabled'),
  5104.                     $this->container->getParameter('notification_server'),
  5105.                     $request->getSession()->get(UserConstants::USER_APP_ID),
  5106.                     $request->getSession()->get(UserConstants::USER_COMPANY_ID),
  5107.                     "Salary Segregation Policy : " $doc_here->getDocumentHash() . " Has Been Created And is Under Processing",
  5108.                     'pos',
  5109.                     System::getPositionIdsByDepartment($emGeneralConstant::HRM_DEPARTMENT),
  5110.                     'success',
  5111.                     //                    $url . "/" . $TransID,
  5112.                     $url "/" $docId,
  5113.                     "Journal"
  5114.                 );
  5115.                 return $this->redirect($url "/" $docId);
  5116.             }
  5117.         }
  5118.         //for edits
  5119.         if ($id == 0) {
  5120.         } else {
  5121.             $extDocData $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
  5122.                 array(
  5123.                     'id' => $id///material
  5124.                 )
  5125.             );
  5126.             //now if its not editable, redirect to view
  5127.             if ($extDocData) {
  5128.                 if ($extDocData->getEditFlag() != 1) {
  5129. //          $url = $this->generateUrl(
  5130. ////              'view_salary_segregation_policy'
  5131. //              'salary_segregation_policy'
  5132. //          );
  5133. //          return $this->redirect($url . "/" . $id);
  5134.                 } else {
  5135. //          $extVoucherDetailsData = Accounts::GetVoucherDataForEdit($em, $voucherId);
  5136. //          $extDetailsData = $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
  5137. //              array(
  5138. //                  'transactionId' => $id, ///material
  5139. //
  5140. //              )
  5141. //          );
  5142.                 }
  5143.             } else {
  5144.             }
  5145.         }
  5146.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  5147.         $employeeType HumanResourceConstant::$employeeType;
  5148.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  5149.         $branch $em->getRepository(Branch::class)->findAll();
  5150.         $departments $em->getRepository(SysDepartment::class)->findAll();
  5151.         $department = [];
  5152.         foreach ($departments as $entry) {
  5153.             $department[$entry->getDepartmentId()] = array(
  5154.                 'id' => $entry->getDepartmentId(),
  5155.                 'name' => $entry->getDepartmentName(),
  5156.             );
  5157.         }
  5158.         return $this->render(
  5159.             'ApplicationBundle:pages/human_resource/input_forms:salary_segregation_policy.html.twig',
  5160.             [
  5161.                 'page_title' => 'Salary Segregation Policy',
  5162.                 'employeeIds' => $employeeIds,
  5163.                 'extId' => $id,
  5164.                 'extDocData' => $extDocData,
  5165.                 'employeeType' => $employeeType,
  5166.                 'Designation' => $Designation,
  5167.                 'branch' => $branch,
  5168.                 'department' => $department,
  5169.             ]
  5170.         );
  5171.     }
  5172.     public function GetSalarySegregationDataForEmployeeEntryAction(Request $request)
  5173.     {
  5174.         $em $this->getDoctrine()->getManager();
  5175.         $companyId $this->getLoggedUserCompanyId($request);
  5176.         if ($request->request->has('salSagDataReq')) {
  5177.             $ajaxData HumanResource::handelXhrForSalSeg($em$request);
  5178.             return new JsonResponse($ajaxData);
  5179.         }
  5180.         return new JsonResponse(array('success' => false));
  5181.     }
  5182.     public function WorkHourPolicyAction(Request $req$id 0)
  5183.     {
  5184.         $em $this->getDoctrine()->getManager();
  5185.         $companyId $this->getLoggedUserCompanyId($req);
  5186.         $extData = [];
  5187.         if ($id != 0) {
  5188.             $extData $em->getRepository('ApplicationBundle:WorkHourPolicy')
  5189.                 ->findOneBy(
  5190.                     array(
  5191.                         'id' => $id
  5192.                     )
  5193.                 );
  5194.         }
  5195.         if ($req->isMethod('POST')) {
  5196.             $storeDataRes HumanResource::checkSignature($em$req);
  5197.             if ($storeDataRes['hasErr']) {
  5198.                 $msg $storeDataRes['msg'];
  5199.                 $this->addFlash(
  5200.                     'error',
  5201.                     $msg
  5202.                 );
  5203.                 return $this->redirectToRoute('work_hour_policy');
  5204.             } else {
  5205.                 HumanResource::storeDataForWhPolicy($em$req$companyId);
  5206.                 $this->addFlash(
  5207.                     'success',
  5208.                     'Policy Successfully Created!'
  5209.                 );
  5210.                 return $this->redirectToRoute('work_hour_policy');
  5211.             }
  5212.         }
  5213.         $twigData HumanResource::twigDataForWorkHourPolicy($em);
  5214.         $timeZonesArray = array();
  5215.         return $this->render(
  5216.             'ApplicationBundle:pages/human_resource/input_forms:work_hour_policy.html.twig',
  5217.             [
  5218.                 'page_title' => 'Work Hour Policy',
  5219.                 'extId' => $id,
  5220.                 'extData' => $extData,
  5221.                 'employeeIds' => $twigData['employeeIds'],
  5222.                 'employeeType' => $twigData['employeeType'],
  5223.                 'Designation' => $twigData['Designation'],
  5224.                 'branch' => $twigData['branch'],
  5225.                 'department' => $twigData['department'],
  5226.             ]
  5227.         );
  5228.     }
  5229.     public function WorkHourPolicyListAction(Request $request)
  5230.     {
  5231.         $em $this->getDoctrine()->getManager();
  5232.         $allowed_ids = [];
  5233.         $companyId $this->getLoggedUserCompanyId($request);
  5234.         $listData HumanResource::GetDataForWorkHourPolicyListAction($em$request->isMethod('POST') ? 'POST' 'GET'$request->request$companyId);
  5235.         if ($request->isMethod('POST')) {
  5236.             if ($request->query->has('dataTableQry')) {
  5237.                 return new JsonResponse(
  5238.                     $listData
  5239.                 );
  5240.             }
  5241.         }
  5242.         return $this->render('ApplicationBundle:pages/human_resource/list:work_hour_policy_list.html.twig',
  5243. //         return $this->render('ApplicationBundle:pages/dashboard:test_pix_invent.html.twig',
  5244.             array(
  5245.                 'page_title' => 'Work Hour Policy List',
  5246. //            'data' => SalesOrderM::GetClientList($em, [], $companyId),
  5247. //            'client_types' => Client::GetClientType($em, $companyId),
  5248. //            'region_list' => Client::RegionList($em, $companyId),
  5249. //            'geographical_region_list' => Client::GeographicalRegionList($em, $companyId)
  5250.             )
  5251.         );
  5252.     }
  5253.     public function WorkPlacePolicyListAction(Request $request)
  5254.     {
  5255.         $em $this->getDoctrine()->getManager();
  5256.         $workplacePolicyDetails $em->getRepository('ApplicationBundle:EmployeeWorkplace')->findAll();
  5257. //        $employee = $em->getRepository('ApplicationBundle:Employee')->findAll();
  5258.         return $this->render('ApplicationBundle:pages/human_resource/list:work_place_policy_list.html.twig', array(
  5259.             'page_title' => 'Work Place Policy List',
  5260.             'workplacePolicyDetails' => $workplacePolicyDetails,
  5261. //            'employee'=>$employee
  5262.         ));
  5263.     }
  5264.     public function workPlacePolicyAction(Request $data$id)
  5265.     {
  5266.         $em $this->getDoctrine()->getManager();
  5267.         $workPlacePolicy $em->getRepository('ApplicationBundle:EmployeeWorkplace')->find($id);
  5268.         $employee $em->getRepository(Employee::class)->findAll();
  5269.         $Approval_data System::checkIfApprovalExists(
  5270.             $em,
  5271.             array_flip(GeneralConstant::$Entity_list)['EmployeeWorkplace'],
  5272.             $id,
  5273.             $data->getSession()->get(UserConstants::USER_LOGIN_ID)
  5274.         );
  5275.         $ApprovalStatus GeneralConstant::$approvalStatus;
  5276.         return $this->render('ApplicationBundle:pages/human_resource/views:viewWorkPlacePolicy.html.twig', array(
  5277.             'page_title' => 'Work Place Policy  View',
  5278.             'workPlacePolicy' => $workPlacePolicy,
  5279.             'employee' => $employee,
  5280.             'approval_data' => $Approval_data,
  5281.             'approval_status' => $workPlacePolicy->getApproved(),
  5282.             'id' => $id,
  5283.         ));
  5284.     }
  5285.     public function SalarySegregationPolicyListAction(Request $request)
  5286.     {
  5287.         $em $this->getDoctrine()->getManager();
  5288.         $allowed_ids = [];
  5289.         $companyId $this->getLoggedUserCompanyId($request);
  5290.         $listData HumanResource::GetDataForSalarySegregationPolicyListAction($em$request->isMethod('POST') ? 'POST' 'GET'$request->request$companyId);
  5291.         if ($request->isMethod('POST')) {
  5292.             if ($request->query->has('dataTableQry')) {
  5293.                 return new JsonResponse(
  5294.                     $listData
  5295.                 );
  5296.             }
  5297.         }
  5298.         return $this->render('ApplicationBundle:pages/human_resource/list:salary_segregation_policy_list.html.twig',
  5299. //         return $this->render('ApplicationBundle:pages/dashboard:test_pix_invent.html.twig',
  5300.             array(
  5301.                 'page_title' => 'Salary Segregation Policy List',
  5302. //            'data' => SalesOrderM::GetClientList($em, [], $companyId),
  5303. //            'client_types' => Client::GetClientType($em, $companyId),
  5304. //            'region_list' => Client::RegionList($em, $companyId),
  5305. //            'geographical_region_list' => Client::GeographicalRegionList($em, $companyId)
  5306.             )
  5307.         );
  5308.     }
  5309.     public function HolidayCalendarListAction(Request $request)
  5310.     {
  5311.         $q $this->getDoctrine()
  5312.             ->getRepository('ApplicationBundle:HolidayCalendar')
  5313.             ->findBy(
  5314.                 array(
  5315. //                'status' => GeneralConstant::ACTIVE,
  5316.                     'CompanyId' => $this->getLoggedUserCompanyId($request)
  5317. //                    'approved' =>  GeneralConstant::APPROVED,
  5318.                 )
  5319.             );
  5320.         $stage_list = array(
  5321.             => 'Pending',
  5322.             => 'Pending',
  5323.             => 'Complete',
  5324.             => 'Partial',
  5325.         );
  5326.         $data = [];
  5327.         foreach ($q as $entry) {
  5328.             $data[] = array(
  5329. //          'doc_date' => $entry->getSalesReplacementDate(),
  5330.                 'id' => $entry->getHolidayCalendarId(),
  5331.                 'title' => $entry->getHoliDayTitle(),
  5332.                 'approval_status' => GeneralConstant::$approvalStatus[$entry->getApproved()],
  5333. //          'stage' => $stage_list[$entry->getStage()]
  5334.             );
  5335.         }
  5336.         return $this->render('ApplicationBundle:pages/human_resource/list:holiday_calendar_list.html.twig',
  5337.             array(
  5338.                 'page_title' => 'Holiday Calendar List',
  5339.                 'data' => $data
  5340.             )
  5341.         );
  5342.     }
  5343.     public function PayrollPolicyListAction(Request $request)
  5344.     {
  5345.         $em $this->getDoctrine()->getManager();
  5346.         $allowed_ids = [];
  5347.         $companyId $this->getLoggedUserCompanyId($request);
  5348.         $listData HumanResource::GetDataForPayrollPolicyListAction($em$request->isMethod('POST') ? 'POST' 'GET'$request->request$companyId);
  5349.         if ($request->isMethod('POST')) {
  5350.             if ($request->query->has('dataTableQry')) {
  5351.                 return new JsonResponse(
  5352.                     $listData
  5353.                 );
  5354.             }
  5355.         }
  5356.         return $this->render('ApplicationBundle:pages/human_resource/list:payroll_policy_list.html.twig',
  5357. //         return $this->render('ApplicationBundle:pages/dashboard:test_pix_invent.html.twig',
  5358.             array(
  5359.                 'page_title' => 'Payroll Policy List',
  5360. //            'data' => SalesOrderM::GetClientList($em, [], $companyId),
  5361. //            'client_types' => Client::GetClientType($em, $companyId),
  5362. //            'region_list' => Client::RegionList($em, $companyId),
  5363. //            'geographical_region_list' => Client::GeographicalRegionList($em, $companyId)
  5364.             )
  5365.         );
  5366.     }
  5367.     public function payslipAction(Request $req$action 0$id 0)
  5368.     {
  5369.         $em $this->getDoctrine()->getManager();
  5370.         $attendanceSource HumanResourceConstant::$attendanceSources;
  5371.         if ($action === 'list') {
  5372.             $response HumanResource::twigDataForPayslipList($em);
  5373.             $approval_status GeneralConstant::$approvalAction;
  5374.             return $this->render(
  5375.                 'ApplicationBundle:pages/human_resource/list:payslip_list.html.twig',
  5376.                 [
  5377.                     'page_title' => 'Payslip List',
  5378.                     'reports' => $response,
  5379.                     'approval_status' => $approval_status
  5380.                 ]
  5381.             );
  5382.         }
  5383.         if ($action === 'view') {
  5384.             $response HumanResource::twigDataForPayslipViewAndPrint($em$req$id);
  5385.             return $this->render(
  5386.                 'ApplicationBundle:pages/human_resource/views:payslip_view.html.twig',
  5387.                 [
  5388.                     'page_title' => 'View Payslip',
  5389.                     'approval_data' => $response['approval_data'],
  5390.                     'payslip' => $response['payslip'],
  5391.                     'bankAccount' => $response['bankAccount'],
  5392.                     'tin' => $response['tin'],
  5393.                     'employeeCode' => $response['employeeCode'],
  5394.                     'earningValues' => $response['earningValues'],
  5395.                     'facilityValues' => $response['facilityValues'],
  5396.                     'deductionValues' => $response['deductionValues'],
  5397.                     'document_log' => $response['document_log'],
  5398.                     'approval_status' => $response['approval_status'],
  5399.                     'created_by' => $response['created_by'],
  5400.                     'updated_at' => $response['updated_at'],
  5401.                     'employeeId' => $response['employeeId'],
  5402.                     'totalAttendance' => $response['totalPresent'],
  5403.                     'leaveList' => HumanResourceConstant::$LeaveType,
  5404.                     'AttReportData' => $response['AttReportData'],
  5405. //                    'attendanceLog' => $response['attendanceLog'],
  5406.                     'attendanceSource' => $attendanceSource,
  5407.                     'auto_created' => 0,
  5408.                 ]
  5409.             );
  5410.         }
  5411.         if ($action === 'print') {
  5412.             $em $this->getDoctrine()->getManager();
  5413.             $company_data Company::getCompanyData($em1);
  5414.             $Authorizations System::getSignatureListForDocumentPrint($emarray_flip(GeneralConstant::$Entity_list)['Payslip'], $id);
  5415.             $response HumanResource::twigDataForPayslipViewAndPrint($em$req$id);
  5416.             return $this->render(
  5417.                 'ApplicationBundle:pages/human_resource/print:payslip_print.html.twig',
  5418.                 array(
  5419.                     'page_title' => 'Print Payslip',
  5420.                     'export' => 'pdf,print',
  5421.                     'payslip' => $response['payslip'],
  5422.                     'bankAccount' => $response['bankAccount'],
  5423.                     'tin' => $response['tin'],
  5424.                     'employeeCode' => $response['employeeCode'],
  5425.                     'earningValues' => $response['earningValues'],
  5426.                     'facilityValues' => $response['facilityValues'],
  5427.                     'deductionValues' => $response['deductionValues'],
  5428.                     'company_name' => $company_data->getName(),
  5429.                     'company_data' => $company_data,
  5430.                     'company_address' => $company_data->getAddress(),
  5431.                     'company_image' => $company_data->getImage(),
  5432.                     'Authorizations' => $Authorizations,
  5433.                     'totalAttendance' => $response['totalPresent'],
  5434.                     'leaveList' => HumanResourceConstant::$LeaveType,
  5435.                     'AttReportData' => $response['AttReportData'],
  5436.                     'attendanceSource' => $attendanceSource,
  5437.                     'red' => 0
  5438.                 )
  5439.             );
  5440.         }
  5441.         if ($req->isMethod('POST')) {
  5442.             $sigRes HumanResource::checkSignature($em$req);
  5443.             if ($sigRes['hasErr']) {
  5444.                 $msg $sigRes['msg'];
  5445.                 return new JsonResponse(['success' => false'msg' => $msg]);
  5446.             }
  5447.             HumanResource::storeDataForPayslip($em$req);
  5448.             return new JsonResponse(['success' => true]);
  5449.         }
  5450.     }
  5451.     public function applicantInfoAction(Request $request$id)
  5452.     {
  5453.         $em $this->getDoctrine()->getManager('company_group');
  5454.         $session $request->getSession();
  5455.         $consultantDetails $em->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
  5456.         $skillDetails $em->getRepository(EntitySkill::class)->findAll();
  5457.         $companyId $this->getLoggedUserCompanyId($request);
  5458.         $gender HumanResourceConstant::$sex;
  5459.         $blood HumanResourceConstant::$BloodGroup;
  5460.         $userId $session->get(UserConstants::USER_ID);
  5461.         $encData $request->query->has('ref') ? $request->query->get('ref') : '';
  5462.         $education = array(
  5463.             'instituteName' => $request->get('instituteName'),
  5464.             'courseOfStudy' => $request->get('courseOfStudy'),
  5465.             'courseStartDate' => $request->get('courseStartDate'),
  5466.             'courseEndDate' => $request->get('courseEndDate'),
  5467.             'result' => $request->get('result'),
  5468.             'grade' => $request->get('grade'),
  5469.             'degree' => $request->get('degree'),
  5470.         );
  5471.         $workExperience = array(
  5472.             'title' => $request->get('title'),
  5473.             'companyName' => $request->get('companyName'),
  5474.             'jobStartDate' => $request->get('jobStartDate'),
  5475.             'jobEndDate' => $request->get('jobEndDate'),
  5476.             'description' => $request->get('description'),
  5477.         );
  5478.         $certificate = array(
  5479.             'certificatename' => $request->get('certificatename'),
  5480.             'issuedDate' => $request->get('issuedDate'),
  5481.         );
  5482.         $courses = array(
  5483.             'courseName' => $request->get('courseName'),
  5484.             'date' => $request->get('date'),
  5485.             'duration' => $request->get('duration')
  5486.         );
  5487.         $languages = array(
  5488.             'languageName' => $request->get('languageName'),
  5489.             'writtenSkill' => $request->get('writtenSkill'),
  5490.             'verbalSkill' => $request->get('verbalSkill'),
  5491.         );
  5492.         if ($request->isMethod('POST')) {
  5493.             if ($consultantDetails)
  5494.                 $consultant $consultantDetails;
  5495.             else
  5496.                 $consultant = new EntityApplicantDetails();
  5497.             $consultant->setApplicationText($request->request->get('applicationText'));
  5498.             $consultant->setFirstname($request->request->get('firstname'));
  5499.             $consultant->setLastname($request->request->get('lastname'));
  5500.             $consultant->setIsImgLegal($request->request->get('is_img_legal'));
  5501.             $consultant->setNid($request->request->get('nid'));
  5502.             $consultant->setDob(new \DateTime($request->get('dob')));
  5503.             $consultant->setSex($request->request->get('sex'));
  5504.             $consultant->setFather($request->request->get('father'));
  5505.             $consultant->setMother($request->request->get('mother'));
  5506.             $consultant->setBlood($request->request->get('blood'));
  5507.             $consultant->setPhone($request->request->get('phone'));
  5508.             $consultant->setCountry($request->request->get('country'));
  5509.             $consultant->setPostalCode($request->request->get('postalCode'));
  5510.             $consultant->setCurrAddr($request->request->get('curr_addr'));
  5511.             $consultant->setSkill(json_encode($request->request->get('skill')));
  5512.             $consultant->setEmergencyContactNumber($request->request->get('emm_contact'));
  5513.             $consultant->setCurrentEmployment($request->request->get('currentEmployment'));
  5514.             $consultant->setTin($request->request->get('tin'));
  5515.             $consultant->setEducationData(json_encode($education));
  5516.             $consultant->setWorkExperienceData(json_encode($workExperience));
  5517.             $consultant->setCertificateData(json_encode($certificate));
  5518.             $consultant->setCoursesData(json_encode($courses));
  5519.             $consultant->setLanguagesData(json_encode($languages));
  5520.             $consultant->setWorkExperienceYear($request->request->get('workExperienceYear'));
  5521.             //$consultant->setApplyForConsultant(1);
  5522.             $em->persist($consultant);
  5523.             $em->flush();
  5524.             $path "";
  5525.             $defaultProductImage '';
  5526.             $uploadedFile null;
  5527.             $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/applicantCv/';
  5528.             $uploadedFile $request->files->get('docUpload');
  5529.             if ($uploadedFile != null) {
  5530.                 $fileName 'cv' $consultantDetails->getApplicantId() . '.' $uploadedFile->guessExtension();
  5531.                 $path $fileName;
  5532. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  5533.                 if (!file_exists($upl_dir)) {
  5534.                     mkdir($upl_dir0777true);
  5535.                 }
  5536.                 $uploadedFile->move($upl_dir$path);
  5537.                 $defaultProductImage 'uploads/applicantCv/' $path;
  5538.                 $consultant->setDocImage($defaultProductImage);
  5539.                 $em->flush();
  5540.             }
  5541.             $this->addFlash(
  5542.                 'success',
  5543.                 'Data Updated.'
  5544.             );
  5545.             if ($encData != '') {
  5546.                 $url $this->generateUrl(
  5547.                     'applicant_job_recruitment_view'
  5548.                 );
  5549.                 return $this->redirect($url '?auto_apply=1&encData=' $encData);
  5550.             }
  5551.             $url $this->generateUrl(
  5552.                 'job_recruitment_list_applicant'
  5553.             );
  5554.             return $this->redirect($url);
  5555.         }
  5556.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:applicant_info.html.twig', array(
  5557.             'page_title' => 'My Information ',
  5558.             'gender' => $gender,
  5559.             'blood' => $blood,
  5560.             'consultantDetails' => $consultantDetails,
  5561.             'education' => json_decode($consultantDetails->getEducationData(), true),
  5562.             'workExperience' => json_decode($consultantDetails->getWorkExperienceData(), true),
  5563.             'certificate' => json_decode($consultantDetails->getCertificateData(), true),
  5564.             'courses' => json_decode($consultantDetails->getCoursesData(), true),
  5565.             'languages' => json_decode($consultantDetails->getLanguagesData(), true),
  5566.             'skill' => json_decode($consultantDetails->getSkill(), true),
  5567.             'skillDetails' => $skillDetails
  5568.         ));
  5569. //        $em = $this->getDoctrine()->getManager('company_group');
  5570. //        $applicantRepo = $em->getRepository(EntityApplicantDetails::class);
  5571. //        $skillDetails = $em->getRepository(EntitySkill::class)->findAll();
  5572. //
  5573. //
  5574. //        if ($req->isMethod('POST')) {
  5575. //            $applicant = $applicantRepo->find($id);
  5576. //
  5577. //            if ($req->files->get('img')) {
  5578. //                $ImgName = HumanResource::StoreFiles($req->files->get('img'), 'Applicant');
  5579. //                $applicant->setImage($ImgName);
  5580. //            }
  5581. //
  5582. //            $applicant->setFirstname($req->request->get('firstname'));
  5583. //            $applicant->setLastname($req->request->get('lastname'));
  5584. //            $applicant->setIsImgLegal($req->request->get('is_img_legal'));
  5585. //            $applicant->setNid($req->request->get('nid'));
  5586. //            $applicant->setDob(HumanResource::StringToDate($req->request->get('dob')));
  5587. //            $applicant->setSex($req->request->get('sex'));
  5588. //            $applicant->setFather($req->request->get('father'));
  5589. //            $applicant->setMother($req->request->get('mother'));
  5590. //            $applicant->setSpouse($req->request->get('spouse'));
  5591. //            $applicant->setChild1($req->request->get('child_1'));
  5592. //            $applicant->setChild2($req->request->get('child_2'));
  5593. //            $applicant->setBlood($req->request->get('blood'));
  5594. //            $applicant->setPhone($req->request->get('phone'));
  5595. //            $applicant->setOAuthEmail($req->request->get('oauth_email'));
  5596. //            $applicant->setCurrAddr($req->request->get('curr_addr'));
  5597. //            $applicant->setPermAddr($req->request->get('perm_addr'));
  5598. //            $applicant->setEmmContact($req->request->get('emm_contact'));
  5599. //
  5600. //            $applicant->setInst1($req->request->get('inst1'));
  5601. //            $applicant->setYr1($req->request->get('yr1'));
  5602. //            $applicant->setDur1($req->request->get('dur1'));
  5603. //            $applicant->setInst2($req->request->get('inst2'));
  5604. //            $applicant->setYr2($req->request->get('yr2'));
  5605. //            $applicant->setDur2($req->request->get('dur2'));
  5606. //            $applicant->setInst3($req->request->get('inst3'));
  5607. //            $applicant->setYr3($req->request->get('yr3'));
  5608. //            $applicant->setDur3($req->request->get('dur3'));
  5609. //            $applicant->setEinst1($req->request->get('einst1'));
  5610. //            $applicant->setEyr1($req->request->get('eyr1'));
  5611. //            $applicant->setEdeg1($req->request->get('edeg1'));
  5612. //            $applicant->setEinst2($req->request->get('einst2'));
  5613. //            $applicant->setEyr2($req->request->get('eyr2'));
  5614. //            $applicant->setEdeg2($req->request->get('edeg2'));
  5615. //            $applicant->setEinst3($req->request->get('einst3'));
  5616. //            $applicant->setEyr3($req->request->get('eyr3'));
  5617. //            $applicant->setEdeg3($req->request->get('edeg3'));
  5618. //
  5619. //            $em->persist($applicant);
  5620. //            $em->flush();
  5621. //
  5622. //            return $this->render(
  5623. //                'ApplicationBundle:pages/human_resource/input_forms:applicant_info.html.twig',
  5624. //                [
  5625. //                    'page_title' => 'Applicant Info',
  5626. //                    'applicant_info' => $applicant,
  5627. //                    'blood' => HumanResourceConstant::$BloodGroup,
  5628. //                    'gender' => HumanResourceConstant::$sex,
  5629. //                    'skillDetails' => $skillDetails,
  5630. //                    'HasUpdateMode' => true,
  5631. //                ]
  5632. //            );
  5633. //        }
  5634. //
  5635. //        if ($id) {
  5636. //            $applicant = $applicantRepo->find($id);
  5637. //
  5638. //            return $this->render(
  5639. //                'ApplicationBundle:pages/human_resource/input_forms:applicant_info.html.twig',
  5640. //                [
  5641. //                    'page_title' => 'Applicant Info',
  5642. //                    'applicant_info' => $applicant,
  5643. //                    'blood' => HumanResourceConstant::$BloodGroup,
  5644. //                    'gender' => HumanResourceConstant::$sex,
  5645. //                    'skillDetails' => $skillDetails,
  5646. //                    'HasUpdateMode' => false,
  5647. //                ]
  5648. //            );
  5649. //        }
  5650. //
  5651. //        $google_client = new Google_Client();
  5652. //        $google_client->setClientId('916737688016-l2qfmb9p37cumudkaqpu8s7ndngq9una.apps.googleusercontent.com');
  5653. //        $google_client->setClientSecret('BEWpEBRvv3-hSoB4cGBrVB3z');
  5654. //        $google_client->setRedirectUri('http://localhost/applicant_info');
  5655. //        $google_client->addScope('email');
  5656. //        $google_client->addScope('profile');
  5657.     }
  5658.     public function applicantDashboardAction()
  5659.     {
  5660.         return new JsonResponse(['this is applicant dashboard']);
  5661.     }
  5662.     public function resignApplicationAction(Request $req$id)
  5663.     {
  5664.         $em $this->getDoctrine()->getManager();
  5665.         if ($req->request->has('xhrReq')) {
  5666.             $response HumanResource::HandelXhrForResignApplication($em$req);
  5667.             return new JsonResponse($response);
  5668.         }
  5669.         if ($req->isMethod('GET')) {
  5670.             $applicant $em->getRepository(EmployeeDetails::class)->findBy(['emp_status' => 1]);
  5671.             $resignReason HumanResourceConstant::$resignReason;
  5672.             return $this->render(
  5673.                 'ApplicationBundle:pages/human_resource/input_forms:resign_application.html.twig',
  5674.                 [
  5675.                     'page_title' => 'Resign Application',
  5676.                     'employeeIds' => $applicant,
  5677.                     'resignReasons' => $resignReason,
  5678.                     'HasUpdateMode' => false,
  5679.                 ]
  5680.             );
  5681.         }
  5682.         if ($req->isMethod('POST')) {
  5683.             $approveHash $req->request->get('approvalHash');
  5684.             $loginId $req->getSession()->get(UserConstants::USER_LOGIN_ID);
  5685.             $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  5686.             if ($isSignatureOk) {
  5687.                 $response HumanResource::storeResignApplicationData($em$req);
  5688.                 if ($response) {
  5689.                     return $this->redirectToRoute(
  5690.                         'view_resign_application',
  5691.                         array('id' => $response->getResignApplicationId()),
  5692.                         Response::HTTP_MOVED_PERMANENTLY
  5693.                     );
  5694.                 }
  5695.             } else {
  5696.                 $this->addFlash(
  5697.                     'error',
  5698.                     'Invalid Approval Hash!'
  5699.                 );
  5700.                 return $this->redirectToRoute('resign_application');
  5701.             }
  5702.         }
  5703.     }
  5704.     public function viewResignApplicationAction(Request $req$id 0)
  5705.     {
  5706.         $em $this->getDoctrine()->getManager();
  5707.         $response HumanResource::twigDataForResignApplicationView($em$req$id);
  5708.         return $this->render(
  5709.             'ApplicationBundle:pages/human_resource/views:resign_application_view.html.twig',
  5710.             [
  5711.                 'page_title' => 'View Resign Application',
  5712.                 'approval_data' => $response['approval_data'],
  5713.                 'application' => $response['application'],
  5714.                 'applicant' => $response['applicant'],
  5715.                 'document_log' => $response['document_log'],
  5716.                 'approval_status' => $response['approval_status'],
  5717.                 'created_by' => $response['created_by'],
  5718.                 'updated_at' => $response['updated_at'],
  5719.                 'auto_created' => 0,
  5720.             ]
  5721.         );
  5722.     }
  5723.     public function printResignApplicationAction(Request $req$id)
  5724.     {
  5725.         if ($id) {
  5726.             $em $this->getDoctrine()->getManager();
  5727.             $company_data Company::getCompanyData($em1);
  5728.             $authorizations System::getSignatureListForDocumentPrint($emarray_flip(GeneralConstant::$Entity_list)['ResignApplication'], $id);
  5729.             $response HumanResource::twigDataForResignApplicationView($em$req$id);
  5730.             return $this->render(
  5731.                 'ApplicationBundle:pages/human_resource/print:resign_application_print.html.twig',
  5732.                 array(
  5733.                     'page_title' => 'Print Resign Application',
  5734.                     'export' => 'pdf,print',
  5735.                     'company_name' => $company_data->getName(),
  5736.                     'company_data' => $company_data,
  5737.                     'company_address' => $company_data->getAddress(),
  5738.                     'company_image' => $company_data->getImage(),
  5739.                     'application' => $response['application'],
  5740.                     'applicant' => $response['applicant'],
  5741.                     'Authorizations' => $authorizations,
  5742.                     'red' => 0
  5743.                 )
  5744.             );
  5745.         }
  5746.         return new JsonResponse(array(
  5747.             'success' => false,
  5748.             'msg' => 'Wrong URL format! Please try with application ID'
  5749.         ));
  5750.     }
  5751.     public function listResignApplicationAction(Request $req)
  5752.     {
  5753.         $em $this->getDoctrine()->getManager();
  5754.         $response HumanResource::getResignApplicationList($em$req);
  5755.         return $this->render("ApplicationBundle:pages/human_resource/list:resign_application_list.html.twig", array(
  5756.             'page_title' => 'Resign Application List',
  5757.             'applications' => $response,
  5758.         ));
  5759.     }
  5760.     public function viewNocApprovalAction(Request $req$id)
  5761.     {
  5762.         $em $this->getDoctrine()->getManager();
  5763.         $response HumanResource::twigDataForNocView($em$req$id);
  5764.         return $this->render(
  5765.             'ApplicationBundle:pages/human_resource/views:noc_view.html.twig',
  5766.             [
  5767.                 'page_title' => 'View NOC',
  5768.                 'approval_data' => $response['approval_data'],
  5769.                 'noc_application' => $response['noc_application'],
  5770.                 'resign_application' => $response['resign_application'],
  5771.                 'applicant' => $response['applicant'],
  5772.                 'document_log' => $response['document_log'],
  5773.                 'approval_status' => $response['approval_status'],
  5774.                 'created_by' => $response['created_by'],
  5775.                 'updated_at' => $response['updated_at'],
  5776.                 'auto_created' => 0,
  5777.             ]
  5778.         );
  5779.     }
  5780.     public function printNocApprovalAction(Request $req$id)
  5781.     {
  5782.         $em $this->getDoctrine()->getManager();
  5783.         $company_data Company::getCompanyData($em1);
  5784.         $Authorizations System::getSignatureListForDocumentPrint($emarray_flip(GeneralConstant::$Entity_list)['NocApproval'], $id);
  5785.         $response HumanResource::twigDataForNocView($em$req$id);
  5786.         return $this->render(
  5787.             'ApplicationBundle:pages/human_resource/print:noc_print.html.twig',
  5788.             [
  5789.                 'page_title' => 'Print NOC',
  5790.                 'noc_application' => $response['noc_application'],
  5791.                 'resign_application' => $response['resign_application'],
  5792.                 'applicant' => $response['applicant'],
  5793.                 'export' => 'pdf,print',
  5794.                 'company_name' => $company_data->getName(),
  5795.                 'company_data' => $company_data,
  5796.                 'company_address' => $company_data->getAddress(),
  5797.                 'company_image' => $company_data->getImage(),
  5798.                 'Authorizations' => $Authorizations,
  5799.                 'red' => 0
  5800.             ]
  5801.         );
  5802.     }
  5803.     public function createHolidayAction(Request $request$id)
  5804.     {
  5805.         $em $this->getDoctrine()->getManager();
  5806.         $companyId $this->getLoggedUserCompanyId($request);
  5807.         if ($request->isMethod('POST')) {
  5808.             $entity_id array_flip(GeneralConstant::$Entity_list)['HolidayCalendar']; //change
  5809.             $dochash $request->request->get('doc_hash'); //change
  5810.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  5811.             $approveRole $request->request->get('approvalRole');
  5812.             $approveHash $request->request->get('approvalHash');
  5813.             if (!DocValidation::isInsertable(
  5814.                 $em,
  5815.                 $entity_id,
  5816.                 $dochash,
  5817.                 $loginId,
  5818.                 $approveRole,
  5819.                 $approveHash,
  5820.                 $id
  5821.             )
  5822.             ) {
  5823.                 $this->addFlash(
  5824.                     'error',
  5825.                     'Sorry Couldnot insert Data.'
  5826.                 );
  5827.             } else {
  5828.                 $funcname 'HolidayCalendar';
  5829.                 $doc_id $id;
  5830.                 DeleteDocument::$funcname($em$doc_id0);
  5831.                 if ($id != 0)
  5832.                     $HolidayCalender $em->getRepository(HolidayCalendar::class)->find($id);
  5833.                 else
  5834.                     $HolidayCalender = new HolidayCalendar;
  5835.                 $HolidayCalender->setDocumentHash($request->request->get('doc_hash'));
  5836.                 $HolidayCalender->setHoliDayTitle($request->request->get('holidayCalendarTitle'));
  5837.                 $HolidayCalender->setEmployeeIds(json_encode($request->request->get('employee')));
  5838.                 $HolidayCalender->setEmployeeTypeIds(json_encode($request->request->get('emp_status')));
  5839.                 $HolidayCalender->setDesignationIds(json_encode($request->request->get('desg', [])));
  5840.                 $HolidayCalender->setDepartmentIds(json_encode($request->request->get('dept', [])));
  5841.                 $HolidayCalender->setBranchIds(json_encode($request->request->get('branch', [])));
  5842.                 $HolidayCalender->setLevelSelectionStr($request->get('levelSelectionStr'''));
  5843.                 $HolidayCalender->setLevels(json_encode(HumanResource::getLevelsFromLevelSelectionStr($request->get('levelSelectionStr'''))));
  5844.                 $HolidayCalender->setCompanyId($companyId);
  5845.                 $HolidayCalender->setTypeHash('HD');
  5846.                 $HolidayCalender->setEditFlag(1); //editable usually
  5847.                 $HolidayCalender->setPrefixHash($request->request->get('prefix'));
  5848.                 $HolidayCalender->setAssocHash($request->request->get('assoc'));
  5849.                 $HolidayCalender->setNumberHash($request->request->get('number_hash'));
  5850.                 $HolidayCalender->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  5851.                 $HolidayCalender->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
  5852.                 $HolidayCalender->setAutocreated(0);
  5853. //
  5854. //        $arr = [
  5855. //            'date' =>$request->request->get('start_date'),
  5856. //            'title' => $request->request->get('title'),
  5857. //        ];
  5858. //
  5859. //        $HolidayCalender->setData(json_encode($arr));
  5860.                 $em->persist($HolidayCalender);
  5861.                 $em->flush();
  5862.                 $indHolidays = [];
  5863.                 if ($request->request->has('start_date'))
  5864.                     $indHolidays $request->request->get('start_date');
  5865.                 foreach ($indHolidays as $ind => $dateRangeStr) {
  5866.                     $currRow $request->request->get('row')[$ind];//string
  5867.                     $holidayTitle $request->request->get('title')[$ind];//string
  5868.                     $currStartDate $request->request->get('start_date')[$ind];//string
  5869.                     $currEndDate $request->request->get('end_date')[$ind];//string
  5870.                     $HolidayDate = new HolidayCalendarDates();
  5871.                     $HolidayDate->setHolidayCalendarId($HolidayCalender->getHolidayCalendarId());
  5872.                     $HolidayDate->setDateRange($currStartDate '-' $currEndDate);//string
  5873.                     $HolidayDate->setStartDate(new \DateTime($currStartDate));//date
  5874.                     $HolidayDate->setEndDate(new \DateTime($currEndDate ' 23:59:59'));//date
  5875.                     $HolidayDate->setHolidayTitle($holidayTitle);
  5876. //          $HolidayDate->setIsVariableEachYearFlag($request->request->get('is_variable_each_year',null));
  5877.                     $HolidayDate->setIsVariableEachYearFlag($request->request->get('is_variable_each_year_' $currRownull));
  5878.                     $HolidayDate->setAllDayFlag($request->request->get('all_day_flag_' $currRow1));
  5879.                     $em->persist($HolidayDate);
  5880.                     $em->flush();
  5881.                 }
  5882.                 $options = [];
  5883.                 $entity array_flip(GeneralConstant::$Entity_list)['HolidayCalendar'];
  5884.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  5885.                 $approveRole $request->request->get('approvalRole');
  5886.                 System::setApprovalInfo(
  5887.                     $em,
  5888.                     $options,
  5889.                     $entity,
  5890.                     $HolidayCalender->getHolidayCalendarId(),
  5891.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  5892.                 );
  5893.                 System::createEditSignatureHash(
  5894.                     $em,
  5895.                     $entity,
  5896.                     $HolidayCalender->getHolidayCalendarId(),
  5897.                     $loginId,
  5898.                     $approveRole,
  5899.                     $request->request->get('approvalHash')
  5900.                 );
  5901.                 $url $this->generateUrl(
  5902.                     'view_holiday_calendar'
  5903.                 );
  5904.                 return $this->redirect($url "/" $HolidayCalender->getHolidayCalendarId());
  5905.             }
  5906.         }
  5907.         $em $this->getDoctrine()->getManager();
  5908.         $branches $em->getRepository(Branch::class)->findAll();
  5909.         $employee $em->getRepository(Employee::class)->findAll();
  5910.         $departments $em->getRepository(SysDepartment::class)->findAll();
  5911.         $departmentPositions $em->getRepository(SysDepartmentPosition::class)->findAll();
  5912.         $EmploymentStatus HumanResourceConstant::$employeeType;
  5913.         $em $this->getDoctrine()->getManager();
  5914.         $extDocData = [];
  5915.         if ($id != 0)
  5916.             $extDocData $em->getRepository(HolidayCalendar::class)->find($id);
  5917.         return $this->render(
  5918.             'ApplicationBundle:pages/human_resource/input_forms:create_holiday.html.twig',
  5919.             [
  5920.                 'page_title' => 'Create Holiday',
  5921.                 'branches' => $branches,
  5922.                 'id' => $id,
  5923.                 'extDocData' => $extDocData,
  5924.                 'departments' => $departments,
  5925.                 'departmentPositions' => $departmentPositions,
  5926.                 'employeeStatus' => $EmploymentStatus,
  5927.                 'employeeIds' => $employee,
  5928.                 'holidayCalendarList' => $em->getRepository('ApplicationBundle:HolidayCalendar')
  5929.                     ->findBy(array())
  5930.             ]
  5931.         );
  5932.     }
  5933.     public function HolidayViewAction(Request $request$id)
  5934.     {
  5935.         $em $this->getDoctrine()->getManager();
  5936.         $HolidaysCalendar $em->getRepository(HolidayCalendar::class)->find($id);
  5937.         $holidayCalendarDetails $em->getRepository('ApplicationBundle:HolidayCalendarDates')
  5938.             ->findBy(array(
  5939.                 'holidayCalendarId' => $id
  5940.             ));
  5941.         $Approval_data System::checkIfApprovalExists(
  5942.             $em,
  5943.             array_flip(GeneralConstant::$Entity_list)['HolidayCalendar'],
  5944.             $id,
  5945.             $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  5946.         );
  5947.         return $this->render('ApplicationBundle:pages/human_resource/views:holidays_view.html.twig', array(
  5948.             'page_title' => 'View Holiday',
  5949.             'holidays' => $HolidaysCalendar,
  5950.             'holidayCalendarDetails' => $holidayCalendarDetails,
  5951.             'approval_status' => $HolidaysCalendar->getApproved(),
  5952.             'approval_data' => $Approval_data,
  5953.             'auto_created' => $HolidaysCalendar->getAutocreated(),
  5954.             'document_log' => $HolidaysCalendar->getAutocreated() == System::getDocumentLog(
  5955.                 $this->getDoctrine()->getManager(),
  5956.                 array_flip(GeneralConstant::$Entity_list)['HolidayCalendar'],
  5957.                 $id,
  5958.                 $HolidaysCalendar->getCreatedLoginId(),
  5959.                 $HolidaysCalendar->getEditedLoginId()
  5960.             ) : []
  5961.         ));
  5962.     }
  5963.     public function GetHolidayDetailsAction(Request $request$id)
  5964.     {
  5965.         $em $this->getDoctrine()->getManager();
  5966.         $holidayCalendar $em->getRepository('ApplicationBundle:HolidayCalendar')
  5967.             ->findOneBy(array(
  5968.                 'holidayCalendarId' => $id
  5969.             ));
  5970.         $holidayCalendarDetails $em->getRepository('ApplicationBundle:HolidayCalendarDates')
  5971.             ->findBy(array(
  5972.                 'holidayCalendarId' => $id
  5973.             ));
  5974.         $holidayList = [];
  5975.         foreach ($holidayCalendarDetails as $det) {
  5976.             $dateDet = array(
  5977.                 'title' => $det->getHolidayTitle(),
  5978.                 'startDate' => $det->getStartDate()->format('Y-m-d'),
  5979.                 'endDate' => $det->getEndDate()->format('Y-m-d'),
  5980.             );
  5981.             $holidayList[] = $dateDet;
  5982.         }
  5983.         return new JsonResponse(
  5984.             array(
  5985.                 'success' => true,
  5986.                 'holidayList' => $holidayList
  5987.             )
  5988.         );
  5989.     }
  5990.     public function GetHolidayListByEmployeeIdAction(Request $request$id)
  5991.     {
  5992.         $em $this->getDoctrine()->getManager();
  5993.         $options = [];
  5994.         $options['employeeId'] = $id;
  5995.         HumanResource::getFilteredHolidaysSingle($em$options);
  5996.         $holidayCalendar $em->getRepository('ApplicationBundle:HolidayCalendar')
  5997.             ->findOneBy(array(
  5998.                 'holidayCalendarId' => $id
  5999.             ));
  6000.         $holidayCalendarDetails $em->getRepository('ApplicationBundle:HolidayCalendarDates')
  6001.             ->findBy(array(
  6002.                 'holidayCalendarId' => $id
  6003.             ));
  6004.         $holidayList = [];
  6005.         foreach ($holidayCalendarDetails as $det) {
  6006.             $dateDet = array(
  6007.                 'title' => $det->getHolidayTitle(),
  6008.                 'startDate' => $det->getStartDate()->format('Y-m-d'),
  6009.                 'endDate' => $det->getEndDate()->format('Y-m-d'),
  6010.             );
  6011.             $holidayList[] = $dateDet;
  6012.         }
  6013.         return new JsonResponse(
  6014.             array(
  6015.                 'success' => true,
  6016.                 'holidayList' => $holidayList
  6017.             )
  6018.         );
  6019.     }
  6020.     public function createQuestionAction(Request $request)
  6021.     {
  6022.         $em $this->getDoctrine()->getManager();
  6023.         $em_goc $this->getDoctrine()->getManager('company_group');
  6024.         $companyId $this->getLoggedUserCompanyId($request);
  6025.         if ($request->isMethod('POST')) {
  6026.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6027.             $question = new Questionnaire();
  6028.             $question->setQuestionTitle($request->request->get('questionTitle'''));
  6029.             $question->setQuestionText($request->request->get('questionText'''));
  6030.             $question->setIsForPlanningItem($request->request->has('forPlanningItem') ? 0);
  6031.             $question->setIsForInterview($request->request->has('forInterview') ? 0);
  6032.             $question->setIsForMock($request->request->has('forMock') ? 0);
  6033.             $question->setIsForTraining($request->request->has('forTraining') ? 0);
  6034.             $question->setTaggedSkillHashes($request->request->get('skillHash'));
  6035.             $question->setCorrectAnswers(json_encode($request->request->get('correctAns')));
  6036.             $question->setCompanyId($companyId);
  6037.             $optionData = [];
  6038.             foreach ($request->request->get('optionText') as $key => $val) {
  6039.                 $option = array(
  6040.                     'index' => $request->request->get('optionIndex')[$key],
  6041.                     'text' => $val,
  6042.                 );
  6043.                 $optionData[] = $option;
  6044.             }
  6045.             $question->setOptions(json_encode($optionData));
  6046.             $question->setQuestionValueWeight(1);
  6047.             $question->setQuestionText($request->request->get('questionText'));
  6048.             $question->setUniqueHash('_NONE_');
  6049.             $question->setType($request->request->get('type'0));
  6050.             //$skill->setEditFlag(1); //editable usually
  6051.             $question->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  6052.             //$skill->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
  6053.             //$skill->setAutocreated(0);
  6054.             $em->persist($question);
  6055.             $em->flush();
  6056.             $questionId $question->getQuestionId();
  6057.             $file_path_list = [];
  6058.             if ($questionId != 0)
  6059.                 if (!empty($request->files)) {
  6060.                     MiscActions::RemoveFilesForEntityDoc($em_goc'Question'$questionId);
  6061.                     $storePath 'uploads/Questionnaire/';
  6062.                     $path "";
  6063.                     $file_path "";
  6064.                     $session $request->getSession();
  6065. //                    MiscActions::RemoveExpiredFiles($em_goc);
  6066.                     foreach ($request->files as $uploadedFileGG) {
  6067.                         //            if($uploadedFile->getImage())
  6068.                         //                var_dump($uploadedFile->getFile());
  6069.                         //                var_dump($uploadedFile);
  6070.                         $tempD $uploadedFileGG;
  6071.                         if (!is_array($uploadedFileGG)) {
  6072.                             $uploadedFileGG = array();
  6073.                             $uploadedFileGG[] = $tempD;
  6074.                         }
  6075.                         foreach ($uploadedFileGG as $uploadedFile) {
  6076.                             if ($uploadedFile != null) {
  6077.                                 $extension $uploadedFile->guessExtension();
  6078.                                 $size $uploadedFile->getSize();
  6079.                                 $fileName 'QUES_' $questionId '_' . (md5(uniqid())) . '.' $uploadedFile->guessExtension();
  6080.                                 $path $fileName;
  6081.                                 $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/' $storePath;
  6082.                                 if (!file_exists($upl_dir)) {
  6083.                                     mkdir($upl_dir0777true);
  6084.                                 }
  6085.                                 if (file_exists($upl_dir '' $path)) {
  6086.                                     chmod($upl_dir '' $path0755);
  6087.                                     unlink($upl_dir '' $path);
  6088.                                 }
  6089.                                 $file $uploadedFile->move($upl_dir$path);
  6090.                                 $expireNever 1;
  6091.                                 $expireTs 0;
  6092.                                 $EntityFile = new EntityFile();
  6093.                                 $EntityFile->setPath($this->container->getParameter('kernel.root_dir') . '/../web/' $storePath $path);
  6094.                                 $EntityFile->setMarker('_GEN_');
  6095.                                 $EntityFile->setExtension($extension);
  6096.                                 $EntityFile->setExpireTs($expireTs);
  6097.                                 $EntityFile->setSize($size);
  6098.                                 $EntityFile->setRelativePath($storePath $path);
  6099.                                 $EntityFile->setEntityName('Questionnaire');
  6100.                                 $EntityFile->setEntityBundle('ApplicationBundle');
  6101.                                 $EntityFile->setEntityId($questionId);
  6102.                                 $EntityFile->setEntityIdField('questionId');
  6103.                                 $EntityFile->setModifyFieldSetter('setFiles');
  6104.                                 $EntityFile->setDocIdForApplicant(0);
  6105.                                 $EntityFile->setUserId($session->get(UserConstants::USER_ID0));
  6106.                                 $EntityFile->setAppId($session->get(UserConstants::USER_APP_ID0));
  6107.                                 $EntityFile->setEmployeeId($session->get(UserConstants::USER_EMPLOYEE_ID0));
  6108.                                 $EntityFile->setUserType($session->get(UserConstants::USER_TYPE0));
  6109.                                 $em_goc->persist($EntityFile);
  6110.                                 $em_goc->flush();
  6111.                                 $EntityFileId $EntityFile->getId();
  6112.                             }
  6113.                             if ($path != "")
  6114.                                 $file_path_list[] = ($storePath $path);
  6115.                         }
  6116.                     }
  6117.                     $g_path $this->container->getParameter('kernel.root_dir') . '/../web/' $storePath $path;
  6118.                     $question->setFiles(implode(','$file_path_list));
  6119.                     $em->flush();
  6120.                 }
  6121.             if ($request->request->has('returnJson') || $request->query->has('returnJson')) {
  6122.                 if ($question)
  6123.                     return new JsonResponse(
  6124.                         array(
  6125.                             'id' => $questionId,
  6126.                             'value' => $questionId,
  6127.                             'question_id' => $questionId,
  6128.                             'text' => $question->getQuestionText(),
  6129.                             'question_text' => $question->getQuestionText(),
  6130.                             'question_title' => $question->getQuestionTitle(),
  6131.                             'files' => explode(','$question->getFiles()),
  6132.                             'options' => json_decode($question->getFiles(), true),
  6133.                             'answer_text' => '',
  6134.                             'success' => true
  6135.                         )
  6136.                     );
  6137.                 else
  6138.                     return new JsonResponse(
  6139.                         array(
  6140.                             'success' => false
  6141.                         )
  6142.                     );
  6143.             }
  6144.         }
  6145.         $skillDetails $em->getRepository(Skill::class)->findAll();
  6146.         $skillListObj = [];
  6147.         $skillListArray = [];
  6148.         foreach ($skillDetails as $skillDetail) {
  6149.             $dt = array(
  6150.                 'id' => $skillDetail->getSkillId(),
  6151.                 'name' => $skillDetail->getName(),
  6152.                 'hash' => $skillDetail->getUniqueHash(),
  6153.             );
  6154.             $skillListArray[] = $dt;
  6155.         }
  6156.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:createQuestion.html.twig', array(
  6157.             'page_title' => 'Create Question',
  6158.             'skiillDetails' => $skillDetails,
  6159.             'skillListArray' => $skillListArray,
  6160.         ));
  6161.     }
  6162.     public function createSkillAction(Request $request)
  6163.     {
  6164.         $em $this->getDoctrine()->getManager();
  6165.         $companyId $this->getLoggedUserCompanyId($request);
  6166.         if ($request->isMethod('POST')) {
  6167.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6168.             $skill = new Skill;
  6169.             $skill->setName($request->request->get('skillName'));
  6170.             $skill->setParentId($request->request->get('parentName'));
  6171.             $skill->setUniqueHash($request->request->get('uniqueHash'));
  6172.             $skill->setCompanyId($companyId);
  6173.             //$skill->setEditFlag(1); //editable usually
  6174.             $skill->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  6175.             //$skill->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
  6176.             //$skill->setAutocreated(0);
  6177.             $em->persist($skill);
  6178.             $em->flush();
  6179.         }
  6180.         $skillDetails $em->getRepository(Skill::class)->findAll();
  6181.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:createSkill.html.twig', array(
  6182.             'page_title' => 'Create Skill',
  6183.             'skiillDetails' => $skillDetails,
  6184.         ));
  6185.     }
  6186.     public function createEducationQualificationAction(Request $request)
  6187.     {
  6188.         $em $this->getDoctrine()->getManager();
  6189.         $companyId $this->getLoggedUserCompanyId($request);
  6190.         if ($request->isMethod('POST')) {
  6191.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6192.             $new = new EducationQualification;
  6193.             $new->setName($request->request->get('educationName'));
  6194.             $new->setParentId($request->request->get('parentName'));
  6195.             $new->setUniqueHash($request->request->get('uniqueHash'));
  6196.             $new->setCompanyId($companyId);
  6197.             //$skill->setEditFlag(1); //editable usually
  6198.             $new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  6199.             //$skill->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
  6200.             //$skill->setAutocreated(0);
  6201.             $em->persist($new);
  6202.             $em->flush();
  6203.         }
  6204.         $educationDetails $em->getRepository(EducationQualification::class)->findAll();
  6205.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_education.html.twig', array(
  6206.             'page_title' => 'Create Education',
  6207.             'educationDetails' => $educationDetails,
  6208.         ));
  6209.     }
  6210.     public function createEvaluationCategoryAction(Request $request$id 0)
  6211.     {
  6212.         $em $this->getDoctrine()->getManager();
  6213.         $companyId $this->getLoggedUserCompanyId($request);
  6214.         if ($request->isMethod('POST')) {
  6215.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6216.             $new = new EvaluationCategory;
  6217.             $new->setName($request->request->get('name'));
  6218.             $new->setBranch($request->request->get('branch'));
  6219.             $new->setSelectionType($request->request->get('selection_type'));
  6220.             $new->setEmployeeIds($request->request->get('selected_employeeIds'));
  6221.             $new->setEmployeeTypeIds($request->request->get('employee_types'));
  6222.             $new->setDesignationIds($request->request->get('designation'));
  6223.             $new->setDesignationIds($request->request->get('designation'));
  6224.             $new->setmark($request->request->get('mark'));
  6225.             $new->setSkills(json_encode($request->request->get('skill')));
  6226.             $new->setLevelSelectionStr($request->request->get('levelSelectionStr'));
  6227.             $new->setCompanyId($companyId);
  6228.             $new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  6229.             $em->persist($new);
  6230.             $em->flush();
  6231.         }
  6232.         $skill $em->getRepository(Skill::class)->findAll();
  6233.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  6234.         $employeeType HumanResourceConstant::$employeeType;
  6235.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  6236.         $branch $em->getRepository(Branch::class)->findAll();
  6237.         $departments $em->getRepository(SysDepartment::class)->findAll();
  6238.         $department = [];
  6239.         foreach ($departments as $entry) {
  6240.             $department[$entry->getDepartmentId()] = array(
  6241.                 'id' => $entry->getDepartmentId(),
  6242.                 'name' => $entry->getDepartmentName(),
  6243.             );
  6244.             return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_evaluation_category.html.twig', array(
  6245.                 'page_title' => 'Create Evaluation Category',
  6246.                 'employeeIds' => $employeeIds,
  6247.                 'employeeType' => $employeeType,
  6248.                 'Designation' => $Designation,
  6249.                 'branch' => $branch,
  6250.                 'department' => $department,
  6251.                 'skill' => $skill,
  6252.             ));
  6253.         }
  6254.     }
  6255.     public function createWorkplaceHarassmentAction(Request $request$id 0)
  6256.     {
  6257.         $em $this->getDoctrine()->getManager();
  6258.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  6259.         //$employeeType = HumanResourceConstant::$employeeType;
  6260.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  6261.         $branches $em->getRepository(Branch::class)->findAll();
  6262.         $departments $em->getRepository(SysDepartment::class)->findAll();
  6263.         $harassmentType HumanResourceConstant::$harrasmentType;
  6264.         $department = [];
  6265.         foreach ($departments as $entry) {
  6266.             $department[$entry->getDepartmentId()] = array(
  6267.                 'id' => $entry->getDepartmentId(),
  6268.                 'name' => $entry->getDepartmentName(),
  6269.             );
  6270.         }
  6271.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_workplace_harrasment.html.twig', array(
  6272.             'page_title' => 'Create Workplace Harrasment',
  6273.             'employeeIds' => $employeeIds,
  6274.             'branches' => $branches,
  6275.             'harassmentType' => $harassmentType,
  6276.             'departments' => $department,
  6277.             'designationIds' => $Designation
  6278.         ));
  6279.     }
  6280.     public function ViewHarasssmentComplainAction()
  6281.     {
  6282.         return $this->render('ApplicationBundle:pages/human_resource/views:view_harassment_compalin.html.twig', array(
  6283.             'page_title' => 'View Harassment Complain',
  6284.         ));
  6285.     }
  6286.     public function createWorkplaceViolenceAction(Request $request$id 0)
  6287.     {
  6288.         $em $this->getDoctrine()->getManager();
  6289.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  6290.         //$employeeType = HumanResourceConstant::$employeeType;
  6291.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  6292.         $branches $em->getRepository(Branch::class)->findAll();
  6293.         $departments $em->getRepository(SysDepartment::class)->findAll();
  6294.         $harassmentType HumanResourceConstant::$harrasmentType;
  6295.         $department = [];
  6296.         foreach ($departments as $entry) {
  6297.             $department[$entry->getDepartmentId()] = array(
  6298.                 'id' => $entry->getDepartmentId(),
  6299.                 'name' => $entry->getDepartmentName(),
  6300.             );
  6301.         }
  6302.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:register_workplace_complaint.html.twig', array(
  6303.             'page_title' => 'Register Complaint',
  6304.             'employeeIds' => $employeeIds,
  6305.             'branches' => $branches,
  6306.             'harassmentType' => $harassmentType,
  6307.             'departments' => $department,
  6308.             'designationIds' => $Designation
  6309.         ));
  6310.     }
  6311.     public function createBonusPolicyAction(Request $request$id 0)
  6312.     {
  6313.         $em $this->getDoctrine()->getManager();
  6314.         $companyId $this->getLoggedUserCompanyId($request);
  6315.         $extDocData = [];
  6316.         $extDetailsData = [];
  6317.         if ($request->isMethod('POST')) {
  6318.             //            Generic::debugMessage($_POST);
  6319.             $em $this->getDoctrine()->getManager();
  6320.             $entity_id array_flip(GeneralConstant::$Entity_list)['BonusPolicy']; //change
  6321.             $dochash $request->request->get('docHash'); //change
  6322.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6323.             $approveRole $request->request->get('approvalRole');
  6324.             $approveHash $request->request->get('approvalHash');
  6325.             if (!DocValidation::isInsertable(
  6326.                 $em,
  6327.                 $entity_id,
  6328.                 $dochash,
  6329.                 $loginId,
  6330.                 $approveRole,
  6331.                 $approveHash,
  6332.                 $id
  6333.             )
  6334.             ) {
  6335.                 $this->addFlash(
  6336.                     'error',
  6337.                     'Sorry Couldnot insert Data.'
  6338.                 );
  6339.             } else {
  6340.                 $funcname 'BonusPolicy';
  6341.                 DeleteDocument::$funcname($em$id0);
  6342.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6343.                 $docId HumanResource::createBonusPolicy($em$request$companyId$loginId0);
  6344.                 //now add Approval info
  6345.                 $approveRole $request->request->get('approvalRole');
  6346.                 $options = array(
  6347.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  6348.                     'notification_server' => $this->container->getParameter('notification_server'),
  6349.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  6350.                     'url' => $this->generateUrl(
  6351.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['BonusPolicy']]['entity_view_route_path_name']
  6352.                     )
  6353.                 );
  6354.                 System::setApprovalInfo(
  6355.                     $this->getDoctrine()->getManager(),
  6356.                     $options,
  6357.                     array_flip(GeneralConstant::$Entity_list)['BonusPolicy'],
  6358.                     $docId,
  6359.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  6360.                 );
  6361.                 System::createEditSignatureHash(
  6362.                     $this->getDoctrine()->getManager(),
  6363.                     array_flip(GeneralConstant::$Entity_list)['BonusPolicy'],
  6364.                     $docId,
  6365.                     $loginId,
  6366.                     $approveRole,
  6367.                     $request->request->get('approvalHash')
  6368.                 );
  6369.                 $doc_here $this->getDoctrine()
  6370.                     ->getRepository('ApplicationBundle:BonusPolicy')
  6371.                     ->findOneBy(
  6372.                         array(
  6373.                             'id' => $docId
  6374.                         )
  6375.                     );
  6376.                 //notify
  6377.                 $this->addFlash(
  6378.                     'success',
  6379.                     'Policy Successfully Updated.'
  6380.                 );
  6381.                 $url $this->generateUrl(
  6382.                     'view_bonus_policy'
  6383.                 );
  6384. //                System::AddNewNotification(
  6385. //                    $this->container->getParameter('notification_enabled'),
  6386. //                    $this->container->getParameter('notification_server'),
  6387. //                    $request->getSession()->get(UserConstants::USER_APP_ID),
  6388. //                    $request->getSession()->get(UserConstants::USER_COMPANY_ID),
  6389. //                    "Salary Segregation Policy : " . $doc_here->getDocumentHash() . " Has Been Created And is Under Processing",
  6390. //                    'pos',
  6391. //                    System::getPositionIdsByDepartment($em, GeneralConstant::HRM_DEPARTMENT),
  6392. //                    'success',
  6393. //                    //                    $url . "/" . $TransID,
  6394. //                    $url . "/" . $docId,
  6395. //                    "Journal"
  6396. //
  6397. //                );
  6398.                 return $this->redirect($url "/" $docId);
  6399.             }
  6400.         }
  6401.         //for edits
  6402.         if ($id == 0) {
  6403.         } else {
  6404.             $extDocData $em->getRepository('ApplicationBundle:BonusPolicy')->findOneBy(
  6405.                 array(
  6406.                     'id' => $id///material
  6407.                 )
  6408.             );
  6409.             //now if its not editable, redirect to view
  6410.             if ($extDocData) {
  6411.                 if ($extDocData->getEditFlag() != 1) {
  6412. //          $url = $this->generateUrl(
  6413. ////              'view_salary_segregation_policy'
  6414. //              'salary_segregation_policy'
  6415. //          );
  6416. //          return $this->redirect($url . "/" . $id);
  6417.                 } else {
  6418. //          $extVoucherDetailsData = Accounts::GetVoucherDataForEdit($em, $voucherId);
  6419. //          $extDetailsData = $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
  6420. //              array(
  6421. //                  'transactionId' => $id, ///material
  6422. //
  6423. //              )
  6424. //          );
  6425.                 }
  6426.             } else {
  6427.             }
  6428.         }
  6429.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  6430.         $employeeType HumanResourceConstant::$employeeType;
  6431.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  6432.         $branch $em->getRepository(Branch::class)->findAll();
  6433.         $departments $em->getRepository(SysDepartment::class)->findAll();
  6434.         $department = [];
  6435.         foreach ($departments as $entry) {
  6436.             $department[$entry->getDepartmentId()] = array(
  6437.                 'id' => $entry->getDepartmentId(),
  6438.                 'name' => $entry->getDepartmentName(),
  6439.             );
  6440.         }
  6441.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_bonus_policy.html.twig', array(
  6442.             'page_title' => 'Create Bonus Policy',
  6443.             'employeeIds' => $employeeIds,
  6444.             'employeeType' => $employeeType,
  6445.             'Designation' => $Designation,
  6446.             'branch' => $branch,
  6447.             'department' => $department,
  6448.         ));
  6449.     }
  6450.     public function BonusPolicyListAction()
  6451.     {
  6452.         $em $this->getDoctrine()->getManager();
  6453.         $bonusPolicy $em->getRepository(BonusPolicy::class)->findAll();
  6454.         return $this->render('ApplicationBundle:pages/human_resource/list:bonus_policy_list.html.twig', array(
  6455.             'page_title' => 'Increment Policy List',
  6456.             'bonusPolicy' => $bonusPolicy
  6457.         ));
  6458.     }
  6459.     public function createIncrementPolicyAction(Request $request$id 0)
  6460.     {
  6461.         $em $this->getDoctrine()->getManager();
  6462.         $companyId $this->getLoggedUserCompanyId($request);
  6463.         $extDocData = [];
  6464.         $extDetailsData = [];
  6465.         if ($request->isMethod('POST')) {
  6466.             //            Generic::debugMessage($_POST);
  6467.             $em $this->getDoctrine()->getManager();
  6468.             $entity_id array_flip(GeneralConstant::$Entity_list)['IncrementPolicy']; //change
  6469.             $dochash $request->request->get('docHash'); //change
  6470.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6471.             $approveRole $request->request->get('approvalRole');
  6472.             $approveHash $request->request->get('approvalHash');
  6473.             if (!DocValidation::isInsertable(
  6474.                 $em,
  6475.                 $entity_id,
  6476.                 $dochash,
  6477.                 $loginId,
  6478.                 $approveRole,
  6479.                 $approveHash,
  6480.                 $id
  6481.             )
  6482.             ) {
  6483.                 $this->addFlash(
  6484.                     'error',
  6485.                     'Sorry Couldnot insert Data.'
  6486.                 );
  6487.             } else {
  6488.                 $funcname 'IncrementPolicy';
  6489.                 DeleteDocument::$funcname($em$id0);
  6490.                 $docId HumanResource::createIncrementPolicy($em$request$companyId0);
  6491.                 //now add Approval info
  6492.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6493.                 $approveRole $request->request->get('approvalRole');
  6494.                 $options = array(
  6495.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  6496.                     'notification_server' => $this->container->getParameter('notification_server'),
  6497.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  6498.                     'url' => $this->generateUrl(
  6499.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['IncrementPolicy']]['view_increment_policy']
  6500.                     )
  6501.                 );
  6502.                 System::setApprovalInfo(
  6503.                     $this->getDoctrine()->getManager(),
  6504.                     $options,
  6505.                     array_flip(GeneralConstant::$Entity_list)['IncrementPolicy'],
  6506.                     $docId,
  6507.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID),
  6508.                     3    //journal voucher
  6509.                 );
  6510.                 System::createEditSignatureHash(
  6511.                     $this->getDoctrine()->getManager(),
  6512.                     array_flip(GeneralConstant::$Entity_list)['IncrementPolicy'],
  6513.                     $docId,
  6514.                     $loginId,
  6515.                     $approveRole,
  6516.                     $request->request->get('approvalHash')
  6517.                 );
  6518.                 $doc_here $this->getDoctrine()
  6519.                     ->getRepository('ApplicationBundle:IncrementPolicy')
  6520.                     ->findOneBy(
  6521.                         array(
  6522.                             'id' => $docId
  6523.                         )
  6524.                     );
  6525.                 //notify
  6526.                 $this->addFlash(
  6527.                     'success',
  6528.                     'Policy Successfully Updated.'
  6529.                 );
  6530.                 $url $this->generateUrl(
  6531.                     'view_increment_policy'
  6532.                 );
  6533. //                System::AddNewNotification(
  6534. //                    $this->container->getParameter('notification_enabled'),
  6535. //                    $this->container->getParameter('notification_server'),
  6536. //                    $request->getSession()->get(UserConstants::USER_APP_ID),
  6537. //                    $request->getSession()->get(UserConstants::USER_COMPANY_ID),
  6538. //                    "Salary Segregation Policy : " . $doc_here->getDocumentHash() . " Has Been Created And is Under Processing",
  6539. //                    'pos',
  6540. //                    System::getPositionIdsByDepartment($em, GeneralConstant::HRM_DEPARTMENT),
  6541. //                    'success',
  6542. //                    //                    $url . "/" . $TransID,
  6543. //                    $url . "/" . $docId,
  6544. //                    "Journal"
  6545. //
  6546. //                );
  6547.                 return $this->redirect($url "/" $docId);
  6548.             }
  6549.         }
  6550.         //for edits
  6551.         if ($id == 0) {
  6552.         } else {
  6553.             $extDocData $em->getRepository('ApplicationBundle:IncrementPolicy')->findOneBy(
  6554.                 array(
  6555.                     'id' => $id///material
  6556.                 )
  6557.             );
  6558.             //now if its not editable, redirect to view
  6559.             if ($extDocData) {
  6560.                 if ($extDocData->getEditFlag() != 1) {
  6561. //          $url = $this->generateUrl(
  6562. ////              'view_salary_segregation_policy'
  6563. //              'salary_segregation_policy'
  6564. //          );
  6565. //          return $this->redirect($url . "/" . $id);
  6566.                 } else {
  6567. //          $extVoucherDetailsData = Accounts::GetVoucherDataForEdit($em, $voucherId);
  6568. //          $extDetailsData = $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
  6569. //              array(
  6570. //                  'transactionId' => $id, ///material
  6571. //
  6572. //              )
  6573. //          );
  6574.                 }
  6575.             } else {
  6576.             }
  6577.         }
  6578.         //$em = $this->getDoctrine()->getManager();
  6579.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  6580.         $employeeType HumanResourceConstant::$employeeType;
  6581.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  6582.         $branch $em->getRepository(Branch::class)->findAll();
  6583.         $departments $em->getRepository(SysDepartment::class)->findAll();
  6584.         $department = [];
  6585.         foreach ($departments as $entry) {
  6586.             $department[$entry->getDepartmentId()] = array(
  6587.                 'id' => $entry->getDepartmentId(),
  6588.                 'name' => $entry->getDepartmentName(),
  6589.             );
  6590.         }
  6591.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_increment_policy.html.twig', array(
  6592.             'page_title' => 'Create Increment Policy',
  6593.             'employeeIds' => $employeeIds,
  6594.             'employeeType' => $employeeType,
  6595.             'Designation' => $Designation,
  6596.             'branch' => $branch,
  6597.             'department' => $department,
  6598.         ));
  6599.     }
  6600.     public function IncrementPolicyListAction()
  6601.     {
  6602.         $em $this->getDoctrine()->getManager();
  6603.         $incrementPolicy $em->getRepository(IncrementPolicy::class)->findAll();
  6604.         return $this->render('ApplicationBundle:pages/human_resource/list:increment_policy_list.html.twig', array(
  6605.             'page_title' => 'Increment Policy List',
  6606.             'incrementPolicy' => $incrementPolicy
  6607.         ));
  6608.     }
  6609.     public function ViewIncrementPolicyAction(Request $request$id)
  6610.     {
  6611.         $em $this->getDoctrine()->getManager();
  6612.         $incrementPolicy $em->getRepository(IncrementPolicy::class)->find($id);
  6613.         $Approval_data System::checkIfApprovalExists(
  6614.             $em,
  6615.             array_flip(GeneralConstant::$Entity_list)['IncrementPolicy'],
  6616.             $id,
  6617.             $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  6618.         );
  6619.         return $this->render('ApplicationBundle:pages/human_resource/views:view_increment_policy.html.twig', array(
  6620.             'page_title' => 'Increment Policy List',
  6621.             'incrementPolicy' => $incrementPolicy,
  6622.             'approval_status' => $incrementPolicy->getApproved(),
  6623.             'approval_data' => $Approval_data,
  6624.             'auto_created' => $incrementPolicy->getAutocreated(),
  6625.             'id' => $id,
  6626.             'document_log' => $incrementPolicy->getAutocreated() == System::getDocumentLog(
  6627.                 $this->getDoctrine()->getManager(),
  6628.                 array_flip(GeneralConstant::$Entity_list)['FundRequisition'],
  6629.                 $id,
  6630.                 $incrementPolicy->getCreatedLoginId(),
  6631.                 $incrementPolicy->getEditedLoginId()
  6632.             ) : []
  6633.         ));
  6634.     }
  6635.     public function createConsultancyTopicAction(Request $request$id 0)
  6636.     {
  6637.         $em $this->getDoctrine()->getManager();
  6638.         $companyId $this->getLoggedUserCompanyId($request);
  6639.         if ($request->isMethod('POST')) {
  6640.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6641.             $new = new ConsultancyTopic();
  6642.             $new->setTopicName($request->request->get('topicName'));
  6643.             $new->setParentTopicName($request->request->get('parentTopicName'));
  6644.             $new->setUniqueHash($request->request->get('uniqueHash'));
  6645.             $new->setCompanyId($companyId);
  6646.             $new->setTopicSlug($request->request->get('topicSlug'));
  6647.             $new->setTitle($request->request->get('title'));
  6648.             $new->setSubTitle($request->request->get('subTitle'));
  6649.             $new->setSummary($request->request->get('content'));
  6650.             $new->setVideo($request->request->get('video'));
  6651.             $new->setAuthor($request->request->get('author'));
  6652.             $new->setAuthorSummary($request->request->get('authorSummary'));
  6653.             $new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  6654. //            $arr = [
  6655. //                'requirement' => $request->request->get('requirement'),
  6656. //
  6657. //            ];
  6658. //            $new->setRequirementData(json_encode($arr));
  6659.             $em->persist($new);
  6660.             $em->flush();
  6661.         }
  6662. //            $data = [];
  6663. //            $em = $this->getDoctrine()->getManager();
  6664. //            $companyId = $this->getLoggedUserCompanyId($request);
  6665. //            if ($request->isMethod('POST')) {
  6666. //                $em = $this->getDoctrine()->getManager();
  6667. //                $entity_id = array_flip(GeneralConstant::$Entity_list)['ConsultancyTopic'];
  6668. //                //$dochash = $request->request->get('docHash');//change
  6669. //                $approveRole = $request->request->get('approvalRole');
  6670. //                $approveHash = $request->request->get('approvalHash');
  6671. //                $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6672. //                if (!DocValidation::isInsertable($em, $entity_id,
  6673. //                    $loginId, $approveRole, $approveHash, $id)
  6674. //                ) {
  6675. //                    $this->addFlash(
  6676. //                        'error',
  6677. //                        'Sorry Could not insert Data.'
  6678. //                    );
  6679. //                }  else {
  6680. //                    $data = $request->request;
  6681. //                    $docId = HumanResource::createConsultancyTopic($em, $loginId, $id, $data, $companyId);
  6682. ////                    now add Approval info
  6683. //
  6684. //                    $approveRole = $request->request->get('approvalRole');
  6685. //                    $options = array(
  6686. //                        'notification_enabled' => $this->container->getParameter('notification_enabled'),
  6687. //                        'notification_server' => $this->container->getParameter('notification_server'),
  6688. //                        'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  6689. ////                        'url' => $this->generateUrl(
  6690. ////                            GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['EmployeePerformanceEvolution']]
  6691. ////                            ['entity_view_route_path_name']
  6692. ////                        )
  6693. //                    );
  6694. //                    System::setApprovalInfo($this->getDoctrine()->getManager(), $options,
  6695. //                        array_flip(GeneralConstant::$Entity_list)['ConsultancyTopic'],
  6696. //                        $docId,
  6697. //                        $request->getSession()->get(UserConstants::USER_LOGIN_ID)    //journal voucher
  6698. //                    );
  6699. //                    System::createEditSignatureHash($this->getDoctrine()->getManager(), array_flip(GeneralConstant::$Entity_list)['ConsultancyTopic'],
  6700. //                        $docId,
  6701. //                        $loginId,
  6702. //                        $request->request->get('approvalHash'));
  6703. //                    $this->addFlash(
  6704. //                        'success',
  6705. //                        'New Consultancy Topic Added.'
  6706. //                    );
  6707. ////                    $url = $this->generateUrl(
  6708. ////                        'create_consultancy_topic'
  6709. ////                    );
  6710. //                    //return $this->redirect($url);
  6711. //
  6712. //                }
  6713. //            }
  6714.         $consultancyDetails $em->getRepository('ApplicationBundle:ConsultancyTopic')->findAll();
  6715.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_consultancy.html.twig', array(
  6716.             'page_title' => 'Consultancy Topic',
  6717.             'consultancyDetails' => $consultancyDetails,
  6718. //                'requirement' => json_decode($consultancyDetails->getRequirementData())
  6719.         ));
  6720.     }
  6721.     public function createTopicAction(Request $request$id 0)
  6722.     {
  6723.         $em $this->getDoctrine()->getManager('company_group');
  6724.         $companyId $this->getLoggedUserCompanyId($request);
  6725.         $documentQRY $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->findAll();
  6726.         $topicList $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findAll();
  6727.         $topic = [];
  6728.         $sessionName BuddybeeConstant::$sessionName;
  6729.         $document = [];
  6730.         foreach ($documentQRY as $d) {
  6731.             $document[$d->getId()] = array(
  6732.                 'id' => $d->getId(),
  6733.                 'documentName' => $d->getDocumentName(),
  6734.                 'text' => $d->getDocumentName(),
  6735.             );
  6736.         }
  6737.         $topicId $id;
  6738.         if ($topicId != 0)
  6739.             $topic $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
  6740.                 array(
  6741.                     'id' => $topicId
  6742.                 )
  6743.             );
  6744.         if ($request->isMethod('POST')) {
  6745.             if ($request->request->has('topicId'))
  6746.                 $topicId $request->request->get('topicId');
  6747. //            $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6748.             if ($topicId != 0)
  6749.                 $new $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
  6750.                     array(
  6751.                         'id' => $topicId
  6752.                     )
  6753.                 );
  6754.             else
  6755.                 $new = new EntityCreateTopic();
  6756.             $new->setTopicName($request->request->get('topicName'));
  6757.             $new->setParentTopicId($request->request->get('parentTopic'));
  6758.             if ($request->request->get('countryId') != '')
  6759.                 $new->setCountryId($request->request->get('countryId'));
  6760.             else if ($request->request->get('parentTopic') != '') {
  6761.                 $parentTopic $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
  6762.                     array(
  6763.                         'id' => $request->request->get('parentTopic')
  6764.                     )
  6765.                 );
  6766.                 if ($parentTopic)
  6767.                     $new->setCountryId($parentTopic->getCountryId());
  6768.             }
  6769.             $new->setTimeSlotMultipliers($request->request->get('timeSlotMultipliers'));
  6770.             $new->setOnlyBookableByAdmin($request->request->get('onlyBookableByAdmin'0));
  6771.             $new->setMeetingType($request->request->get('meetingType'0));
  6772.             $new->setConsultantCanUpload($request->request->get('consultantCanUpload'0));
  6773.             $new->setTopicMarker($request->request->get('topicMarker'));
  6774.             $new->setCoinMultiplierValue($request->request->get('coinMultiplierValue'1));
  6775.             $new->setMinLifetimeCoinsBalance($request->request->get('minLifetimeCoinsBalance'0));
  6776.             $new->setMapEmbedIframe($request->request->get('mapEmbedIframe'''));
  6777.             $new->setTopicSummary($request->request->get('topicSummary'));
  6778.             $new->setAddress($request->request->get('address'));
  6779.             $new->setLocationString($request->request->get('locationString'));
  6780.             $new->setLocationLat($request->request->get('locationLat'));
  6781.             $new->setLocationLong($request->request->get('locationLong'));
  6782.             $new->setUniversityRanking($request->request->get('universityRanking'));
  6783.             $new->setIsParent($request->request->get('isParent'));
  6784.             $new->setIsEvent($request->request->get('isEvent'));
  6785.             $new->setConsultancyEnabled($request->request->get('consultancyEnabled'0));
  6786.             $new->setEventExpired($request->request->get('eventExpired'0));
  6787.             $new->setEventDesc($request->request->get('eventDesc'0));
  6788.             $eventStartDate = new \DateTime($request->request->get('eventStartDate'));
  6789.             $eventEndDate = new \DateTime($request->request->get('eventStartDate'));
  6790.             $new->setEventStartDate($eventStartDate);
  6791.             $new->setEventStartDateTs($eventStartDate->format('U'));
  6792.             $new->setEventEndDate($eventEndDate);
  6793.             $new->setEventStartDateTs($eventEndDate->format('U'));
  6794.             $new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  6795.             $checkListStringArray = [];
  6796.             if ($request->request->has('checkList'))
  6797.                 foreach ($request->request->get('checkList') as $value) {
  6798.                     $checkListStringArray [] = explode(","$value);
  6799.                 }
  6800.             $docData = [];
  6801.             foreach ($request->request->get('document', []) as $key => $value)
  6802.                 $docData[] = [
  6803.                     'document' => $request->request->get('document')[$key],
  6804.                     'expDays' => $request->request->get('expDays')[$key],
  6805.                     'stage' => $request->request->get('stage')[$key],
  6806.                     'generalProcessingDays' => $request->request->get('generalProcessingDays')[$key],
  6807.                     'emergencyProcessingDays' => $request->request->get('emergencyProcessingDays')[$key],
  6808.                     'thresholdDaysOffset' => $request->request->get('thresholdDaysOffset')[$key],
  6809.                     'checklist' => explode(","$request->request->get('checkList')[$key])
  6810.                 ];
  6811.             $coursePlanData = [];
  6812.             foreach ($request->request->get('coursePlanSessionNo', []) as $key => $value)
  6813.                 if ($request->request->get('coursePlanSessionNo')[$key] != '' and $request->request->get('coursePlanSessionNo')[$key] != null) {
  6814.                     if (!isset($coursePlanData[$request->request->get('coursePlanSessionNo')[$key]]))
  6815.                         $coursePlanData[$request->request->get('coursePlanSessionNo')[$key]] = [];
  6816.                     $coursePlanData[$request->request->get('coursePlanSessionNo')[$key]][] = [
  6817.                         'sessionNo' => $request->request->get('coursePlanSessionNo')[$key],
  6818.                         'subject' => $request->request->get('coursePlanSubject')[$key],
  6819.                         'details' => $request->request->get('coursePlanDetails')[$key],
  6820.                         'optimumMin' => $request->request->get('coursePlanOptimumMin')[$key],
  6821.                     ];
  6822.                 }
  6823.             $routineData = [];
  6824.             foreach ($request->request->get('routine_sequence', []) as $key => $value) {
  6825.                 $routineData[] = [
  6826.                     'sequence' => $request->request->get('routine_sequence')[$key],
  6827.                     'topicId' => $request->request->get('routine_topic_id')[$key],
  6828.                     'topicName' => $request->request->get('routine_topic_name')[$key],
  6829.                     'meetingType' => $request->request->get('routine_topic_meeting_type')[$key],
  6830.                     'duration' => $request->request->get('routine_duration')[$key],
  6831.                     'offset' => $request->request->get('routine_offset')[$key],
  6832.                     'coins' => $request->request->get('routine_coins')[$key],
  6833.                     'nextSequenceStart' => $request->request->has('routine_next_sequence_start_' $value) ? 0,
  6834.                     'modifiable' => $request->request->has('routine_modifiable_' $value) ? 0,
  6835.                 ];
  6836.             }
  6837.             $sessionData = [];
  6838.             foreach ($request->request->get('sessionId', []) as $key => $value)
  6839.                 $sessionData[] = [
  6840.                     'sessionId' => $request->request->get('sessionId')[$key],
  6841.                     'sessionYear' => $request->request->get('year')[$key],
  6842.                     'threshold' => $request->request->get('threshold')[$key],
  6843.                     'sessionStart' => $request->request->get('sessionStart')[$key],
  6844.                     'applicationStartDate' => $request->request->get('applicationStartDate')[$key],
  6845.                 ];
  6846.             $coursesData = [];
  6847.             foreach ($request->request->get('courseName', []) as $key => $value)
  6848.                 $coursesData[] = [
  6849.                     'courseName' => $request->request->get('courseName')[$key],
  6850.                 ];
  6851.             $departmentData = [];
  6852.             foreach ($request->request->get('departmentName', []) as $key => $value)
  6853.                 $departmentData[] = [
  6854.                     'departmentName' => $request->request->get('departmentName')[$key],
  6855.                 ];
  6856.             $benefitsData = [];
  6857.             foreach ($request->request->get('benefit', []) as $key => $value)
  6858.                 $benefitsData[] = [
  6859.                     'benefit' => $request->request->get('benefit')[$key],
  6860.                 ];
  6861.             $new->setRoutineData(json_encode($routineData));
  6862.             $new->setDocumentData(json_encode($docData));
  6863.             $new->setCoursePlanData(json_encode($coursePlanData));
  6864.             $new->setSessionData(json_encode($sessionData));
  6865.             $new->setCourses(json_encode($coursesData));
  6866.             $new->setDepartments(json_encode($departmentData));
  6867.             $new->setBenefits(json_encode($benefitsData));
  6868.             $otherDataObj = [];
  6869.             foreach (BuddybeeConstant::$otherDataByHash as $ohash => $otherDataGroup)
  6870.                 foreach ($otherDataGroup as $otherData) {
  6871.                     $fieldExists $request->request->has($ohash '_' $otherData['field']);
  6872.                     if ($fieldExists) {
  6873.                         $fieldValue $request->request->get($ohash '_' $otherData['field'], '');
  6874.                         $otherDataObj[$ohash '_' $otherData['field']] = $fieldValue;
  6875.                     }
  6876.                 }
  6877.             $new->setOtherData(json_encode($otherDataObj));
  6878.             $new->setBenefits(json_encode($benefitsData));
  6879.             $em->persist($new);
  6880.             $em->flush();
  6881.             $path "";
  6882.             $defaultProductImage '';
  6883.             $uploadedFile null;
  6884.             $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/topicImage/';
  6885.             $uploadedFile $request->files->get('topicSummaryImage');
  6886.             if ($uploadedFile != null) {
  6887.                 $fileName 'TSI' $new->getId() . '.' $uploadedFile->guessExtension();
  6888.                 $path $fileName;
  6889. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  6890.                 if (!file_exists($upl_dir)) {
  6891.                     mkdir($upl_dir0777true);
  6892.                 }
  6893.                 $uploadedFile->move($upl_dir$path);
  6894.                 $defaultProductImage 'uploads/topicImage/' $path;
  6895.                 $new->setTopicSummaryImage($defaultProductImage);
  6896.                 $em->flush();
  6897.             }
  6898.             $path "";
  6899.             $defaultProductImage '';
  6900.             $uploadedFile null;
  6901.             $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/topicImage/';
  6902.             $uploadedFile $request->files->get('topicImage');
  6903.             if ($uploadedFile != null) {
  6904.                 $fileName 'TI' $new->getId() . '.' $uploadedFile->guessExtension();
  6905.                 $path $fileName;
  6906. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  6907.                 if (!file_exists($upl_dir)) {
  6908.                     mkdir($upl_dir0777true);
  6909.                 }
  6910.                 $uploadedFile->move($upl_dir$path);
  6911.                 $defaultProductImage 'uploads/topicImage/' $path;
  6912.                 $new->setTopicImage($defaultProductImage);
  6913.                 $em->flush();
  6914.             }
  6915.             $this->addFlash(
  6916.                 'success',
  6917.                 'Topic Added.'
  6918.             );
  6919.         }
  6920.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_topic.html.twig', array(
  6921.             'page_title' => 'Create Topic',
  6922.             'defaultCoursePlan' => BuddybeeConstant::$defaultCoursePlan,
  6923.             'coursePlanSessionTitle' => BuddybeeConstant::$coursePlanSessionTitle,
  6924.             'coursePlanSessionTitleShort' => BuddybeeConstant::$coursePlanSessionTitleShort,
  6925.             'document' => $document,
  6926.             'topic' => $topic,
  6927.             'otherDataByHash' => BuddybeeConstant::$otherDataByHash,
  6928.             'topicId' => $topicId,
  6929.             'topicList' => $topicList,
  6930.             'topicMarker' => BuddybeeConstant::$topicMarkup,
  6931.             'sessionName' => $sessionName,
  6932.         ));
  6933.     }
  6934.     public function ConsultancyRequirementSettingsAction(Request $request$id 0)
  6935.     {
  6936.         $em $this->getDoctrine()->getManager('company_group');
  6937.         $entityList $em->getRepository('CompanyGroupBundle:EntityCountryConsultantRequirements')->findAll();
  6938.         $documentQRY $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->findAll();
  6939.         $entity = [];
  6940.         $sessionName BuddybeeConstant::$sessionName;
  6941.         $document = [];
  6942.         foreach ($documentQRY as $d) {
  6943.             $document[$d->getId()] = array(
  6944.                 'id' => $d->getId(),
  6945.                 'documentName' => $d->getDocumentName(),
  6946.                 'text' => $d->getDocumentName(),
  6947.             );
  6948.         }
  6949.         $countryId $id;
  6950.         if ($countryId != 0)
  6951.             $entity $em->getRepository('CompanyGroupBundle:EntityCountryConsultantRequirements')->findOneBy(
  6952.                 array(
  6953.                     'countryId' => $countryId
  6954.                 )
  6955.             );
  6956.         if ($request->isMethod('POST')) {
  6957.             if ($request->request->has('countryId'))
  6958.                 $countryId $request->request->get('countryId');
  6959. //            $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6960.             if ($countryId != 0) {
  6961.                 $new $em->getRepository('CompanyGroupBundle:EntityCountryConsultantRequirements')->findOneBy(
  6962.                     array(
  6963.                         'countryId' => $countryId
  6964.                     )
  6965.                 );
  6966.                 if (!$new)
  6967.                     $new = new EntityCountryConsultantRequirements();
  6968.             } else
  6969.                 $new = new EntityCountryConsultantRequirements();
  6970.             $new->setCountryId($request->request->get('countryId'));
  6971.             $new->setContractLetterHtml($request->request->get('contractLetterHtml'));
  6972.             $new->setRequiredFields($request->request->get('requiredFields'));
  6973.             $new->setAllowedWorkingHoursPerDay($request->request->get('allowedWorkingHoursPerDay'));
  6974.             $new->setAllowedWorkingHoursPerMonth($request->request->get('allowedWorkingHoursPerMonth'));
  6975.             $new->setAllowedWorkingHoursPerWeek($request->request->get('allowedWorkingHoursPerWeek'));
  6976.             $new->setAllowedWorkingHoursPerYear($request->request->get('allowedWorkingHoursPerYear'));
  6977.             $new->setAllowedEarningPerDay($request->request->get('allowedEarningPerDay'));
  6978.             $new->setAllowedEarningPerMonth($request->request->get('allowedEarningPerMonth'));
  6979.             $new->setAllowedEarningPerWeek($request->request->get('allowedEarningPerWeek'));
  6980.             $new->setAllowedEarningPerYear($request->request->get('allowedEarningPerYear'));
  6981.             $new->setRevenuePercentagePerSession($request->request->get('revenuePercentagePerSession'));
  6982.             $docData = [];
  6983.             foreach ($request->request->get('document', []) as $key => $value)
  6984.                 $docData[] = [
  6985.                     'document' => $request->request->get('document')[$key],
  6986.                     'expDays' => $request->request->get('expDays')[$key],
  6987.                     'stage' => $request->request->get('stage')[$key],
  6988.                     'generalProcessingDays' => $request->request->get('generalProcessingDays')[$key],
  6989.                     'emergencyProcessingDays' => $request->request->get('emergencyProcessingDays')[$key],
  6990.                     'thresholdDaysOffset' => $request->request->get('thresholdDaysOffset')[$key],
  6991.                     'checklist' => explode(","$request->request->get('checkList')[$key])
  6992.                 ];
  6993.             $new->setDocumentList(json_encode($docData));
  6994.             $em->persist($new);
  6995.             $em->flush();
  6996.             $this->addFlash(
  6997.                 'success',
  6998.                 'Restriction Updated.'
  6999.             );
  7000.         }
  7001.         return $this->render('@Buddybee/pages/create_consultancy_requirements.html.twig', array(
  7002.             'page_title' => 'Create Requirements',
  7003.             'defaultCoursePlan' => BuddybeeConstant::$defaultCoursePlan,
  7004.             'coursePlanSessionTitle' => BuddybeeConstant::$coursePlanSessionTitle,
  7005.             'coursePlanSessionTitleShort' => BuddybeeConstant::$coursePlanSessionTitleShort,
  7006.             'document' => $document,
  7007.             'entity' => $entity,
  7008.             'otherDataByHash' => BuddybeeConstant::$otherDataByHash,
  7009.             'countryId' => $countryId,
  7010.             'entityList' => $entityList,
  7011.             'topicMarker' => BuddybeeConstant::$topicMarkup,
  7012.             'sessionName' => $sessionName,
  7013.         ));
  7014.     }
  7015.     public function PromoCodeSettingsAction(Request $request$id 0)
  7016.     {
  7017.         $em $this->getDoctrine()->getManager('company_group');
  7018.         $entityList $em->getRepository('CompanyGroupBundle:PromoCode')->findAll();
  7019.         $applicantList $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findAll();
  7020.         $promoCodeId $id;
  7021.         $entity = [];
  7022.         if ($promoCodeId != 0)
  7023.             $entity $em->getRepository('CompanyGroupBundle:PromoCode')->findOneBy(
  7024.                 array(
  7025.                     'id' => $promoCodeId
  7026.                 )
  7027.             );
  7028.         if ($request->isMethod('POST')) {
  7029.             if ($request->request->has('promoCodeId'))
  7030.                 $promoCodeId $request->request->get('promoCodeId');
  7031. //            $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7032.             if ($promoCodeId != 0) {
  7033.                 $new $em->getRepository('CompanyGroupBundle:PromoCode')->findOneBy(
  7034.                     array(
  7035.                         'id' => $promoCodeId
  7036.                     )
  7037.                 );
  7038.                 if (!$new)
  7039.                     $new = new PromoCode();
  7040.             } else
  7041.                 $new = new PromoCode();
  7042. //            $new->setCountryId($request->request->get('countryId'));
  7043.             $new->setCode($request->request->get('code'''));
  7044.             $new->setPromoType($request->request->get('promoType'1));
  7045.             $new->setPromoCodeType($request->request->get('promoCodeType'1));
  7046.             $new->setPromoValue($request->request->get('promoValue'0));
  7047.             $new->setPerpetual($request->request->get('perpetual'0));
  7048.             $new->setMaxDiscountAmount($request->request->get('maxDiscountAmount', -1));
  7049.             $new->setMaxCoinAddition($request->request->get('maxCoinAddition', -1));
  7050.             $new->setMinAmountForApplication($request->request->get('minAmountForApplication'0));
  7051.             $new->setMinCoinForApplication($request->request->get('minCoinForApplication'0));
  7052.             $new->setNextApplicationEachCoinCount($request->request->get('nextApplicationEachCoinCount', -1));
  7053.             $new->setMaxUseCount($request->request->get('maxUseCount', -1));
  7054.             $new->setMaxUseCountPerUser($request->request->get('maxUseCountPerUser', -1));
  7055.             $new->setUseCountBalance($request->request->get('useCountBalance', -1));
  7056.             $new->setReferralApplicantId($request->request->get('referralApplicantId'0));
  7057.             $new->setMaxReferralCommissionCount($request->request->get('maxReferralCommissionCount'0));
  7058.             $new->setReferralCommissionCountBalance($request->request->get('referralCommissionCountBalance'0));
  7059.             $new->setReferralCommissionType($request->request->get('referralCommissionType'1));
  7060.             $new->setReferralAmount($request->request->get('referralAmount'0));
  7061.             $startsAt = new \DateTime($request->request->get('startsAt'''));
  7062.             $expiresAt = new \DateTime($request->request->get('expiresAt'''));
  7063.             $new->setStartsAtTs($startsAt->format('U'));
  7064.             $new->setExpiresAtTs($expiresAt->format('U'));
  7065. //
  7066. //        startsAtTs:
  7067. //            type: integer
  7068. //            nullable: true
  7069. //        expiresAtTs:
  7070. //            type: integer
  7071. //            nullable: true
  7072.             $em->persist($new);
  7073.             $em->flush();
  7074.             $this->addFlash(
  7075.                 'success',
  7076.                 'Promo Code Updated.'
  7077.             );
  7078.         }
  7079.         return $this->render('@Buddybee/pages/buddybee_promo_code_settings.html.twig', array(
  7080.             'page_title' => 'Promo Codes',
  7081.             'entity' => $entity,
  7082.             'promoCodeId' => $promoCodeId,
  7083.             'entityList' => $entityList,
  7084.             'applicantList' => $applicantList,
  7085.         ));
  7086.     }
  7087.     public function createDocumentAction(Request $request$id 0)
  7088.     {
  7089.         $em $this->getDoctrine()->getManager('company_group');
  7090.         $companyId $this->getLoggedUserCompanyId($request);
  7091.         $document $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->findAll();
  7092.         $thisDoc = [];
  7093.         if ($id != 0)
  7094.             $thisDoc $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->findOneBy(
  7095.                 array(
  7096.                     'Id' => $id
  7097.                 )
  7098.             );
  7099.         if ($request->isMethod('POST')) {
  7100.             if ($id != 0)
  7101.                 $new $thisDoc;
  7102.             else
  7103.                 $new = new EntityCreateDocument();
  7104.             $new->setDocumentName($request->request->get('docName'));
  7105.             $new->setExpiryDays($request->request->get('expDays'));
  7106.             $new->setProcessingDays($request->request->get('processingDays'));
  7107.             $new->setEmergencyProcessingDays($request->request->get('emergencyProcessingDays'));
  7108.             $new->setDocVideo($request->request->get('docVideoLink'));
  7109.             $new->setRequiredDocument(json_encode($request->request->get('requiredDoc')));
  7110.             $new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  7111.             $arr = [
  7112.                 'checkListName' => $request->request->get('checkListName'),
  7113.             ];
  7114.             $new->setCheckList(json_encode($arr));
  7115.             $em->persist($new);
  7116.             $em->flush();
  7117.         }
  7118.         $this->addFlash(
  7119.             'Document Added',
  7120.             'Topic Added.'
  7121.         );
  7122.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_document.html.twig', array(
  7123.             'page_title' => 'Create Document',
  7124.             'document' => $document,
  7125.             'thisDoc' => $thisDoc
  7126.         ));
  7127.     }
  7128.     public function getIndividualDocumentAction(Request $request$id)
  7129.     {
  7130.         $em $this->getDoctrine()->getManager('company_group');
  7131.         if ($id == 0) {
  7132.             if ($request->request->has('documentId'))
  7133.                 $id $request->request->get('documentId');
  7134.         }
  7135.         $document $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->find($id);
  7136.         return new JsonResponse(
  7137.             array(
  7138.                 'success' => true,
  7139.                 'rowId' => $request->request->get('rowId'),
  7140.                 'expiryDays' => $document->getExpiryDays(),
  7141.                 'processingDays' => $document->getProcessingDays(),
  7142.                 'emergencyProcessing' => $document->getEmergencyProcessingDays(),
  7143.                 'checklist' => json_decode($document->getCheckList()),
  7144.             )
  7145.         );
  7146.     }
  7147.     public function createBlogAction(Request $request$id)
  7148.     {
  7149.         if (!$id) {
  7150.             if ($request->isMethod('POST')) {
  7151.                 $em $this->getDoctrine()->getManager('company_group');
  7152.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7153.                 $new = new EntityCreateBlog();
  7154.                 $new->setTopicId($request->request->get('topicId'));
  7155.                 $new->setTitle($request->request->get('title'));
  7156.                 $new->setSubtitle($request->request->get('subTitle'));
  7157.                 $new->setContent($request->request->get('content'));
  7158.                 $new->setVideoLink($request->request->get('videoLink'));
  7159.                 $new->setAuthorName($request->request->get('authorName'));
  7160.                 $new->setAuthorSummary($request->request->get('authorSummary'));
  7161.                 $new->setIsPrimaryBlog($request->request->get('checkPrimaryBlog'));
  7162.                 $em->persist($new);
  7163.                 $em->flush();
  7164.                 //$fileName = 'cv' . $consultantDetails->getApplicantId() . '.' . $uploadedFile->guessExtension();
  7165.                 $path "";
  7166.                 $defaultProductImage '';
  7167.                 $uploadedFile null;
  7168.                 $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/authorImage/';
  7169.                 $uploadedFile $request->files->get('authorImage');
  7170.                 if ($uploadedFile != null) {
  7171.                     $fileName 'authorImage' $new->getId() . '.' $uploadedFile->guessExtension();
  7172.                     $path $fileName;
  7173. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  7174.                     if (!file_exists($upl_dir)) {
  7175.                         mkdir($upl_dir0777true);
  7176.                     }
  7177.                     $uploadedFile->move($upl_dir$path);
  7178.                     $defaultProductImage 'uploads/authorImage/' $path;
  7179.                     $new->setAuthorImage($defaultProductImage);
  7180.                     $em->flush();
  7181.                 }
  7182.                 $path "";
  7183.                 $defaultProductImage '';
  7184.                 $uploadedFile null;
  7185.                 $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/mainImage/';
  7186.                 $uploadedFile $request->files->get('main_img');
  7187.                 if ($uploadedFile != null) {
  7188.                     $fileName 'mainImage' $new->getId() . '.' $uploadedFile->guessExtension();
  7189.                     $path $fileName;
  7190. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  7191.                     if (!file_exists($upl_dir)) {
  7192.                         mkdir($upl_dir0777true);
  7193.                     }
  7194.                     $uploadedFile->move($upl_dir$path);
  7195.                     $defaultProductImage 'uploads/mainImage/' $path;
  7196.                     $new->setMainImage($defaultProductImage);
  7197.                     $em->flush();
  7198.                 }
  7199.                 $topicDetails $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
  7200.                     array(
  7201.                         'id' => $request->request->get('topicId')
  7202.                     )
  7203.                 );
  7204.                 if ($new->getIsPrimaryBlog() == 1) {
  7205.                     if ($topicDetails)
  7206.                         $topic $topicDetails;
  7207.                     else
  7208.                         $topic = new EntityCreateTopic();
  7209.                     $topic->setPrimaryBlogId($new->getId());
  7210.                     $em->flush();
  7211.                 }
  7212.                 $this->addFlash(
  7213.                     'success',
  7214.                     'Blog Added.'
  7215.                 );
  7216.             } else {
  7217.                 $em $this->getDoctrine()->getManager('company_group');
  7218.                 $topic $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findAll();
  7219.                 $applicant $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findAll();
  7220.                 $blogs $em->getRepository('CompanyGroupBundle:EntityCreateBlog')->findAll();
  7221.                 $topicIds = [];
  7222.                 foreach ($blogs as $blog) {
  7223.                     $topicIds [] = $blog->getTopicId();
  7224.                 }
  7225. //                $topic = $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findBy(
  7226. //                    array(
  7227. //                        'id' => $topicIds
  7228. //                    )
  7229. //                );
  7230.                 return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_blog.html.twig', array(
  7231.                     'page_title' => 'Create Blog',
  7232.                     'topic' => $topic,
  7233.                     'applicant' => $applicant,
  7234.                     'blog' => $blogs,
  7235.                     'id' => $id,
  7236.                 ));
  7237.             }
  7238.         } else {
  7239.             if ($request->isMethod('GET')) {
  7240.                 $em $this->getDoctrine()->getManager('company_group');
  7241.                 $topic $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findAll();
  7242.                 $applicant $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findAll();
  7243.                 $blogs $em->getRepository('CompanyGroupBundle:EntityCreateBlog')->find($id);
  7244.                 return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_blog.html.twig', array(
  7245.                     'page_title' => 'Create Blog',
  7246.                     'topic' => $topic,
  7247.                     'applicant' => $applicant,
  7248.                     'blog' => $blogs,
  7249.                     'id' => $id,
  7250.                 ));
  7251.             } else {
  7252.                 $em $this->getDoctrine()->getManager('company_group');
  7253.                 $new = new EntityCreateBlog();
  7254.                 $new->setTopicId($request->request->get('topicId'));
  7255.                 $new->setTitle($request->request->get('title'));
  7256.                 $new->setSubtitle($request->request->get('subTitle'));
  7257.                 $new->setContent($request->request->get('content'));
  7258.                 $new->setVideoLink($request->request->get('videoLink'));
  7259.                 $new->setAuthorName($request->request->get('authorName'));
  7260.                 $new->setAuthorSummary($request->request->get('authorSummary'));
  7261.                 //$em->persist($new);
  7262.                 $em->flush();
  7263.                 $path "";
  7264.                 $defaultProductImage '';
  7265.                 $uploadedFile null;
  7266.                 $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/authorImage/';
  7267.                 $uploadedFile $request->files->get('authorImage');
  7268.                 if ($uploadedFile != null) {
  7269.                     $fileName 'authorImage' '.' $uploadedFile->guessExtension();
  7270.                     $path $fileName;
  7271. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  7272.                     if (!file_exists($upl_dir)) {
  7273.                         mkdir($upl_dir0777true);
  7274.                     }
  7275.                     $uploadedFile->move($upl_dir$path);
  7276.                     $defaultProductImage 'uploads/authorImage/' $path;
  7277.                     $new->setAuthorImage($defaultProductImage);
  7278.                     $em->flush();
  7279.                 }
  7280.                 $this->addFlash(
  7281.                     'success',
  7282.                     'Blog Updated.'
  7283.                 );
  7284.             }
  7285.         }
  7286.         return new JsonResponse(
  7287.             array(
  7288.                 'success' => true,
  7289.             )
  7290.         );
  7291. //        if ($request->isMethod('POST')) {
  7292. //            $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7293. //
  7294. //            $new = new EntityCreateBlog();
  7295. //
  7296. //            $new->setTopicId($request->request->get('topicId'));
  7297. //            $new->setTitle($request->request->get('title'));
  7298. //            $new->setSubtitle($request->request->get('subTitle'));
  7299. //            $new->setContent($request->request->get('content'));
  7300. //            $new->setVideoLink($request->request->get('videoLink'));
  7301. //            $new->setAuthorName($request->request->get('authorName'));
  7302. //            $new->setAuthorSummary($request->request->get('authorSummary'));
  7303. //
  7304. //            $em->persist($new);
  7305. //            $em->flush();
  7306. //
  7307. //
  7308. //            $path = "";
  7309. //            $defaultProductImage = '';
  7310. //            $uploadedFile = null;
  7311. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/authorImage/';
  7312. //            $uploadedFile=  $request->files->get('authorImage');
  7313. //
  7314. //            if ($uploadedFile != null) {
  7315. //
  7316. //                $fileName = 'authorImage' .'.' . $uploadedFile->guessExtension();
  7317. //                $path = $fileName;
  7318. ////            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  7319. //                if (!file_exists($upl_dir)) {
  7320. //                    mkdir($upl_dir, 0777, true);
  7321. //                }
  7322. //                $uploadedFile->move($upl_dir, $path);
  7323. //                $defaultProductImage = 'uploads/authorImage/' . $path;
  7324. //                $new->setAuthorImage($defaultProductImage);
  7325. //                $em->flush();
  7326. //
  7327. //            }
  7328. //            $this->addFlash(
  7329. //                'success',
  7330. //                'Blog Added.'
  7331. //            );
  7332. //        }
  7333. //        return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_blog.html.twig', array(
  7334. //            'page_title' => 'Create Blog',
  7335. //            'topic'=> $topic,
  7336. //            'applicant' => $applicant,
  7337. //            'blog' => $blogs
  7338. //        ));
  7339.     }
  7340.     public function applicantConsultancyAction()
  7341.     {
  7342.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:consultancy.html.twig', array(
  7343.             'page_title' => 'Consultancy',
  7344.         ));
  7345.     }
  7346.     public function viewConsultantDetailsAction(Request $request$id 0)
  7347.     {
  7348.         $gocEnabled 1;
  7349.         $currAppId 4;
  7350.         $honeybeeAppId 1;
  7351.         $buddybeeAppId 4;
  7352.         $em_goc $this->getDoctrine()->getManager('company_group');
  7353.         $em $this->getDoctrine()->getManager();
  7354.         $option = [];
  7355.         $option['appId'] = $currAppId//honeybee
  7356.         $option['departmentId'] = 18//consultancy
  7357.         $option['designationId'] = 50;
  7358. //        $dataToConnect = System::changeDoctrineManagerByAppId(
  7359. //            $this->getDoctrine()->getManager('company_group'),
  7360. //            $gocEnabled,
  7361. //            $currAppId
  7362. //        );
  7363. //        if (!empty($dataToConnect)) {
  7364. //            $connector = $this->container->get('application_connector');
  7365. //            $connector->resetConnection(
  7366. //                'default',
  7367. //                $dataToConnect['dbName'],
  7368. //                $dataToConnect['dbUser'],
  7369. //                $dataToConnect['dbPass'],
  7370. //                $dataToConnect['dbHost'],
  7371. //                $reset = true
  7372. //            );
  7373. //            $em = $this->getDoctrine()->getManager();
  7374. //        } else {
  7375. //            $currAppId = $honeybeeAppId;
  7376. //            $dataToConnectAgain = System::changeDoctrineManagerByAppId(
  7377. //                $this->getDoctrine()->getManager('company_group'),
  7378. //                $gocEnabled,
  7379. //                $currAppId
  7380. //            );
  7381. //            if (!empty($dataToConnectAgain)) {
  7382. //                $connector = $this->container->get('application_connector');
  7383. //                $connector->resetConnection(
  7384. //                    'default',
  7385. //                    $dataToConnect['dbName'],
  7386. //                    $dataToConnect['dbUser'],
  7387. //                    $dataToConnect['dbPass'],
  7388. //                    $dataToConnect['dbHost'],
  7389. //                    $reset = true
  7390. //                );
  7391. //                $em = $this->getDoctrine()->getManager();
  7392. //            }
  7393. //
  7394. //        }
  7395.         $consultantDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($id);
  7396.         $skill $em_goc->getRepository(EntitySkill::class)->findAll();
  7397.         $gender HumanResourceConstant::$sex;
  7398.         $blood HumanResourceConstant::$BloodGroup;
  7399.         $consultantLevel HumanResourceConstant::$consultantLevel;
  7400.         $companyId $this->getLoggedUserCompanyId($request);
  7401.         $designation $em->getRepository("ApplicationBundle:SysDepartmentPosition")->findAll();
  7402.         $departments $em->getRepository("ApplicationBundle:SysDepartment")->findAll();
  7403.         $companyData Company::getCompanyData($em$companyId);
  7404.         $currDate = new \DateTime();
  7405.         if ($request->isMethod('POST')) {
  7406.             //for consultant only
  7407.             $convertToConsultant HumanResource::convertToConsultant($em_goc$em$id$option$request->request);
  7408.             if ($request->request->get('confirmStatus'0) == 1) {
  7409.                 $bodyTemplate 'ApplicationBundle:email/templates:consultantApprovalEmail.html.twig';
  7410.                 $contractLetterHtml '';
  7411.                 $bodyData = array(
  7412.                     'name' => $consultantDetails->getFirstname() . ' ' $consultantDetails->getLastname(),
  7413.                     'companyData' => $companyData,
  7414.                     'contractLetterHtml' => $contractLetterHtml,
  7415.                     'commentText' => $request->request->get('commentText'),
  7416.                 );
  7417.                 $new_mail $this->get('mail_module');
  7418.                 $new_mail->sendMyMail(array(
  7419.                     'senderHash' => '_CUSTOM_',
  7420.                     'encryptionMethod' => 'ssl',
  7421.                     'userName' => 'management@buddybee.eu',
  7422.                     'fromAddress' => 'management@buddybee.eu',
  7423.                     'password' => 'Eco@0112',
  7424.                     'smtpServer' => 'smtp.hostinger.com',
  7425.                     'smtpPort' => '465',
  7426.                     'forwardToMailAddress' => $consultantDetails->getEmail(),
  7427.                     'subject' => 'Consultant Contract Letter Of ' $consultantDetails->getFirstName(),
  7428.                     'fileName' => '',
  7429.                     //'attachments' => $attachments,
  7430.                     'toAddress' => $consultantDetails->getEmail(),
  7431.                     'mailTemplate' => $bodyTemplate,
  7432.                     'templateData' => $bodyData,
  7433.                     'embedCompanyImage' => 1,
  7434.                     'companyId' => $companyId,
  7435.                     'companyImagePath' => ""
  7436.                 ));
  7437.             }
  7438.             if ($request->request->get('confirmStatus'0) == 0) {
  7439.                 $bodyTemplate 'ApplicationBundle:email/templates:consultantRejectionEmail.html.twig';
  7440.                 $contractLetterHtml '';
  7441.                 $bodyData = array(
  7442.                     'name' => $consultantDetails->getFirstname() . ' ' $consultantDetails->getLastname(),
  7443.                     'companyData' => $companyData,
  7444.                     'contractLetterHtml' => $contractLetterHtml,
  7445.                     'commentText' => $request->request->get('commentText'),
  7446.                 );
  7447.                 $new_mail $this->get('mail_module');
  7448.                 $new_mail->sendMyMail(array(
  7449.                     'senderHash' => '_CUSTOM_',
  7450.                     'encryptionMethod' => 'ssl',
  7451.                     'userName' => 'management@buddybee.eu',
  7452.                     'fromAddress' => 'management@buddybee.eu',
  7453.                     'password' => 'Eco@0112',
  7454.                     'smtpServer' => 'smtp.hostinger.com',
  7455.                     'smtpPort' => '465',
  7456.                     'forwardToMailAddress' => $consultantDetails->getEmail(),
  7457.                     'subject' => 'Rejection Letter Of ' $consultantDetails->getFirstName(),
  7458.                     'fileName' => '',
  7459.                     //'attachments' => $attachments,
  7460.                     'toAddress' => $consultantDetails->getEmail(),
  7461.                     'mailTemplate' => $bodyTemplate,
  7462.                     'templateData' => $bodyData,
  7463.                     'embedCompanyImage' => 1,
  7464.                     'companyId' => $companyId,
  7465.                     'companyImagePath' => ""
  7466.                 ));
  7467.             }
  7468.         }
  7469.         $docList MiscActions::GetDocumentDataForBuddybeeConsultantApply($em_goc,
  7470.             $id,
  7471.             $consultantDetails->getCurrentCountryId()
  7472.         );
  7473.         return $this->render('ApplicationBundle:pages/human_resource/views:viewConsultantDetails.html.twig', array(
  7474.             'page_title' => 'Consultant Details',
  7475.             'applicantId' => $id,
  7476.             'consultantDetails' => $consultantDetails,
  7477.             'education' => json_decode($consultantDetails->getEducationData(), true),
  7478.             'workExperience' => json_decode($consultantDetails->getWorkExperienceData(), true),
  7479.             'certificate' => json_decode($consultantDetails->getCertificateData(), true),
  7480.             'gender' => $gender,
  7481.             'blood' => $blood,
  7482.             'skill' => $skill,
  7483.             'docList' => $docList,
  7484.             'countryId' => $consultantDetails->getCurrentCountryId(),
  7485.             'consultantLevel' => $consultantLevel,
  7486.             'designation' => $designation,
  7487.             'department' => $departments
  7488.         ));
  7489.     }
  7490.     public function ApplicableEmployeSettingsAction()
  7491.     {
  7492.         $em $this->getDoctrine()->getManager();
  7493.         $employeeIds $em->getRepository(Employee::class)->findAll();
  7494.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:applicable_employee_settings.html.twig', array(
  7495.             'page_title' => 'Applicable Employee Settings',
  7496.             'employeeIds' => $employeeIds
  7497.         ));
  7498.     }
  7499.     public function GetApplicableSettingsForSingleEmployeeAction($id)
  7500.     {
  7501.         $em $this->getDoctrine()->getManager();
  7502.         $bankLists $em->getRepository(WorkHourPolicy::class)->findAll();
  7503.         if (json_decode($bankLists->getEmployeeIds()) == $id) {
  7504.             return new JsonResponse(
  7505.                 array(
  7506.                     'success' => true,
  7507.                     'msg' => 'employee found'
  7508.                 )
  7509.             );
  7510.         } else {
  7511.             return new JsonResponse(
  7512.                 array(
  7513.                     'success' => true,
  7514.                     'msg' => 'employee not found'
  7515.                 )
  7516.             );
  7517.         }
  7518.     }
  7519. //    public function  getEmployeeDataAction(){
  7520. //        $em = $this->getDoctrine()->getManager();
  7521. //        $emplyeeDetails =  $em->getRepository('ApplicationBundle:EmployeeDeatils')->findAll();
  7522. //        $days = HumanResourceConstant::$days;
  7523. //        $holidays = ;
  7524. //        $workHourPolicies = ;
  7525. //
  7526. //    }
  7527.     public function meetingSchedulingForTabAction()
  7528.     {
  7529.         $em $this->getDoctrine()->getManager();
  7530.         $date date('Y-m-d');
  7531.         $month date('m');
  7532.         $year date('Y');
  7533.         $monthName date("F"mktime(000$month));
  7534.         $totalDayOfMonth cal_days_in_month(CAL_GREGORIAN$month$year);
  7535.         $fromdt date('Y-m-01 'strtotime("First Day Of  $monthName $year"));
  7536. //        echo "Start Date : $fromdt" . "<br>";
  7537.         $todt date('Y-m-d 'strtotime("Last Day of $monthName $year"));
  7538. //        echo "End Date : $todt" . "<br>";
  7539.         $num_friday '';
  7540.         for ($i 0$i < ((strtotime($todt) - strtotime($fromdt)) / 86400); $i++) {
  7541.             if (date('l'strtotime($fromdt) + ($i 86400)) == 'Friday') {
  7542.                 $num_friday++;
  7543.             }
  7544.         }
  7545.         $num_saturday '';
  7546.         for ($i 0$i < ((strtotime($todt) - strtotime($fromdt)) / 86400); $i++) {
  7547.             if (date('l'strtotime($fromdt) + ($i 86400)) == 'Saturday') {
  7548.                 $num_saturday++;
  7549.             }
  7550.         }
  7551.         $totalWeekends $num_saturday $num_friday;
  7552.         $totalCompanyWorkingDay $totalDayOfMonth $totalWeekends;
  7553. //        $attendanceData=$em->getRepository('ApplicationBundle:EmployeeAttendanceLog')->findOneBy(
  7554. //            array(
  7555. //                'employeeId' => 3
  7556. //            )
  7557. //        );
  7558.         $DateRange = [];
  7559.         $holidayDates $em->getRepository('ApplicationBundle:HolidayCalendarDates')->findAll();
  7560.         foreach ($holidayDates as $holiday) {
  7561.             $holidaayData = array(
  7562.                 'startDate' => $holiday->getStartDate(),
  7563.                 'endDate' => $holiday->getEndDate(),
  7564.             );
  7565.             $DateRange $holidaayData;
  7566.         }
  7567.         $employeeDataDetail = [];
  7568.         $employeeDetail $em->getRepository('ApplicationBundle:EmployeeDetails')->findOneBy(
  7569.             array(
  7570.                 'id' => 3
  7571.             )
  7572.         );
  7573. //        foreach($employeeDetail as $employee){
  7574.         $employeeData = array(
  7575.             'firstName' => $employeeDetail->getFirstname(),
  7576.             'basic' => $employeeDetail->getEar1(),
  7577.             'dearness' => $employeeDetail->getEar2(),
  7578.             'houseRent' => $employeeDetail->getEar3(),
  7579.             'medical' => $employeeDetail->getEar4(),
  7580.             'leaveTravel' => $employeeDetail->getEar5(),
  7581.             'childEducation' => $employeeDetail->getEar6(),
  7582.             'totalEarning' => $employeeDetail->getEart(),
  7583.         );
  7584.         $employeeDataDetail $employeeData;
  7585. //        }
  7586.         $attendanceData $em->getRepository(EmployeeAttendanceLog::class);
  7587. //        $employeeId = $attendanceData->getEmployeeId();
  7588. //        $countId = count($employeeId);
  7589.         $totalPresent $attendanceData->createQueryBuilder('a')
  7590.             // Filter by some parameter if you want
  7591.             ->where('a.employeeId = 3')
  7592.             ->andWhere('a.isPresent = 1')
  7593.             ->select('a.isPresent')
  7594.             ->getQuery()
  7595.             ->getResult();
  7596. //        $countAt = 0;
  7597.         $count count($totalPresent);
  7598. //        $count = $countAt+$count;
  7599.         //get holiday
  7600.         $holidayStartDate $DateRange['startDate']->format('Y-m-d');
  7601.         $holidayEndDate $DateRange['endDate']->format('Y-m-d');
  7602.         $dates HumanResource::getBetweenDates($holidayStartDate$holidayEndDate);
  7603.         $dateCount count($dates);
  7604.         $totalOffDay $totalWeekends $dateCount;
  7605.         $totalCompanyWorkingDay $totalDayOfMonth $totalOffDay;
  7606.         $totalAbsent $totalCompanyWorkingDay $count;
  7607. //        foreach($dates as $compDate ){
  7608. //
  7609. //
  7610. //
  7611. //            if($date == $compDate){
  7612. //                echo $date;
  7613. //                echo $compDate;
  7614. //                echo "holiday" ;
  7615. //
  7616. //            }
  7617. //            else{
  7618. //                echo "no holiday" ;
  7619. //            }
  7620. //        }
  7621.         $twigData HumanResource::twigDataForWorkHourPolicy($em);
  7622.         return $this->render('ApplicationBundle:pages/human_resource/list:meeting_schedule_list_for_tab.html.twig', array(
  7623.             'page_title' => 'Meeting Schedule List',
  7624.             'date' => $date,
  7625.             'totalWeekends' => $totalWeekends,
  7626.             'totalCompanyWorkingDay' => $totalCompanyWorkingDay,
  7627. //            'attendanceData' => $attendanceData,
  7628. //            'employeeId' => $employeeId,
  7629.             'count' => $count,
  7630.             'totalAbsent' => $totalAbsent,
  7631.             'employeeDataDetail' => $employeeDataDetail,
  7632.             'holiday' => $DateRange,
  7633.             'holidayStartDate' => $holidayStartDate,
  7634.             'holidayEndDate' => $holidayEndDate,
  7635.             'holidayCount' => $dateCount,
  7636.             'totalOffDay' => $totalOffDay,
  7637.             'employeeIds' => $twigData['employeeIds'],
  7638.         ));
  7639.     }
  7640.     public function getEmployeeDataForDisburseAction($id)
  7641.     {
  7642.         $em $this->getDoctrine()->getManager();
  7643.         $employeeDetail $em->getRepository('ApplicationBundle:EmployeeDetails')->find($id);
  7644.         return new JsonResponse(
  7645.             array(
  7646.                 'success' => true,
  7647.                 'firstName' => $employeeDetail->getFirstName(),
  7648.             )
  7649.         );
  7650.     }
  7651.     public function BulkAttendanceAction(Request $request)
  7652.     {
  7653.         $em $this->getDoctrine()->getManager();
  7654.         $companyId $this->getLoggedUserCompanyId($request);
  7655.         if ($request->isMethod('POST')) {
  7656.             $attendance = [];
  7657.             foreach ($request->request->get('date') as $key => $val) {
  7658.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7659.                 $bulkAttendance null;
  7660.                 if ($request->request->get('attId')[$key] != 0)
  7661.                     $bulkAttendance $em->getRepository('ApplicationBundle:EmployeeAttendance')->findOneBy(array(
  7662.                         'id' => $request->request->get('attId')[$key],
  7663.                     ));
  7664.                 if (!$bulkAttendance)
  7665.                     $bulkAttendance = new EmployeeAttendance;
  7666.                 $theDate = new \DateTime($request->request->get('date')[$key]);
  7667.                 $bulkAttendance->setEmployeeId($request->request->get('employeeId'));
  7668.                 $bulkAttendance->setDate($theDate);
  7669.                 $bulkAttendance->setEntry(
  7670.                     ($request->request->get('startTimeTs')[$key] == '' ||
  7671.                         $request->request->get('startTimeTs')[$key] == 'NaN' ||
  7672.                         $request->request->get('startTimeTs')[$key] == 0) ? null :
  7673.                         new \DateTime('@' $request->request->get('startTimeTs')[$key])
  7674.                 );
  7675.                 $bulkAttendance->setLastOut(($request->request->get('endTimeTs')[$key] == '' ||
  7676.                     $request->request->get('endTimeTs')[$key] == 'NaN' ||
  7677.                     $request->request->get('endTimeTs')[$key] == 0) ? null :
  7678.                     new \DateTime('@' $request->request->get('endTimeTs')[$key]));
  7679.                 $bulkAttendance->setData(json_encode(
  7680.                     array(
  7681.                         "in" => json_decode($request->request->get('entryDataIn')[$key], true),
  7682.                         "out" => json_decode($request->request->get('entryDataOut')[$key], true)
  7683.                     )
  7684.                 ));
  7685. //                $bulkAttendance->setLastStartTime(new \DateTime($request->request->get('startDate')));
  7686. //                $bulkAttendance->setIsPresent(1);
  7687.                 $bulkAttendance->setLastStartTimeTs($request->request->get('startTimeTs')[$key]);
  7688.                 $bulkAttendance->setLastEndTimeTs($request->request->get('endTimeTs')[$key]);
  7689. //                $bulkAttendance->setTotalWorkHour($request->request->get('totalWorkHour')[$key]);
  7690.                 $em->persist($bulkAttendance);
  7691.                 $em->flush();
  7692.                 $bulkAttendanceLog $em->getRepository('ApplicationBundle:EmployeeAttendanceLog')->findOneBy(array(
  7693.                     'attendance_id' => $bulkAttendance->getId(),
  7694.                 ));
  7695.                 if (!$bulkAttendanceLog)
  7696.                     $bulkAttendanceLog = new EmployeeAttendanceLog;
  7697.                 $bulkAttendanceLog->setAttendanceId($bulkAttendance->getId());
  7698.                 $bulkAttendanceLog->setEmployeeId($request->request->get('employeeId'));
  7699.                 $bulkAttendanceLog->setLastStartTime(
  7700.                     ($request->request->get('startTimeTs')[$key] == '' ||
  7701.                         $request->request->get('startTimeTs')[$key] == 'NaN' ||
  7702.                         $request->request->get('startTimeTs')[$key] == 0) ? null :
  7703.                         new \DateTime('@' $request->request->get('startTimeTs')[$key])
  7704.                 );
  7705.                 $bulkAttendanceLog->setLastEndTime(($request->request->get('endTimeTs')[$key] == '' ||
  7706.                     $request->request->get('endTimeTs')[$key] == 'NaN' ||
  7707.                     $request->request->get('endTimeTs')[$key] == 0) ? null :
  7708.                     new \DateTime('@' $request->request->get('endTimeTs')[$key]));
  7709. //                $bulkAttendance->setLastStartTime(new \DateTime($request->request->get('startDate')));
  7710.                 $bulkAttendanceLog->setIsPresent(1);
  7711.                 $bulkAttendanceLog->setLastStartTimeTs($request->request->get('startTimeTs')[$key]);
  7712.                 $bulkAttendanceLog->setLastEndTimeTs($request->request->get('endTimeTs')[$key]);
  7713.                 $bulkAttendanceLog->setTotalWorkHour($request->request->get('totalWorkHour')[$key]);
  7714. //                $bulkAttendanceLog->setPositionArray(json_encode($request->request->get('locations')[$key]));
  7715.                 $em->persist($bulkAttendanceLog);
  7716.                 $em->flush();
  7717.             }
  7718.         }
  7719.         $startDate $request->query->get('start_date''');
  7720.         $endDate $request->query->get('end_date''');
  7721.         $employeeId $request->query->get('employee_id'0);
  7722.         $existingData = [];
  7723.         $startDateTs 0;
  7724.         $endDateTs 0;
  7725.         $returnData = array(
  7726.             'page_title' => 'Bulk Attendance',
  7727.             'existingData' => $existingData,
  7728.             'startDateTs' => $startDateTs,
  7729.             'endDateTs' => $endDateTs,
  7730.         );
  7731.         if ($request->query->has('returnJson')) {
  7732.             if ($startDate != '' && $endDate != '' && $employeeId != 0) {
  7733.                 $startDateDt = new \DateTime($startDate);
  7734.                 $endDateDt = new \DateTime($endDate);
  7735.                 $startDateTs $startDateDt->format('U');
  7736.                 $endDateTs $endDateDt->format('U');
  7737.                 $attendanceQuery $em->getRepository('ApplicationBundle:EmployeeAttendance')
  7738.                     ->createQueryBuilder('p')
  7739.                     ->where("p.employeeId = " $employeeId)
  7740. //                ->andWhere("p.date => '" . ($startDateDt->format('Y-m-d'))."'")
  7741.                     ->andWhere("p.date <= :last")
  7742.                     ->andWhere("p.date >= :start")
  7743.                     ->setParameter('start'$startDateDt)
  7744.                     ->setParameter('last'$endDateDt);
  7745.                 $attendanceResults $attendanceQuery->getQuery()->getResult();
  7746.                 foreach ($attendanceResults as $att) {
  7747.                     $entryDateTime null;
  7748.                     $outDateTime null;
  7749.                     if ($att->getEntry()) $entryDateTime = new \DateTime($att->getDate()->format('Y-m-d') . ' ' $att->getEntry()->format('H:i:00 +0000'));
  7750.                     if ($att->getLastOut()) $outDateTime = new \DateTime($att->getDate()->format('Y-m-d') . ' ' $att->getLastOut()->format('H:i:00 +0000'));
  7751.                     $attData = array(
  7752.                         'id' => $att->getId(),
  7753.                         'date_str' => $att->getDate()->format('Y-m-d'),
  7754.                         'date_str_full' => $att->getDate()->format('Y-m-d H:i:s'),
  7755.                         'in_time_full' => $entryDateTime $entryDateTime->format(DATE_RFC2822) : '',
  7756.                         'date_ts' => $att->getDate()->format('U'),
  7757.                         'in_time' => $entryDateTime $entryDateTime->format('H:i:s') : '',
  7758.                         'in_time_ts' => $entryDateTime $entryDateTime->format('U') : 0,
  7759.                         'last_out_time' => $outDateTime $outDateTime->format('H:i:s') : '',
  7760.                         'last_out_time_ts' => $outDateTime $outDateTime->format('U') : '',
  7761.                     );
  7762.                     $locations = [];
  7763.                     $locList = [];
  7764.                     $logHere $em->getRepository('ApplicationBundle:EmployeeAttendanceLog')->findOneBy(array(
  7765.                         'attendance_id' => $att->getId(),
  7766.                     ));
  7767.                     if ($logHere)
  7768.                         $locList json_decode($logHere->getPositionArray(), true);
  7769.                     if ($locList == null)
  7770.                         $locList = [];
  7771.                     $entry_data json_decode($att->getData(), true);
  7772.                     if ($entry_data == null$entry_data = [];
  7773.                     $lastLat 0;
  7774.                     $lastLng 0;
  7775.                     foreach ($locList as $lg) {
  7776.                         $dist 0;
  7777.                         if (isset($lg['lat'])) {
  7778.                             if ($lastLat == 0) {
  7779.                                 $lastLat $lg['lat'];
  7780.                                 $lastLng $lg['lng'];
  7781.                             }
  7782.                             $theta $lastLng $lg['lng'];
  7783.                             $dist sin(deg2rad($lastLat)) * sin(deg2rad($lg['lat'])) + cos(deg2rad($lastLat)) * cos(deg2rad($lg['lat'])) * cos(deg2rad($theta));
  7784.                             $dist acos($dist);
  7785.                             $dist rad2deg($dist);
  7786.                             $miles $dist 60 1.1515;
  7787.                             $dist $miles 1609.344;
  7788.                             if (abs($dist) > 1000) {
  7789.                                 $locations[] = array(
  7790.                                     'ts' => $lg['ts'],
  7791.                                     'lat' => $lg['lat'],
  7792.                                     'lng' => $lg['lng'],
  7793.                                 );
  7794.                                 $lastLat $lg['lat'];
  7795.                                 $lastLng $lg['lng'];
  7796.                             }
  7797.                         }
  7798.                     }
  7799.                     $attData['locations'] = $locations;
  7800.                     $attData['entryData'] = $entry_data;
  7801.                     $existingData[$att->getDate()->format('U')] = $attData;
  7802.                 }
  7803.             }
  7804.             $returnData = array(
  7805.                 'page_title' => 'Bulk Attendance',
  7806.                 'existingData' => $existingData,
  7807.                 'startDateTs' => $startDateTs,
  7808.                 'endDateTs' => $endDateTs,
  7809.             );
  7810.             return new JsonResponse($returnData);
  7811.         } else
  7812.             return $this->render('ApplicationBundle:pages/human_resource/attendance:bulk_attendance.html.twig'$returnData);
  7813.     }
  7814.     public function CreateAttendanceAmendmentAction(Request $request$id 0)
  7815.     {
  7816.         $em $this->getDoctrine()->getManager();
  7817.         $companyId $this->getLoggedUserCompanyId($request);
  7818.         $extDocData = [];
  7819.         if ($request->isMethod('POST')) {
  7820.             $em $this->getDoctrine()->getManager();
  7821.             $entity_id array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment']; //change
  7822.             $dochash $request->request->get('docHash'); //change
  7823.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7824.             $approveRole $request->request->get('approvalRole');
  7825.             $approveHash $request->request->get('approvalHash');
  7826.             if ($dochash == '') {
  7827.                 $numberHash MiscActions::GetNumberHash($em'ATAM'$request->request->get('prefix_hash'$request->request->get('employeeId'0)), $request->request->get('assoc_hash'0), ''1);
  7828.                 $dochash 'ATAM' '/' $request->request->get('prefix_hash'$request->request->get('employeeId'0)) . '/' $request->request->get('assoc_hash'0) . '/' $numberHash;
  7829.             } else
  7830.                 $numberHash $request->request->get('number_hash');
  7831.             if (!DocValidation::isInsertable($em$entity_id$dochash,
  7832.                 $loginId$approveRole$approveHash$id)
  7833.             ) {
  7834.                 if ($request->request->has('returnJson')) {
  7835.                     return new JsonResponse(array(
  7836.                         'success' => false,
  7837.                         'documentHash' => 0,
  7838.                         'documentId' => 0,
  7839.                     ));
  7840.                 } else
  7841.                     $this->addFlash(
  7842.                         'error',
  7843.                         'Sorry Could not insert Data.'
  7844.                     );
  7845.             } else {
  7846.                 $funcname 'AttendanceAmendment';
  7847.                 $doc_id $id;
  7848.                 DeleteDocument::$funcname($em$doc_id0);
  7849.                 $attendanceAmendment = new AttendanceAmendment();
  7850.                 $attendanceAmendment->setDocumentHash($dochash);
  7851.                 $attendanceAmendment->setAttendanceAmendmentDate(new \DateTime($request->request->get('docDate''')));
  7852.                 $attendanceAmendment->setStartDate(new \DateTime($request->request->get('startDate''')));
  7853.                 $attendanceAmendment->setEndDate(new \DateTime($request->request->get('endDate''')));
  7854.                 $attendanceAmendment->setTypeHash('ATAM');
  7855.                 $attendanceAmendment->setPrefixHash($request->request->get('prefix_hash'0));
  7856.                 $attendanceAmendment->setAssocHash($request->request->get('assoc_hash'0));
  7857.                 $attendanceAmendment->setNumberHash($numberHash);
  7858.                 $attendanceAmendment->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  7859.                 $attendanceAmendment->setApproved(array_flip(GeneralConstant::$approvalStatus)['pending']);
  7860.                 $attendanceAmendment->setAutoCreated($request->request->get('fullApprove'0));
  7861.                 $attendanceAmendment->setEmployeeId($request->request->get('forcedEmployeeId'$request->request->get('employeeId'0)));
  7862. //                $attendanceAmendment->setAutocreated(0);
  7863.                 if ($request->request->has('dataArrayJson')) {
  7864.                     $attendanceAmendment->setData($request->request->get('dataArrayJson''[]'));
  7865.                 } else {
  7866.                     $arr = [
  7867.                     ];
  7868.                     //dump($arr);
  7869.                     foreach ($request->request->get('date', []) as $key => $val) {
  7870.                         if ($request->request->get('isChanged')[$key] == 1) {
  7871.                             $dt = array(
  7872.                                 'enabled' => 1,
  7873.                                 'attId' => $request->request->get('attId')[$key],
  7874.                                 'note' => $request->request->get('note')[$key],
  7875.                                 'startTimeTs' => $request->request->get('startTimeTs')[$key],
  7876.                                 'endTimeTs' => $request->request->get('endTimeTs')[$key],
  7877.                                 'totalWorkHour' => $request->request->get('totalWorkHour')[$key],
  7878.                                 'entryDataIn' => json_decode($request->request->get('entryDataIn')[$key], true),
  7879.                                 'entryDataOut' => json_decode($request->request->get('entryDataOut')[$key], true),
  7880.                             );
  7881.                             $arr[$val] = $dt;
  7882.                         }
  7883.                     }
  7884.                     $attendanceAmendment->setData(json_encode($arr));
  7885.                 }
  7886.                 $em->persist($attendanceAmendment);
  7887.                 $em->flush();
  7888.                 $ID $attendanceAmendment->getAttendanceAmendmentId();
  7889.                 //now add Approval info
  7890.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7891.                 $approveRole 1;  //created
  7892.                 $options = array(
  7893.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  7894.                     'notification_server' => $this->container->getParameter('notification_server'),
  7895.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  7896.                     'url' => $this->generateUrl(
  7897.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment']]
  7898.                         ['entity_view_route_path_name']
  7899.                     )
  7900.                 );
  7901.                 System::setApprovalInfo($this->getDoctrine()->getManager(), $options,
  7902.                     array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  7903.                     $ID,
  7904.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)    //journal voucher
  7905.                 );
  7906.                 if ($request->request->get('fullApprove'0) == 1) {
  7907.                     DeleteDocument::AttendanceAmendment($em$ID);
  7908.                 } else {
  7909.                     System::createEditSignatureHash($this->getDoctrine()->getManager(), array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'], $ID,
  7910.                         $loginId,
  7911.                         $approveRole,
  7912.                         $request->request->get('approvalHash'));
  7913.                     $url $this->generateUrl(
  7914.                         'view_attendance_amendment'
  7915.                     );
  7916.                     if ($request->request->has('returnJson')) {
  7917.                         return new JsonResponse(array(
  7918.                             'success' => true,
  7919.                             'documentHash' => $dochash,
  7920.                             'documentId' => $ID,
  7921.                             'viewUrl' => $url "/" $ID,
  7922.                         ));
  7923.                     } else {
  7924.                         $this->addFlash(
  7925.                             'success',
  7926.                             'Attendance Amendment Note Added.'
  7927.                         );
  7928.                         return $this->redirect($url "/" $ID);
  7929.                     }
  7930.                 }
  7931.             }
  7932.         }
  7933.         if ($id == 0) {
  7934.         } else {
  7935.             $extDoc $em->getRepository('ApplicationBundle:AttendanceAmendment')->findOneBy(
  7936.                 array(
  7937.                     'salesOrderId' => $id///material
  7938.                 )
  7939.             );
  7940.             //now if its not editable, redirect to view
  7941.             if ($extDoc) {
  7942.                 if ($extDoc->getEditFlag() != 1) {
  7943.                     $url $this->generateUrl(
  7944.                         'view_attendance_amendment'
  7945.                     );
  7946.                     return $this->redirect($url "/" $id);
  7947.                 } else {
  7948.                     $extDocData $extDoc;
  7949.                 }
  7950.             } else {
  7951.             }
  7952.         }
  7953.         $startDate $request->query->get('start_date''');
  7954.         $endDate $request->query->get('end_date''');
  7955.         $employeeId $request->query->get('employee_id'0);
  7956.         $existingData = [];
  7957.         $startDateTs 0;
  7958.         $endDateTs 0;
  7959.         $returnData = array(
  7960.             'page_title' => 'Attendance Amendment',
  7961.             'existingData' => $existingData,
  7962.             'startDateTs' => $startDateTs,
  7963.             'extDocData' => $extDocData,
  7964.             'endDateTs' => $endDateTs,
  7965.         );
  7966.         if ($request->query->has('returnJson')) {
  7967.             if ($startDate != '' && $endDate != '' && $employeeId != 0) {
  7968.                 $startDateDt = new \DateTime($startDate);
  7969.                 $endDateDt = new \DateTime($endDate);
  7970.                 $startDateTs $startDateDt->format('U');
  7971.                 $endDateTs $endDateDt->format('U');
  7972.                 $attendanceQuery $em->getRepository('ApplicationBundle:EmployeeAttendance')
  7973.                     ->createQueryBuilder('p')
  7974.                     ->where("p.employeeId = " $employeeId)
  7975. //                ->andWhere("p.date => '" . ($startDateDt->format('Y-m-d'))."'")
  7976.                     ->andWhere("p.date <= :last")
  7977.                     ->andWhere("p.date >= :start")
  7978.                     ->setParameter('start'$startDateDt)
  7979.                     ->setParameter('last'$endDateDt);
  7980.                 $attendanceResults $attendanceQuery->getQuery()->getResult();
  7981.                 foreach ($attendanceResults as $att) {
  7982.                     $entryDateTime null;
  7983.                     $outDateTime null;
  7984.                     if ($att->getEntry()) $entryDateTime = new \DateTime($att->getDate()->format('Y-m-d') . ' ' $att->getEntry()->format('H:i:00 +0000'));
  7985.                     if ($att->getLastOut()) $outDateTime = new \DateTime($att->getDate()->format('Y-m-d') . ' ' $att->getLastOut()->format('H:i:00 +0000'));
  7986.                     $attData = array(
  7987.                         'id' => $att->getId(),
  7988.                         'date_str' => $att->getDate()->format('Y-m-d'),
  7989.                         'date_str_full' => $att->getDate()->format('Y-m-d H:i:s'),
  7990.                         'in_time_full' => $entryDateTime $entryDateTime->format(DATE_RFC2822) : '',
  7991.                         'date_ts' => $att->getDate()->format('U'),
  7992.                         'in_time' => $entryDateTime $entryDateTime->format('H:i:s') : '',
  7993.                         'in_time_ts' => $entryDateTime $entryDateTime->format('U') : 0,
  7994.                         'last_out_time' => $outDateTime $outDateTime->format('H:i:s') : '',
  7995.                         'last_out_time_ts' => $outDateTime $outDateTime->format('U') : '',
  7996.                     );
  7997.                     $locations = [];
  7998.                     $locList = [];
  7999.                     $logHere $em->getRepository('ApplicationBundle:EmployeeAttendanceLog')->findOneBy(array(
  8000.                         'attendance_id' => $att->getId(),
  8001.                     ));
  8002.                     if ($logHere)
  8003.                         $locList json_decode($logHere->getPositionArray(), true);
  8004.                     if ($locList == null)
  8005.                         $locList = [];
  8006.                     $entry_data json_decode($att->getData(), true);
  8007.                     if ($entry_data == null$entry_data = [];
  8008.                     $lastLat 0;
  8009.                     $lastLng 0;
  8010.                     foreach ($locList as $lg) {
  8011.                         $dist 0;
  8012.                         if (isset($lg['lat'])) {
  8013.                             if ($lastLat == 0) {
  8014.                                 $lastLat $lg['lat'];
  8015.                                 $lastLng $lg['lng'];
  8016.                             }
  8017.                             $theta $lastLng $lg['lng'];
  8018.                             $dist sin(deg2rad($lastLat)) * sin(deg2rad($lg['lat'])) + cos(deg2rad($lastLat)) * cos(deg2rad($lg['lat'])) * cos(deg2rad($theta));
  8019.                             $dist acos($dist);
  8020.                             $dist rad2deg($dist);
  8021.                             $miles $dist 60 1.1515;
  8022.                             $dist $miles 1609.344;
  8023.                             if (abs($dist) > 1000) {
  8024.                                 $locations[] = array(
  8025.                                     'ts' => $lg['ts'],
  8026.                                     'lat' => $lg['lat'],
  8027.                                     'lng' => $lg['lng'],
  8028.                                 );
  8029.                                 $lastLat $lg['lat'];
  8030.                                 $lastLng $lg['lng'];
  8031.                             }
  8032.                         }
  8033.                     }
  8034.                     $attData['locations'] = $locations;
  8035.                     $attData['entryData'] = $entry_data;
  8036.                     $existingData[$att->getDate()->format('U')] = $attData;
  8037.                 }
  8038.             }
  8039.             $returnData = array(
  8040.                 'page_title' => 'Attendance Amendment',
  8041.                 'existingData' => $existingData,
  8042.                 'startDateTs' => $startDateTs,
  8043.                 'extDocData' => $extDocData,
  8044.                 'endDateTs' => $endDateTs,
  8045.             );
  8046.             return new JsonResponse($returnData);
  8047.         } else
  8048.             return $this->render('ApplicationBundle:pages/human_resource/attendance:create_attendance_amendment.html.twig'$returnData);
  8049.     }
  8050.     public function AttendanceAmendmentListAction(Request $request)
  8051.     {
  8052.         $data = [];
  8053.         return $this->render('ApplicationBundle:pages/human_resource/list:attendance_amendment_list.html.twig',
  8054.             array(
  8055.                 'page_title' => 'Attendance Amendment List',
  8056.                 'data' => $data
  8057.             )
  8058.         );
  8059.     }
  8060.     public function ViewAttendanceAmendmentAction(Request $request$id)
  8061.     {
  8062.         $em $this->getDoctrine()->getManager();
  8063.         $dt HumanResource::GetAttendanceAmendmentDetails($em$id);
  8064.         return $this->render('ApplicationBundle:pages/human_resource/views:view_attendance_amendment.html.twig',
  8065.             array(
  8066.                 'page_title' => 'Attendance Amendment',
  8067.                 'data' => $dt,
  8068.                 'approval_data' => System::checkIfApprovalExists($emarray_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  8069.                     $id$request->getSession()->get(UserConstants::USER_LOGIN_ID)),
  8070.                 'document_log' => System::getDocumentLog($this->getDoctrine()->getManager(),
  8071.                     array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  8072.                     $id,
  8073.                     $dt['created_by'],
  8074.                     $dt['edited_by'])
  8075.             )
  8076.         );
  8077.     }
  8078.     public function PrintAttendanceAmendmentAction(Request $request$id)
  8079.     {
  8080.         $em $this->getDoctrine()->getManager();
  8081.         $dt HumanResource::GetAttendanceAmendmentDetails($em$id);
  8082.         $company_data Company::getCompanyData($em1);
  8083.         $document_mark = array(
  8084.             'original' => '/images/Original-Stamp-PNG-Picture.png',
  8085.             'copy' => ''
  8086.         );
  8087.         if ($request->query->has('pdf') && $this->get('knp_snappy.pdf')) {
  8088.             $html $this->renderView('@Inventory/pages/print/print_stock_received_note.html.twig',
  8089.                 array(
  8090.                     //full array here
  8091.                     'pdf' => true,
  8092.                     'page_title' => 'Stock Received Note',
  8093.                     'export' => 'pdf,print',
  8094.                     'data' => $dt,
  8095.                     'approval_data' => System::checkIfApprovalExists($emarray_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  8096.                         $id$request->getSession()->get(UserConstants::USER_LOGIN_ID)),
  8097.                     'document_log' => System::getDocumentLog($this->getDoctrine()->getManager(),
  8098.                         array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  8099.                         $id,
  8100.                         $dt['created_by'],
  8101.                         $dt['edited_by']),
  8102.                     'document_mark_image' => $document_mark['original'],
  8103.                     'company_name' => $company_data->getName(),
  8104.                     'company_data' => $company_data,
  8105.                     'company_address' => $company_data->getAddress(),
  8106.                     'company_image' => $company_data->getImage(),
  8107.                     'invoice_footer' => $company_data->getInvoiceFooter(),
  8108.                     'red' => 0
  8109.                 )
  8110.             );
  8111.             $pdf_response $this->get('knp_snappy.pdf')->getOutputFromHtml($html, array(
  8112. //                'orientation' => 'landscape',
  8113. //                'enable-javascript' => true,
  8114. //                'javascript-delay' => 1000,0
  8115.                 'no-stop-slow-scripts' => false,
  8116.                 'no-background' => false,
  8117.                 'lowquality' => false,
  8118.                 'encoding' => 'utf-8',
  8119. //            'images' => true,
  8120. //            'cookie' => array(),
  8121.                 'dpi' => 300,
  8122.                 'image-dpi' => 300,
  8123. //                'enable-external-links' => true,
  8124. //                'enable-internal-links' => true
  8125.             ));
  8126.             return new Response(
  8127.                 $pdf_response,
  8128.                 200,
  8129.                 array(
  8130.                     'Content-Type' => 'application/pdf',
  8131.                     'Content-Disposition' => 'attachment; filename="stock_received_note_' $id '.pdf"'
  8132.                 )
  8133.             );
  8134.         }
  8135.         return $this->render('ApplicationBundle:pages/human_resource/views:view_attendance_amendment.html.twig',
  8136.             array(
  8137.                 'page_title' => 'Attendance Amendment',
  8138.                 'data' => $dt,
  8139.                 'approval_data' => System::checkIfApprovalExists($emarray_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  8140.                     $id$request->getSession()->get(UserConstants::USER_LOGIN_ID)),
  8141.                 'document_log' => System::getDocumentLog($this->getDoctrine()->getManager(),
  8142.                     array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  8143.                     $id,
  8144.                     $dt['created_by'],
  8145.                     $dt['edited_by'])
  8146.             )
  8147.         );
  8148.     }
  8149.     public function createRoomAction(Request $request)
  8150.     {
  8151.         $em $this->getDoctrine()->getManager();
  8152.         $companyId $this->getLoggedUserCompanyId($request);
  8153.         if ($request->isMethod('POST')) {
  8154.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  8155.             $room = new Room;
  8156.             $room->setRoomNo($request->request->get('RoomNo'));
  8157.             //$room->setRoomName($request->request->get('RoomName'));
  8158.             $room->setBuilding($request->request->get('buildingName'));
  8159.             $room->setFloor($request->request->get('floor'));
  8160.             $room->setCapacity($request->request->get('capacity'));
  8161.             $room->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  8162.             $em->persist($room);
  8163.             $em->flush();
  8164.         }
  8165.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_room.html.twig', array(
  8166.             'page_title' => 'Add Room',
  8167.         ));
  8168.     }
  8169.     public function ExpenseTypeAction()
  8170.     {
  8171.         $expenseType HumanResourceConstant::$employeeExpenseAllowanceTypes;
  8172.         $expenseTypeArray = [];
  8173.         foreach ($expenseType as $k => $dt) {
  8174.             $dt['id'] = $k;
  8175.             $newSegs = [];
  8176.             foreach ($dt['segregations'] as $l => $s) {
  8177.                 $newOptions = [];
  8178.                 foreach ($s['options'] as $l2 => $s2) {
  8179.                     $s3 = array(
  8180.                         'value' => $l2,
  8181.                         'text' => $s2,
  8182.                     );
  8183.                     $newOptions[] = $s3;
  8184.                 }
  8185.                 $s['options'] = $newOptions;
  8186.                 if (is_string($s['defaultVal'])) $s['defaultVal'] = [$s['defaultVal']];
  8187.                 $newSegs[] = $s;
  8188.             }
  8189.             $dt['segregations'] = $newSegs;
  8190.             $expenseTypeArray[] = $dt;
  8191.         }
  8192.         return new JsonResponse(
  8193.             array(
  8194.                 'success' => true,
  8195.                 'expenseType' => $expenseType,
  8196.                 'expenseTypeArray' => $expenseTypeArray,
  8197.             )
  8198.         );
  8199.     }
  8200.     public function DemoDataTableAction()
  8201.     {
  8202.         return $this->render('ApplicationBundle:pages/human_resource/list:demo_data_table.html.twig', array(
  8203.             'page_title' => 'Add Room',
  8204.         ));
  8205.     }
  8206.     public function workEnrtyAction(Request $request)
  8207.     {
  8208. //        $em = $this->getDoctrine()->getManager();
  8209. //        $companyId = $this->getLoggedUserCompanyId($request);
  8210. //        if ($request->isMethod('POST')) {
  8211. //            $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  8212. //            $labour = new Labour();
  8213. //            $labour->setLabourName($request->request->get('labourName'));
  8214. //            $labour->setNidNumber($request->request->get('nidNumber'));
  8215. //            $em->persist($labour);
  8216. //            $em->flush();
  8217. //            $this->addFlash(
  8218. //                'success',
  8219. //                'Labour Added'
  8220. //            );
  8221. //        }
  8222.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:work_entry.html.twig', array(
  8223.             'page_title' => 'Work Entry',
  8224.         ));
  8225.     }
  8226.     public function ViewContractLetterAction(Request $request$id)
  8227.     {
  8228.         $em $this->getDoctrine()->getManager();
  8229.         $employeeDetail $em->getRepository('ApplicationBundle:EmployeeDetails')->find($id);
  8230. //        $employeeData = [];
  8231. //        foreach ($employeeDetails as $employeeDetail) {
  8232. //            $data = array(
  8233. //                'firstName' => $employeeDetail->getNid(),
  8234. //
  8235. //
  8236. //
  8237. //            );
  8238. //
  8239. //
  8240. //            $employeeData[] = $data;
  8241. //        }
  8242.         return $this->render('ApplicationBundle:pages/human_resource/views:viewContractLetter.html.twig', array(
  8243.             'page_title' => 'Contract Letter',
  8244.             'employeeDetail' => $employeeDetail
  8245.         ));
  8246.     }
  8247.     public function getAttendanceReportForEmployeeAction(Request $request)
  8248.     {
  8249.         $em $this->getDoctrine()->getManager();
  8250.         $session $request->getSession();
  8251.         $fromDateRow = (new \DateTime($request->get('start_date''')));
  8252. //        $fromDate = $fromDateRow->format("M d, Y");
  8253.         $toDateRow = (new \DateTime($request->get('end_date'$fromDateRow) . ' 23:59:59'));
  8254. //        $toDate = $toDateRow->format("M d, Y");
  8255. //        $startDate = "2025-02-13";
  8256. //        $endDate = "2025-02-16";
  8257.         $userId $session->get(UserConstants::USER_ID);
  8258.         $attendanceDetails $em->getRepository('ApplicationBundle:EmployeeAttendance')->createQueryBuilder('A')
  8259. //            ->select('A.createdAt','A.data')
  8260.             ->where('A.sysId = :userId')
  8261.             ->andWhere('A.createdAt >=  :startDate')
  8262.             ->andWhere('A.createdAt <=  :endDate')
  8263.             ->setParameter('userId'$userId)
  8264.             ->setParameter('startDate'$fromDateRow)
  8265.             ->setParameter('endDate'$toDateRow)
  8266.             ->getQuery()
  8267.             ->getResult();
  8268.         $attendance = [];
  8269.         $dt = [];
  8270.         foreach ($attendanceDetails as $data) {
  8271.             $in_out_data json_decode($data->getData(), true);
  8272.             $new_in_data = [];
  8273.             $elapsed_data = [];
  8274.             $new_out_data = [];
  8275.             if ($in_out_data == null$in_out_data = [];
  8276.             if (isset($in_out_data['in'])) {
  8277.                 foreach ($in_out_data['in'] as $ind => $g) {
  8278.                     if (!isset($elapsed_data[$ind])) {
  8279.                         $elapsed_data[$ind] = 0;
  8280.                     }
  8281.                     $the_time = new \DateTime($data->getDate()->format('Y-m-d ') . $g ' +0000');
  8282.                     $new_in_data[] = $the_time->format('U');
  8283.                 }
  8284.             }
  8285.             if (isset($in_out_data['out'])) {
  8286.                 foreach ($in_out_data['out'] as $ind => $g) {
  8287.                     if (!isset($elapsed_data[$ind])) {
  8288.                         $elapsed_data[$ind] = 0;
  8289.                     }
  8290.                     $the_time = new \DateTime($data->getDate()->format('Y-m-d ') . $g ' +0000');
  8291.                     $new_out_data[] = $the_time->format('U');
  8292.                     if (isset($new_in_data[$ind])) {
  8293.                         $elapsed_data[$ind] = $new_out_data[$ind] - $new_in_data[$ind];
  8294.                     }
  8295.                 }
  8296.             }
  8297.             $list = array(
  8298.                 'date' => $data->getDate()->format('F d Y'),
  8299.                 'attendanceData' => [
  8300.                     'in' => $new_in_data,
  8301.                     'out' => $new_out_data,
  8302.                     'elapsedSec' => $elapsed_data,
  8303.                 ]
  8304.             );
  8305.             $dt[] = $list;
  8306.         }
  8307.         $count count($attendance);
  8308. //        for ($i=0;$i < $count; $i++){
  8309. //            $dt[] = $attendance[$i]['date'];
  8310. //            $dt[] = ($attendance[$i]['attendanceData']);
  8311. //        }
  8312. ////        $decodeData = json_decode($dt, true);
  8313. //
  8314. //        $work_hours = [];
  8315. //
  8316. //        foreach ($dt as $index => $entry) {
  8317. //            $in_times = $entry['in'];
  8318. //            $out_times = $entry['out'];
  8319. //
  8320. //
  8321. //            $count = min(count($in_times), count($out_times));
  8322. //
  8323. //            for ($i = 0; $i < $count; $i++) {
  8324. //                $time_in = new DateTime($in_times[$i]);
  8325. //                $time_out = new DateTime($out_times[$i]);
  8326. //
  8327. //
  8328. //                $interval = $time_in->diff($time_out);
  8329. //                $total_hours = $interval->format('%h');
  8330. //                $total_minutes = $interval->format('%i');
  8331. //
  8332. //
  8333. //                $work_hours[] = [
  8334. ////                    "set" => $index + 1,
  8335. //                    "in" => $in_times[$i],
  8336. //                    "out" => $out_times[$i],
  8337. //                    "worked" => "$total_hours hours, $total_minutes minutes"
  8338. //                ];
  8339. //            }
  8340. //        }
  8341. //
  8342. ////        foreach ($work_hours as $work) {
  8343. ////           return new  JsonResponse(
  8344. ////               array(
  8345. ////                   'in'=>$work['in'],
  8346. ////                   'out' => $work['out'],
  8347. ////                   'hour' => $work['worked']
  8348. ////               )
  8349. ////           ) ;
  8350. //////            echo "Set {$work['set']} - IN: {$work['in']} - OUT: {$work['out']} => Worked: {$work['worked']}\n";
  8351. ////        }
  8352.         return new JsonResponse($dt);
  8353.     }
  8354.     public function getTotalWorkHourAction(Request $request)
  8355.     {
  8356.         $em $this->getDoctrine()->getManager();
  8357.         $currentDate = new \DateTime(date('y-m-d'));
  8358.         $session $request->getSession();
  8359.         $employeeId $session->get(UserConstants::USER_EMPLOYEE_ID);
  8360.         $planningItemId $session->get(UserConstants::USER_CURRENT_PLANNING_ITEM_ID);
  8361.         $attendanceData $em->getRepository('ApplicationBundle:EmployeeAttendance');
  8362.         $currentStatus HumanResource::getCurrentStatusFromDb($attendanceData$employeeId$currentDate);
  8363.         $planningItemDetails $em->getRepository(PlanningItem::class)->createQueryBuilder('p')
  8364.             ->select('p.itemAlias')
  8365.             ->where('p.id = :planningItemId')
  8366.             ->setParameter('planningItemId'$planningItemId)
  8367.             ->getQuery()
  8368.             ->getResult();
  8369.         // Check if "data" key exists and contains "in" times
  8370.         if (empty($currentStatus["data"]["in"])) {
  8371.             return new JsonResponse([
  8372. //                'message' => 'No attendance data available',
  8373.                 'currentStatus' => $currentStatus,
  8374.                 'totalWorkingTime' => '00:00:00'
  8375.             ]);
  8376.         }
  8377.         $totalSeconds 0;
  8378.         for ($i 0$i count($currentStatus["data"]["in"]); $i++) {
  8379.             $inTime $currentStatus["data"]["in"][$i];
  8380.             // Check if "out" time exists for this "in" time
  8381.             if (!isset($currentStatus["data"]["out"][$i])) {
  8382.                 continue; // Skip this entry if there is no out time
  8383.             }
  8384.             $outTime $currentStatus["data"]["out"][$i];
  8385.             // Calculate the difference
  8386.             $totalSeconds += ($outTime $inTime);
  8387.         }
  8388.         // If no valid time pairs were found, return 00:00:00
  8389. //        if ($totalSeconds == 0) {
  8390. //            return new JsonResponse([
  8391. //                'message' => 'No complete in-out records found',
  8392. //                'totalWorkingTime' => '00:00:00'
  8393. //            ]);
  8394. //        }
  8395.         // Convert total seconds to hours, minutes, and seconds
  8396.         $hours floor($totalSeconds 3600);
  8397.         $minutes floor(($totalSeconds 3600) / 60);
  8398.         $seconds $totalSeconds 60;
  8399.         $totalWorkingTime sprintf("%02d:%02d:%02d"$hours$minutes$seconds);
  8400.         return new JsonResponse([
  8401.             'taskName' => isset($planningItemDetails[0]) ? $planningItemDetails[0]['itemAlias'] : '',
  8402.             'currentStatus' => $currentStatus,
  8403.             'totalWorkingTime' => $totalWorkingTime
  8404.         ]);
  8405.     }
  8406. //    public function getEmployeeDataAction(Request $request)
  8407. //    {
  8408. //        $em = $this->getDoctrine()->getManager();
  8409. //        $session = $request->getSession();
  8410. //        $employeeId = $session->get(UserConstants::USER_EMPLOYEE_ID);
  8411. //
  8412. //
  8413. //        $employeeDetails = $em->getRepository('ApplicationBundle:EmployeeDetails')->createQueryBuilder('E')
  8414. //            ->select('E.firstname', 'E.lastname', 'E.nid', 'E.tin','E.image', 'P.positionName')
  8415. //            ->addSelect('A.current_balance')
  8416. //            ->leftJoin('ApplicationBundle:SysDepartmentPosition', 'P', 'WITH', 'E.desg = P.positionId')
  8417. //            ->leftJoin('ApplicationBundle:Employee', 'EMP', 'WITH', 'EMP.employeeId = E.id')
  8418. //            ->leftJoin('ApplicationBundle:AccAccountsHead', 'A', 'WITH', 'EMP.accountsHeadId = A.accountsHeadId')
  8419. //            ->where('E.id = :employeeId')
  8420. //            ->setParameter('employeeId', $employeeId)
  8421. //            ->getQuery()
  8422. //            ->getResult();
  8423. //
  8424. //        return new JsonResponse($employeeDetails[0]);
  8425. //    }
  8426. //    public function getEmployeeDataAction(Request $request)
  8427. //    {
  8428. //        $em = $this->getDoctrine()->getManager();
  8429. //        $session = $request->getSession();
  8430. //        $employeeId = $session->get(UserConstants::USER_EMPLOYEE_ID);
  8431. //        $image = $session->get(UserConstants::USER_IMAGE);
  8432. //        $absoluteUrl = $this->generateUrl('dashboard', [], UrlGenerator::ABSOLUTE_URL);
  8433. //
  8434. //        $employeeDetails = $em->getRepository('ApplicationBundle:EmployeeDetails')->createQueryBuilder('E')
  8435. //            ->select('E.firstname', 'E.lastname', 'E.nid', 'E.tin', 'E.image', 'P.positionName')
  8436. //            ->addSelect('A.current_balance')
  8437. //            ->leftJoin('ApplicationBundle:SysDepartmentPosition', 'P', 'WITH', 'E.desg = P.positionId')
  8438. //            ->leftJoin('ApplicationBundle:Employee', 'EMP', 'WITH', 'EMP.employeeId = E.id')
  8439. //            ->leftJoin('ApplicationBundle:AccAccountsHead', 'A', 'WITH', 'EMP.accountsHeadId = A.accountsHeadId')
  8440. //            ->where('E.id = :employeeId')
  8441. //            ->setParameter('employeeId', $employeeId)
  8442. //            ->getQuery()
  8443. //            ->getResult();
  8444. //
  8445. //        // If image is null or empty, assign empty string
  8446. //        if (empty($employeeDetails['image'])) {
  8447. //            $employeeDetails['image'] =  $image;
  8448. //        }
  8449. //
  8450. //        return new JsonResponse($employeeDetails);
  8451. //    }
  8452.     public function getEmployeeDataAction(Request $request)
  8453.     {
  8454.         $em $this->getDoctrine()->getManager();
  8455.         $session $request->getSession();
  8456.         $employeeId $session->get(UserConstants::USER_EMPLOYEE_ID);
  8457.         $image $session->get(UserConstants::USER_IMAGE);
  8458.         $absoluteUrl $this->generateUrl('dashboard', [], UrlGenerator::ABSOLUTE_URL);
  8459.         $userImage $session->get(UserConstants::USER_IMAGE);
  8460.         $employeeDetails $em->getRepository('ApplicationBundle:EmployeeDetails')->createQueryBuilder('E')
  8461.             ->select('E.firstname''E.lastname''E.nid''E.tin''E.image''P.positionName')
  8462.             ->addSelect('A.current_balance')
  8463.             ->leftJoin('ApplicationBundle:SysDepartmentPosition''P''WITH''E.desg = P.positionId')
  8464.             ->leftJoin('ApplicationBundle:Employee''EMP''WITH''EMP.employeeId = E.id')
  8465.             ->leftJoin('ApplicationBundle:AccAccountsHead''A''WITH''EMP.accountsHeadId = A.accountsHeadId')
  8466.             ->where('E.id = :employeeId')
  8467.             ->setParameter('employeeId'$employeeId)
  8468.             ->getQuery()
  8469.             ->getOneOrNullResult(\Doctrine\ORM\Query::HYDRATE_ARRAY); // Only one employee expected
  8470.         if (!$employeeDetails) {
  8471.             return new JsonResponse(['error' => 'Employee not found'], 404);
  8472.         }
  8473.         // If image is missing, fallback to session image
  8474.         if (empty($employeeDetails['image'])) {
  8475.             $employeeDetails['image'] = $image;
  8476.         }
  8477.         // If image is still available, prefix it with absolute URL
  8478.         if (!empty($employeeDetails['image'])) {
  8479.             $employeeDetails['image_url'] = $absoluteUrl '' $userImage;
  8480.         } else {
  8481.             $employeeDetails['image_url'] = ''// no image
  8482.         }
  8483.         return new JsonResponse($employeeDetails);
  8484.     }
  8485.     public function updateEmployeeDataForAppAction(Request $request)
  8486.     {
  8487.         $em $this->getDoctrine()->getManager();
  8488.         $session $request->getSession();
  8489.         $employeeId $session->get(UserConstants::USER_EMPLOYEE_ID);
  8490.         $employeeDetails $em->getRepository('ApplicationBundle:EmployeeDetails')->find($employeeId);
  8491.         if ($request->isMethod('POST')) {
  8492.             $firstname $request->request->get('firstname');
  8493.             $lastname $request->request->get('lastname');
  8494.             $nid $request->request->get('nid');
  8495.             $tin $request->request->get('tin');
  8496.             if ($firstname !== null) {
  8497.                 $employeeDetails->setFirstName($firstname);
  8498.             }
  8499.             if ($lastname !== null) {
  8500.                 $employeeDetails->setLastName($lastname);
  8501.             }
  8502.             if ($nid !== null) {
  8503.                 $employeeDetails->setNid($nid);
  8504.             }
  8505.             if ($tin !== null) {
  8506.                 $employeeDetails->setTin($tin);
  8507.             }
  8508.             $em->flush();
  8509.             return new JsonResponse(['success' => true]);
  8510.         }
  8511.         return new JsonResponse(['success' => false'message' => 'Invalid request method']);
  8512.     }
  8513. //    public function updateEmployeeDataForAppAction(Request $request){
  8514. //        $em = $this->getDoctrine()->getManager();
  8515. //        $session = $request->getSession();
  8516. //        $employeeId = $session->get(UserConstants::USER_EMPLOYEE_ID);
  8517. //        $employeeDetails = $em->getRepository('ApplicationBundle:EmployeeDetails')->find($employeeId);
  8518. //
  8519. //        if ($request->isMethod('POST')) {
  8520. //            $employeeDetails->setFirstName(($request->request->get('firstname',$employeeDetails->getFirstName())));
  8521. //            $employeeDetails->setLastName($request->request->get('lastname',$employeeDetails->getLastName()));
  8522. //            $employeeDetails->setNid($request->request->get('nid'),$employeeDetails->getNid());
  8523. //            $employeeDetails->setTin($request->request->get('tin'),$employeeDetails->getTin());
  8524. //
  8525. //            $em->flush(); //
  8526. //
  8527. //            return new JsonResponse(['success' => true]);
  8528. //        }
  8529. //
  8530. //
  8531. //    }
  8532.     public function leaveApplicationListForAppAction(Request $request)
  8533.     {
  8534.         $em $this->getDoctrine()->getManager();
  8535.         $session $request->getSession();
  8536.         $employeeId $session->get(UserConstants::USER_EMPLOYEE_ID);
  8537.         $leaveType HumanResourceConstant::$LeaveType;
  8538.         $approvalStatus GeneralConstant::$approvalAction;
  8539.         $leaveCategory HumanResourceConstant::$leavCategory;
  8540.         // Get page and limit from request (default: page=1, limit=10)
  8541.         $page max((int)$request->query->get('page'1), 1);
  8542.         $limit max((int)$request->query->get('limit'10), 1);
  8543.         $offset = ($page 1) * $limit;
  8544.         // Get total count
  8545.         $total $em->getRepository('ApplicationBundle:EmployeeLeaveApplication')
  8546.             ->createQueryBuilder('L')
  8547.             ->select('COUNT(L.employeeLeaveApplicationId)')
  8548.             ->where('L.employeeId = :employeeId')
  8549.             ->setParameter('employeeId'$employeeId)
  8550.             ->getQuery()
  8551.             ->getSingleScalarResult();
  8552.         // Get paginated results
  8553.         $leaveRecords $em->getRepository('ApplicationBundle:EmployeeLeaveApplication')
  8554.             ->createQueryBuilder('L')
  8555.             ->select(
  8556.                 'L.documentHash',
  8557.                 'L.employeeLeaveApplicationId',
  8558.                 'L.leaveStartDate',
  8559.                 'L.leaveEndDate',
  8560.                 'L.leaveTypeId',
  8561.                 'L.leaveCategory',
  8562.                 'L.approved',
  8563.                 'L.createdAt',
  8564.                 'L.alternateDate',
  8565.                 'L.leaveComment',
  8566.                 'L.createdAt',
  8567.                 'L.approved_by'
  8568.             )
  8569.             ->where('L.employeeId = :employeeId')
  8570.             ->setParameter('employeeId'$employeeId)
  8571.             ->setFirstResult($offset)
  8572.             ->setMaxResults($limit)
  8573.             ->getQuery()
  8574.             ->getResult();
  8575.         // Format the results
  8576.         $formattedData = [];
  8577.         foreach ($leaveRecords as $leave) {
  8578.             $formattedData[] = [
  8579.                 'documentHash' => $leave['documentHash'],
  8580.                 'employeeLeaveApplicationId' => $leave['employeeLeaveApplicationId'],
  8581.                 'leaveStartDate' => $leave['leaveStartDate'] ? $leave['leaveStartDate']->getTimestamp() : 0,
  8582.                 'leaveEndDate' => $leave['leaveEndDate'] ? $leave['leaveEndDate']->getTimestamp() : 0,
  8583.                 'leaveType' => $leaveType[$leave['leaveTypeId']] ?? 'Unknown',
  8584.                 'leaveCategory' => $leaveCategory[$leave['leaveCategory']] ?? 'Unknown',
  8585.                 'approved' => $approvalStatus[$leave['approved']] ?? 'Unknown',
  8586.                 'createdAt' => $leave['createdAt'] ? $leave['createdAt']->getTimestamp() : 0,
  8587.                 'alternateDate' => $leave['alternateDate'] ? $leave['alternateDate']->getTimestamp() : 0,
  8588.                 'note' => $leave['leaveComment'] ? $leave['leaveComment'] : '',
  8589.                 'appliedOn' => $leave['createdAt'] ? $leave['createdAt']->getTimestamp() : 0,
  8590.                 'approvedBy' => $leave['approved_by'] ? $leave['approved_by'] : 'automatically approved',
  8591.             ];
  8592.         }
  8593.         // Final response with pagination meta
  8594.         return new JsonResponse([
  8595.             'CurrentPage' => $page,
  8596.             'limit' => $limit,
  8597.             'total' => (int)$total,
  8598.             'data' => $formattedData,
  8599.         ]);
  8600.     }
  8601.     public function PublicProfilePageAction(Request $request)
  8602.     {
  8603.         return new JsonResponse(['success' => true]);
  8604.     }
  8605.     public function leaveSettingsAction(Request $request)
  8606.     {
  8607.         $em $this->getDoctrine()->getManager();
  8608.         if ($request->isMethod('POST')) {
  8609.             $ids $request->request->get('id', []);
  8610.             $leaveTitles $request->request->get('leaveTitle', []);
  8611.             $carryForwardTypes $request->request->get('carryForwardType', []);
  8612.             $carryForwardQtys $request->request->get('number', []);
  8613.             $totalLeaves $request->request->get('totalLeave', []);
  8614.             $resetFreqTypes $request->request->get('resetFrequencyType', []);
  8615.             $resetFreqQtys $request->request->get('resetFrequencyQty', []);
  8616.             $additionConditions $request->request->get('additionCondition', []);
  8617.             $additionDurations $request->request->get('additionConditionDuration', []);
  8618.             for ($i 0$i count($leaveTitles); $i++) {
  8619.                 if (
  8620.                     isset(
  8621.                         $carryForwardTypes[$i],
  8622.                         $carryForwardQtys[$i],
  8623.                         $totalLeaves[$i],
  8624.                         $resetFreqTypes[$i],
  8625.                         $resetFreqQtys[$i],
  8626.                         $additionConditions[$i],
  8627.                         $additionDurations[$i]
  8628.                     )
  8629.                 ) {
  8630.                     $id $ids[$i] ?? null;
  8631.                     $leaveSetting null;
  8632.                     $existingLeaveSettings $em->getRepository('ApplicationBundle:LeaveSettings')->findAll();
  8633.                     foreach ($existingLeaveSettings as $extLv) {
  8634.                         $em->remove($extLv);
  8635.                         $em->flush();
  8636.                     }
  8637. //                    if ($id) {
  8638. //                        $leaveSettings = $em->getRepository('ApplicationBundle:LeaveSettings')->find($id);
  8639. //                    }
  8640. //                    if (!$leaveSetting) {
  8641.                         $leaveSetting = new LeaveSettings();
  8642. //                    }
  8643.                     $leaveSetting->setId($i+1);
  8644.                     $leaveSetting->setLeaveTitle($leaveTitles[$i]);
  8645.                     $leaveSetting->setCarryForwardType((int)$carryForwardTypes[$i]);
  8646.                     $leaveSetting->setCarryForwardQty((int)$carryForwardQtys[$i]);
  8647.                     $leaveSetting->setTotalLeave((int)$totalLeaves[$i]);
  8648.                     $leaveSetting->setResetFrequencyType((int)$resetFreqTypes[$i]);
  8649.                     $leaveSetting->setResetFrequencyQty((int)$resetFreqQtys[$i]);
  8650.                     $leaveSetting->setAdditionCondition((int)$additionConditions[$i]);
  8651.                     $leaveSetting->setAdditionConditionDuration((int)$additionDurations[$i]);
  8652.                     $em->persist($leaveSetting);
  8653.                 }
  8654.             }
  8655.             $em->flush();
  8656.             $this->addFlash('success''Leave settings saved successfully!');
  8657.             return $this->redirectToRoute('leave_settings_list');
  8658.         }
  8659.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:leave_settings.html.twig', [
  8660.             'page_title' => 'Leave Settings',
  8661.         ]);
  8662.     }
  8663.     public function leavePolicyListAction()
  8664.     {
  8665.         return $this->render("ApplicationBundle:pages/human_resource/list:leaveApplicationSettingsList.html.twig", array(
  8666.             'page_title' => 'Leave PolicyList',
  8667.         ));
  8668.     }
  8669. }