<?php
namespace ApplicationBundle\Controller;
use ApplicationBundle\ApplicationBundle;
use ApplicationBundle\Constants\AccountsConstant;
use ApplicationBundle\Constants\ConsultancyConstant;
use ApplicationBundle\Constants\HumanResourceConstant;
use ApplicationBundle\Constants\GeneralConstant;
use ApplicationBundle\Constants\MeetingSchedulingConstant;
use ApplicationBundle\Constants\InventoryConstant;
use ApplicationBundle\Constants\UserConstants;
use ApplicationBundle\Entity\AccCheck;
use ApplicationBundle\Entity\AccCostCentre;
use ApplicationBundle\Entity\AccSettings;
use ApplicationBundle\Entity\AttendanceAmendment;
use ApplicationBundle\Entity\CheckFormat;
use ApplicationBundle\Entity\FiscalClosing;
use ApplicationBundle\Entity\HolidayCalendar;
use ApplicationBundle\Entity\HolidayCalendarDates;
use ApplicationBundle\Entity\Questionnaire;
use ApplicationBundle\Entity\Skill;
use ApplicationBundle\Entity\ConsultancyTopic;
use ApplicationBundle\Entity\EvaluationCategory;
use ApplicationBundle\Entity\BonusPolicy;
use ApplicationBundle\Entity\IncrementPolicy;
use ApplicationBundle\Entity\JobRecruitment;
use ApplicationBundle\Entity\EducationQualification;
use ApplicationBundle\Entity\TrainingCourse;
use ApplicationBundle\Entity\EmployeePerformanceEvolution;
use ApplicationBundle\Helper\Generic;
use ApplicationBundle\Modules\User\Users;
use ApplicationBundle\Entity\Brs;
//use Symfony\Bundle\FrameworkBundle\Console\Application;
//use Symfony\Component\Console\Input\ArrayInput;
//use Symfony\Component\Console\Output\NullOutput;
use ApplicationBundle\Interfaces\SessionCheckInterface;
use ApplicationBundle\Modules\Accounts\Accounts;
use ApplicationBundle\Modules\FixedAsset\FixedAsset;
use ApplicationBundle\Modules\Inventory\Inventory;
use ApplicationBundle\Modules\Purchase\Purchase;
use ApplicationBundle\Modules\Sales\Client;
use ApplicationBundle\Modules\Sales\SalesOrderM;
use ApplicationBundle\Modules\System\DeleteDocument;
use ApplicationBundle\Modules\System\DocValidation;
use ApplicationBundle\Modules\System\Email;
use ApplicationBundle\Modules\System\MiscActions;
use ApplicationBundle\Modules\User\Company;
use ApplicationBundle\Modules\System\System;
use ApplicationBundle\TimeService\EntityManagerFactory;
use ApplicationBundle\Modules\System\ApprovalFunction;
use CompanyGroupBundle\Entity\EntityApplicantDetails;
use CompanyGroupBundle\Entity\EntityCreateBlog;
use CompanyGroupBundle\Entity\EntityCreateDocument;
use CompanyGroupBundle\Entity\EntityCreateTopic;
use CompanyGroupBundle\Entity\EntityCountryConsultantRequirements;
use CompanyGroupBundle\Entity\EntityFile;
use CompanyGroupBundle\Entity\EntitySkill;
use CompanyGroupBundle\Entity\PromoCode;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\StreamedResponse;
use ApplicationBundle\Entity\AccTransactions;
use ApplicationBundle\Entity\ApplicantDetails;
use ApplicationBundle\Entity\Approval;
use ApplicationBundle\Entity\Branch;
use ApplicationBundle\Entity\Employee;
use ApplicationBundle\Entity\EmployeeAttendance;
use ApplicationBundle\Entity\EmployeeAttendanceLog;
use ApplicationBundle\Entity\EmployeeDetails;
use ApplicationBundle\Entity\EmployeeLeaveApplication;
use ApplicationBundle\Entity\EmployeeLeaveDetails;
use ApplicationBundle\Entity\EmployeeWorkplace;
use ApplicationBundle\Entity\FixedAssetProduct;
use ApplicationBundle\Entity\PayrollPolicy;
use ApplicationBundle\Entity\Payslip;
use ApplicationBundle\Entity\PurchaseOrder;
use ApplicationBundle\Entity\Region;
use ApplicationBundle\Entity\ResignApplication;
use ApplicationBundle\Entity\SalarySegregationPolicy;
use ApplicationBundle\Entity\SalesOrder;
use ApplicationBundle\Entity\ScheduledMeeting;
use ApplicationBundle\Entity\SysDepartment;
use ApplicationBundle\Entity\SysDepartmentPosition;
use ApplicationBundle\Entity\SysUser;
use ApplicationBundle\Entity\WorkHourPolicy;
use CompanyGroupBundle\Entity\EntityApplicantApplicationList;
use ApplicationBundle\Modules\HumanResource\HumanResource;
use CompanyGroupBundle\Modules\ApplicantM;
use DateInterval;
use DatePeriod;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\Validator\Constraints\DateTime;
use Ps\PdfBundle\Annotation\Pdf;
use Doctrine\ORM\EntityManager;
use Symfony\Component\Serializer\Encoder\JsonDecode;
use Symfony\Component\Validator\Constraints\Json;
use Google_Client;
use Google_Service_Oauth2;
class HumanResourceController extends GenericController implements SessionCheckInterface
{
public function AddEmployeeAction(Request $data, $id)
{
$em = $this->getDoctrine()->getManager();
$skills = $em->getRepository(Skill::class)->findAll();
$consultancyLevel = HumanResourceConstant::$consultantLevel;
if ($id) {
if ($data->isMethod('GET')) {
$Employee = $this->getDoctrine()->getRepository(EmployeeDetails::class)->find($id);
if (!$Employee) {
$this->addFlash(
'error',
'Invalid User ID!'
);
return $this->redirectToRoute('add_employee');
} else {
$EmployeeRes = HumanResource::TwigDataForAddEmployee($em, $id);
$Employee = $EmployeeRes['employee'];
$EmployeeMain = $EmployeeRes['employeeMain'];
$sysUserId = $em->getRepository(Employee::class)->find($Employee->getId())->getUserId();
$existingSysUser = $sysUserId ? $em->getRepository(SysUser::class)->find($sysUserId) : [];
$TwigData = HumanResource::TwigDataForAddEmployee($em, 0);
return $this->render(
'ApplicationBundle:pages/human_resource/input_forms:add_employee.html.twig',
array(
'page_title' => 'Update Employee',
'branches' => $TwigData['branches'],
'heads' => Accounts::getLedgerHeadsWithParents($em),
'departments' => $TwigData['departments'],
'departmentPositions' => $TwigData['departmentPositions'],
'regions' => $TwigData['regions'],
'supervisors' => $TwigData['supervisors'],
'sysUsers' => $TwigData['sysUser'],
'EmploymentStatus' => $TwigData['EmploymentStatus'],
'sex' => $TwigData['sex'],
'BloodGroup' => $TwigData['BloodGroup'],
'days' => $TwigData['days'],
'employeeMain' => $EmployeeMain,
'employee' => $Employee,
'skills' => $skills,
'existingSysUser' => $existingSysUser,
'id' => $id,
'default_route' => $EmployeeRes['defaultRoute'],
'user_type' => $EmployeeRes['userType'],
'user_type_data' => HumanResourceConstant::$userType,
'AccountTypes' => $TwigData['AccountType'],
'weekends' => explode(',', $Employee->getWeeklyHoliday()),
'consultancyLevel' => $consultancyLevel,
'module_data_array' => $TwigData['module_data_array'],
'HasUpdateMode' => true
)
);
}
} else {
$approveHash = $data->request->get('approvalHash');
$loginId = $data->getSession()->get(UserConstants::USER_LOGIN_ID);
$isSignatureOk = DocValidation::isSignatureOk($em, $loginId, $approveHash);
if ($isSignatureOk) {
$CompanyId = $this->getLoggedUserCompanyId($data);
$isSuccess = HumanResource::StoreDataForAddEmployee($em, $data, $id, $CompanyId);
if ($isSuccess) {
// $EmployeeDetails = $em->getRepository(EmployeeDetails::class)->find($id);
$Employee = $em->getRepository(Employee::class)->find($id);
$sysUserId = $Employee->getUserId();
$message = $this->get('user_module')->updateUser(
$sysUserId,
$data->request->get('firstname') . " " . $data->request->get('lastname'),
$data->request->has('email') ? $data->request->get('email') : '_UNCHANGED_',
$data->request->has('username') ? $data->request->get('username') : '_UNCHANGED_',
$data->request->get('password'),
1,
$data->request->get('user_type'),
$data->request->get('supervisor'),
$data->request->get('default_route'),
$data->request->get('branch'),
$data->request->has('access_module') ? 1 : 0,
$data->getSession()->get(UserConstants::USER_LOGIN_ID)
);
// $SysUserRepo = $em->getRepository(SysUser::class);
// $SysUser = $SysUserRepo->findOneBy(array(
// 'email' => $data->request->get('email')
// ));
// $isSuccess->setUserId($SysUser->getUserId());
// $em->persist($isSuccess);
// $em->flush();
// $companyData = $message[2];
// $emailmessage = (new \Swift_Message('Update to Entity'))
// ->setFrom('registration@entity.innobd.com')
// ->setTo($data->request->get('email'))
// ->setBody(
// $this->renderView(
// 'ApplicationBundle:email/user:registration.html.twig',
// array(
// 'name' => $data->request->get('name'),
// 'companyData' => $companyData,
// 'userName' => $data->request->get('email'),
// 'password' => $data->request->get('password'),
// )
// ),
// 'text/html'
// );
// $this->get('mailer')->send($emailmessage);
return $this->redirectToRoute('employee_list');
}
} else {
$this->addFlash(
'error',
'Invalid Approval Hash!'
);
return $this->redirectToRoute('add_employee');
}
}
} else {
if ($data->isMethod('GET')) {
$TwigData = HumanResource::TwigDataForAddEmployee($em, 0);
return $this->render(
'ApplicationBundle:pages/human_resource/input_forms:add_employee.html.twig',
array(
'page_title' => 'Add Employee',
'heads' => Accounts::getLedgerHeadsWithParents($em),
'branches' => $TwigData['branches'],
'departments' => $TwigData['departments'],
'departmentPositions' => $TwigData['departmentPositions'],
'regions' => $TwigData['regions'],
'supervisors' => $TwigData['supervisors'],
'sysUsers' => $TwigData['sysUser'],
'EmploymentStatus' => $TwigData['EmploymentStatus'],
'sex' => $TwigData['sex'],
'skills' => $skills,
'consultancyLevel' => $consultancyLevel,
'existingSysUser' => null,
'BloodGroup' => $TwigData['BloodGroup'],
'days' => $TwigData['days'],
'AccountTypes' => $TwigData['AccountType'],
'module_data_array' => $TwigData['module_data_array'],
'user_type_data' => HumanResourceConstant::$userType,
'HasUpdateMode' => false,
)
);
} else {
$approveHash = $data->request->get('approvalHash');
$loginId = $data->getSession()->get(UserConstants::USER_LOGIN_ID);
$isSignatureOk = DocValidation::isSignatureOk($em, $loginId, $approveHash);
$isUserExist = $em->getRepository(EmployeeDetails::class)
->findOneBy(array('email' => $data->request->get('email')));
if ($isSignatureOk) {
if ($isUserExist) {
$this->addFlash(
'error',
'User Already Exist!'
);
return $this->redirectToRoute('add_employee');
} else {
$CompanyId = $this->getLoggedUserCompanyId($data);
$isSuccess = HumanResource::StoreDataForAddEmployee($em, $data, false, $CompanyId);
if ($isSuccess) {
if ($data->request->has('send_appointment')) {
$email = $data->request->get('email');
$emailmessage = (new \Swift_Message("Appointment Letter - Honeybee IOT Inc"))
->setFrom('registration@entity.innobd.com')
->setTo($email)
->setBody(
$this->renderView(
'ApplicationBundle:email/general:appointment_letter_test.html.twig',
array()
),
'text/html'
);
$this->get('mailer')->send($emailmessage);
}
// Mailer function
if ($data->get("send_mail") && empty($data->get('sys_user'))) {
$message = $this->get('user_module')->addNewUser(
$data->request->get('firstname') . " " . $data->request->get('lastname'),
$data->request->get('email'),
$data->request->get('username'),
$data->request->get('password'),
$data->request->get('desg'),
$this->getLoggedUserLoginId($data),
$data->request->get('company'),
$data->request->get('user_type'),
$data->request->get('companyIdList'),
$data->request->get('branch'),
$data->request->get('supervisor'),
$data->request->get('default_route'),
$data->request->has('access_module') ? 1 : 0
);
$SysUserRepo = $em->getRepository(SysUser::class);
$SysUser = $SysUserRepo->findOneBy(array(
'email' => $data->request->get('email')
));
$isSuccess->setUserId($SysUser->getUserId());
$em->persist($isSuccess);
$em->flush();
$companyData = $message[2];
if ($message[0] == 'success' && GeneralConstant::EMAIL_ENABLED == 1) {
$bodyHtml = '';
$bodyTemplate = 'ApplicationBundle:email/user:registration.html.twig';
$bodyData = array(
'name' => $data->request->get('name'),
'companyData' => $companyData,
'userName' => $data->request->get('username'),
'password' => $data->request->get('password'),
);
$attachments = [];
// $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
$new_mail = $this->get('mail_module');
$new_mail->sendMyMail(array(
'senderHash' => '_USER_MANAGEMENT_',
// 'senderHash'=>'_CUSTOM_',
'forwardToMailAddress' => $data->request->get('email'),
'subject' => 'User Registration on HoneyBee Ecosystem under Entity ' . $companyData->getName(),
'fileName' => '',
'attachments' => $attachments,
'toAddress' => $data->request->get('email'),
// 'fromAddress'=>'sales@entity.innobd.com',
// 'userName'=>'sales@entity.innobd.com',
// 'password'=>'Y41dh8g0112',
// 'smtpServer'=>'smtp.hostinger.com',
// 'smtpPort'=>587,
// 'emailBody'=>$bodyHtml,
'mailTemplate' => $bodyTemplate,
'templateData' => $bodyData,
'embedCompanyImage' => 1,
'companyId' => $data->request->get('company'),
'companyImagePath' => $companyData->getImage()
));
// $emailmessage = (new \Swift_Message('Registration to Entity'))
// ->setFrom('registration@entity.innobd.com')
// ->setTo($data->request->get('email'))
// ->setBody(
// $this->renderView(
// 'ApplicationBundle:email/user:registration.html.twig',
// array(
// 'name' => $data->request->get('name'),
// 'companyData' => $companyData,
// 'userName' => $data->request->get('email'),
// 'password' => $data->request->get('password'),
// )
// ),
// 'text/html'
// );
// $this->get('mailer')->send($emailmessage);
}
}
// End Mailer function
$this->addFlash(
'success',
'New Employee Successfully Added!'
);
return $this->redirectToRoute('employee_list');
} else {
$this->addFlash(
'error',
'Something Went Wrong!'
);
return $this->redirectToRoute('add_employee');
}
}
} else {
$this->addFlash(
'error',
'Invalid Approval Hash!'
);
return $this->redirectToRoute('add_employee');
}
}
}
}
public function EmployeeListAction(Request $data)
{
$em = $this->getDoctrine()->getManager();
$response = HumanResource::twigDataForEmpList($em, $data);
if ($data->isMethod('GET')) {
return $this->render("ApplicationBundle:pages/human_resource/list:list_employee.html.twig", array(
'page_title' => 'Employee List',
'employeeIds' => $response,
));
}
}
public function OrganizationChartAction()
{
$em = $this->getDoctrine()->getManager();
$Reponse = HumanResource::TwigDataForOrgChart($em);
return $this->render('ApplicationBundle:pages/human_resource/views:org_chart.html.twig', array(
'page_title' => 'Organization Chart',
'supervisors' => $Reponse['TreantJsData'],
'alluser' => $Reponse['TreantJsInitUser']
));
}
public function EmployeeListSelectizeAjaxAction(Request $request, $str = '_EMPTY_')
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($request);
$company_data = Company::getCompanyData($em, $companyId);
$data = [];
$html = '';
$qryStrs = explode(' ', $str);
$qryStrAddedForSpacedName = "";
if ($str == '_EMPTY_') {
$query = "SELECT *
from employee order by employee_id asc limit 10";
} else {
foreach ($qryStrs as $qryStr) {
$qryStrAddedForSpacedName .= "or first_name like '%$qryStr%' or last_name like '%$qryStr%' ";
}
$query = "SELECT *
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";
}
$stmt = $em->getConnection()->prepare($query);
$stmt->execute();
$res = $stmt->fetchAll();
// if(!empty($res)) {
foreach ($res as $i => $r) {
$res[$i]['id_padded'] = str_pad($r['employee_id'], 8, '0', STR_PAD_LEFT);
}
// }
return new JsonResponse(
array(
'success' => true,
'data' => $res,
)
);
}
public function AttendanceAction(Request $data)
{
$em = $this->getDoctrine()->getManager();
$workHourPolicy = $em->getRepository('ApplicationBundle:WorkHourPolicy')->findAll();
$options = array(
'notification_enabled' => $this->container->getParameter('notification_enabled'),
'notification_server' => $this->container->getParameter('notification_server'),
);
if ($data->get('DataTable')) {
$response = HumanResource::HandelAjaxRequestForManualAttendance($em, $data);
return new JsonResponse($response);
}
if ($data->request->get('getAttendanceStatus')) {
$response = HumanResource::getAttendanceStatus($em, $data);
return new JsonResponse($response);
}
$session = $data->getSession();
// if ($session->get('devAdminMode', 0) != 1 && $data->get('returnJson', 0) == 0)
// return $this->redirectToRoute('permission_denied_page');
// Auto attendance
if ($data->get('autoAttendance') && $data->request->has('position_array')) {
$empId = $data->query->get('id');
$positionsArray = $data->request->get('position_array', []);
if (is_string($positionsArray)) $positionsArray = json_decode($positionsArray, true);
if ($positionsArray == null) $positionsArray = [];
$dataByAttId = [];
$workPlaceType = '_UNSET_';
foreach ($positionsArray as $d) {
$sysUserId = 0;
$userId = 0;
$empId = 0;
$dtTs = 0;
$timeZoneStr = '+0000';
// $timeZoneStr = '+0600';
if (isset($d['employeeId'])) $empId = $d['employeeId'];
if (isset($d['userId'])) $userId = $d['userId'];
if (isset($d['sysUserId'])) $sysUserId = $d['sysUserId'];
if (isset($d['tsMilSec'])) {
$dtTs = ceil((1 * $d['tsMilSec']) / 1000);
}
if ($sysUserId == 0)
$sysUserId = $userId;
if ($sysUserId == 0)
$sysUserId = $em->getRepository(Employee::class)
->findOneBy(['employeeId' => $empId])->getUserId();
if ($dtTs == 0) {
$currTsTime = new \DateTime();
$dtTs = $currTsTime->format('U');
} else {
$currTsTime = new \DateTime('@' . $dtTs);
}
$currTsTime->setTimezone(new \DateTimeZone('UTC'));
$attDate = new \DateTime($currTsTime->format('Y-m-d') . ' 00:00:00' . $timeZoneStr);
$EmployeeAttendance = $this->getDoctrine()
->getRepository(EmployeeAttendance::class)
->findOneBy(array('employeeId' => $empId, 'date' => $attDate));
if (!$EmployeeAttendance)
$EmployeeAttendance = new EmployeeAttendance;
$attendanceInfo = HumanResource::StoreAttendance($em, $empId, $sysUserId, $data, $EmployeeAttendance, $attDate, $dtTs, $timeZoneStr, $d['markerId']);
if ($d['markerId'] == HumanResourceConstant::ATTENDANCE_MARKER_CLOCK_IN) {
if ($empId == 24)
$workPlaceType = '_HYBRID_';
else
$workPlaceType = '_STATIC_';
}
if (!isset($dataByAttId[$attendanceInfo->getId()]))
$dataByAttId[$attendanceInfo->getId()] = array(
'attendanceInfo' => $attendanceInfo,
'empId' => $empId,
'lat' => 0,
'lng' => 0,
'address' => 0,
'sysUserId' => $sysUserId,
'companyId' => $data->getSession()->get(UserConstants::USER_COMPANY_ID),
'appId' => $data->getSession()->get(UserConstants::USER_APP_ID),
'positionArray' => []
);
$posData = array(
'ts' => $dtTs,
'lat' => $d['lat'],
'lng' => $d['lng'],
'marker' => $d['markerId'],
'src' => 2,
);
$posDataArray = array(
$dtTs,
$d['lat'],
$d['lng'],
$d['markerId'],
2
);
$dataByAttId[$attendanceInfo->getId()]['markerId'] = $d['markerId'];
//this markerId will be calclulted and modified to check if user is in our out of office/workplace later
$dataByAttId[$attendanceInfo->getId()]['attendanceInfo'] = $attendanceInfo;
$dataByAttId[$attendanceInfo->getId()]['positionArray'][] = $posData;
$dataByAttId[$attendanceInfo->getId()]['lat'] = $d['lat']; //for last lat lng etc
$dataByAttId[$attendanceInfo->getId()]['lng'] = $d['lng']; //for last lat lng etc
if (isset($d['address']))
$dataByAttId[$attendanceInfo->getId()]['address'] = $d['address']; //for last lat lng etc
// $dataByAttId[$attendanceInfo->getId()]['positionArray'][]=$posDataArray;
}
$response = array(
'success' => true,
);
foreach ($dataByAttId as $attInfoId => $d) {
$response = HumanResource::setAttendanceLogFlutterApp($em,
$d['empId'],
$d['sysUserId'],
$d['companyId'],
$d['appId'],
$data,
$d['attendanceInfo'],
$options,
$d['positionArray'],
$d['lat'],
$d['lng'],
$d['address'],
$d['markerId']
);
}
if ($data->request->get('requestFromMobile')) {
$today = new \DateTime(date('y-m-d'));
$repository = $this->getDoctrine()->getRepository(EmployeeAttendance::class);
$ActivitiesTemplate = HumanResource::getCurrentStatusFromDb($repository, $empId, $today);
return new JsonResponse(array(
'success' => $response['success'] == true ? true : false,
'msg' => $response['success'] == true ? 'Employee activities successfully updated.' : 'Action Failed',
'workPlaceType' => $workPlaceType,
'data' => $ActivitiesTemplate
));
}
return new JsonResponse(
array(
'success' => true,
'msg' => 'Employee activities successfully updated.',
'workPlaceType' => $workPlaceType,
)
);
} else if ($data->get('autoAttendance')) {
$sysUserId = 0;
$userId = 0;
$empId = 0;
$dtTs = 0;
// $timeZoneStr = '+0600';
$timeZoneStr = '+0000';
if ($data->request->get('requestFromMobile')) {
$empId = $data->request->get('employeeId');
$userId = $data->request->get('userId', 0);
$sysUserId = $data->request->get('id', 0);
// $empId = $em->getRepository(Employee::class)
// ->findOneBy(['userId' => $userId])->getEmployeeId();
} else {
$empId = $data->request->get('employeeId', 0);
$sysUserId = $data->request->get('userId', 0);
}
$dtTs = $data->request->get('timeTs', 0);
if ($sysUserId == 0)
$sysUserId = $userId;
if ($sysUserId == 0)
$sysUserId = $em->getRepository(Employee::class)
->findOneBy(['employeeId' => $empId])->getUserId();
if ($dtTs == 0) {
$currTsTime = new \DateTime();
$dtTs = $currTsTime->format('U');
} else {
$currTsTime = new \DateTime('@' . $dtTs);
}
if ($sysUserId == 0)
$sysUserId = $userId;
if ($sysUserId == 0)
$sysUserId = $em->getRepository(Employee::class)
->findOneBy(['employeeId' => $empId])->getUserId();
$today = new \DateTime(date('y-m-d'));
$currTsTime->setTimezone(new \DateTimeZone('UTC'));
$attDate = new \DateTime($currTsTime->format('Y-m-d') . ' 00:00:00' . $timeZoneStr);
$EmployeeAttendance = $this->getDoctrine()
->getRepository(EmployeeAttendance::class)
->findOneBy(array('employeeId' => $empId, 'date' => $attDate));
if (!$EmployeeAttendance)
$EmployeeAttendance = new EmployeeAttendance;
// return new JsonResponse(["success" => true, "data" => $ActivitiesTemplate]);
// $attendanceInfo = HumanResource::StoreAttendance($em, $empId, $sysUserId, $data, $EmployeeAttendance, $customTime);
$attendanceInfo = HumanResource::StoreAttendance($em, $empId, $sysUserId, $data, $EmployeeAttendance, $attDate, $dtTs, $timeZoneStr, HumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED);
if (!isset($dataByAttId[$attendanceInfo->getId()]))
$dataByAttId[$attendanceInfo->getId()] = array(
'attendanceInfo' => $attendanceInfo,
'empId' => $empId,
'lat' => 0,
'lng' => 0,
'address' => 0,
'sysUserId' => $sysUserId,
'companyId' => $data->getSession()->get(UserConstants::USER_COMPANY_ID),
'appId' => $data->getSession()->get(UserConstants::USER_APP_ID),
'positionArray' => []
);
$posData = array(
'ts' => $dtTs,
'lat' => 0,
'lng' => 0,
'marker' => HumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED,
'src' => 1,
);
$posDataArray = array(
$dtTs,
0,
0,
HumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED,
1
);
$dataByAttId[$attendanceInfo->getId()]['markerId'] = HumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED;
//this markerId will be calclulted and modified to check if user is in our out of office/workplace later
$dataByAttId[$attendanceInfo->getId()]['attendanceInfo'] = $attendanceInfo;
$dataByAttId[$attendanceInfo->getId()]['positionArray'][] = $posData;
$dataByAttId[$attendanceInfo->getId()]['lat'] = 0; //for last lat lng etc
$dataByAttId[$attendanceInfo->getId()]['lng'] = 0; //for last lat lng etc
if (isset($d['address']))
$dataByAttId[$attendanceInfo->getId()]['address'] = ''; //for last lat lng etc
$response = array(
'success' => true
);
foreach ($dataByAttId as $attInfoId => $d) {
$response = HumanResource::setAttendanceLogFlutterApp($em,
$d['empId'],
$d['sysUserId'],
$d['companyId'],
$d['appId'],
$data,
$d['attendanceInfo'],
$options,
$d['positionArray'],
$d['lat'],
$d['lng'],
$d['address'],
$d['markerId']
);
}
if ($data->request->get('requestFromMobile')) {
return new JsonResponse(array(
'success' => $response['success'] == true ? true : false,
'msg' => $response['success'] == true ? 'Employee activities successfully updated.' : 'Action Failed',
));
}
return new JsonResponse(
array(
'success' => true,
'dtTs' => $dtTs,
'attDate' => $attDate->format(DATE_RFC822),
'currTsTime' => $currTsTime->format(DATE_RFC822),
'msg' => 'Employee activities successfully updated.',
)
);
//
//
// $response = HumanResource::setAttendanceLog($em, $empId, $sysUserId,
// $data->getSession()->get(UserConstants::USER_COMPANY_ID),
// $data->getSession()->get(UserConstants::USER_APP_ID),
// $data, $attendanceInfo, $options);
//
// if ($data->request->get('requestFromMobile')) {
// return new JsonResponse($response);
// }
//
// return new JsonResponse(
// array(
// 'success' => true,
// 'msg' => 'Employee activities successfully updated.'
// )
// );
// }
// else {
// return new JsonResponse(
// array(
// 'success' => false,
// 'msg' => "Invalid employee ID"
// )
// );
// }
} else {
if ($data->get('manualAttendance')) {
return $this->render(
'ApplicationBundle:pages/human_resource/input_forms:manual_attendance.html.twig',
array(
'page_title' => 'Manual Attendance',
'workPolicy' => $workHourPolicy,
// 'workTime' => json_decode($workHourPolicy->getRepeatationData()),
// 'workTime' => json_decode($workHourPolicy->getRepeatationData()),
// 'workTime' => json_decode($workHourPolicy->getEmployeeTypeIds(),true),
)
);
}
// Show all matching employee list during ajax request
// Show current location according to id
if ($data->get('getCurrLocById')) {
$Id = $data->get("id");
$options = array(
'employeeId' => $Id,
'entityDbaseName' => 'work_hour_policy',
'entityDbaseIdField' => 'id',
'entityDbaseEmployeeIdsField' => 'employeeIds',
'entityDesignationIdsField' => 'designationIds',
'entityDepartmentIdsField' => 'departmentIds',
'entityEmployeeTypeIdsField' => 'employee_types',
'limit' => 1,
'single' => 1,
);
$workHourPolicyData = HumanResource::getApplicableSettingsDataForEmployee($em, $options);
$today = new \DateTime(date('y-m-d'));
$repository = $this->getDoctrine()->getRepository(EmployeeAttendance::class);
$ActivitiesTemplate = HumanResource::getActivitiesTemplate($repository, $Id, $today);
return new JsonResponse(["success" => true, "workHourPolicyData" => $workHourPolicyData, "template" => $ActivitiesTemplate]);
}
}
}
public function getCurrentStatusAction($id)
{
$today = new \DateTime(date('y-m-d'));
$repository = $this->getDoctrine()->getRepository(EmployeeAttendance::class);
$ActivitiesTemplate = HumanResource::getCurrentStatusFromDb($repository, $id, $today);
return new JsonResponse(["success" => true, "data" => $ActivitiesTemplate]);
}
public function CurrentAttendanceAction(Request $data)
{
$em = $this->getDoctrine()->getManager();
$options = array(
'notification_enabled' => $this->container->getParameter('notification_enabled'),
'notification_server' => $this->container->getParameter('notification_server'),
);
if ($data->get('DataTable')) {
$response = HumanResource::HandelAjaxRequestForManualAttendance($em, $data);
return new JsonResponse($response);
}
if ($data->request->get('getAttendanceStatus')) {
$response = HumanResource::getAttendanceStatus($em, $data);
return new JsonResponse($response);
}
// Auto attendance
if ($data->get('autoAttendance')) {
$empId = $data->query->get('id');
$sysUserId = 0;
if ($data->get('requestFromMobile')) {
$sysUserId = $data->request->get('id');
$empId = $em->getRepository(Employee::class)
->findOneBy(['userId' => $sysUserId])->getEmployeeId();
} else {
$sysUserId = $em->getRepository(Employee::class)
->findOneBy(['employeeId' => $empId])->getUserId();
}
$customTime = $data->get('time');
$today = new \DateTime(date('y-m-d'));
$EmployeeAttendance = $this->getDoctrine()
->getRepository(EmployeeAttendance::class)
->findOneBy(array('employeeId' => $empId, 'date' => $today));
if (!$EmployeeAttendance)
$EmployeeAttendance = new EmployeeAttendance;
$attendanceInfo = HumanResource::StoreAttendance($em, $empId, $sysUserId, $data, $EmployeeAttendance, $customTime);
$response = HumanResource::setAttendanceLog($em, $empId, $sysUserId,
$data->getSession()->get(UserConstants::USER_COMPANY_ID),
$data->getSession()->get(UserConstants::USER_APP_ID),
$data, $attendanceInfo, $options);
if ($data->get('requestFromMobile')) {
return new JsonResponse([$response]);
}
return new JsonResponse(
array(
'success' => true,
'msg' => 'Employee activities successfully updated.'
)
);
// }
// else {
// return new JsonResponse(
// array(
// 'success' => false,
// 'msg' => "Invalid employee ID"
// )
// );
// }
} else {
if ($data->get('manualAttendance')) {
return $this->render(
'ApplicationBundle:pages/human_resource/report:current_attendance.html.twig',
array(
'page_title' => 'Current Attendance Status',
)
);
}
// Show all matching employee list during ajax request
// Show current location according to id
if ($data->get('getCurrLocById')) {
$Id = $data->get("id");
$today = new \DateTime(date('y-m-d'));
$repository = $this->getDoctrine()->getRepository(EmployeeAttendance::class);
$ActivitiesTemplate = HumanResource::getActivitiesTemplate($repository, $Id, $today);
return new JsonResponse(["success" => true, "template" => $ActivitiesTemplate]);
}
}
}
public function EmployeeLeaveAction(Request $data, $id)
{
$em = $this->getDoctrine()->getManager();
$request=$data;
if (!$id) {
if ($data->isMethod('GET')) {
$EmpID = $data->query->get('id');
$LeaveType = $data->query->get('leaveType');
if ($data->query->has('id') && $data->query->has('leaveType')) {
$response = HumanResource::HandelAjaxRequestForLeaveApp($em, $EmpID, $LeaveType);
return new JsonResponse($response);
}
if ($data->query->has('id')) {
$Response = HumanResource::HandelAjaxRequestForLeaveApp($em, $EmpID);
return new JsonResponse($Response);
}
$TemplateData = HumanResource::TwigDataForLeaveApp($em, False);
return $this->render(
'ApplicationBundle:pages/human_resource/input_forms:employee_leave.html.twig',
array(
'page_title' => $TemplateData['Title'],
'EmployeeList' => $TemplateData['EmployeeList'],
'DesignationList' => $TemplateData['DesignationList'],
'HasUpdateMode' => false
)
);
} else {
$CompanyId = $this->getLoggedUserCompanyId($data);
$Response = HumanResource::StoreDataForLeaveApplication($em, $id, $data, false, $CompanyId);
if ($Response['HasErr']) {
$this->addFlash('error', $Response['msg']);
if ($data->request->has('returnJson')) {
return new JsonResponse(array(
'success' => false,
'errorStr' => $Response['msg'],
));
} else {
return $this->redirectToRoute('employee_leave');
}
}
$applicationId = $Response['applicationId'];
$em_goc = $this->getDoctrine()->getManager('company_group');
$file_path_list=[];
if($applicationId!=0) {
if (!empty($request->files)) {
MiscActions::RemoveFilesForEntityDoc($em_goc, 'EmployeeLeaveApplication', $applicationId);
$storePath = 'uploads/LeaveDoc/';
$path = "";
$file_path = "";
$session = $request->getSession();
MiscActions::RemoveExpiredFiles($em_goc);
foreach ($request->files as $uploadedFileGG) {
// if($uploadedFile->getImage())
// var_dump($uploadedFile->getFile());
// var_dump($uploadedFile);
$tempD = $uploadedFileGG;
if (!is_array($uploadedFileGG)) {
$uploadedFileGG = array();
$uploadedFileGG[] = $tempD;
}
foreach ($uploadedFileGG as $uploadedFile) {
if ($uploadedFile != null) {
$extension = $uploadedFile->guessExtension();
$size = $uploadedFile->getSize();
$fileName = 'LDOC_' . $applicationId . '_' . (md5(uniqid())) . '.' . $uploadedFile->guessExtension();
$path = $fileName;
$upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/' . $storePath;
if (!file_exists($upl_dir)) {
mkdir($upl_dir, 0777, true);
}
if (file_exists($upl_dir . '' . $path)) {
chmod($upl_dir . '' . $path, 0755);
unlink($upl_dir . '' . $path);
}
$file = $uploadedFile->move($upl_dir, $path);
$expireNever = 1;
$expireTs = 0;
$EntityFile = new EntityFile();
$EntityFile->setPath($this->container->getParameter('kernel.root_dir') . '/../web/' . $storePath . $path);
$EntityFile->setMarker('_GEN_');
$EntityFile->setExtension($extension);
$EntityFile->setExpireTs($expireTs);
$EntityFile->setSize($size);
$EntityFile->setRelativePath($storePath . $path);
$EntityFile->setEntityName('EmployeeLeaveApplication');
$EntityFile->setEntityBundle('EmployeeLeaveApplication');
$EntityFile->setEntityId($applicationId);
$EntityFile->setEntityIdField('employeeLeaveApplicationId');
$EntityFile->setModifyFieldSetter('setFiles');
$EntityFile->setDocIdForApplicant(0);
$EntityFile->setUserId($session->get(UserConstants::USER_ID, 0));
$EntityFile->setAppId($session->get(UserConstants::USER_APP_ID, 0));
$EntityFile->setEmployeeId($session->get(UserConstants::USER_EMPLOYEE_ID, 0));
$EntityFile->setUserType($session->get(UserConstants::USER_TYPE, 0));
$em_goc->persist($EntityFile);
$em_goc->flush();
$EntityFileId = $EntityFile->getId();
}
if ($path != "")
$file_path_list[] = ($storePath . $path);
}
}
$g_path = $this->container->getParameter('kernel.root_dir') . '/../web/' . $storePath . $path;
$v = $em->getRepository('ApplicationBundle:EmployeeLeaveApplication')->findOneBy(array(
'employeeLeaveApplicationId' => $applicationId,
));
if ($v) {
$v->setFiles(implode(',', $file_path_list));
$em->flush();
} else {
}
}
}
// $this->addFlash('success', 'Application submitted successfully!');
// return $this->redirectToRoute('leave_application_list');
if ($data->request->has('returnJson')) {
return new JsonResponse(array(
'success' => true,
));
} else {
return $this->redirectToRoute('view_employee_leave_application', array('id' => $applicationId));
}
}
}
else {
if ($data->isMethod('GET')) {
$ApplicationRepo = $em->getRepository(EmployeeLeaveApplication::class);
$OldData = $ApplicationRepo->find(array('employeeLeaveApplicationId' => $id));
$TemplateData = HumanResource::TwigDataForLeaveApp($em, $OldData);
return $this->render(
'ApplicationBundle:pages/human_resource/input_forms:employee_leave.html.twig',
array(
'page_title' => $TemplateData['Title'],
'EmployeeList' => $TemplateData['EmployeeList'],
'DesignationList' => $TemplateData['DesignationList'],
'OldData' => $TemplateData['OldData'],
'AvailableLeave' => $TemplateData['AvailableLeave'],
'HasUpdateMode' => true
)
);
} else {
$CompanyId = $this->getLoggedUserCompanyId($data);
$Response = HumanResource::StoreDataForLeaveApplication($em, $id, $data, true, $CompanyId);
if ($Response['HasErr']) {
$this->addFlash('error', $Response['msg']);
return $this->redirectToRoute('employee_leave');
}
$this->addFlash('success', "Application updated successfully!");
return $this->redirectToRoute('leave_application_list');
}
}
}
public function ViewLeaveApplicationAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
if ($id) {
$TwigData = HumanResource::TwigDataForViewLeaveApplication($em, $request, $id);
if ($TwigData['HasErr']) {
return new JsonResponse(array(
'success' => false,
'msg' => $TwigData['Msg']
));
}
return $this->render(
'ApplicationBundle:pages/human_resource/views:leave_application_view.html.twig',
array(
'page_title' => 'View Leave Application',
'Applicant' => $TwigData['Applicant'],
'Application' => $TwigData['Application'],
'LeaveType' => $TwigData['LeaveType'],
'LeaveCategory' => $TwigData['LeaveCategory'],
'FrwdEmp' => $TwigData['FrwdEmp'],
'ApplicantDesg' => $TwigData['ApplicantDesg'],
'approval_status' => $TwigData['approval_status'],
'approval_data' => $TwigData['approval_data'],
'document_log' => $TwigData['document_log'],
'auto_created' => 0,
)
);
}
return new JsonResponse(array(
'success' => false,
'msg' => 'Wrong URL format! Please try with application ID'
));
}
public function PrintLeaveApplicationAction(Request $request, $id)
{
if ($id) {
$em = $this->getDoctrine()->getManager();
$company_data = Company::getCompanyData($em, 1);
$Application = $em->getRepository(EmployeeLeaveApplication::class)->find($id);
$Authorizations = System::getSignatureListForDocumentPrint($em, array_flip(GeneralConstant::$Entity_list)['EmployeeLeaveApplication'], $id);
$ApplicationCategory = $Application->getLeaveCategory();
$ApplicationType = ($ApplicationCategory!=1 && $ApplicationCategory!= 2)?HumanResourceConstant::$LeaveType[$Application->getLeaveTypeId()]:'';
$Applicant = $em->getRepository(EmployeeDetails::class)
->find($Application->getEmployeeId());
return $this->render(
'ApplicationBundle:pages/human_resource/print:leave_application_print.html.twig',
array(
'page_title' => 'Print Leave Application',
'export' => 'pdf,print',
'company_name' => $company_data->getName(),
'company_data' => $company_data,
'company_address' => $company_data->getAddress(),
'company_image' => $company_data->getImage(),
'Application' => $Application,
'Applicant' => $Applicant,
'Authorizations' => $Authorizations,
'ApplicationType' => $ApplicationType,
'ApplicationCategory' => $ApplicationCategory,
'red' => 0
)
);
}
return new JsonResponse(array(
'success' => false,
'msg' => 'Wrong URL format! Please try with application ID'
));
}
public function LeaveApplicationListAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$response = HumanResource::GetEmployeeLeaveApplicationList($em, $request);
if ($request->isMethod('GET')) {
return $this->render("ApplicationBundle:pages/human_resource/list:leave_application_list.html.twig", array(
'page_title' => 'Leave Application List',
'application_data' => $response,
));
}
}
public function PayrollPolicySettingsAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$CompanyId = $this->getLoggedUserCompanyId($request);
if ($id) {
if ($request->isMethod('GET')) {
$Row = $em->getRepository(PayrollPolicy::class)->find($id);
if (!$Row) {
$this->addFlash('error', 'Invalid Payroll Policy Id');
return $this->redirectToRoute('payroll_policy_settings');
}
$TwigData = HumanResource::GetPayrollPolicyTwigData($em);
$OldData = HumanResource::GetPayrollPolicyTwigData($em, $id);
return $this->render('ApplicationBundle:pages/human_resource/input_forms:payroll_policy_settings.html.twig', array(
'page_title' => 'Update Payroll Policy Settings',
'EmployeeIds' => $TwigData['EmployeeIds'],
'EmployeeType' => $TwigData['EmployeeType'],
'department' => $TwigData['department'],
'Designation' => $TwigData['Designation'],
'WorkingDays' => $TwigData['WorkingDays'],
'OldData' => $OldData['Row'],
'earningAspects' => HumanResourceConstant::$earningAspectsForPayrollPolicy,
'leaveTypes' => HumanResourceConstant::$LeaveTypeForPayrollPolicy,
'leaveTypesArray' => HumanResourceConstant::$LeaveTypeArrayForPayrollPolicy,
'deductionAspects' => HumanResourceConstant::$deductionAspects,
'deductionCondition' => json_decode($Row->getDeductionCondition(), true),
'HasUpdateMode' => true,
));
} else {
$Response = HumanResource::StorePayrollPolicyData($em, $id, $CompanyId, $request);
if ($Response['HasErr']) {
$this->addFlash('error', $Response['msg']);
return $this->redirectToRoute('payroll_policy_settings');
}
return $this->redirectToRoute('payroll_policy_settings');
// if ($Response['isSuccess']) {
// return new JsonResponse(array('success' => true, 'msg' => 'don\'t forget to redirect'));
// }
// return new JsonResponse(array('success' => false, 'msg' => 'Sorry something went wrong'));
}
} else {
if ($request->isMethod('GET')) {
if ($request->query->get('GetDocHash')) {
$Dochash = HumanResource::GenerateDocHashForPayrollSettings($em, $request);
return new JsonResponse($Dochash);
}
$TwigData = HumanResource::GetPayrollPolicyTwigData($em);
return $this->render(
'ApplicationBundle:pages/human_resource/input_forms:payroll_policy_settings.html.twig',
array(
'page_title' => 'Create Payroll Policy Settings',
'EmployeeIds' => $TwigData['EmployeeIds'],
'EmployeeType' => $TwigData['EmployeeType'],
'WorkingDays' => $TwigData['WorkingDays'],
'Designation' => $TwigData['Designation'],
'department' => $TwigData['department'],
'earningAspects' => HumanResourceConstant::$earningAspectsForPayrollPolicy,
'leaveTypes' => HumanResourceConstant::$LeaveTypeForPayrollPolicy,
'leaveTypesArray' => HumanResourceConstant::$LeaveTypeArrayForPayrollPolicy,
'deductionAspects' => HumanResourceConstant::$deductionAspects,
'HasUpdateMode' => false
)
);
} else {
$Response = HumanResource::StorePayrollPolicyData($em, $id, $CompanyId, $request);
if ($Response['HasErr']) {
$this->addFlash('error', $Response['msg']);
return $this->redirectToRoute('payroll_policy_settings');
}
return $this->redirectToRoute('payroll_policy_settings');
// return new JsonResponse(array("success" => true, 'msg' => 'Dont forget to redirect!'));
}
}
}
public function AttendanceReportAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$EmployeeIds = $em->getRepository(EmployeeDetails::class)->findAll();
$Departments = $em->getRepository(SysDepartment::class)->findAll();
$attendanceSource = HumanResourceConstant::$attendanceSources;
if ($request->isMethod('GET')) {
return $this->render('ApplicationBundle:pages/human_resource/report:attendance_report.html.twig', array(
'page_title' => 'Attendance Report',
'employes' => $EmployeeIds,
'departments' => $Departments,
'isMethodGet' => true,
'from_date' => '',
'to_date' => '',
'report_for' => '',
'attendance' => [],
'Reports' => [],
'qry' => ''
));
}
$ReportData = HumanResource::GenerateAttendanceReport($em, $request,$request->request->get('considerCurrTsIfNoOut',0));
if($request->request->get('returnJson',0)==1)
{
return new JsonResponse($ReportData);
}
$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') : []));
return $this->render('ApplicationBundle:pages/human_resource/report:attendance_report.html.twig', array(
'page_title' => 'Attendance Report',
'isMethodGet' => false,
'departments' => $Departments,
'employes' => $EmployeeIds,
'attendanceSource' => $attendanceSource,
'Reports' => $ReportData['Reports'],
'from_date' => $ReportData['from_date'],
'to_date' => $ReportData['to_date'],
'report_for' => $ReportData['generated_for'],
'attendance' => $ReportData['attendance'],
'qry' => $Qry
));
}
public function PrintAttendanceReportAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$company_data = Company::getCompanyData($em, 1);
$ReportData = HumanResource::GenerateAttendanceReport($em, $request);
return $this->render(
'ApplicationBundle:pages/human_resource/print:print_attendance_report.html.twig',
array(
'page_title' => 'Print Attendance Report',
'export' => 'pdf,print',
'company_name' => $company_data->getName(),
'company_data' => $company_data,
'company_address' => $company_data->getAddress(),
'company_image' => $company_data->getImage(),
'Reports' => $ReportData['Reports'],
'from_date' => $ReportData['from_date'],
'to_date' => $ReportData['to_date'],
'report_for' => $ReportData['generated_for'],
'attendance' => $ReportData['attendance'],
'red' => 0
)
);
}
public function DisburseSalaryAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$EmployeeIds = $em->getRepository(EmployeeDetails::class)->findAll();
$Departments = $em->getRepository(SysDepartment::class)->findAll();
$attendance = $em->getRepository(EmployeeAttendanceLog::class)->findAll();
if ($request->isMethod('GET')) {
return $this->render('ApplicationBundle:pages/human_resource/report:disburse_salary.html.twig', array(
'page_title' => 'Disburse Salary',
'EmployeeIds' => $EmployeeIds,
'departments' => $Departments,
'attendance' => $attendance,
'from_date' => '',
'to_date' => '',
'Qry' => '',
'isMethodGet' => true
));
}
$SalaryReports = HumanResource::BasicDeduction($em, $request);
// $SalaryReportsNew = HumanResource::calculateSalary($em,
// array(
// 'startDate' => $request->get('salary_start_date', ''),
// 'endDate' => $request->get('salary_end_date', ''),
// 'timeZone' => $request->get('time_zone', '+0600'),
// 'employeeIds' => $request->get('employeeIds', []),
// 'departmentIds' => $request->get('department', []),
// 'allFlag' => $request->get('show_all', 0),
//
// )
// );
$Qry = "salary_till_date=" . $SalaryReports[0]['to_date'] . '&' . "show_all=" . $request->get('show_all') . '&' . "department=" . $SalaryReports[0]['department_id'] . '&' . "employeeIds=" . implode(',', ($request->get('employeeIds') ? $request->get('employeeIds') : []));
// if ($request->get('returnJson', 0) == 1) {
if ($request->get('returnJson', 0) == 1) {
return new JsonResponse(array(
'SalaryReports' => $SalaryReports,
));
} else {
return $this->render('ApplicationBundle:pages/human_resource/report:disburse_salary.html.twig', array(
'page_title' => 'Disburse Salary',
'EmployeeIds' => $EmployeeIds,
'departments' => $Departments,
'SalaryReports' => $SalaryReports,
'for_month' => $SalaryReports[0]['for_month'],
'from_date' => $SalaryReports[0]['form_date'],
'to_date' => $SalaryReports[0]['to_date'],
'Qry' => $Qry,
'isMethodGet' => false
));
}
}
public function PrintDisburseSalaryAction(Request $Req)
{
$em = $this->getDoctrine()->getManager();
$company_data = Company::getCompanyData($em, 1);
$SalaryReports = HumanResource::BasicDeduction($em, $Req);
return $this->render(
'ApplicationBundle:pages/human_resource/print:print_disburse_salary.html.twig',
array(
'page_title' => 'Print Disburse Salary',
'export' => 'pdf,print',
'company_name' => $company_data->getName(),
'company_data' => $company_data,
'company_address' => $company_data->getAddress(),
'company_image' => $company_data->getImage(),
'SalaryReports' => $SalaryReports,
'for_month' => $SalaryReports[0]['for_month'],
'from_date' => $SalaryReports[0]['form_date'],
'to_date' => $SalaryReports[0]['to_date'],
'red' => 0
)
);
}
public function createJobRecruitmentAction(Request $request, $id = 0)
{
$data = [];
$em_goc = $this->getDoctrine()->getManager('company_group');
$skillDetails = $em_goc->getRepository(EntitySkill::class)->findAll();
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($request);
if ($request->isMethod('POST')) {
$em = $this->getDoctrine()->getManager();
$entity_id = array_flip(GeneralConstant::$Entity_list)['JobRecruitment']; //change
$dochash = $request->request->get('docHash'); //change
$loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
$approveRole = $request->request->get('approvalRole');
$approveHash = $request->request->get('approvalHash');
if (!DocValidation::isInsertable($em, $entity_id, $dochash,
$loginId, $approveRole, $approveHash, $id)
) {
$this->addFlash(
'error',
'Sorry Could not insert Data.'
);
} else {
$data = $request->request;
$docId = HumanResource::createJobRecruitment($em, $loginId, $id, $data, $companyId);
//now add Approval info
$approveRole = $request->request->get('approvalRole');
$options = array(
'notification_enabled' => $this->container->getParameter('notification_enabled'),
'notification_server' => $this->container->getParameter('notification_server'),
'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
'url' => $this->generateUrl(
GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['JobRecruitment']]
['entity_view_route_path_name']
)
);
System::setApprovalInfo($this->getDoctrine()->getManager(), $options,
array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
$docId,
$request->getSession()->get(UserConstants::USER_LOGIN_ID) //journal voucher
);
System::createEditSignatureHash($this->getDoctrine()->getManager(), array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
$docId,
$loginId,
$approveRole,
$request->request->get('approvalHash'));
$this->addFlash(
'success',
'New Recruitment Document Added.'
);
$url = $this->generateUrl(
'view_job_recruitment'
);
return $this->redirect($url . "/" . $docId);
}
}
if ($id == 0) {
} else {
$extDoc = $em->getRepository('ApplicationBundle:JobRecruitment')->findOneBy(
array(
'jobRecruitmentId' => $id, ///material
)
);
//now if its not editable, redirect to view
if ($extDoc) {
if ($extDoc->getEditFlag() != 1) {
$url = $this->generateUrl(
'view_job_recruitment'
);
return $this->redirect($url . "/" . $id);
}
}
}
$jobType = HumanResourceConstant::$employeeType;
//$skillDetails = $em->getRepository(Skill::class)->findAll();
$educationDetails = $em->getRepository('ApplicationBundle:EducationQualification')->findAll();
$employeeIds = $em->getRepository('ApplicationBundle:Employee')->findAll();
$location = HumanResourceConstant::$location;
$salaryPer = HumanResourceConstant::$salaryPer;
$workExperience = HumanResourceConstant::$workExperience;
$jobOpeningStatus = HumanResourceConstant::$jobOpeningStatus;
$compatibility = HumanResourceConstant::$compatibility;
return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_new_job_post.html.twig', [
'page_title' => 'Create New Job Post',
'jobType' => $jobType,
'skillDetails' => $skillDetails,
'educationDetails' => $educationDetails,
'employeeIds' => $employeeIds,
'location' => $location,
'salaryPer' => $salaryPer,
'workExperience' => $workExperience,
'jobOpeningStatus' => $jobOpeningStatus,
'compatibility' => $compatibility
]);
}
public function viewApplicantInfoAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager('company_group');
//$session = $request->getSession();
$consultantDetails = $em->getRepository(EntityApplicantDetails::class)->find($id);
$skillDetails = $em->getRepository('CompanyGroupBundle:EntitySkill')->findAll();
//$companyId = $this->getLoggedUserCompanyId($request);
$gender = HumanResourceConstant::$sex;
$blood = HumanResourceConstant::$BloodGroup;
//$userId = $session->get(UserConstants::USER_ID);
return $this->render('ApplicationBundle:pages/human_resource/views:view_applicant_info.html.twig', [
'page_title' => 'Applicant Information',
'gender' => $gender,
'blood' => $blood,
'consultantDetails' => $consultantDetails,
'education' => json_decode($consultantDetails->getEducationData(), true),
'workExperience' => json_decode($consultantDetails->getWorkExperienceData(), true),
'certificate' => json_decode($consultantDetails->getCertificateData(), true),
'courses' => json_decode($consultantDetails->getCoursesData(), true),
'languages' => json_decode($consultantDetails->getLanguagesData(), true),
'skillDetails' => $skillDetails
]);
}
public function ListJobRecruitmentAction()
{
$em = $this->getDoctrine()->getManager();
$jobRecruitmentList = [];
$jobRecruitments = $em->getRepository('ApplicationBundle:JobRecruitment')->findAll();
foreach ($jobRecruitments as $jobRecruitment) {
$jobData = array(
'jobRecruitmentId' => $jobRecruitment->getJobRecruitmentId(),
'title' => $jobRecruitment->getTitle(),
'date' => $jobRecruitment->getDate(),
'jobOpeningStatus' => $jobRecruitment->getJobOpeningStatus(),
'applicationOpeningDate' => $jobRecruitment->getApplicationOpeningDate(),
'applicationClosingDate' => $jobRecruitment->getApplicationClosingDate(),
);
$jobRecruitmentList[] = $jobData;
}
return $this->render('ApplicationBundle:pages/human_resource/list:job_recruitment_list.html.twig', [
'page_title' => 'Job RecruitmentAction List',
'jobRecruitments' => $jobRecruitmentList
]);
}
public function ViewJobRecruitmentAction(Request $request, $id = 0)
{
$em_goc = $this->getDoctrine()->getManager('company_group');
$skillDetails = $em_goc->getRepository('CompanyGroupBundle:EntitySkill')->findAll();
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($request);
$company_data = Company::getCompanyData($em, $companyId);
// return new JsonResponse($encryptedDataArray);
$location = HumanResourceConstant::$location;
$salaryPer = HumanResourceConstant::$salaryPer;
$workExperience = HumanResourceConstant::$workExperience;
$jobOpeningStatus = HumanResourceConstant::$jobOpeningStatus;
$compatibility = HumanResourceConstant::$compatibility;
$jobType = HumanResourceConstant::$employeeType;
$educationDetail = $em->getRepository(EducationQualification::class)->findAll();
$jobRecruitments = $em->getRepository('ApplicationBundle:JobRecruitment')->find($id);
$em_goc = $this->getDoctrine()->getManager('company_group');
$applicantApplicationList = $em_goc->getRepository("CompanyGroupBundle:EntityApplicantApplicationList")->findBy(
array(
'jobPostId' => $id,
'CompanyId' => $companyId,
'appId' => $company_data->getAppId()
)
);
$applicantIdList = [];
foreach ($applicantApplicationList as $dt) {
$applicantIdList[] = $dt->getApplicantId();
}
$applicantList = ApplicantM::getApplicantList($em_goc, $applicantIdList);
$Approval_data = [
'exists' => 0,
'approvalId' => 0,
'roleType' => 0,
'required' => 0,
'acted' => 0,
'entity' => array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
'entityId' => $id,
];
if (in_array($request->getSession()->get(UserConstants::USER_TYPE), [1, 2, 5]))
$Approval_data = System::checkIfApprovalExists(
$em,
array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
$id,
$request->getSession()->get(UserConstants::USER_LOGIN_ID)
);
return $this->render('ApplicationBundle:pages/human_resource/views:view_job_recruitment.html.twig', [
'page_title' => 'View Job RecruitmentAction',
'jobRecruitments' => $jobRecruitments,
'applicantApplicationList' => $applicantApplicationList,
'applicantList' => $applicantList,
// 'encryptedData' => $encryptedData,
'skills' => json_decode($jobRecruitments->getskills()),
'skillDetails' => $skillDetails,
'education' => json_decode($jobRecruitments->getEducations()),
'educationDetails' => $educationDetail,
'location' => $location,
'salaryPer' => $salaryPer,
'workExperience' => $workExperience,
'jobType' => $jobType,
'compatibility' => $compatibility,
'approval_status' => $jobRecruitments->getApproved(),
'jobOpeningStatus' => $jobOpeningStatus,
'approval_data' => $Approval_data,
'auto_created' => $jobRecruitments->getAutocreated(),
'document_log' => $jobRecruitments->getAutocreated() == 0 ? System::getDocumentLog(
$em,
array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
$id,
$jobRecruitments->getCreatedLoginId(),
$jobRecruitments->getEditedLoginId()
) : []
]);
}
public function ViewApplicantScheduleAction(Request $request, $id = 0)
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($request);
$company_data = Company::getCompanyData($em, $companyId);
$em_goc = $this->getDoctrine()->getManager('company_group');
$applicantApplicationList = $em_goc->getRepository("CompanyGroupBundle:EntityApplicantApplicationList")->findBy(
array(
'jobPostId' => $id,
'CompanyId' => $companyId,
'appId' => $company_data->getAppId()
)
);
$applicantIdList = [];
foreach ($applicantApplicationList as $dt) {
$applicantIdList[] = $dt->getApplicantId();
}
$applicantList = ApplicantM::getApplicantList($em_goc, $applicantIdList);
return $this->render('ApplicationBundle:pages/human_resource/views:view_applicant_scheduled.html.twig', [
'page_title' => 'View Applicant Scheduled',
'applicantApplicationList' => $applicantApplicationList,
'applicantList' => $applicantList,
]);
}
public function ViewApplicantReportAction(Request $request, $id = 0)
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($request);
$company_data = Company::getCompanyData($em, $companyId);
$em_goc = $this->getDoctrine()->getManager('company_group');
$applicantApplicationList = $em_goc->getRepository("CompanyGroupBundle:EntityApplicantApplicationList")->findBy(
array(
'jobPostId' => $id,
'CompanyId' => $companyId,
'appId' => $company_data->getAppId()
)
);
$applicantIdList = [];
foreach ($applicantApplicationList as $dt) {
$applicantIdList[] = $dt->getApplicantId();
}
$applicantList = ApplicantM::getApplicantList($em_goc, $applicantIdList);
return $this->render('ApplicationBundle:pages/human_resource/views:view_applicant_report.html.twig', [
'page_title' => 'View Applicant Report',
'applicantApplicationList' => $applicantApplicationList,
'applicantList' => $applicantList,
]);
}
public function createEmployeePerformanceEvaluationAction(Request $request, $id = 0)
{
$data = [];
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($request);
if ($request->isMethod('POST')) {
$em = $this->getDoctrine()->getManager();
$entity_id = array_flip(GeneralConstant::$Entity_list)['EmployeePerformanceEvolution']; //change
$dochash = $request->request->get('docHash'); //change
$loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
$approveRole = $request->request->get('approvalRole');
$approveHash = $request->request->get('approvalHash');
if (!DocValidation::isInsertable($em, $entity_id, $dochash,
$loginId, $approveRole, $approveHash, $id)
) {
$this->addFlash(
'error',
'Sorry Could not insert Data.'
);
} else {
$data = $request->request;
$docId = HumanResource::createEmployeePerformanceEvaluation($em, $loginId, $id, $data, $companyId);
//now add Approval info
$approveRole = $request->request->get('approvalRole');
$options = array(
'notification_enabled' => $this->container->getParameter('notification_enabled'),
'notification_server' => $this->container->getParameter('notification_server'),
'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
'url' => $this->generateUrl(
GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['EmployeePerformanceEvolution']]
['entity_view_route_path_name']
)
);
System::setApprovalInfo($this->getDoctrine()->getManager(), $options,
array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
$docId,
$request->getSession()->get(UserConstants::USER_LOGIN_ID) //journal voucher
);
System::createEditSignatureHash($this->getDoctrine()->getManager(), array_flip(GeneralConstant::$Entity_list)['EmployeePerformanceEvolution'],
$docId,
$loginId,
$approveRole,
$request->request->get('approvalHash'));
$this->addFlash(
'success',
'New Recruitment Document Added.'
);
$url = $this->generateUrl(
'view_employee_performance_evolution'
);
return $this->redirect($url . "/" . $docId);
}
}
$skill = $em->getRepository(Skill::class)->findAll();
$educationDetail = $em->getRepository(EducationQualification::class)->findAll();
$employeeIds = $em->getRepository(EmployeeDetails::class)->findAll();
$employeeType = HumanResourceConstant::$employeeType;
$Designation = $em->getRepository(SysDepartmentPosition::class)->findAll();
$branch = $em->getRepository(Branch::class)->findAll();
$departments = $em->getRepository(SysDepartment::class)->findAll();
$department = [];
foreach ($departments as $entry) {
$department[$entry->getDepartmentId()] = array(
'id' => $entry->getDepartmentId(),
'name' => $entry->getDepartmentName(),
);
}
return $this->render('ApplicationBundle:pages/human_resource/input_forms:employee_performance_evolution.html.twig',
array(
'page_title' => 'Create Employee Performance Evaluation',
'employeeIds' => $employeeIds,
'employeeType' => $employeeType,
'Designation' => $Designation,
'branch' => $branch,
'department' => $department,
'skill' => $skill,
'educationDetail' => $educationDetail
)
);
}
public function ViewIndividualReviewAction()
{
return $this->render('ApplicationBundle:pages/human_resource/views:individual_review.html.twig',
array(
'page_title' => 'Individual Performance View',
)
);
}
public function EmployeeListBySkillPerformanceAction()
{
$em = $this->getDoctrine()->getManager();
$employee = $em->getRepository('ApplicationBundle:EmployeeDetails')->findAll();
$skill = $em->getRepository('ApplicationBundle:Skill')->findAll();
return $this->render('ApplicationBundle:pages/human_resource/list:employee_performance_evolution_list.html.twig',
array(
'page_title' => 'Employee Skill & Performance',
'employee' => $employee,
//'employeeSkill' => json_decode($employee->getSkill(),true),
'skill' => $skill,
)
);
}
public function setWorkPlaceAction(Request $req)
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($req);
// function getAddress($latitude, $longitude)
// {
// //google map api url
// $url = "http://maps.google.com/maps/api/geocode/json?latlng=$latitude,$longitude";
//
// // send http request
// $geocode = file_get_contents($url);
// $json = json_decode($geocode);
// $address = $json->results[0]->formatted_address;
// return $address;
// }
//
// $lat= 23.8623834; //latitude
// $lng= 90.3979294; //longitude
// $address= getAddress($lat,$lng);
// if($address)
// {
// echo $address;
// }
// else
// {
// echo "Not found";
// }
if ($req->request->has('XHRreq')) {
return new JsonResponse([HumanResource::HandelXHRreqForEmpWorkplace($em, $req)]);
}
if ($req->isMethod('GET')) {
$TwigData = HumanResource::TwigDataForEmployeeWorkplace($em);
return $this->render(
'ApplicationBundle:pages/human_resource/input_forms:set_workplace.html.twig',
[
'page_title' => 'Set Workplace',
'employeeIds' => $TwigData['employeeIds']
]
);
}
if ($req->isMethod('POST')) {
$approveHash = $req->request->get('approvalHash');
$loginId = $req->getSession()->get(UserConstants::USER_LOGIN_ID);
$isSignatureOk = DocValidation::isSignatureOk($em, $loginId, $approveHash);
if ($isSignatureOk) {
$isSuccess = HumanResource::CreateOrUpdateForEmpWorkplace($em, $req, $companyId);
if ($isSuccess) {
$this->addFlash(
'success',
'Workplace set!'
);
return $this->redirectToRoute('set_workplace');
}
} else {
$this->addFlash(
'error',
'Invalid Approval Hash!'
);
return $this->redirectToRoute('set_workplace');
}
}
}
public function ViewMeetingAction(Request $req, $action = 0, $id = 0)
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($req);
if ($req->request->has('XHRreq')) {
return new JsonResponse([HumanResource::HandelXHRreqForMeetingScheduling($em, $req)]);
}
if ($action === 'view') {
$response = HumanResource::TwigDataForScheduledMeetingView($em, $req, $id);
return $this->render(
'ApplicationBundle:pages/human_resource/views:scheduled_meeting_view.html.twig',
[
'page_title' => 'View Scheduled Meeting',
'duration' => $response['duration'],
'appId' => $response['appId'],
'publicView' => 0,
'meeting_data' => $response['meeting_data'],
'agenda_list' => $response['agenda_list'],
'id' => $req->query->get('view_meeting'),
'approval_data' => $response['approval_data'],
'document_log' => $response['document_log'],
'approval_status' => $response['approval_status'],
'created_by' => $response['created_by'],
'updated_at' => $response['updated_at'],
'auto_created' => 0,
]
);
}
if ($action === 'print') {
$response = HumanResource::TwigDataForScheduledMeetingView($em, $req, $id);
// $id = $req->query->get('print_meeting');
$em = $this->getDoctrine()->getManager();
$company_data = Company::getCompanyData($em, 1);
$Authorizations = System::getSignatureListForDocumentPrint($em, array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'], $id);
return $this->render(
'ApplicationBundle:pages/human_resource/print:scheduled_meeting_print.html.twig',
array(
'page_title' => 'View Scheduled Meeting',
'duration' => $response['duration'],
'meeting_data' => $response['meeting_data'],
'agenda_list' => $response['agenda_list'],
'export' => 'pdf,print',
'company_name' => $company_data->getName(),
'company_data' => $company_data,
'company_address' => $company_data->getAddress(),
'company_image' => $company_data->getImage(),
'Authorizations' => $Authorizations,
'red' => 0
)
);
}
}
public function UpdateMeetingMinutesAction(Request $req, $action = 0, $id = 0)
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($req);
$scheduleId = $req->request->get('scheduleId');
$minuteText = $req->request->get('minuteText');
$agendaKey = $req->request->get('key');
$scheduledMeeting = $em->getRepository(ScheduledMeeting::class)
->find($scheduleId);
$agendaList = json_decode($scheduledMeeting->getAgendaList(), true);
foreach ($agendaList as $key => $item) {
if ($key == $agendaKey)
$agendaList[$key]['minutes'] = $minuteText;
}
$scheduledMeeting->setAgendaList(json_encode($agendaList));
$em->flush();
return new JsonResponse(array(
'success' => true
));
}
public function SendMeetingUpdatesAction(Request $req, $action = 0, $id = 0)
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($req);
$session = $req->getSession();
$companyData = Company::getCompanyData($em, $companyId);
$scheduleId = $req->request->get('scheduleId');
$minuteText = $req->request->get('minuteText');
$agendaKey = $req->request->get('key');
$scheduledMeeting = $em->getRepository(ScheduledMeeting::class)
->find($scheduleId);
$sendEmailInvitationTo = json_decode($scheduledMeeting->getAllParticipantsNameEmail(), true);
if ($sendEmailInvitationTo == null)
$sendEmailInvitationTo = [];
$agendaList = json_decode($scheduledMeeting->getAgendaList(), true);
if ($agendaList == null)
$agendaList = [];
$EmployeeList = HumanResource::GetEmployeeList($em, []);
$meetingType = MeetingSchedulingConstant::$meetingType[$scheduledMeeting->getMeetingType()];
foreach ($sendEmailInvitationTo as $key => $email) {
$name = ucWords(str_replace("_", " ", $key));
$bodyHtml = '';
$bodyTemplate = 'ApplicationBundle:email/meeting_scheduling:scheduled_meeting_update.html.twig';
$bodyData = array(
'name' => $name,
'gocId' => $session->get(UserConstants::USER_GOC_ID),
'appId' => $session->get(UserConstants::USER_APP_ID),
'email' => $email,
'meetingData' => $scheduledMeeting,
'meeting_type' => $meetingType,
'agenda_list' => $agendaList,
'companyData' => $companyData,
'employeeList' => $EmployeeList,
);
$attachments = [];
$new_mail = $this->get('mail_module');
$new_mail->sendMyMail(array(
'senderHash' => '_MEETING_',
'forwardToMailAddress' => $email,
'subject' => "Meeting Updates Arranged By - " . $companyData->getName() . " on " . $scheduledMeeting->getTitle() . ". ",
'fileName' => '',
'attachments' => $attachments,
'toAddress' => $email,
'mailTemplate' => $bodyTemplate,
'templateData' => $bodyData,
'embedCompanyImage' => 1,
'companyId' => $companyId,
'companyImagePath' => $companyData->getImage()
));
}
return new JsonResponse(array(
'success' => true
));
}
public function meetingSchedulingAction(Request $req, $action = 0)
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($req);
$session = $req->getSession();
if ($req->request->has('XHRreq')) {
return new JsonResponse([HumanResource::HandelXHRreqForMeetingScheduling($em, $req)]);
}
if ($action === 'list') {
$response = HumanResource::TwigDataForScheduledMeetingList($em, [0, null]);
return $this->render(
'ApplicationBundle:pages/human_resource/list:scheduled_meeting_list.html.twig',
[
'page_title' => 'Scheduled Meeting List',
'list' => $response
]
);
}
if ($req->isMethod('GET')) {
$response = HumanResource::twigDataForMeetingScheduling($em);
return $this->render(
'ApplicationBundle:pages/human_resource/input_forms:meeting_scheduling.html.twig',
[
'page_title' => 'Schedule a Meeting',
'employeeIds' => $response['employeeIds'],
'branches' => $response['branches'],
'asset' => $response['asset'],
'rooms' => $response['rooms'],
'sales_orders' => $response['salesOrders'],
'purchase_orders' => $response['purchaseOrders'],
'meeting_types' => $response['meetingType'],
]
);
}
if ($req->isMethod('POST')) {
$approveHash = $req->request->get('approvalHash');
$approveRole = $req->request->get('approvalRole');
$loginId = $req->getSession()->get(UserConstants::USER_LOGIN_ID);
$isSignatureOk = DocValidation::isSignatureOk($em, $loginId, $approveHash);
$companyData = Company::getCompanyData($em, $companyId);
if ($isSignatureOk) {
$isSuccess = HumanResource::createOrUpdateDataForMeetingScheduling($em, $req);
if ($isSuccess) {
$options = array(
'notification_enabled' => $this->container->getParameter('notification_enabled'),
'notification_server' => $this->container->getParameter('notification_server'),
'appId' => $req->getSession()->get(UserConstants::USER_APP_ID),
'url' => $this->generateUrl(
GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting']]['entity_view_route_path_name']
)
);
$meetingId = $isSuccess[1];
System::setApprovalInfo(
$this->getDoctrine()->getManager(),
$options,
array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'],
$meetingId,
$req->getSession()->get(UserConstants::USER_LOGIN_ID),
0, //normal meeting
0,
$this->get('mail_module')
);
System::createEditSignatureHash(
$this->getDoctrine()->getManager(),
array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'],
$meetingId,
$loginId,
$approveRole,
$req->request->get('approvalHash')
);
$url = $this->generateUrl(
'view_scheduled_meeting'
);
return $this->redirect($url . "/" . $meetingId);
} else {
return new JsonResponse(array(
'success' => false
));
}
} else {
$this->addFlash(
'error',
'Invalid Approval Hash!'
);
return $this->redirectToRoute('meeting_scheduling');
}
}
return $this->redirectToRoute('meeting_scheduling');
}
public function CreateTrainingScheduleAction(Request $req, $action = 0)
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($req);
$session = $req->getSession();
if ($req->request->has('XHRreq')) {
return new JsonResponse([HumanResource::HandelXHRreqForMeetingScheduling($em, $req)]);
}
if ($action === 'list') {
$response = HumanResource::TwigDataForScheduledMeetingList($em, [1]);
return $this->render(
'ApplicationBundle:pages/human_resource/list:scheduled_meeting_list.html.twig',
[
'page_title' => 'Training Schedule List',
'list' => $response
]
);
}
if ($req->isMethod('GET')) {
}
if ($req->isMethod('POST')) {
$approveHash = $req->request->get('approvalHash');
$approveRole = $req->request->get('approvalRole');
$loginId = $req->getSession()->get(UserConstants::USER_LOGIN_ID);
$isSignatureOk = DocValidation::isSignatureOk($em, $loginId, $approveHash);
$companyData = Company::getCompanyData($em, $companyId);
if ($isSignatureOk) {
$isSuccess = HumanResource::createOrUpdateDataForMeetingScheduling($em, $req);
if ($isSuccess) {
$options = array(
'notification_enabled' => $this->container->getParameter('notification_enabled'),
'notification_server' => $this->container->getParameter('notification_server'),
'appId' => $req->getSession()->get(UserConstants::USER_APP_ID),
'url' => $this->generateUrl(
GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting']]['entity_view_route_path_name']
)
);
$meetingId = $isSuccess[1];
System::setApprovalInfo(
$this->getDoctrine()->getManager(),
$options,
array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'],
$meetingId,
$req->getSession()->get(UserConstants::USER_LOGIN_ID),
'',
0,
$this->get('mail_module')
);
System::createEditSignatureHash(
$this->getDoctrine()->getManager(),
array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'],
$meetingId,
$loginId,
$approveRole,
$req->request->get('approvalHash')
);
$url = $this->generateUrl(
'view_scheduled_meeting'
);
return $this->redirect($url . "/" . $meetingId);
} else {
return new JsonResponse(array(
'success' => false
));
}
} else {
$this->addFlash(
'error',
'Invalid Approval Hash!'
);
return $this->redirectToRoute('create_training_schedule');
}
}
$response = HumanResource::twigDataForTrainingScheduling($em);
return $this->render(
'ApplicationBundle:pages/human_resource/input_forms:create_training_schedule.html.twig',
[
'page_title' => 'Schedule a Training',
'employeeIds' => $response['employeeIds'],
'branches' => $response['branches'],
'asset' => $response['asset'],
'rooms' => $response['rooms'],
'courseList' => $response['courseList'],
'sales_orders' => $response['salesOrders'],
'purchase_orders' => $response['purchaseOrders'],
'meeting_types' => $response['meetingType'],
'skillList' => $response['skillList'],
]
);
}
public function ScheduledTrainingListAction(Request $req, $action = 0)
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($req);
$session = $req->getSession();
$response = HumanResource::TwigDataForScheduledMeetingList($em, [1]);
return $this->render(
'ApplicationBundle:pages/human_resource/list:scheduled_training_list.html.twig',
[
'page_title' => 'Scheduled Trainings ',
'list' => $response
]
);
}
public function ScheduledInterviewListAction(Request $req, $action = 0)
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($req);
$session = $req->getSession();
$response = HumanResource::TwigDataForScheduledMeetingList($em, [2]);
return $this->render(
'ApplicationBundle:pages/human_resource/list:scheduled_interview_list.html.twig',
[
'page_title' => 'Scheduled Interviews ',
'list' => $response
]
);
}
public function GetFilteredQuestionsAction(Request $request, $search = '')
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($request);
if ($search == '' || $search == '_EMPTY_')
$Query = "SELECT * FROM questionnaire WHERE 1 limit 10;";
else
$Query = "SELECT * FROM questionnaire WHERE question_text like '%$search%' limit 10;";
$stmt = $em->getConnection()->prepare($Query);
$stmt->execute();
$queryResult = $stmt->fetchAll();
$parent_head_ids = [];
$queryResultIndexed = [];
foreach ($queryResult as $dt) {
$queryResultIndexed[$dt['question_id']] = $dt;
}
return new JsonResponse(array(
'data' => $queryResult,
'queryResultIndexed' => $queryResultIndexed,
));
}
public function CreateTrainingCourseAction(Request $request, $id = 0)
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($request);
$skills = $em->getRepository('ApplicationBundle:Skill')->findAll();
$courses = $em->getRepository('ApplicationBundle:TrainingCourse')->findAll();
if ($request->isMethod('POST')) {
$loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
$skill = new TrainingCourse;
$skill->setTitle($request->request->get('name'));
$skill->setCourseHash($request->request->get('coursehash'));
$skill->setTrainingMaterialText($request->request->get('overview'));
$skill->setTaggedSkillHashes(json_encode($request->request->get('skill')));
$skill->setCompanyId($companyId);
//$skill->setEditFlag(1); //editable usually
$skill->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
//$skill->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
//$skill->setAutocreated(0);
$em->persist($skill);
$em->flush();
}
return $this->render(
'ApplicationBundle:pages/human_resource/input_forms:create_training_course.html.twig',
[
'page_title' => 'Create Training Course',
'skills' => $skills,
'courses' => $courses
]
);
}
public function CreateEmployeeExpenseAllowanceSettingsAction(Request $request, $id = 0)
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($request);
$extDocData = [];
$extDetailsData = [];
if ($request->isMethod('POST')) {
// Generic::debugMessage($_POST);
$em = $this->getDoctrine()->getManager();
$entity_id = array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings']; //change
$dochash = $request->request->get('docHash'); //change
$loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
$approveRole = $request->request->get('approvalRole');
$approveHash = $request->request->get('approvalHash');
if (!DocValidation::isInsertable(
$em,
$entity_id,
$dochash,
$loginId,
$approveRole,
$approveHash,
$id
)
) {
$this->addFlash(
'error',
'Sorry Could not insert Data.'
);
} else {
$funcname = 'EmployeeExpenseAllowanceSettings';
DeleteDocument::$funcname($em, $id, 0);
$docId = HumanResource::CreateSalarySegregationPolicy($em, $request, $companyId, 0);
//now add Approval info
$loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
$approveRole = $request->request->get('approvalRole');
$options = array(
'notification_enabled' => $this->container->getParameter('notification_enabled'),
'notification_server' => $this->container->getParameter('notification_server'),
'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
'url' => $this->generateUrl(
GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings']]['entity_view_route_path_name']
)
);
System::setApprovalInfo(
$this->getDoctrine()->getManager(),
$options,
array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings'],
$docId,
$request->getSession()->get(UserConstants::USER_LOGIN_ID)
);
System::createEditSignatureHash(
$this->getDoctrine()->getManager(),
array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings'],
$docId,
$loginId,
$approveRole,
$request->request->get('approvalHash')
);
$doc_here = $this->getDoctrine()
->getRepository('ApplicationBundle:EmployeeExpenseAllowanceSettings')
->findOneBy(
array(
'id' => $docId
)
);
//notify
$this->addFlash(
'success',
'Settings Successfully Updated.'
);
$url = $this->generateUrl(
GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings']]['entity_view_route_path_name']
);
System::AddNewNotification(
$this->container->getParameter('notification_enabled'),
$this->container->getParameter('notification_server'),
$request->getSession()->get(UserConstants::USER_APP_ID),
$request->getSession()->get(UserConstants::USER_COMPANY_ID),
"Salary Segregation Policy : " . $doc_here->getDocumentHash() . " Has Been Created And is Under Processing",
'pos',
System::getPositionIdsByDepartment($em, GeneralConstant::HRM_DEPARTMENT),
'success',
// $url . "/" . $TransID,
$url . "/" . $docId,
"Journal"
);
return $this->redirect($url . "/" . $docId);
}
}
//for edits
if ($id == 0) {
} else {
$extDocData = $em->getRepository('ApplicationBundle:EmployeeExpenseAllowanceSettings')->findOneBy(
array(
'id' => $id, ///material
)
);
//now if its not editable, redirect to view
if ($extDocData) {
if ($extDocData->getEditFlag() != 1) {
// $url = $this->generateUrl(
//// 'view_salary_segregation_policy'
// 'salary_segregation_policy'
// );
// return $this->redirect($url . "/" . $id);
} else {
// $extVoucherDetailsData = Accounts::GetVoucherDataForEdit($em, $voucherId);
// $extDetailsData = $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
// array(
// 'transactionId' => $id, ///material
//
// )
// );
}
} else {
}
}
$employeeIds = $em->getRepository("ApplicationBundle:Employee")->findAll();
$employeeType = HumanResourceConstant::$employeeType;
$employeeExpenseAllowanceTypes = HumanResourceConstant::$employeeExpenseAllowanceTypes;
$Designation = $em->getRepository("ApplicationBundle:SysDepartmentPosition")->findAll();
$branch = $em->getRepository("ApplicationBundle:Branch")->findAll();
$departments = $em->getRepository("ApplicationBundle:SysDepartment")->findAll();
$department = [];
foreach ($departments as $entry) {
$department[$entry->getDepartmentId()] = array(
'id' => $entry->getDepartmentId(),
'name' => $entry->getDepartmentName(),
);
}
return $this->render(
'ApplicationBundle:pages/human_resource/input_forms:create_employee_expense_allowance_settings.html.twig',
[
'page_title' => 'Employee Expense Allowance Settings',
'employeeIds' => $employeeIds,
'extId' => $id,
'extDocData' => $extDocData,
'employeeType' => $employeeType,
'employeeExpenseAllowanceTypes' => $employeeExpenseAllowanceTypes,
'Designation' => $Designation,
'branch' => $branch,
'department' => $department,
]
);
}
public function EmployeeExpenseAllowanceSettingsListAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$allowed_ids = [];
$companyId = $this->getLoggedUserCompanyId($request);
$listData = HumanResource::GetDataForEmployeeExpenseAllowanceSettingsListAction($em, $request->isMethod('POST') ? 'POST' : 'GET', $request->request, $companyId);
if ($request->isMethod('POST')) {
if ($request->query->has('dataTableQry')) {
return new JsonResponse(
$listData
);
}
}
return $this->render('ApplicationBundle:pages/human_resource/list:employee_expense_allowance_settings_list.html.twig',
// return $this->render('ApplicationBundle:pages/dashboard:test_pix_invent.html.twig',
array(
'page_title' => 'Expense Allowance Settings List',
// 'data' => SalesOrderM::GetClientList($em, [], $companyId),
// 'client_types' => Client::GetClientType($em, $companyId),
// 'region_list' => Client::RegionList($em, $companyId),
// 'geographical_region_list' => Client::GeographicalRegionList($em, $companyId)
)
);
}
public function salarySegAction(Request $request, $id = 0)
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($request);
$extDocData = [];
$extDetailsData = [];
if ($request->isMethod('POST')) {
// Generic::debugMessage($_POST);
$em = $this->getDoctrine()->getManager();
$entity_id = array_flip(GeneralConstant::$Entity_list)['SalarySegregationPolicy']; //change
$dochash = $request->request->get('docHash'); //change
$loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
$approveRole = $request->request->get('approvalRole');
$approveHash = $request->request->get('approvalHash');
if (!DocValidation::isInsertable(
$em,
$entity_id,
$dochash,
$loginId,
$approveRole,
$approveHash,
$id
)
) {
$this->addFlash(
'error',
'Sorry Couldnot insert Data.'
);
} else {
$funcname = 'SalarySegregationPolicy';
DeleteDocument::$funcname($em, $id, 0);
$docId = HumanResource::CreateSalarySegregationPolicy($em, $request, $companyId, 0);
//now add Approval info
$loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
$approveRole = $request->request->get('approvalRole');
$options = array(
'notification_enabled' => $this->container->getParameter('notification_enabled'),
'notification_server' => $this->container->getParameter('notification_server'),
'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
'url' => $this->generateUrl(
GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['SalarySegregationPolicy']]['entity_view_route_path_name']
)
);
System::setApprovalInfo(
$this->getDoctrine()->getManager(),
$options,
array_flip(GeneralConstant::$Entity_list)['SalarySegregationPolicy'],
$docId,
$request->getSession()->get(UserConstants::USER_LOGIN_ID),
3 //journal voucher
);
System::createEditSignatureHash(
$this->getDoctrine()->getManager(),
array_flip(GeneralConstant::$Entity_list)['SalarySegregationPolicy'],
$docId,
$loginId,
$approveRole,
$request->request->get('approvalHash')
);
$doc_here = $this->getDoctrine()
->getRepository('ApplicationBundle:SalarySegregationPolicy')
->findOneBy(
array(
'id' => $docId
)
);
//notify
$this->addFlash(
'success',
'Policy Successfully Updated.'
);
$url = $this->generateUrl(
'salary_segregation_policy'
);
System::AddNewNotification(
$this->container->getParameter('notification_enabled'),
$this->container->getParameter('notification_server'),
$request->getSession()->get(UserConstants::USER_APP_ID),
$request->getSession()->get(UserConstants::USER_COMPANY_ID),
"Salary Segregation Policy : " . $doc_here->getDocumentHash() . " Has Been Created And is Under Processing",
'pos',
System::getPositionIdsByDepartment($em, GeneralConstant::HRM_DEPARTMENT),
'success',
// $url . "/" . $TransID,
$url . "/" . $docId,
"Journal"
);
return $this->redirect($url . "/" . $docId);
}
}
//for edits
if ($id == 0) {
} else {
$extDocData = $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
array(
'id' => $id, ///material
)
);
//now if its not editable, redirect to view
if ($extDocData) {
if ($extDocData->getEditFlag() != 1) {
// $url = $this->generateUrl(
//// 'view_salary_segregation_policy'
// 'salary_segregation_policy'
// );
// return $this->redirect($url . "/" . $id);
} else {
// $extVoucherDetailsData = Accounts::GetVoucherDataForEdit($em, $voucherId);
// $extDetailsData = $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
// array(
// 'transactionId' => $id, ///material
//
// )
// );
}
} else {
}
}
$employeeIds = $em->getRepository(EmployeeDetails::class)->findAll();
$employeeType = HumanResourceConstant::$employeeType;
$Designation = $em->getRepository(SysDepartmentPosition::class)->findAll();
$branch = $em->getRepository(Branch::class)->findAll();
$departments = $em->getRepository(SysDepartment::class)->findAll();
$department = [];
foreach ($departments as $entry) {
$department[$entry->getDepartmentId()] = array(
'id' => $entry->getDepartmentId(),
'name' => $entry->getDepartmentName(),
);
}
return $this->render(
'ApplicationBundle:pages/human_resource/input_forms:salary_segregation_policy.html.twig',
[
'page_title' => 'Salary Segregation Policy',
'employeeIds' => $employeeIds,
'extId' => $id,
'extDocData' => $extDocData,
'employeeType' => $employeeType,
'Designation' => $Designation,
'branch' => $branch,
'department' => $department,
]
);
}
public function GetSalarySegregationDataForEmployeeEntryAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($request);
if ($request->request->has('salSagDataReq')) {
$ajaxData = HumanResource::handelXhrForSalSeg($em, $request);
return new JsonResponse($ajaxData);
}
return new JsonResponse(array('success' => false));
}
public function WorkHourPolicyAction(Request $req, $id = 0)
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($req);
$extData = [];
if ($id != 0) {
$extData = $em->getRepository('ApplicationBundle:WorkHourPolicy')
->findOneBy(
array(
'id' => $id
)
);
}
if ($req->isMethod('POST')) {
$storeDataRes = HumanResource::checkSignature($em, $req);
if ($storeDataRes['hasErr']) {
$msg = $storeDataRes['msg'];
$this->addFlash(
'error',
$msg
);
return $this->redirectToRoute('work_hour_policy');
} else {
HumanResource::storeDataForWhPolicy($em, $req, $companyId);
$this->addFlash(
'success',
'Policy Successfully Created!'
);
return $this->redirectToRoute('work_hour_policy');
}
}
$twigData = HumanResource::twigDataForWorkHourPolicy($em);
$timeZonesArray = array();
return $this->render(
'ApplicationBundle:pages/human_resource/input_forms:work_hour_policy.html.twig',
[
'page_title' => 'Work Hour Policy',
'extId' => $id,
'extData' => $extData,
'employeeIds' => $twigData['employeeIds'],
'employeeType' => $twigData['employeeType'],
'Designation' => $twigData['Designation'],
'branch' => $twigData['branch'],
'department' => $twigData['department'],
]
);
}
public function WorkHourPolicyListAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$allowed_ids = [];
$companyId = $this->getLoggedUserCompanyId($request);
$listData = HumanResource::GetDataForWorkHourPolicyListAction($em, $request->isMethod('POST') ? 'POST' : 'GET', $request->request, $companyId);
if ($request->isMethod('POST')) {
if ($request->query->has('dataTableQry')) {
return new JsonResponse(
$listData
);
}
}
return $this->render('ApplicationBundle:pages/human_resource/list:work_hour_policy_list.html.twig',
// return $this->render('ApplicationBundle:pages/dashboard:test_pix_invent.html.twig',
array(
'page_title' => 'Work Hour Policy List',
// 'data' => SalesOrderM::GetClientList($em, [], $companyId),
// 'client_types' => Client::GetClientType($em, $companyId),
// 'region_list' => Client::RegionList($em, $companyId),
// 'geographical_region_list' => Client::GeographicalRegionList($em, $companyId)
)
);
}
public function WorkPlacePolicyListAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$workplacePolicyDetails = $em->getRepository('ApplicationBundle:EmployeeWorkplace')->findAll();
// $employee = $em->getRepository('ApplicationBundle:Employee')->findAll();
return $this->render('ApplicationBundle:pages/human_resource/list:work_place_policy_list.html.twig', array(
'page_title' => 'Work Place Policy List',
'workplacePolicyDetails' => $workplacePolicyDetails,
// 'employee'=>$employee
));
}
public function workPlacePolicyAction(Request $data, $id)
{
$em = $this->getDoctrine()->getManager();
$workPlacePolicy = $em->getRepository('ApplicationBundle:EmployeeWorkplace')->find($id);
$employee = $em->getRepository(Employee::class)->findAll();
$Approval_data = System::checkIfApprovalExists(
$em,
array_flip(GeneralConstant::$Entity_list)['EmployeeWorkplace'],
$id,
$data->getSession()->get(UserConstants::USER_LOGIN_ID)
);
$ApprovalStatus = GeneralConstant::$approvalStatus;
return $this->render('ApplicationBundle:pages/human_resource/views:viewWorkPlacePolicy.html.twig', array(
'page_title' => 'Work Place Policy View',
'workPlacePolicy' => $workPlacePolicy,
'employee' => $employee,
'approval_data' => $Approval_data,
'approval_status' => $workPlacePolicy->getApproved(),
'id' => $id,
));
}
public function SalarySegregationPolicyListAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$allowed_ids = [];
$companyId = $this->getLoggedUserCompanyId($request);
$listData = HumanResource::GetDataForSalarySegregationPolicyListAction($em, $request->isMethod('POST') ? 'POST' : 'GET', $request->request, $companyId);
if ($request->isMethod('POST')) {
if ($request->query->has('dataTableQry')) {
return new JsonResponse(
$listData
);
}
}
return $this->render('ApplicationBundle:pages/human_resource/list:salary_segregation_policy_list.html.twig',
// return $this->render('ApplicationBundle:pages/dashboard:test_pix_invent.html.twig',
array(
'page_title' => 'Salary Segregation Policy List',
// 'data' => SalesOrderM::GetClientList($em, [], $companyId),
// 'client_types' => Client::GetClientType($em, $companyId),
// 'region_list' => Client::RegionList($em, $companyId),
// 'geographical_region_list' => Client::GeographicalRegionList($em, $companyId)
)
);
}
public function HolidayCalendarListAction(Request $request)
{
$q = $this->getDoctrine()
->getRepository('ApplicationBundle:HolidayCalendar')
->findBy(
array(
// 'status' => GeneralConstant::ACTIVE,
'CompanyId' => $this->getLoggedUserCompanyId($request)
// 'approved' => GeneralConstant::APPROVED,
)
);
$stage_list = array(
0 => 'Pending',
1 => 'Pending',
2 => 'Complete',
4 => 'Partial',
);
$data = [];
foreach ($q as $entry) {
$data[] = array(
// 'doc_date' => $entry->getSalesReplacementDate(),
'id' => $entry->getHolidayCalendarId(),
'title' => $entry->getHoliDayTitle(),
'approval_status' => GeneralConstant::$approvalStatus[$entry->getApproved()],
// 'stage' => $stage_list[$entry->getStage()]
);
}
return $this->render('ApplicationBundle:pages/human_resource/list:holiday_calendar_list.html.twig',
array(
'page_title' => 'Holiday Calendar List',
'data' => $data
)
);
}
public function PayrollPolicyListAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$allowed_ids = [];
$companyId = $this->getLoggedUserCompanyId($request);
$listData = HumanResource::GetDataForPayrollPolicyListAction($em, $request->isMethod('POST') ? 'POST' : 'GET', $request->request, $companyId);
if ($request->isMethod('POST')) {
if ($request->query->has('dataTableQry')) {
return new JsonResponse(
$listData
);
}
}
return $this->render('ApplicationBundle:pages/human_resource/list:payroll_policy_list.html.twig',
// return $this->render('ApplicationBundle:pages/dashboard:test_pix_invent.html.twig',
array(
'page_title' => 'Payroll Policy List',
// 'data' => SalesOrderM::GetClientList($em, [], $companyId),
// 'client_types' => Client::GetClientType($em, $companyId),
// 'region_list' => Client::RegionList($em, $companyId),
// 'geographical_region_list' => Client::GeographicalRegionList($em, $companyId)
)
);
}
public function payslipAction(Request $req, $action = 0, $id = 0)
{
$em = $this->getDoctrine()->getManager();
$attendanceSource = HumanResourceConstant::$attendanceSources;
if ($action === 'list') {
$response = HumanResource::twigDataForPayslipList($em);
$approval_status = GeneralConstant::$approvalAction;
return $this->render(
'ApplicationBundle:pages/human_resource/list:payslip_list.html.twig',
[
'page_title' => 'Payslip List',
'reports' => $response,
'approval_status' => $approval_status
]
);
}
if ($action === 'view') {
$response = HumanResource::twigDataForPayslipViewAndPrint($em, $req, $id);
return $this->render(
'ApplicationBundle:pages/human_resource/views:payslip_view.html.twig',
[
'page_title' => 'View Payslip',
'approval_data' => $response['approval_data'],
'payslip' => $response['payslip'],
'document_log' => $response['document_log'],
'approval_status' => $response['approval_status'],
'created_by' => $response['created_by'],
'updated_at' => $response['updated_at'],
'employeeId' => $response['employeeId'],
'totalAttendance' => $response['totalPresent'],
'leaveList' => HumanResourceConstant::$LeaveType,
'AttReportData' => $response['AttReportData'],
// 'attendanceLog' => $response['attendanceLog'],
'attendanceSource' => $attendanceSource,
'auto_created' => 0,
]
);
}
if ($action === 'print') {
$em = $this->getDoctrine()->getManager();
$company_data = Company::getCompanyData($em, 1);
$Authorizations = System::getSignatureListForDocumentPrint($em, array_flip(GeneralConstant::$Entity_list)['Payslip'], $id);
$response = HumanResource::twigDataForPayslipViewAndPrint($em, $req, $id);
return $this->render(
'ApplicationBundle:pages/human_resource/print:payslip_print.html.twig',
array(
'page_title' => 'Print Payslip',
'export' => 'pdf,print',
'payslip' => $response['payslip'],
'company_name' => $company_data->getName(),
'company_data' => $company_data,
'company_address' => $company_data->getAddress(),
'company_image' => $company_data->getImage(),
'Authorizations' => $Authorizations,
'totalAttendance' => $response['totalPresent'],
'leaveList' => HumanResourceConstant::$LeaveType,
'AttReportData' => $response['AttReportData'],
'attendanceSource' => $attendanceSource,
'red' => 0
)
);
}
if ($req->isMethod('POST')) {
$sigRes = HumanResource::checkSignature($em, $req);
if ($sigRes['hasErr']) {
$msg = $sigRes['msg'];
return new JsonResponse(['success' => false, 'msg' => $msg]);
}
HumanResource::storeDataForPayslip($em, $req);
return new JsonResponse(['success' => true]);
}
}
public function applicantInfoAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager('company_group');
$session = $request->getSession();
$consultantDetails = $em->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
$skillDetails = $em->getRepository(EntitySkill::class)->findAll();
$companyId = $this->getLoggedUserCompanyId($request);
$gender = HumanResourceConstant::$sex;
$blood = HumanResourceConstant::$BloodGroup;
$userId = $session->get(UserConstants::USER_ID);
$encData = $request->query->has('ref') ? $request->query->get('ref') : '';
$education = array(
'instituteName' => $request->get('instituteName'),
'courseOfStudy' => $request->get('courseOfStudy'),
'courseStartDate' => $request->get('courseStartDate'),
'courseEndDate' => $request->get('courseEndDate'),
'result' => $request->get('result'),
'grade' => $request->get('grade'),
'degree' => $request->get('degree'),
);
$workExperience = array(
'title' => $request->get('title'),
'companyName' => $request->get('companyName'),
'jobStartDate' => $request->get('jobStartDate'),
'jobEndDate' => $request->get('jobEndDate'),
'description' => $request->get('description'),
);
$certificate = array(
'certificatename' => $request->get('certificatename'),
'issuedDate' => $request->get('issuedDate'),
);
$courses = array(
'courseName' => $request->get('courseName'),
'date' => $request->get('date'),
'duration' => $request->get('duration')
);
$languages = array(
'languageName' => $request->get('languageName'),
'writtenSkill' => $request->get('writtenSkill'),
'verbalSkill' => $request->get('verbalSkill'),
);
if ($request->isMethod('POST')) {
if ($consultantDetails)
$consultant = $consultantDetails;
else
$consultant = new EntityApplicantDetails();
$consultant->setApplicationText($request->request->get('applicationText'));
$consultant->setFirstname($request->request->get('firstname'));
$consultant->setLastname($request->request->get('lastname'));
$consultant->setIsImgLegal($request->request->get('is_img_legal'));
$consultant->setNid($request->request->get('nid'));
$consultant->setDob(new \DateTime($request->get('dob')));
$consultant->setSex($request->request->get('sex'));
$consultant->setFather($request->request->get('father'));
$consultant->setMother($request->request->get('mother'));
$consultant->setBlood($request->request->get('blood'));
$consultant->setPhone($request->request->get('phone'));
$consultant->setCountry($request->request->get('country'));
$consultant->setPostalCode($request->request->get('postalCode'));
$consultant->setCurrAddr($request->request->get('curr_addr'));
$consultant->setSkill(json_encode($request->request->get('skill')));
$consultant->setEmergencyContactNumber($request->request->get('emm_contact'));
$consultant->setCurrentEmployment($request->request->get('currentEmployment'));
$consultant->setTin($request->request->get('tin'));
$consultant->setEducationData(json_encode($education));
$consultant->setWorkExperienceData(json_encode($workExperience));
$consultant->setCertificateData(json_encode($certificate));
$consultant->setCoursesData(json_encode($courses));
$consultant->setLanguagesData(json_encode($languages));
$consultant->setWorkExperienceYear($request->request->get('workExperienceYear'));
//$consultant->setApplyForConsultant(1);
$em->persist($consultant);
$em->flush();
$path = "";
$defaultProductImage = '';
$uploadedFile = null;
$upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/applicantCv/';
$uploadedFile = $request->files->get('docUpload');
if ($uploadedFile != null) {
$fileName = 'cv' . $consultantDetails->getApplicantId() . '.' . $uploadedFile->guessExtension();
$path = $fileName;
// $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
if (!file_exists($upl_dir)) {
mkdir($upl_dir, 0777, true);
}
$uploadedFile->move($upl_dir, $path);
$defaultProductImage = 'uploads/applicantCv/' . $path;
$consultant->setDocImage($defaultProductImage);
$em->flush();
}
$this->addFlash(
'success',
'Data Updated.'
);
if ($encData != '') {
$url = $this->generateUrl(
'applicant_job_recruitment_view'
);
return $this->redirect($url . '?auto_apply=1&encData=' . $encData);
}
$url = $this->generateUrl(
'job_recruitment_list_applicant'
);
return $this->redirect($url);
}
return $this->render('ApplicationBundle:pages/human_resource/input_forms:applicant_info.html.twig', array(
'page_title' => 'My Information ',
'gender' => $gender,
'blood' => $blood,
'consultantDetails' => $consultantDetails,
'education' => json_decode($consultantDetails->getEducationData(), true),
'workExperience' => json_decode($consultantDetails->getWorkExperienceData(), true),
'certificate' => json_decode($consultantDetails->getCertificateData(), true),
'courses' => json_decode($consultantDetails->getCoursesData(), true),
'languages' => json_decode($consultantDetails->getLanguagesData(), true),
'skill' => json_decode($consultantDetails->getSkill(), true),
'skillDetails' => $skillDetails
));
// $em = $this->getDoctrine()->getManager('company_group');
// $applicantRepo = $em->getRepository(EntityApplicantDetails::class);
// $skillDetails = $em->getRepository(EntitySkill::class)->findAll();
//
//
// if ($req->isMethod('POST')) {
// $applicant = $applicantRepo->find($id);
//
// if ($req->files->get('img')) {
// $ImgName = HumanResource::StoreFiles($req->files->get('img'), 'Applicant');
// $applicant->setImage($ImgName);
// }
//
// $applicant->setFirstname($req->request->get('firstname'));
// $applicant->setLastname($req->request->get('lastname'));
// $applicant->setIsImgLegal($req->request->get('is_img_legal'));
// $applicant->setNid($req->request->get('nid'));
// $applicant->setDob(HumanResource::StringToDate($req->request->get('dob')));
// $applicant->setSex($req->request->get('sex'));
// $applicant->setFather($req->request->get('father'));
// $applicant->setMother($req->request->get('mother'));
// $applicant->setSpouse($req->request->get('spouse'));
// $applicant->setChild1($req->request->get('child_1'));
// $applicant->setChild2($req->request->get('child_2'));
// $applicant->setBlood($req->request->get('blood'));
// $applicant->setPhone($req->request->get('phone'));
// $applicant->setOAuthEmail($req->request->get('oauth_email'));
// $applicant->setCurrAddr($req->request->get('curr_addr'));
// $applicant->setPermAddr($req->request->get('perm_addr'));
// $applicant->setEmmContact($req->request->get('emm_contact'));
//
// $applicant->setInst1($req->request->get('inst1'));
// $applicant->setYr1($req->request->get('yr1'));
// $applicant->setDur1($req->request->get('dur1'));
// $applicant->setInst2($req->request->get('inst2'));
// $applicant->setYr2($req->request->get('yr2'));
// $applicant->setDur2($req->request->get('dur2'));
// $applicant->setInst3($req->request->get('inst3'));
// $applicant->setYr3($req->request->get('yr3'));
// $applicant->setDur3($req->request->get('dur3'));
// $applicant->setEinst1($req->request->get('einst1'));
// $applicant->setEyr1($req->request->get('eyr1'));
// $applicant->setEdeg1($req->request->get('edeg1'));
// $applicant->setEinst2($req->request->get('einst2'));
// $applicant->setEyr2($req->request->get('eyr2'));
// $applicant->setEdeg2($req->request->get('edeg2'));
// $applicant->setEinst3($req->request->get('einst3'));
// $applicant->setEyr3($req->request->get('eyr3'));
// $applicant->setEdeg3($req->request->get('edeg3'));
//
// $em->persist($applicant);
// $em->flush();
//
// return $this->render(
// 'ApplicationBundle:pages/human_resource/input_forms:applicant_info.html.twig',
// [
// 'page_title' => 'Applicant Info',
// 'applicant_info' => $applicant,
// 'blood' => HumanResourceConstant::$BloodGroup,
// 'gender' => HumanResourceConstant::$sex,
// 'skillDetails' => $skillDetails,
// 'HasUpdateMode' => true,
// ]
// );
// }
//
// if ($id) {
// $applicant = $applicantRepo->find($id);
//
// return $this->render(
// 'ApplicationBundle:pages/human_resource/input_forms:applicant_info.html.twig',
// [
// 'page_title' => 'Applicant Info',
// 'applicant_info' => $applicant,
// 'blood' => HumanResourceConstant::$BloodGroup,
// 'gender' => HumanResourceConstant::$sex,
// 'skillDetails' => $skillDetails,
// 'HasUpdateMode' => false,
// ]
// );
// }
//
// $google_client = new Google_Client();
// $google_client->setClientId('916737688016-l2qfmb9p37cumudkaqpu8s7ndngq9una.apps.googleusercontent.com');
// $google_client->setClientSecret('BEWpEBRvv3-hSoB4cGBrVB3z');
// $google_client->setRedirectUri('http://localhost/applicant_info');
// $google_client->addScope('email');
// $google_client->addScope('profile');
}
public function applicantDashboardAction()
{
return new JsonResponse(['this is applicant dashboard']);
}
public function resignApplicationAction(Request $req, $id)
{
$em = $this->getDoctrine()->getManager();
if ($req->request->has('xhrReq')) {
$response = HumanResource::HandelXhrForResignApplication($em, $req);
return new JsonResponse($response);
}
if ($req->isMethod('GET')) {
$applicant = $em->getRepository(EmployeeDetails::class)->findBy(['emp_status' => 1]);
$resignReason = HumanResourceConstant::$resignReason;
return $this->render(
'ApplicationBundle:pages/human_resource/input_forms:resign_application.html.twig',
[
'page_title' => 'Resign Application',
'employeeIds' => $applicant,
'resignReasons' => $resignReason,
'HasUpdateMode' => false,
]
);
}
if ($req->isMethod('POST')) {
$approveHash = $req->request->get('approvalHash');
$loginId = $req->getSession()->get(UserConstants::USER_LOGIN_ID);
$isSignatureOk = DocValidation::isSignatureOk($em, $loginId, $approveHash);
if ($isSignatureOk) {
$response = HumanResource::storeResignApplicationData($em, $req);
if ($response) {
return $this->redirectToRoute(
'view_resign_application',
array('id' => $response->getResignApplicationId()),
Response::HTTP_MOVED_PERMANENTLY
);
}
} else {
$this->addFlash(
'error',
'Invalid Approval Hash!'
);
return $this->redirectToRoute('resign_application');
}
}
}
public function viewResignApplicationAction(Request $req, $id = 0)
{
$em = $this->getDoctrine()->getManager();
$response = HumanResource::twigDataForResignApplicationView($em, $req, $id);
return $this->render(
'ApplicationBundle:pages/human_resource/views:resign_application_view.html.twig',
[
'page_title' => 'View Resign Application',
'approval_data' => $response['approval_data'],
'application' => $response['application'],
'applicant' => $response['applicant'],
'document_log' => $response['document_log'],
'approval_status' => $response['approval_status'],
'created_by' => $response['created_by'],
'updated_at' => $response['updated_at'],
'auto_created' => 0,
]
);
}
public function printResignApplicationAction(Request $req, $id)
{
if ($id) {
$em = $this->getDoctrine()->getManager();
$company_data = Company::getCompanyData($em, 1);
$authorizations = System::getSignatureListForDocumentPrint($em, array_flip(GeneralConstant::$Entity_list)['ResignApplication'], $id);
$response = HumanResource::twigDataForResignApplicationView($em, $req, $id);
return $this->render(
'ApplicationBundle:pages/human_resource/print:resign_application_print.html.twig',
array(
'page_title' => 'Print Resign Application',
'export' => 'pdf,print',
'company_name' => $company_data->getName(),
'company_data' => $company_data,
'company_address' => $company_data->getAddress(),
'company_image' => $company_data->getImage(),
'application' => $response['application'],
'applicant' => $response['applicant'],
'Authorizations' => $authorizations,
'red' => 0
)
);
}
return new JsonResponse(array(
'success' => false,
'msg' => 'Wrong URL format! Please try with application ID'
));
}
public function listResignApplicationAction(Request $req)
{
$em = $this->getDoctrine()->getManager();
$response = HumanResource::getResignApplicationList($em, $req);
return $this->render("ApplicationBundle:pages/human_resource/list:resign_application_list.html.twig", array(
'page_title' => 'Leave Application List',
'applications' => $response,
));
}
public function viewNocApprovalAction(Request $req, $id)
{
$em = $this->getDoctrine()->getManager();
$response = HumanResource::twigDataForNocView($em, $req, $id);
return $this->render(
'ApplicationBundle:pages/human_resource/views:noc_view.html.twig',
[
'page_title' => 'View NOC',
'approval_data' => $response['approval_data'],
'noc_application' => $response['noc_application'],
'resign_application' => $response['resign_application'],
'applicant' => $response['applicant'],
'document_log' => $response['document_log'],
'approval_status' => $response['approval_status'],
'created_by' => $response['created_by'],
'updated_at' => $response['updated_at'],
'auto_created' => 0,
]
);
}
public function printNocApprovalAction(Request $req, $id)
{
$em = $this->getDoctrine()->getManager();
$company_data = Company::getCompanyData($em, 1);
$Authorizations = System::getSignatureListForDocumentPrint($em, array_flip(GeneralConstant::$Entity_list)['NocApproval'], $id);
$response = HumanResource::twigDataForNocView($em, $req, $id);
return $this->render(
'ApplicationBundle:pages/human_resource/print:noc_print.html.twig',
[
'page_title' => 'Print NOC',
'noc_application' => $response['noc_application'],
'resign_application' => $response['resign_application'],
'applicant' => $response['applicant'],
'export' => 'pdf,print',
'company_name' => $company_data->getName(),
'company_data' => $company_data,
'company_address' => $company_data->getAddress(),
'company_image' => $company_data->getImage(),
'Authorizations' => $Authorizations,
'red' => 0
]
);
}
public function createHolidayAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($request);
if ($request->isMethod('POST')) {
$entity_id = array_flip(GeneralConstant::$Entity_list)['HolidayCalendar']; //change
$dochash = $request->request->get('doc_hash'); //change
$loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
$approveRole = $request->request->get('approvalRole');
$approveHash = $request->request->get('approvalHash');
if (!DocValidation::isInsertable(
$em,
$entity_id,
$dochash,
$loginId,
$approveRole,
$approveHash,
$id
)
) {
$this->addFlash(
'error',
'Sorry Couldnot insert Data.'
);
} else {
$funcname = 'HolidayCalendar';
$doc_id = $id;
DeleteDocument::$funcname($em, $doc_id, 0);
if ($id != 0)
$HolidayCalender = $em->getRepository(HolidayCalendar::class)->find($id);
else
$HolidayCalender = new HolidayCalendar;
$HolidayCalender->setDocumentHash($request->request->get('doc_hash'));
$HolidayCalender->setHoliDayTitle($request->request->get('holidayCalendarTitle'));
$HolidayCalender->setEmployeeIds(json_encode($request->request->get('employee')));
$HolidayCalender->setEmployeeTypeIds(json_encode($request->request->get('emp_status')));
$HolidayCalender->setDesignationIds(json_encode($request->request->get('desg', [])));
$HolidayCalender->setDepartmentIds(json_encode($request->request->get('dept', [])));
$HolidayCalender->setBranchIds(json_encode($request->request->get('branch', [])));
$HolidayCalender->setLevelSelectionStr($request->get('levelSelectionStr', ''));
$HolidayCalender->setLevels(json_encode(HumanResource::getLevelsFromLevelSelectionStr($request->get('levelSelectionStr', ''))));
$HolidayCalender->setCompanyId($companyId);
$HolidayCalender->setTypeHash('HD');
$HolidayCalender->setEditFlag(1); //editable usually
$HolidayCalender->setPrefixHash($request->request->get('prefix'));
$HolidayCalender->setAssocHash($request->request->get('assoc'));
$HolidayCalender->setNumberHash($request->request->get('number_hash'));
$HolidayCalender->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
$HolidayCalender->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
$HolidayCalender->setAutocreated(0);
//
// $arr = [
// 'date' =>$request->request->get('start_date'),
// 'title' => $request->request->get('title'),
// ];
//
// $HolidayCalender->setData(json_encode($arr));
$em->persist($HolidayCalender);
$em->flush();
$indHolidays = [];
if ($request->request->has('start_date'))
$indHolidays = $request->request->get('start_date');
foreach ($indHolidays as $ind => $dateRangeStr) {
$currRow = $request->request->get('row')[$ind];//string
$holidayTitle = $request->request->get('title')[$ind];//string
$currStartDate = $request->request->get('start_date')[$ind];//string
$currEndDate = $request->request->get('end_date')[$ind];//string
$HolidayDate = new HolidayCalendarDates();
$HolidayDate->setHolidayCalendarId($HolidayCalender->getHolidayCalendarId());
$HolidayDate->setDateRange($currStartDate . '-' . $currEndDate);//string
$HolidayDate->setStartDate(new \DateTime($currStartDate));//date
$HolidayDate->setEndDate(new \DateTime($currEndDate . ' 23:59:59'));//date
$HolidayDate->setHolidayTitle($holidayTitle);
// $HolidayDate->setIsVariableEachYearFlag($request->request->get('is_variable_each_year',null));
$HolidayDate->setIsVariableEachYearFlag($request->request->get('is_variable_each_year_' . $currRow, null));
$HolidayDate->setAllDayFlag($request->request->get('all_day_flag_' . $currRow, 1));
$em->persist($HolidayDate);
$em->flush();
}
$options = [];
$entity = array_flip(GeneralConstant::$Entity_list)['HolidayCalendar'];
$loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
$approveRole = $request->request->get('approvalRole');
System::setApprovalInfo(
$em,
$options,
$entity,
$HolidayCalender->getHolidayCalendarId(),
$request->getSession()->get(UserConstants::USER_LOGIN_ID)
);
System::createEditSignatureHash(
$em,
$entity,
$HolidayCalender->getHolidayCalendarId(),
$loginId,
$approveRole,
$request->request->get('approvalHash')
);
$url = $this->generateUrl(
'view_holiday_calendar'
);
return $this->redirect($url . "/" . $HolidayCalender->getHolidayCalendarId());
}
}
$em = $this->getDoctrine()->getManager();
$branches = $em->getRepository(Branch::class)->findAll();
$employee = $em->getRepository(Employee::class)->findAll();
$departments = $em->getRepository(SysDepartment::class)->findAll();
$departmentPositions = $em->getRepository(SysDepartmentPosition::class)->findAll();
$EmploymentStatus = HumanResourceConstant::$employeeType;
$em = $this->getDoctrine()->getManager();
$extDocData = [];
if ($id != 0)
$extDocData = $em->getRepository(HolidayCalendar::class)->find($id);
return $this->render(
'ApplicationBundle:pages/human_resource/input_forms:create_holiday.html.twig',
[
'page_title' => 'Create Holiday',
'branches' => $branches,
'id' => $id,
'extDocData' => $extDocData,
'departments' => $departments,
'departmentPositions' => $departmentPositions,
'employeeStatus' => $EmploymentStatus,
'employeeIds' => $employee,
'holidayCalendarList' => $em->getRepository('ApplicationBundle:HolidayCalendar')
->findBy(array())
]
);
}
public function HolidayViewAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$HolidaysCalendar = $em->getRepository(HolidayCalendar::class)->find($id);
$holidayCalendarDetails = $em->getRepository('ApplicationBundle:HolidayCalendarDates')
->findBy(array(
'holidayCalendarId' => $id
));
$Approval_data = System::checkIfApprovalExists(
$em,
array_flip(GeneralConstant::$Entity_list)['HolidayCalendar'],
$id,
$request->getSession()->get(UserConstants::USER_LOGIN_ID)
);
return $this->render('ApplicationBundle:pages/human_resource/views:holidays_view.html.twig', array(
'page_title' => 'View Holiday',
'holidays' => $HolidaysCalendar,
'holidayCalendarDetails' => $holidayCalendarDetails,
'approval_status' => $HolidaysCalendar->getApproved(),
'approval_data' => $Approval_data,
'auto_created' => $HolidaysCalendar->getAutocreated(),
'document_log' => $HolidaysCalendar->getAutocreated() == 0 ? System::getDocumentLog(
$this->getDoctrine()->getManager(),
array_flip(GeneralConstant::$Entity_list)['HolidayCalendar'],
$id,
$HolidaysCalendar->getCreatedLoginId(),
$HolidaysCalendar->getEditedLoginId()
) : []
));
}
public function GetHolidayDetailsAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$holidayCalendar = $em->getRepository('ApplicationBundle:HolidayCalendar')
->findOneBy(array(
'holidayCalendarId' => $id
));
$holidayCalendarDetails = $em->getRepository('ApplicationBundle:HolidayCalendarDates')
->findBy(array(
'holidayCalendarId' => $id
));
$holidayList = [];
foreach ($holidayCalendarDetails as $det) {
$dateDet = array(
'title' => $det->getHolidayTitle(),
'startDate' => $det->getStartDate()->format('Y-m-d'),
'endDate' => $det->getEndDate()->format('Y-m-d'),
);
$holidayList[] = $dateDet;
}
return new JsonResponse(
array(
'success' => true,
'holidayList' => $holidayList
)
);
}
public function GetHolidayListByEmployeeIdAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$options = [];
$options['employeeId'] = $id;
HumanResource::getFilteredHolidaysSingle($em, $options);
$holidayCalendar = $em->getRepository('ApplicationBundle:HolidayCalendar')
->findOneBy(array(
'holidayCalendarId' => $id
));
$holidayCalendarDetails = $em->getRepository('ApplicationBundle:HolidayCalendarDates')
->findBy(array(
'holidayCalendarId' => $id
));
$holidayList = [];
foreach ($holidayCalendarDetails as $det) {
$dateDet = array(
'title' => $det->getHolidayTitle(),
'startDate' => $det->getStartDate()->format('Y-m-d'),
'endDate' => $det->getEndDate()->format('Y-m-d'),
);
$holidayList[] = $dateDet;
}
return new JsonResponse(
array(
'success' => true,
'holidayList' => $holidayList
)
);
}
public function createQuestionAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$em_goc = $this->getDoctrine()->getManager('company_group');
$companyId = $this->getLoggedUserCompanyId($request);
if ($request->isMethod('POST')) {
$loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
$question = new Questionnaire();
$question->setQuestionTitle($request->request->get('questionTitle', ''));
$question->setQuestionText($request->request->get('questionText', ''));
$question->setIsForPlanningItem($request->request->has('forPlanningItem') ? 1 : 0);
$question->setIsForInterview($request->request->has('forInterview') ? 1 : 0);
$question->setIsForMock($request->request->has('forMock') ? 1 : 0);
$question->setIsForTraining($request->request->has('forTraining') ? 1 : 0);
$question->setTaggedSkillHashes($request->request->get('skillHash'));
$question->setCorrectAnswers(json_encode($request->request->get('correctAns')));
$question->setCompanyId($companyId);
$optionData = [];
foreach ($request->request->get('optionText') as $key => $val) {
$option = array(
'index' => $request->request->get('optionIndex')[$key],
'text' => $val,
);
$optionData[] = $option;
}
$question->setOptions(json_encode($optionData));
$question->setQuestionValueWeight(1);
$question->setQuestionText($request->request->get('questionText'));
$question->setUniqueHash('_NONE_');
$question->setType($request->request->get('type', 0));
//$skill->setEditFlag(1); //editable usually
$question->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
//$skill->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
//$skill->setAutocreated(0);
$em->persist($question);
$em->flush();
$questionId = $question->getQuestionId();
$file_path_list = [];
if ($questionId != 0)
if (!empty($request->files)) {
MiscActions::RemoveFilesForEntityDoc($em_goc, 'Question', $questionId);
$storePath = 'uploads/Questionnaire/';
$path = "";
$file_path = "";
$session = $request->getSession();
// MiscActions::RemoveExpiredFiles($em_goc);
foreach ($request->files as $uploadedFileGG) {
// if($uploadedFile->getImage())
// var_dump($uploadedFile->getFile());
// var_dump($uploadedFile);
$tempD = $uploadedFileGG;
if (!is_array($uploadedFileGG)) {
$uploadedFileGG = array();
$uploadedFileGG[] = $tempD;
}
foreach ($uploadedFileGG as $uploadedFile) {
if ($uploadedFile != null) {
$extension = $uploadedFile->guessExtension();
$size = $uploadedFile->getSize();
$fileName = 'QUES_' . $questionId . '_' . (md5(uniqid())) . '.' . $uploadedFile->guessExtension();
$path = $fileName;
$upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/' . $storePath;
if (!file_exists($upl_dir)) {
mkdir($upl_dir, 0777, true);
}
if (file_exists($upl_dir . '' . $path)) {
chmod($upl_dir . '' . $path, 0755);
unlink($upl_dir . '' . $path);
}
$file = $uploadedFile->move($upl_dir, $path);
$expireNever = 1;
$expireTs = 0;
$EntityFile = new EntityFile();
$EntityFile->setPath($this->container->getParameter('kernel.root_dir') . '/../web/' . $storePath . $path);
$EntityFile->setMarker('_GEN_');
$EntityFile->setExtension($extension);
$EntityFile->setExpireTs($expireTs);
$EntityFile->setSize($size);
$EntityFile->setRelativePath($storePath . $path);
$EntityFile->setEntityName('Questionnaire');
$EntityFile->setEntityBundle('ApplicationBundle');
$EntityFile->setEntityId($questionId);
$EntityFile->setEntityIdField('questionId');
$EntityFile->setModifyFieldSetter('setFiles');
$EntityFile->setDocIdForApplicant(0);
$EntityFile->setUserId($session->get(UserConstants::USER_ID, 0));
$EntityFile->setAppId($session->get(UserConstants::USER_APP_ID, 0));
$EntityFile->setEmployeeId($session->get(UserConstants::USER_EMPLOYEE_ID, 0));
$EntityFile->setUserType($session->get(UserConstants::USER_TYPE, 0));
$em_goc->persist($EntityFile);
$em_goc->flush();
$EntityFileId = $EntityFile->getId();
}
if ($path != "")
$file_path_list[] = ($storePath . $path);
}
}
$g_path = $this->container->getParameter('kernel.root_dir') . '/../web/' . $storePath . $path;
$question->setFiles(implode(',', $file_path_list));
$em->flush();
}
if ($request->request->has('returnJson') || $request->query->has('returnJson')) {
if ($question)
return new JsonResponse(
array(
'id' => $questionId,
'value' => $questionId,
'question_id' => $questionId,
'text' => $question->getQuestionText(),
'question_text' => $question->getQuestionText(),
'question_title' => $question->getQuestionTitle(),
'files' => explode(',', $question->getFiles()),
'options' => json_decode($question->getFiles(), true),
'answer_text' => '',
'success' => true
)
);
else
return new JsonResponse(
array(
'success' => false
)
);
}
}
$skillDetails = $em->getRepository(Skill::class)->findAll();
$skillListObj = [];
$skillListArray = [];
foreach ($skillDetails as $skillDetail) {
$dt = array(
'id' => $skillDetail->getSkillId(),
'name' => $skillDetail->getName(),
'hash' => $skillDetail->getUniqueHash(),
);
$skillListArray[] = $dt;
}
return $this->render('ApplicationBundle:pages/human_resource/input_forms:createQuestion.html.twig', array(
'page_title' => 'Create Question',
'skiillDetails' => $skillDetails,
'skillListArray' => $skillListArray,
));
}
public function createSkillAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($request);
if ($request->isMethod('POST')) {
$loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
$skill = new Skill;
$skill->setName($request->request->get('skillName'));
$skill->setParentId($request->request->get('parentName'));
$skill->setUniqueHash($request->request->get('uniqueHash'));
$skill->setCompanyId($companyId);
//$skill->setEditFlag(1); //editable usually
$skill->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
//$skill->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
//$skill->setAutocreated(0);
$em->persist($skill);
$em->flush();
}
$skillDetails = $em->getRepository(Skill::class)->findAll();
return $this->render('ApplicationBundle:pages/human_resource/input_forms:createSkill.html.twig', array(
'page_title' => 'Create Skill',
'skiillDetails' => $skillDetails,
));
}
public function createEducationQualificationAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($request);
if ($request->isMethod('POST')) {
$loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
$new = new EducationQualification;
$new->setName($request->request->get('educationName'));
$new->setParentId($request->request->get('parentName'));
$new->setUniqueHash($request->request->get('uniqueHash'));
$new->setCompanyId($companyId);
//$skill->setEditFlag(1); //editable usually
$new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
//$skill->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
//$skill->setAutocreated(0);
$em->persist($new);
$em->flush();
}
$educationDetails = $em->getRepository(EducationQualification::class)->findAll();
return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_education.html.twig', array(
'page_title' => 'Create Education',
'educationDetails' => $educationDetails,
));
}
public function createEvaluationCategoryAction(Request $request, $id = 0)
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($request);
if ($request->isMethod('POST')) {
$loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
$new = new EvaluationCategory;
$new->setName($request->request->get('name'));
$new->setBranch($request->request->get('branch'));
$new->setSelectionType($request->request->get('selection_type'));
$new->setEmployeeIds($request->request->get('selected_employeeIds'));
$new->setEmployeeTypeIds($request->request->get('employee_types'));
$new->setDesignationIds($request->request->get('designation'));
$new->setDesignationIds($request->request->get('designation'));
$new->setmark($request->request->get('mark'));
$new->setSkills(json_encode($request->request->get('skill')));
$new->setLevelSelectionStr($request->request->get('levelSelectionStr'));
$new->setCompanyId($companyId);
$new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
$em->persist($new);
$em->flush();
}
$skill = $em->getRepository(Skill::class)->findAll();
$employeeIds = $em->getRepository(EmployeeDetails::class)->findAll();
$employeeType = HumanResourceConstant::$employeeType;
$Designation = $em->getRepository(SysDepartmentPosition::class)->findAll();
$branch = $em->getRepository(Branch::class)->findAll();
$departments = $em->getRepository(SysDepartment::class)->findAll();
$department = [];
foreach ($departments as $entry) {
$department[$entry->getDepartmentId()] = array(
'id' => $entry->getDepartmentId(),
'name' => $entry->getDepartmentName(),
);
return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_evaluation_category.html.twig', array(
'page_title' => 'Create Evaluation Category',
'employeeIds' => $employeeIds,
'employeeType' => $employeeType,
'Designation' => $Designation,
'branch' => $branch,
'department' => $department,
'skill' => $skill,
));
}
}
public function createWorkplaceHarassmentAction(Request $request, $id = 0)
{
$em = $this->getDoctrine()->getManager();
$employeeIds = $em->getRepository(EmployeeDetails::class)->findAll();
//$employeeType = HumanResourceConstant::$employeeType;
$Designation = $em->getRepository(SysDepartmentPosition::class)->findAll();
$branches = $em->getRepository(Branch::class)->findAll();
$departments = $em->getRepository(SysDepartment::class)->findAll();
$harassmentType = HumanResourceConstant::$harrasmentType;
$department = [];
foreach ($departments as $entry) {
$department[$entry->getDepartmentId()] = array(
'id' => $entry->getDepartmentId(),
'name' => $entry->getDepartmentName(),
);
}
return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_workplace_harrasment.html.twig', array(
'page_title' => 'Create Workplace Harrasment',
'employeeIds' => $employeeIds,
'branches' => $branches,
'harassmentType' => $harassmentType,
'departments' => $department,
'designationIds' => $Designation
));
}
public function ViewHarasssmentComplainAction()
{
return $this->render('ApplicationBundle:pages/human_resource/views:view_harassment_compalin.html.twig', array(
'page_title' => 'View Harassment Complain',
));
}
public function createWorkplaceViolenceAction(Request $request, $id = 0)
{
$em = $this->getDoctrine()->getManager();
$employeeIds = $em->getRepository(EmployeeDetails::class)->findAll();
//$employeeType = HumanResourceConstant::$employeeType;
$Designation = $em->getRepository(SysDepartmentPosition::class)->findAll();
$branches = $em->getRepository(Branch::class)->findAll();
$departments = $em->getRepository(SysDepartment::class)->findAll();
$harassmentType = HumanResourceConstant::$harrasmentType;
$department = [];
foreach ($departments as $entry) {
$department[$entry->getDepartmentId()] = array(
'id' => $entry->getDepartmentId(),
'name' => $entry->getDepartmentName(),
);
}
return $this->render('ApplicationBundle:pages/human_resource/input_forms:register_workplace_complaint.html.twig', array(
'page_title' => 'Register Complaint',
'employeeIds' => $employeeIds,
'branches' => $branches,
'harassmentType' => $harassmentType,
'departments' => $department,
'designationIds' => $Designation
));
}
public function createBonusPolicyAction(Request $request, $id = 0)
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($request);
$extDocData = [];
$extDetailsData = [];
if ($request->isMethod('POST')) {
// Generic::debugMessage($_POST);
$em = $this->getDoctrine()->getManager();
$entity_id = array_flip(GeneralConstant::$Entity_list)['BonusPolicy']; //change
$dochash = $request->request->get('docHash'); //change
$loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
$approveRole = $request->request->get('approvalRole');
$approveHash = $request->request->get('approvalHash');
if (!DocValidation::isInsertable(
$em,
$entity_id,
$dochash,
$loginId,
$approveRole,
$approveHash,
$id
)
) {
$this->addFlash(
'error',
'Sorry Couldnot insert Data.'
);
} else {
$funcname = 'BonusPolicy';
DeleteDocument::$funcname($em, $id, 0);
$loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
$docId = HumanResource::createBonusPolicy($em, $request, $companyId, $loginId, 0);
//now add Approval info
$approveRole = $request->request->get('approvalRole');
$options = array(
'notification_enabled' => $this->container->getParameter('notification_enabled'),
'notification_server' => $this->container->getParameter('notification_server'),
'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
'url' => $this->generateUrl(
GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['BonusPolicy']]['entity_view_route_path_name']
)
);
System::setApprovalInfo(
$this->getDoctrine()->getManager(),
$options,
array_flip(GeneralConstant::$Entity_list)['BonusPolicy'],
$docId,
$request->getSession()->get(UserConstants::USER_LOGIN_ID)
);
System::createEditSignatureHash(
$this->getDoctrine()->getManager(),
array_flip(GeneralConstant::$Entity_list)['BonusPolicy'],
$docId,
$loginId,
$approveRole,
$request->request->get('approvalHash')
);
$doc_here = $this->getDoctrine()
->getRepository('ApplicationBundle:BonusPolicy')
->findOneBy(
array(
'id' => $docId
)
);
//notify
$this->addFlash(
'success',
'Policy Successfully Updated.'
);
$url = $this->generateUrl(
'view_bonus_policy'
);
// System::AddNewNotification(
// $this->container->getParameter('notification_enabled'),
// $this->container->getParameter('notification_server'),
// $request->getSession()->get(UserConstants::USER_APP_ID),
// $request->getSession()->get(UserConstants::USER_COMPANY_ID),
// "Salary Segregation Policy : " . $doc_here->getDocumentHash() . " Has Been Created And is Under Processing",
// 'pos',
// System::getPositionIdsByDepartment($em, GeneralConstant::HRM_DEPARTMENT),
// 'success',
// // $url . "/" . $TransID,
// $url . "/" . $docId,
// "Journal"
//
// );
return $this->redirect($url . "/" . $docId);
}
}
//for edits
if ($id == 0) {
} else {
$extDocData = $em->getRepository('ApplicationBundle:BonusPolicy')->findOneBy(
array(
'id' => $id, ///material
)
);
//now if its not editable, redirect to view
if ($extDocData) {
if ($extDocData->getEditFlag() != 1) {
// $url = $this->generateUrl(
//// 'view_salary_segregation_policy'
// 'salary_segregation_policy'
// );
// return $this->redirect($url . "/" . $id);
} else {
// $extVoucherDetailsData = Accounts::GetVoucherDataForEdit($em, $voucherId);
// $extDetailsData = $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
// array(
// 'transactionId' => $id, ///material
//
// )
// );
}
} else {
}
}
$employeeIds = $em->getRepository(EmployeeDetails::class)->findAll();
$employeeType = HumanResourceConstant::$employeeType;
$Designation = $em->getRepository(SysDepartmentPosition::class)->findAll();
$branch = $em->getRepository(Branch::class)->findAll();
$departments = $em->getRepository(SysDepartment::class)->findAll();
$department = [];
foreach ($departments as $entry) {
$department[$entry->getDepartmentId()] = array(
'id' => $entry->getDepartmentId(),
'name' => $entry->getDepartmentName(),
);
}
return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_bonus_policy.html.twig', array(
'page_title' => 'Create Bonus Policy',
'employeeIds' => $employeeIds,
'employeeType' => $employeeType,
'Designation' => $Designation,
'branch' => $branch,
'department' => $department,
));
}
public function BonusPolicyListAction()
{
$em = $this->getDoctrine()->getManager();
$bonusPolicy = $em->getRepository(BonusPolicy::class)->findAll();
return $this->render('ApplicationBundle:pages/human_resource/list:bonus_policy_list.html.twig', array(
'page_title' => 'Increment Policy List',
'bonusPolicy' => $bonusPolicy
));
}
public function createIncrementPolicyAction(Request $request, $id = 0)
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($request);
$extDocData = [];
$extDetailsData = [];
if ($request->isMethod('POST')) {
// Generic::debugMessage($_POST);
$em = $this->getDoctrine()->getManager();
$entity_id = array_flip(GeneralConstant::$Entity_list)['IncrementPolicy']; //change
$dochash = $request->request->get('docHash'); //change
$loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
$approveRole = $request->request->get('approvalRole');
$approveHash = $request->request->get('approvalHash');
if (!DocValidation::isInsertable(
$em,
$entity_id,
$dochash,
$loginId,
$approveRole,
$approveHash,
$id
)
) {
$this->addFlash(
'error',
'Sorry Couldnot insert Data.'
);
} else {
$funcname = 'IncrementPolicy';
DeleteDocument::$funcname($em, $id, 0);
$docId = HumanResource::createIncrementPolicy($em, $request, $companyId, 0);
//now add Approval info
$loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
$approveRole = $request->request->get('approvalRole');
$options = array(
'notification_enabled' => $this->container->getParameter('notification_enabled'),
'notification_server' => $this->container->getParameter('notification_server'),
'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
'url' => $this->generateUrl(
GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['IncrementPolicy']]['view_increment_policy']
)
);
System::setApprovalInfo(
$this->getDoctrine()->getManager(),
$options,
array_flip(GeneralConstant::$Entity_list)['IncrementPolicy'],
$docId,
$request->getSession()->get(UserConstants::USER_LOGIN_ID),
3 //journal voucher
);
System::createEditSignatureHash(
$this->getDoctrine()->getManager(),
array_flip(GeneralConstant::$Entity_list)['IncrementPolicy'],
$docId,
$loginId,
$approveRole,
$request->request->get('approvalHash')
);
$doc_here = $this->getDoctrine()
->getRepository('ApplicationBundle:IncrementPolicy')
->findOneBy(
array(
'id' => $docId
)
);
//notify
$this->addFlash(
'success',
'Policy Successfully Updated.'
);
$url = $this->generateUrl(
'view_increment_policy'
);
// System::AddNewNotification(
// $this->container->getParameter('notification_enabled'),
// $this->container->getParameter('notification_server'),
// $request->getSession()->get(UserConstants::USER_APP_ID),
// $request->getSession()->get(UserConstants::USER_COMPANY_ID),
// "Salary Segregation Policy : " . $doc_here->getDocumentHash() . " Has Been Created And is Under Processing",
// 'pos',
// System::getPositionIdsByDepartment($em, GeneralConstant::HRM_DEPARTMENT),
// 'success',
// // $url . "/" . $TransID,
// $url . "/" . $docId,
// "Journal"
//
// );
return $this->redirect($url . "/" . $docId);
}
}
//for edits
if ($id == 0) {
} else {
$extDocData = $em->getRepository('ApplicationBundle:IncrementPolicy')->findOneBy(
array(
'id' => $id, ///material
)
);
//now if its not editable, redirect to view
if ($extDocData) {
if ($extDocData->getEditFlag() != 1) {
// $url = $this->generateUrl(
//// 'view_salary_segregation_policy'
// 'salary_segregation_policy'
// );
// return $this->redirect($url . "/" . $id);
} else {
// $extVoucherDetailsData = Accounts::GetVoucherDataForEdit($em, $voucherId);
// $extDetailsData = $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
// array(
// 'transactionId' => $id, ///material
//
// )
// );
}
} else {
}
}
//$em = $this->getDoctrine()->getManager();
$employeeIds = $em->getRepository(EmployeeDetails::class)->findAll();
$employeeType = HumanResourceConstant::$employeeType;
$Designation = $em->getRepository(SysDepartmentPosition::class)->findAll();
$branch = $em->getRepository(Branch::class)->findAll();
$departments = $em->getRepository(SysDepartment::class)->findAll();
$department = [];
foreach ($departments as $entry) {
$department[$entry->getDepartmentId()] = array(
'id' => $entry->getDepartmentId(),
'name' => $entry->getDepartmentName(),
);
}
return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_increment_policy.html.twig', array(
'page_title' => 'Create Increment Policy',
'employeeIds' => $employeeIds,
'employeeType' => $employeeType,
'Designation' => $Designation,
'branch' => $branch,
'department' => $department,
));
}
public function IncrementPolicyListAction()
{
$em = $this->getDoctrine()->getManager();
$incrementPolicy = $em->getRepository(IncrementPolicy::class)->findAll();
return $this->render('ApplicationBundle:pages/human_resource/list:increment_policy_list.html.twig', array(
'page_title' => 'Increment Policy List',
'incrementPolicy' => $incrementPolicy
));
}
public function ViewIncrementPolicyAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$incrementPolicy = $em->getRepository(IncrementPolicy::class)->find($id);
$Approval_data = System::checkIfApprovalExists(
$em,
array_flip(GeneralConstant::$Entity_list)['IncrementPolicy'],
$id,
$request->getSession()->get(UserConstants::USER_LOGIN_ID)
);
return $this->render('ApplicationBundle:pages/human_resource/views:view_increment_policy.html.twig', array(
'page_title' => 'Increment Policy List',
'incrementPolicy' => $incrementPolicy,
'approval_status' => $incrementPolicy->getApproved(),
'approval_data' => $Approval_data,
'auto_created' => $incrementPolicy->getAutocreated(),
'id' => $id,
'document_log' => $incrementPolicy->getAutocreated() == 0 ? System::getDocumentLog(
$this->getDoctrine()->getManager(),
array_flip(GeneralConstant::$Entity_list)['FundRequisition'],
$id,
$incrementPolicy->getCreatedLoginId(),
$incrementPolicy->getEditedLoginId()
) : []
));
}
public function createConsultancyTopicAction(Request $request, $id = 0)
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($request);
if ($request->isMethod('POST')) {
$loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
$new = new ConsultancyTopic();
$new->setTopicName($request->request->get('topicName'));
$new->setParentTopicName($request->request->get('parentTopicName'));
$new->setUniqueHash($request->request->get('uniqueHash'));
$new->setCompanyId($companyId);
$new->setTopicSlug($request->request->get('topicSlug'));
$new->setTitle($request->request->get('title'));
$new->setSubTitle($request->request->get('subTitle'));
$new->setSummary($request->request->get('content'));
$new->setVideo($request->request->get('video'));
$new->setAuthor($request->request->get('author'));
$new->setAuthorSummary($request->request->get('authorSummary'));
$new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
// $arr = [
// 'requirement' => $request->request->get('requirement'),
//
// ];
// $new->setRequirementData(json_encode($arr));
$em->persist($new);
$em->flush();
}
// $data = [];
// $em = $this->getDoctrine()->getManager();
// $companyId = $this->getLoggedUserCompanyId($request);
// if ($request->isMethod('POST')) {
// $em = $this->getDoctrine()->getManager();
// $entity_id = array_flip(GeneralConstant::$Entity_list)['ConsultancyTopic'];
// //$dochash = $request->request->get('docHash');//change
// $approveRole = $request->request->get('approvalRole');
// $approveHash = $request->request->get('approvalHash');
// $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
// if (!DocValidation::isInsertable($em, $entity_id,
// $loginId, $approveRole, $approveHash, $id)
// ) {
// $this->addFlash(
// 'error',
// 'Sorry Could not insert Data.'
// );
// } else {
// $data = $request->request;
// $docId = HumanResource::createConsultancyTopic($em, $loginId, $id, $data, $companyId);
//// now add Approval info
//
// $approveRole = $request->request->get('approvalRole');
// $options = array(
// 'notification_enabled' => $this->container->getParameter('notification_enabled'),
// 'notification_server' => $this->container->getParameter('notification_server'),
// 'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
//// 'url' => $this->generateUrl(
//// GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['EmployeePerformanceEvolution']]
//// ['entity_view_route_path_name']
//// )
// );
// System::setApprovalInfo($this->getDoctrine()->getManager(), $options,
// array_flip(GeneralConstant::$Entity_list)['ConsultancyTopic'],
// $docId,
// $request->getSession()->get(UserConstants::USER_LOGIN_ID) //journal voucher
// );
// System::createEditSignatureHash($this->getDoctrine()->getManager(), array_flip(GeneralConstant::$Entity_list)['ConsultancyTopic'],
// $docId,
// $loginId,
// $request->request->get('approvalHash'));
// $this->addFlash(
// 'success',
// 'New Consultancy Topic Added.'
// );
//// $url = $this->generateUrl(
//// 'create_consultancy_topic'
//// );
// //return $this->redirect($url);
//
// }
// }
$consultancyDetails = $em->getRepository('ApplicationBundle:ConsultancyTopic')->findAll();
return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_consultancy.html.twig', array(
'page_title' => 'Consultancy Topic',
'consultancyDetails' => $consultancyDetails,
// 'requirement' => json_decode($consultancyDetails->getRequirementData())
));
}
public function createTopicAction(Request $request, $id = 0)
{
$em = $this->getDoctrine()->getManager('company_group');
$companyId = $this->getLoggedUserCompanyId($request);
$documentQRY = $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->findAll();
$topicList = $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findAll();
$topic = [];
$sessionName = ConsultancyConstant::$sessionName;
$document = [];
foreach ($documentQRY as $d) {
$document[$d->getId()] = array(
'id' => $d->getId(),
'documentName' => $d->getDocumentName(),
'text' => $d->getDocumentName(),
);
}
$topicId = $id;
if ($topicId != 0)
$topic = $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
array(
'id' => $topicId
)
);
if ($request->isMethod('POST')) {
if ($request->request->has('topicId'))
$topicId = $request->request->get('topicId');
// $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
if ($topicId != 0)
$new = $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
array(
'id' => $topicId
)
);
else
$new = new EntityCreateTopic();
$new->setTopicName($request->request->get('topicName'));
$new->setParentTopicId($request->request->get('parentTopic'));
if ($request->request->get('countryId') != '')
$new->setCountryId($request->request->get('countryId'));
else if ($request->request->get('parentTopic') != '') {
$parentTopic = $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
array(
'id' => $request->request->get('parentTopic')
)
);
if ($parentTopic)
$new->setCountryId($parentTopic->getCountryId());
}
$new->setTimeSlotMultipliers($request->request->get('timeSlotMultipliers'));
$new->setOnlyBookableByAdmin($request->request->get('onlyBookableByAdmin', 0));
$new->setMeetingType($request->request->get('meetingType', 0));
$new->setConsultantCanUpload($request->request->get('consultantCanUpload', 0));
$new->setTopicMarker($request->request->get('topicMarker'));
$new->setCoinMultiplierValue($request->request->get('coinMultiplierValue', 1));
$new->setMinLifetimeCoinsBalance($request->request->get('minLifetimeCoinsBalance', 0));
$new->setMapEmbedIframe($request->request->get('mapEmbedIframe', ''));
$new->setTopicSummary($request->request->get('topicSummary'));
$new->setAddress($request->request->get('address'));
$new->setLocationString($request->request->get('locationString'));
$new->setLocationLat($request->request->get('locationLat'));
$new->setLocationLong($request->request->get('locationLong'));
$new->setUniversityRanking($request->request->get('universityRanking'));
$new->setIsParent($request->request->get('isParent'));
$new->setIsEvent($request->request->get('isEvent'));
$new->setConsultancyEnabled($request->request->get('consultancyEnabled', 0));
$new->setEventExpired($request->request->get('eventExpired', 0));
$new->setEventDesc($request->request->get('eventDesc', 0));
$eventStartDate = new \DateTime($request->request->get('eventStartDate'));
$eventEndDate = new \DateTime($request->request->get('eventStartDate'));
$new->setEventStartDate($eventStartDate);
$new->setEventStartDateTs($eventStartDate->format('U'));
$new->setEventEndDate($eventEndDate);
$new->setEventStartDateTs($eventEndDate->format('U'));
$new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
$checkListStringArray = [];
if ($request->request->has('checkList'))
foreach ($request->request->get('checkList') as $value) {
$checkListStringArray [] = explode(",", $value);
}
$docData = [];
foreach ($request->request->get('document', []) as $key => $value)
$docData[] = [
'document' => $request->request->get('document')[$key],
'expDays' => $request->request->get('expDays')[$key],
'stage' => $request->request->get('stage')[$key],
'generalProcessingDays' => $request->request->get('generalProcessingDays')[$key],
'emergencyProcessingDays' => $request->request->get('emergencyProcessingDays')[$key],
'thresholdDaysOffset' => $request->request->get('thresholdDaysOffset')[$key],
'checklist' => explode(",", $request->request->get('checkList')[$key])
];
$coursePlanData = [];
foreach ($request->request->get('coursePlanSessionNo', []) as $key => $value)
if ($request->request->get('coursePlanSessionNo')[$key] != '' and $request->request->get('coursePlanSessionNo')[$key] != null) {
if (!isset($coursePlanData[$request->request->get('coursePlanSessionNo')[$key]]))
$coursePlanData[$request->request->get('coursePlanSessionNo')[$key]] = [];
$coursePlanData[$request->request->get('coursePlanSessionNo')[$key]][] = [
'sessionNo' => $request->request->get('coursePlanSessionNo')[$key],
'subject' => $request->request->get('coursePlanSubject')[$key],
'details' => $request->request->get('coursePlanDetails')[$key],
'optimumMin' => $request->request->get('coursePlanOptimumMin')[$key],
];
}
$routineData = [];
foreach ($request->request->get('routine_sequence', []) as $key => $value) {
$routineData[] = [
'sequence' => $request->request->get('routine_sequence')[$key],
'topicId' => $request->request->get('routine_topic_id')[$key],
'topicName' => $request->request->get('routine_topic_name')[$key],
'meetingType' => $request->request->get('routine_topic_meeting_type')[$key],
'duration' => $request->request->get('routine_duration')[$key],
'offset' => $request->request->get('routine_offset')[$key],
'coins' => $request->request->get('routine_coins')[$key],
'nextSequenceStart' => $request->request->has('routine_next_sequence_start_' . $value) ? 1 : 0,
'modifiable' => $request->request->has('routine_modifiable_' . $value) ? 1 : 0,
];
}
$sessionData = [];
foreach ($request->request->get('sessionId', []) as $key => $value)
$sessionData[] = [
'sessionId' => $request->request->get('sessionId')[$key],
'sessionYear' => $request->request->get('year')[$key],
'threshold' => $request->request->get('threshold')[$key],
'sessionStart' => $request->request->get('sessionStart')[$key],
'applicationStartDate' => $request->request->get('applicationStartDate')[$key],
];
$coursesData = [];
foreach ($request->request->get('courseName', []) as $key => $value)
$coursesData[] = [
'courseName' => $request->request->get('courseName')[$key],
];
$departmentData = [];
foreach ($request->request->get('departmentName', []) as $key => $value)
$departmentData[] = [
'departmentName' => $request->request->get('departmentName')[$key],
];
$benefitsData = [];
foreach ($request->request->get('benefit', []) as $key => $value)
$benefitsData[] = [
'benefit' => $request->request->get('benefit')[$key],
];
$new->setRoutineData(json_encode($routineData));
$new->setDocumentData(json_encode($docData));
$new->setCoursePlanData(json_encode($coursePlanData));
$new->setSessionData(json_encode($sessionData));
$new->setCourses(json_encode($coursesData));
$new->setDepartments(json_encode($departmentData));
$new->setBenefits(json_encode($benefitsData));
$otherDataObj = [];
foreach (ConsultancyConstant::$otherDataByHash as $ohash => $otherDataGroup)
foreach ($otherDataGroup as $otherData) {
$fieldExists = $request->request->has($ohash . '_' . $otherData['field']);
if ($fieldExists) {
$fieldValue = $request->request->get($ohash . '_' . $otherData['field'], '');
$otherDataObj[$ohash . '_' . $otherData['field']] = $fieldValue;
}
}
$new->setOtherData(json_encode($otherDataObj));
$new->setBenefits(json_encode($benefitsData));
$em->persist($new);
$em->flush();
$path = "";
$defaultProductImage = '';
$uploadedFile = null;
$upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/topicImage/';
$uploadedFile = $request->files->get('topicSummaryImage');
if ($uploadedFile != null) {
$fileName = 'TSI' . $new->getId() . '.' . $uploadedFile->guessExtension();
$path = $fileName;
// $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
if (!file_exists($upl_dir)) {
mkdir($upl_dir, 0777, true);
}
$uploadedFile->move($upl_dir, $path);
$defaultProductImage = 'uploads/topicImage/' . $path;
$new->setTopicSummaryImage($defaultProductImage);
$em->flush();
}
$path = "";
$defaultProductImage = '';
$uploadedFile = null;
$upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/topicImage/';
$uploadedFile = $request->files->get('topicImage');
if ($uploadedFile != null) {
$fileName = 'TI' . $new->getId() . '.' . $uploadedFile->guessExtension();
$path = $fileName;
// $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
if (!file_exists($upl_dir)) {
mkdir($upl_dir, 0777, true);
}
$uploadedFile->move($upl_dir, $path);
$defaultProductImage = 'uploads/topicImage/' . $path;
$new->setTopicImage($defaultProductImage);
$em->flush();
}
$this->addFlash(
'success',
'Topic Added.'
);
}
return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_topic.html.twig', array(
'page_title' => 'Create Topic',
'defaultCoursePlan' => ConsultancyConstant::$defaultCoursePlan,
'coursePlanSessionTitle' => ConsultancyConstant::$coursePlanSessionTitle,
'coursePlanSessionTitleShort' => ConsultancyConstant::$coursePlanSessionTitleShort,
'document' => $document,
'topic' => $topic,
'otherDataByHash' => ConsultancyConstant::$otherDataByHash,
'topicId' => $topicId,
'topicList' => $topicList,
'topicMarker' => ConsultancyConstant::$topicMarkup,
'sessionName' => $sessionName,
));
}
public function ConsultancyRequirementSettingsAction(Request $request, $id = 0)
{
$em = $this->getDoctrine()->getManager('company_group');
$entityList = $em->getRepository('CompanyGroupBundle:EntityCountryConsultantRequirements')->findAll();
$documentQRY = $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->findAll();
$entity = [];
$sessionName = ConsultancyConstant::$sessionName;
$document = [];
foreach ($documentQRY as $d) {
$document[$d->getId()] = array(
'id' => $d->getId(),
'documentName' => $d->getDocumentName(),
'text' => $d->getDocumentName(),
);
}
$countryId = $id;
if ($countryId != 0)
$entity = $em->getRepository('CompanyGroupBundle:EntityCountryConsultantRequirements')->findOneBy(
array(
'countryId' => $countryId
)
);
if ($request->isMethod('POST')) {
if ($request->request->has('countryId'))
$countryId = $request->request->get('countryId');
// $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
if ($countryId != 0) {
$new = $em->getRepository('CompanyGroupBundle:EntityCountryConsultantRequirements')->findOneBy(
array(
'countryId' => $countryId
)
);
if (!$new)
$new = new EntityCountryConsultantRequirements();
} else
$new = new EntityCountryConsultantRequirements();
$new->setCountryId($request->request->get('countryId'));
$new->setContractLetterHtml($request->request->get('contractLetterHtml'));
$new->setRequiredFields($request->request->get('requiredFields'));
$new->setAllowedWorkingHoursPerDay($request->request->get('allowedWorkingHoursPerDay'));
$new->setAllowedWorkingHoursPerMonth($request->request->get('allowedWorkingHoursPerMonth'));
$new->setAllowedWorkingHoursPerWeek($request->request->get('allowedWorkingHoursPerWeek'));
$new->setAllowedWorkingHoursPerYear($request->request->get('allowedWorkingHoursPerYear'));
$new->setAllowedEarningPerDay($request->request->get('allowedEarningPerDay'));
$new->setAllowedEarningPerMonth($request->request->get('allowedEarningPerMonth'));
$new->setAllowedEarningPerWeek($request->request->get('allowedEarningPerWeek'));
$new->setAllowedEarningPerYear($request->request->get('allowedEarningPerYear'));
$new->setRevenuePercentagePerSession($request->request->get('revenuePercentagePerSession'));
$docData = [];
foreach ($request->request->get('document', []) as $key => $value)
$docData[] = [
'document' => $request->request->get('document')[$key],
'expDays' => $request->request->get('expDays')[$key],
'stage' => $request->request->get('stage')[$key],
'generalProcessingDays' => $request->request->get('generalProcessingDays')[$key],
'emergencyProcessingDays' => $request->request->get('emergencyProcessingDays')[$key],
'thresholdDaysOffset' => $request->request->get('thresholdDaysOffset')[$key],
'checklist' => explode(",", $request->request->get('checkList')[$key])
];
$new->setDocumentList(json_encode($docData));
$em->persist($new);
$em->flush();
$this->addFlash(
'success',
'Restriction Updated.'
);
}
return $this->render('ApplicationBundle:pages/consultancy:create_consultancy_requirements.html.twig', array(
'page_title' => 'Create Requirements',
'defaultCoursePlan' => ConsultancyConstant::$defaultCoursePlan,
'coursePlanSessionTitle' => ConsultancyConstant::$coursePlanSessionTitle,
'coursePlanSessionTitleShort' => ConsultancyConstant::$coursePlanSessionTitleShort,
'document' => $document,
'entity' => $entity,
'otherDataByHash' => ConsultancyConstant::$otherDataByHash,
'countryId' => $countryId,
'entityList' => $entityList,
'topicMarker' => ConsultancyConstant::$topicMarkup,
'sessionName' => $sessionName,
));
}
public function PromoCodeSettingsAction(Request $request, $id = 0)
{
$em = $this->getDoctrine()->getManager('company_group');
$entityList = $em->getRepository('CompanyGroupBundle:PromoCode')->findAll();
$applicantList = $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findAll();
$promoCodeId = $id;
$entity = [];
if ($promoCodeId != 0)
$entity = $em->getRepository('CompanyGroupBundle:PromoCode')->findOneBy(
array(
'id' => $promoCodeId
)
);
if ($request->isMethod('POST')) {
if ($request->request->has('promoCodeId'))
$promoCodeId = $request->request->get('promoCodeId');
// $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
if ($promoCodeId != 0) {
$new = $em->getRepository('CompanyGroupBundle:PromoCode')->findOneBy(
array(
'id' => $promoCodeId
)
);
if (!$new)
$new = new PromoCode();
} else
$new = new PromoCode();
// $new->setCountryId($request->request->get('countryId'));
$new->setCode($request->request->get('code', ''));
$new->setPromoType($request->request->get('promoType', 1));
$new->setPromoCodeType($request->request->get('promoCodeType', 1));
$new->setPromoValue($request->request->get('promoValue', 0));
$new->setPerpetual($request->request->get('perpetual', 0));
$new->setMaxDiscountAmount($request->request->get('maxDiscountAmount', -1));
$new->setMaxCoinAddition($request->request->get('maxCoinAddition', -1));
$new->setMinAmountForApplication($request->request->get('minAmountForApplication', 0));
$new->setMinCoinForApplication($request->request->get('minCoinForApplication', 0));
$new->setNextApplicationEachCoinCount($request->request->get('nextApplicationEachCoinCount', -1));
$new->setMaxUseCount($request->request->get('maxUseCount', -1));
$new->setMaxUseCountPerUser($request->request->get('maxUseCountPerUser', -1));
$new->setUseCountBalance($request->request->get('useCountBalance', -1));
$new->setReferralApplicantId($request->request->get('referralApplicantId', 0));
$new->setMaxReferralCommissionCount($request->request->get('maxReferralCommissionCount', 0));
$new->setReferralCommissionCountBalance($request->request->get('referralCommissionCountBalance', 0));
$new->setReferralCommissionType($request->request->get('referralCommissionType', 1));
$new->setReferralAmount($request->request->get('referralAmount', 0));
$startsAt = new \DateTime($request->request->get('startsAt', ''));
$expiresAt = new \DateTime($request->request->get('expiresAt', ''));
$new->setStartsAtTs($startsAt->format('U'));
$new->setExpiresAtTs($expiresAt->format('U'));
//
// startsAtTs:
// type: integer
// nullable: true
// expiresAtTs:
// type: integer
// nullable: true
$em->persist($new);
$em->flush();
$this->addFlash(
'success',
'Promo Code Updated.'
);
}
return $this->render('ApplicationBundle:pages/consultancy:buddybee_promo_code_settings.html.twig', array(
'page_title' => 'Promo Codes',
'entity' => $entity,
'promoCodeId' => $promoCodeId,
'entityList' => $entityList,
'applicantList' => $applicantList,
));
}
public function createDocumentAction(Request $request, $id = 0)
{
$em = $this->getDoctrine()->getManager('company_group');
$companyId = $this->getLoggedUserCompanyId($request);
$document = $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->findAll();
$thisDoc = [];
if ($id != 0)
$thisDoc = $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->findOneBy(
array(
'Id' => $id
)
);
if ($request->isMethod('POST')) {
if ($id != 0)
$new = $thisDoc;
else
$new = new EntityCreateDocument();
$new->setDocumentName($request->request->get('docName'));
$new->setExpiryDays($request->request->get('expDays'));
$new->setProcessingDays($request->request->get('processingDays'));
$new->setEmergencyProcessingDays($request->request->get('emergencyProcessingDays'));
$new->setDocVideo($request->request->get('docVideoLink'));
$new->setRequiredDocument(json_encode($request->request->get('requiredDoc')));
$new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
$arr = [
'checkListName' => $request->request->get('checkListName'),
];
$new->setCheckList(json_encode($arr));
$em->persist($new);
$em->flush();
}
$this->addFlash(
'Document Added',
'Topic Added.'
);
return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_document.html.twig', array(
'page_title' => 'Create Document',
'document' => $document,
'thisDoc' => $thisDoc
));
}
public function getIndividualDocumentAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager('company_group');
if ($id == 0) {
if ($request->request->has('documentId'))
$id = $request->request->get('documentId');
}
$document = $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->find($id);
return new JsonResponse(
array(
'success' => true,
'rowId' => $request->request->get('rowId'),
'expiryDays' => $document->getExpiryDays(),
'processingDays' => $document->getProcessingDays(),
'emergencyProcessing' => $document->getEmergencyProcessingDays(),
'checklist' => json_decode($document->getCheckList()),
)
);
}
public function createBlogAction(Request $request, $id)
{
if (!$id) {
if ($request->isMethod('POST')) {
$em = $this->getDoctrine()->getManager('company_group');
$loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
$new = new EntityCreateBlog();
$new->setTopicId($request->request->get('topicId'));
$new->setTitle($request->request->get('title'));
$new->setSubtitle($request->request->get('subTitle'));
$new->setContent($request->request->get('content'));
$new->setVideoLink($request->request->get('videoLink'));
$new->setAuthorName($request->request->get('authorName'));
$new->setAuthorSummary($request->request->get('authorSummary'));
$new->setIsPrimaryBlog($request->request->get('checkPrimaryBlog'));
$em->persist($new);
$em->flush();
//$fileName = 'cv' . $consultantDetails->getApplicantId() . '.' . $uploadedFile->guessExtension();
$path = "";
$defaultProductImage = '';
$uploadedFile = null;
$upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/authorImage/';
$uploadedFile = $request->files->get('authorImage');
if ($uploadedFile != null) {
$fileName = 'authorImage' . $new->getId() . '.' . $uploadedFile->guessExtension();
$path = $fileName;
// $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
if (!file_exists($upl_dir)) {
mkdir($upl_dir, 0777, true);
}
$uploadedFile->move($upl_dir, $path);
$defaultProductImage = 'uploads/authorImage/' . $path;
$new->setAuthorImage($defaultProductImage);
$em->flush();
}
$path = "";
$defaultProductImage = '';
$uploadedFile = null;
$upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/mainImage/';
$uploadedFile = $request->files->get('main_img');
if ($uploadedFile != null) {
$fileName = 'mainImage' . $new->getId() . '.' . $uploadedFile->guessExtension();
$path = $fileName;
// $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
if (!file_exists($upl_dir)) {
mkdir($upl_dir, 0777, true);
}
$uploadedFile->move($upl_dir, $path);
$defaultProductImage = 'uploads/mainImage/' . $path;
$new->setMainImage($defaultProductImage);
$em->flush();
}
$topicDetails = $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
array(
'id' => $request->request->get('topicId')
)
);
if ($new->getIsPrimaryBlog() == 1) {
if ($topicDetails)
$topic = $topicDetails;
else
$topic = new EntityCreateTopic();
$topic->setPrimaryBlogId($new->getId());
$em->flush();
}
$this->addFlash(
'success',
'Blog Added.'
);
} else {
$em = $this->getDoctrine()->getManager('company_group');
$topic = $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findAll();
$applicant = $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findAll();
$blogs = $em->getRepository('CompanyGroupBundle:EntityCreateBlog')->findAll();
$topicIds = [];
foreach ($blogs as $blog) {
$topicIds [] = $blog->getTopicId();
}
// $topic = $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findBy(
// array(
// 'id' => $topicIds
// )
// );
return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_blog.html.twig', array(
'page_title' => 'Create Blog',
'topic' => $topic,
'applicant' => $applicant,
'blog' => $blogs,
'id' => $id,
));
}
} else {
if ($request->isMethod('GET')) {
$em = $this->getDoctrine()->getManager('company_group');
$topic = $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findAll();
$applicant = $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findAll();
$blogs = $em->getRepository('CompanyGroupBundle:EntityCreateBlog')->find($id);
return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_blog.html.twig', array(
'page_title' => 'Create Blog',
'topic' => $topic,
'applicant' => $applicant,
'blog' => $blogs,
'id' => $id,
));
} else {
$em = $this->getDoctrine()->getManager('company_group');
$new = new EntityCreateBlog();
$new->setTopicId($request->request->get('topicId'));
$new->setTitle($request->request->get('title'));
$new->setSubtitle($request->request->get('subTitle'));
$new->setContent($request->request->get('content'));
$new->setVideoLink($request->request->get('videoLink'));
$new->setAuthorName($request->request->get('authorName'));
$new->setAuthorSummary($request->request->get('authorSummary'));
//$em->persist($new);
$em->flush();
$path = "";
$defaultProductImage = '';
$uploadedFile = null;
$upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/authorImage/';
$uploadedFile = $request->files->get('authorImage');
if ($uploadedFile != null) {
$fileName = 'authorImage' . '.' . $uploadedFile->guessExtension();
$path = $fileName;
// $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
if (!file_exists($upl_dir)) {
mkdir($upl_dir, 0777, true);
}
$uploadedFile->move($upl_dir, $path);
$defaultProductImage = 'uploads/authorImage/' . $path;
$new->setAuthorImage($defaultProductImage);
$em->flush();
}
$this->addFlash(
'success',
'Blog Updated.'
);
}
}
return new JsonResponse(
array(
'success' => true,
)
);
// if ($request->isMethod('POST')) {
// $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
//
// $new = new EntityCreateBlog();
//
// $new->setTopicId($request->request->get('topicId'));
// $new->setTitle($request->request->get('title'));
// $new->setSubtitle($request->request->get('subTitle'));
// $new->setContent($request->request->get('content'));
// $new->setVideoLink($request->request->get('videoLink'));
// $new->setAuthorName($request->request->get('authorName'));
// $new->setAuthorSummary($request->request->get('authorSummary'));
//
// $em->persist($new);
// $em->flush();
//
//
// $path = "";
// $defaultProductImage = '';
// $uploadedFile = null;
// $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/authorImage/';
// $uploadedFile= $request->files->get('authorImage');
//
// if ($uploadedFile != null) {
//
// $fileName = 'authorImage' .'.' . $uploadedFile->guessExtension();
// $path = $fileName;
//// $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
// if (!file_exists($upl_dir)) {
// mkdir($upl_dir, 0777, true);
// }
// $uploadedFile->move($upl_dir, $path);
// $defaultProductImage = 'uploads/authorImage/' . $path;
// $new->setAuthorImage($defaultProductImage);
// $em->flush();
//
// }
// $this->addFlash(
// 'success',
// 'Blog Added.'
// );
// }
// return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_blog.html.twig', array(
// 'page_title' => 'Create Blog',
// 'topic'=> $topic,
// 'applicant' => $applicant,
// 'blog' => $blogs
// ));
}
public function applicantConsultancyAction()
{
return $this->render('ApplicationBundle:pages/human_resource/input_forms:consultancy.html.twig', array(
'page_title' => 'Consultancy',
));
}
public function viewConsultantDetailsAction(Request $request, $id = 0)
{
$gocEnabled = 1;
$currAppId = 4;
$honeybeeAppId = 1;
$buddybeeAppId = 4;
$em_goc = $this->getDoctrine()->getManager('company_group');
$em = $this->getDoctrine()->getManager();
$option = [];
$option['appId'] = $currAppId; //honeybee
$option['departmentId'] = 18; //consultancy
$option['designationId'] = 50;
// $dataToConnect = System::changeDoctrineManagerByAppId(
// $this->getDoctrine()->getManager('company_group'),
// $gocEnabled,
// $currAppId
// );
// if (!empty($dataToConnect)) {
// $connector = $this->container->get('application_connector');
// $connector->resetConnection(
// 'default',
// $dataToConnect['dbName'],
// $dataToConnect['dbUser'],
// $dataToConnect['dbPass'],
// $dataToConnect['dbHost'],
// $reset = true
// );
// $em = $this->getDoctrine()->getManager();
// } else {
// $currAppId = $honeybeeAppId;
// $dataToConnectAgain = System::changeDoctrineManagerByAppId(
// $this->getDoctrine()->getManager('company_group'),
// $gocEnabled,
// $currAppId
// );
// if (!empty($dataToConnectAgain)) {
// $connector = $this->container->get('application_connector');
// $connector->resetConnection(
// 'default',
// $dataToConnect['dbName'],
// $dataToConnect['dbUser'],
// $dataToConnect['dbPass'],
// $dataToConnect['dbHost'],
// $reset = true
// );
// $em = $this->getDoctrine()->getManager();
// }
//
// }
$consultantDetails = $em_goc->getRepository(EntityApplicantDetails::class)->find($id);
$skill = $em_goc->getRepository(EntitySkill::class)->findAll();
$gender = HumanResourceConstant::$sex;
$blood = HumanResourceConstant::$BloodGroup;
$consultantLevel = HumanResourceConstant::$consultantLevel;
$companyId = $this->getLoggedUserCompanyId($request);
$designation = $em->getRepository("ApplicationBundle:SysDepartmentPosition")->findAll();
$departments = $em->getRepository("ApplicationBundle:SysDepartment")->findAll();
$companyData = Company::getCompanyData($em, $companyId);
$currDate = new \DateTime();
if ($request->isMethod('POST')) {
//for consultant only
$convertToConsultant = HumanResource::convertToConsultant($em_goc, $em, $id, $option, $request->request);
if ($request->request->get('confirmStatus', 0) == 1) {
$bodyTemplate = 'ApplicationBundle:email/templates:consultantApprovalEmail.html.twig';
$contractLetterHtml = '';
$bodyData = array(
'name' => $consultantDetails->getFirstname() . ' ' . $consultantDetails->getLastname(),
'companyData' => $companyData,
'contractLetterHtml' => $contractLetterHtml,
'commentText' => $request->request->get('commentText'),
);
$new_mail = $this->get('mail_module');
$new_mail->sendMyMail(array(
'senderHash' => '_CUSTOM_',
'encryptionMethod' => 'ssl',
'userName' => 'management@buddybee.eu',
'fromAddress' => 'management@buddybee.eu',
'password' => 'Eco@0112',
'smtpServer' => 'smtp.hostinger.com',
'smtpPort' => '465',
'forwardToMailAddress' => $consultantDetails->getEmail(),
'subject' => 'Consultant Contract Letter Of ' . $consultantDetails->getFirstName(),
'fileName' => '',
//'attachments' => $attachments,
'toAddress' => $consultantDetails->getEmail(),
'mailTemplate' => $bodyTemplate,
'templateData' => $bodyData,
'embedCompanyImage' => 1,
'companyId' => $companyId,
'companyImagePath' => ""
));
}
if ($request->request->get('confirmStatus', 0) == 0) {
$bodyTemplate = 'ApplicationBundle:email/templates:consultantRejectionEmail.html.twig';
$contractLetterHtml = '';
$bodyData = array(
'name' => $consultantDetails->getFirstname() . ' ' . $consultantDetails->getLastname(),
'companyData' => $companyData,
'contractLetterHtml' => $contractLetterHtml,
'commentText' => $request->request->get('commentText'),
);
$new_mail = $this->get('mail_module');
$new_mail->sendMyMail(array(
'senderHash' => '_CUSTOM_',
'encryptionMethod' => 'ssl',
'userName' => 'management@buddybee.eu',
'fromAddress' => 'management@buddybee.eu',
'password' => 'Eco@0112',
'smtpServer' => 'smtp.hostinger.com',
'smtpPort' => '465',
'forwardToMailAddress' => $consultantDetails->getEmail(),
'subject' => 'Rejection Letter Of ' . $consultantDetails->getFirstName(),
'fileName' => '',
//'attachments' => $attachments,
'toAddress' => $consultantDetails->getEmail(),
'mailTemplate' => $bodyTemplate,
'templateData' => $bodyData,
'embedCompanyImage' => 1,
'companyId' => $companyId,
'companyImagePath' => ""
));
}
}
$docList = MiscActions::GetDocumentDataForBuddybeeConsultantApply($em_goc,
$id,
$consultantDetails->getCurrentCountryId()
);
return $this->render('ApplicationBundle:pages/human_resource/views:viewConsultantDetails.html.twig', array(
'page_title' => 'Consultant Details',
'applicantId' => $id,
'consultantDetails' => $consultantDetails,
'education' => json_decode($consultantDetails->getEducationData(), true),
'workExperience' => json_decode($consultantDetails->getWorkExperienceData(), true),
'certificate' => json_decode($consultantDetails->getCertificateData(), true),
'gender' => $gender,
'blood' => $blood,
'skill' => $skill,
'docList' => $docList,
'countryId' => $consultantDetails->getCurrentCountryId(),
'consultantLevel' => $consultantLevel,
'designation' => $designation,
'department' => $departments
));
}
public function ApplicableEmployeSettingsAction()
{
$em = $this->getDoctrine()->getManager();
$employeeIds = $em->getRepository(Employee::class)->findAll();
return $this->render('ApplicationBundle:pages/human_resource/input_forms:applicable_employee_settings.html.twig', array(
'page_title' => 'Applicable Employee Settings',
'employeeIds' => $employeeIds
));
}
public function GetApplicableSettingsForSingleEmployeeAction($id)
{
$em = $this->getDoctrine()->getManager();
$bankLists = $em->getRepository(WorkHourPolicy::class)->findAll();
if (json_decode($bankLists->getEmployeeIds()) == $id) {
return new JsonResponse(
array(
'success' => true,
'msg' => 'employee found'
)
);
} else {
return new JsonResponse(
array(
'success' => true,
'msg' => 'employee not found'
)
);
}
}
// public function getEmployeeDataAction(){
// $em = $this->getDoctrine()->getManager();
// $emplyeeDetails = $em->getRepository('ApplicationBundle:EmployeeDeatils')->findAll();
// $days = HumanResourceConstant::$days;
// $holidays = ;
// $workHourPolicies = ;
//
// }
public function meetingSchedulingForTabAction()
{
$em = $this->getDoctrine()->getManager();
$date = date('Y-m-d');
$month = date('m');
$year = date('Y');
$monthName = date("F", mktime(0, 0, 0, $month));
$totalDayOfMonth = cal_days_in_month(CAL_GREGORIAN, $month, $year);
$fromdt = date('Y-m-01 ', strtotime("First Day Of $monthName $year"));
// echo "Start Date : $fromdt" . "<br>";
$todt = date('Y-m-d ', strtotime("Last Day of $monthName $year"));
// echo "End Date : $todt" . "<br>";
$num_friday = '';
for ($i = 0; $i < ((strtotime($todt) - strtotime($fromdt)) / 86400); $i++) {
if (date('l', strtotime($fromdt) + ($i * 86400)) == 'Friday') {
$num_friday++;
}
}
$num_saturday = '';
for ($i = 0; $i < ((strtotime($todt) - strtotime($fromdt)) / 86400); $i++) {
if (date('l', strtotime($fromdt) + ($i * 86400)) == 'Saturday') {
$num_saturday++;
}
}
$totalWeekends = $num_saturday + $num_friday;
$totalCompanyWorkingDay = $totalDayOfMonth - $totalWeekends;
// $attendanceData=$em->getRepository('ApplicationBundle:EmployeeAttendanceLog')->findOneBy(
// array(
// 'employeeId' => 3
// )
// );
$DateRange = [];
$holidayDates = $em->getRepository('ApplicationBundle:HolidayCalendarDates')->findAll();
foreach ($holidayDates as $holiday) {
$holidaayData = array(
'startDate' => $holiday->getStartDate(),
'endDate' => $holiday->getEndDate(),
);
$DateRange = $holidaayData;
}
$employeeDataDetail = [];
$employeeDetail = $em->getRepository('ApplicationBundle:EmployeeDetails')->findOneBy(
array(
'id' => 3
)
);
// foreach($employeeDetail as $employee){
$employeeData = array(
'firstName' => $employeeDetail->getFirstname(),
'basic' => $employeeDetail->getEar1(),
'dearness' => $employeeDetail->getEar2(),
'houseRent' => $employeeDetail->getEar3(),
'medical' => $employeeDetail->getEar4(),
'leaveTravel' => $employeeDetail->getEar5(),
'childEducation' => $employeeDetail->getEar6(),
'totalEarning' => $employeeDetail->getEart(),
);
$employeeDataDetail = $employeeData;
// }
$attendanceData = $em->getRepository(EmployeeAttendanceLog::class);
// $employeeId = $attendanceData->getEmployeeId();
// $countId = count($employeeId);
$totalPresent = $attendanceData->createQueryBuilder('a')
// Filter by some parameter if you want
->where('a.employeeId = 3')
->andWhere('a.isPresent = 1')
->select('a.isPresent')
->getQuery()
->getResult();
// $countAt = 0;
$count = count($totalPresent);
// $count = $countAt+$count;
//get holiday
$holidayStartDate = $DateRange['startDate']->format('Y-m-d');
$holidayEndDate = $DateRange['endDate']->format('Y-m-d');
$dates = HumanResource::getBetweenDates($holidayStartDate, $holidayEndDate);
$dateCount = count($dates);
$totalOffDay = $totalWeekends + $dateCount;
$totalCompanyWorkingDay = $totalDayOfMonth - $totalOffDay;
$totalAbsent = $totalCompanyWorkingDay - $count;
// foreach($dates as $compDate ){
//
//
//
// if($date == $compDate){
// echo $date;
// echo $compDate;
// echo "holiday" ;
//
// }
// else{
// echo "no holiday" ;
// }
// }
$twigData = HumanResource::twigDataForWorkHourPolicy($em);
return $this->render('ApplicationBundle:pages/human_resource/list:meeting_schedule_list_for_tab.html.twig', array(
'page_title' => 'Meeting Schedule List',
'date' => $date,
'totalWeekends' => $totalWeekends,
'totalCompanyWorkingDay' => $totalCompanyWorkingDay,
// 'attendanceData' => $attendanceData,
// 'employeeId' => $employeeId,
'count' => $count,
'totalAbsent' => $totalAbsent,
'employeeDataDetail' => $employeeDataDetail,
'holiday' => $DateRange,
'holidayStartDate' => $holidayStartDate,
'holidayEndDate' => $holidayEndDate,
'holidayCount' => $dateCount,
'totalOffDay' => $totalOffDay,
'employeeIds' => $twigData['employeeIds'],
));
}
public function getEmployeeDataForDisburseAction($id)
{
$em = $this->getDoctrine()->getManager();
$employeeDetail = $em->getRepository('ApplicationBundle:EmployeeDetails')->find($id);
return new JsonResponse(
array(
'success' => true,
'firstName' => $employeeDetail->getFirstName(),
)
);
}
public function BulkAttendanceAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($request);
if ($request->isMethod('POST')) {
$attendance = [];
foreach ($request->request->get('date') as $key => $val) {
$loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
$bulkAttendance=null;
if($request->request->get('attId')[$key]!=0)
$bulkAttendance = $em->getRepository('ApplicationBundle:EmployeeAttendance')->findOneBy(array(
'id' => $request->request->get('attId')[$key],
));
if(!$bulkAttendance)
$bulkAttendance = new EmployeeAttendance;
$theDate=new \DateTime($request->request->get('date')[$key]);
$bulkAttendance->setEmployeeId($request->request->get('employeeId'));
$bulkAttendance->setDate($theDate);
$bulkAttendance->setEntry(
($request->request->get('startTimeTs')[$key] =='' ||
$request->request->get('startTimeTs')[$key]=='NaN' ||
$request->request->get('startTimeTs')[$key]==0) ?null:
new \DateTime('@'.$request->request->get('startTimeTs')[$key])
);
$bulkAttendance->setLastOut(($request->request->get('endTimeTs')[$key] =='' ||
$request->request->get('endTimeTs')[$key]=='NaN' ||
$request->request->get('endTimeTs')[$key]==0) ?null:
new \DateTime('@'.$request->request->get('endTimeTs')[$key]));
$bulkAttendance->setData(json_encode(
array(
"in"=>json_decode($request->request->get('entryDataIn')[$key],true),
"out"=>json_decode($request->request->get('entryDataOut')[$key],true)
)
));
// $bulkAttendance->setLastStartTime(new \DateTime($request->request->get('startDate')));
// $bulkAttendance->setIsPresent(1);
$bulkAttendance->setLastStartTimeTs($request->request->get('startTimeTs')[$key]);
$bulkAttendance->setLastEndTimeTs($request->request->get('endTimeTs')[$key]);
// $bulkAttendance->setTotalWorkHour($request->request->get('totalWorkHour')[$key]);
$em->persist($bulkAttendance);
$em->flush();
$bulkAttendanceLog = $em->getRepository('ApplicationBundle:EmployeeAttendanceLog')->findOneBy(array(
'attendance_id' => $bulkAttendance->getId(),
));
if(!$bulkAttendanceLog)
$bulkAttendanceLog = new EmployeeAttendanceLog;
$bulkAttendanceLog->setAttendanceId($bulkAttendance->getId());
$bulkAttendanceLog->setEmployeeId($request->request->get('employeeId'));
$bulkAttendanceLog->setLastStartTime(
($request->request->get('startTimeTs')[$key] =='' ||
$request->request->get('startTimeTs')[$key]=='NaN' ||
$request->request->get('startTimeTs')[$key]==0) ?null:
new \DateTime('@'.$request->request->get('startTimeTs')[$key])
);
$bulkAttendanceLog->setLastEndTime(($request->request->get('endTimeTs')[$key] =='' ||
$request->request->get('endTimeTs')[$key]=='NaN' ||
$request->request->get('endTimeTs')[$key]==0) ?null:
new \DateTime('@'.$request->request->get('endTimeTs')[$key]));
// $bulkAttendance->setLastStartTime(new \DateTime($request->request->get('startDate')));
$bulkAttendanceLog->setIsPresent(1);
$bulkAttendanceLog->setLastStartTimeTs($request->request->get('startTimeTs')[$key]);
$bulkAttendanceLog->setLastEndTimeTs($request->request->get('endTimeTs')[$key]);
$bulkAttendanceLog->setTotalWorkHour($request->request->get('totalWorkHour')[$key]);
// $bulkAttendanceLog->setPositionArray(json_encode($request->request->get('locations')[$key]));
$em->persist($bulkAttendanceLog);
$em->flush();
}
}
$startDate=$request->query->get('start_date','');
$endDate=$request->query->get('end_date','');
$employeeId=$request->query->get('employee_id',0);
$existingData=[];
$startDateTs=0;
$endDateTs=0;
$returnData=array(
'page_title' => 'Bulk Attendance',
'existingData' => $existingData,
'startDateTs' => $startDateTs,
'endDateTs' => $endDateTs,
);
if ($request->query->has('returnJson')) {
if($startDate !='' && $endDate !='' && $employeeId!=0)
{
$startDateDt=new \DateTime($startDate);
$endDateDt=new \DateTime($endDate);
$startDateTs=$startDateDt->format('U');
$endDateTs=$endDateDt->format('U');
$attendanceQuery = $em->getRepository('ApplicationBundle:EmployeeAttendance')
->createQueryBuilder('p')
->where("p.employeeId = ".$employeeId)
// ->andWhere("p.date => '" . ($startDateDt->format('Y-m-d'))."'")
->andWhere("p.date <= :last" )
->andWhere("p.date >= :start" )
->setParameter('start', $startDateDt)
->setParameter('last', $endDateDt);
$attendanceResults = $attendanceQuery->getQuery()->getResult();
foreach($attendanceResults as $att)
{
$entryDateTime=null;
$outDateTime=null;
if($att->getEntry()) $entryDateTime=new \DateTime($att->getDate()->format('Y-m-d').' '.$att->getEntry()->format('H:i:00 +0000'));
if($att->getLastOut()) $outDateTime=new \DateTime($att->getDate()->format('Y-m-d').' '.$att->getLastOut()->format('H:i:00 +0000'));
$attData=array(
'id'=>$att->getId(),
'date_str'=>$att->getDate()->format('Y-m-d'),
'date_str_full'=>$att->getDate()->format('Y-m-d H:i:s'),
'in_time_full'=>$entryDateTime?$entryDateTime->format(DATE_RFC2822 ):'',
'date_ts'=>$att->getDate()->format('U'),
'in_time' => $entryDateTime?$entryDateTime->format('H:i:s'):'',
'in_time_ts' => $entryDateTime?$entryDateTime->format('U'):0,
'last_out_time' =>$outDateTime?$outDateTime->format('H:i:s'):'',
'last_out_time_ts' => $outDateTime?$outDateTime->format('U'):'',
);
$locations = [];
$locList = [];
$logHere = $em->getRepository('ApplicationBundle:EmployeeAttendanceLog')->findOneBy(array(
'attendance_id' => $att->getId(),
));
if ($logHere)
$locList = json_decode($logHere->getPositionArray(), true);
if ($locList == null)
$locList = [];
$entry_data = json_decode($att->getData(), true);
if ($entry_data == null) $entry_data = [];
$lastLat = 0;
$lastLng = 0;
foreach ($locList as $lg) {
$dist = 0;
if (isset($lg['lat'])) {
if ($lastLat == 0) {
$lastLat = $lg['lat'];
$lastLng = $lg['lng'];
}
$theta = $lastLng - $lg['lng'];
$dist = sin(deg2rad($lastLat)) * sin(deg2rad($lg['lat'])) + cos(deg2rad($lastLat)) * cos(deg2rad($lg['lat'])) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$dist = $miles * 1609.344;
if (abs($dist) > 1000) {
$locations[] = array(
'ts' => $lg['ts'],
'lat' => $lg['lat'],
'lng' => $lg['lng'],
);
$lastLat = $lg['lat'];
$lastLng = $lg['lng'];
}
}
}
$attData['locations']=$locations;
$attData['entryData']=$entry_data;
$existingData[$att->getDate()->format('U')]=$attData;
}
}
$returnData=array(
'page_title' => 'Bulk Attendance',
'existingData' => $existingData,
'startDateTs' => $startDateTs,
'endDateTs' => $endDateTs,
);
return new JsonResponse($returnData);
}
else
return $this->render('ApplicationBundle:pages/human_resource/attendance:bulk_attendance.html.twig', $returnData);
}
public function CreateAttendanceAmendmentAction(Request $request, $id = 0)
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($request);
$extDocData = [];
if ($request->isMethod('POST') ) {
$em = $this->getDoctrine()->getManager();
$entity_id = array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment']; //change
$dochash = $request->request->get('docHash'); //change
$loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
$approveRole = $request->request->get('approvalRole');
$approveHash = $request->request->get('approvalHash');
if ($dochash == '') {
$numberHash = MiscActions::GetNumberHash($em, 'ATAM', $request->request->get('prefix_hash',$request->request->get('employeeId',0)), $request->request->get('assoc_hash',0), '', 1);
$dochash = 'ATAM' . '/' . $request->request->get('prefix_hash',$request->request->get('employeeId',0)) . '/' . $request->request->get('assoc_hash',0) . '/' . $numberHash;
}
else
$numberHash = $request->request->get('number_hash');
if (!DocValidation::isInsertable($em, $entity_id, $dochash,
$loginId, $approveRole, $approveHash, $id)
) {
if ($request->request->has('returnJson')) {
return new JsonResponse(array(
'success' => false,
'documentHash' => 0,
'documentId' => 0,
));
} else
$this->addFlash(
'error',
'Sorry Could not insert Data.'
);
} else {
$funcname = 'AttendanceAmendment';
$doc_id = $id;
DeleteDocument::$funcname($em, $doc_id, 0);
$attendanceAmendment = new AttendanceAmendment();
$attendanceAmendment->setDocumentHash($dochash);
$attendanceAmendment->setAttendanceAmendmentDate(new \DateTime($request->request->get('docDate','')));
$attendanceAmendment->setStartDate(new \DateTime($request->request->get('startDate','')));
$attendanceAmendment->setEndDate(new \DateTime($request->request->get('endDate','')));
$attendanceAmendment->setTypeHash('ATAM');
$attendanceAmendment->setPrefixHash($request->request->get('prefix_hash',0));
$attendanceAmendment->setAssocHash($request->request->get('assoc_hash',0));
$attendanceAmendment->setNumberHash($numberHash);
$attendanceAmendment->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
$attendanceAmendment->setApproved(array_flip(GeneralConstant::$approvalStatus)['pending']);
$attendanceAmendment->setAutoCreated($request->request->get('fullApprove',0));
$attendanceAmendment->setEmployeeId($request->request->get('forcedEmployeeId',$request->request->get('employeeId',0)));
// $attendanceAmendment->setAutocreated(0);
if ($request->request->has('dataArrayJson')) {
$attendanceAmendment->setData($request->request->get('dataArrayJson', '[]'));
} else {
$arr = [
];
//dump($arr);
foreach ($request->request->get('date',[]) as $key => $val) {
if($request->request->get('isChanged')[$key]==1) {
$dt = array(
'enabled' => 1,
'attId' => $request->request->get('attId')[$key],
'note' => $request->request->get('note')[$key],
'startTimeTs' => $request->request->get('startTimeTs')[$key],
'endTimeTs' => $request->request->get('endTimeTs')[$key],
'totalWorkHour' => $request->request->get('totalWorkHour')[$key],
'entryDataIn' => json_decode($request->request->get('entryDataIn')[$key], true),
'entryDataOut' => json_decode($request->request->get('entryDataOut')[$key], true),
);
$arr[$val] = $dt;
}
}
$attendanceAmendment->setData(json_encode($arr));
}
$em->persist($attendanceAmendment);
$em->flush();
$ID=$attendanceAmendment->getAttendanceAmendmentId();
//now add Approval info
$loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
$approveRole = 1; //created
$options = array(
'notification_enabled' => $this->container->getParameter('notification_enabled'),
'notification_server' => $this->container->getParameter('notification_server'),
'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
'url' => $this->generateUrl(
GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment']]
['entity_view_route_path_name']
)
);
System::setApprovalInfo($this->getDoctrine()->getManager(), $options,
array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
$ID,
$request->getSession()->get(UserConstants::USER_LOGIN_ID) //journal voucher
);
if($request->request->get('fullApprove',0)==1)
{
DeleteDocument::AttendanceAmendment($em,$ID);
}
else {
System::createEditSignatureHash($this->getDoctrine()->getManager(), array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'], $ID,
$loginId,
$approveRole,
$request->request->get('approvalHash'));
$url = $this->generateUrl(
'view_attendance_amendment'
);
if ($request->request->has('returnJson')) {
return new JsonResponse(array(
'success' => true,
'documentHash' => $dochash,
'documentId' => $ID,
'viewUrl' => $url . "/" . $ID,
));
} else {
$this->addFlash(
'success',
'Attendance Amendment Note Added.'
);
return $this->redirect($url . "/" . $ID);
}
}
}
}
if ($id == 0) {
}
else {
$extDoc = $em->getRepository('ApplicationBundle:AttendanceAmendment')->findOneBy(
array(
'salesOrderId' => $id, ///material
)
);
//now if its not editable, redirect to view
if ($extDoc) {
if ($extDoc->getEditFlag() != 1) {
$url = $this->generateUrl(
'view_attendance_amendment'
);
return $this->redirect($url . "/" . $id);
} else {
$extDocData = $extDoc;
}
} else {
}
}
$startDate=$request->query->get('start_date','');
$endDate=$request->query->get('end_date','');
$employeeId=$request->query->get('employee_id',0);
$existingData=[];
$startDateTs=0;
$endDateTs=0;
$returnData=array(
'page_title' => 'Attendance Amendment',
'existingData' => $existingData,
'startDateTs' => $startDateTs,
'extDocData' => $extDocData,
'endDateTs' => $endDateTs,
);
if ($request->query->has('returnJson')) {
if($startDate !='' && $endDate !='' && $employeeId!=0)
{
$startDateDt=new \DateTime($startDate);
$endDateDt=new \DateTime($endDate);
$startDateTs=$startDateDt->format('U');
$endDateTs=$endDateDt->format('U');
$attendanceQuery = $em->getRepository('ApplicationBundle:EmployeeAttendance')
->createQueryBuilder('p')
->where("p.employeeId = ".$employeeId)
// ->andWhere("p.date => '" . ($startDateDt->format('Y-m-d'))."'")
->andWhere("p.date <= :last" )
->andWhere("p.date >= :start" )
->setParameter('start', $startDateDt)
->setParameter('last', $endDateDt);
$attendanceResults = $attendanceQuery->getQuery()->getResult();
foreach($attendanceResults as $att)
{
$entryDateTime=null;
$outDateTime=null;
if($att->getEntry()) $entryDateTime=new \DateTime($att->getDate()->format('Y-m-d').' '.$att->getEntry()->format('H:i:00 +0000'));
if($att->getLastOut()) $outDateTime=new \DateTime($att->getDate()->format('Y-m-d').' '.$att->getLastOut()->format('H:i:00 +0000'));
$attData=array(
'id'=>$att->getId(),
'date_str'=>$att->getDate()->format('Y-m-d'),
'date_str_full'=>$att->getDate()->format('Y-m-d H:i:s'),
'in_time_full'=>$entryDateTime?$entryDateTime->format(DATE_RFC2822 ):'',
'date_ts'=>$att->getDate()->format('U'),
'in_time' => $entryDateTime?$entryDateTime->format('H:i:s'):'',
'in_time_ts' => $entryDateTime?$entryDateTime->format('U'):0,
'last_out_time' =>$outDateTime?$outDateTime->format('H:i:s'):'',
'last_out_time_ts' => $outDateTime?$outDateTime->format('U'):'',
);
$locations = [];
$locList = [];
$logHere = $em->getRepository('ApplicationBundle:EmployeeAttendanceLog')->findOneBy(array(
'attendance_id' => $att->getId(),
));
if ($logHere)
$locList = json_decode($logHere->getPositionArray(), true);
if ($locList == null)
$locList = [];
$entry_data = json_decode($att->getData(), true);
if ($entry_data == null) $entry_data = [];
$lastLat = 0;
$lastLng = 0;
foreach ($locList as $lg) {
$dist = 0;
if (isset($lg['lat'])) {
if ($lastLat == 0) {
$lastLat = $lg['lat'];
$lastLng = $lg['lng'];
}
$theta = $lastLng - $lg['lng'];
$dist = sin(deg2rad($lastLat)) * sin(deg2rad($lg['lat'])) + cos(deg2rad($lastLat)) * cos(deg2rad($lg['lat'])) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$dist = $miles * 1609.344;
if (abs($dist) > 1000) {
$locations[] = array(
'ts' => $lg['ts'],
'lat' => $lg['lat'],
'lng' => $lg['lng'],
);
$lastLat = $lg['lat'];
$lastLng = $lg['lng'];
}
}
}
$attData['locations']=$locations;
$attData['entryData']=$entry_data;
$existingData[$att->getDate()->format('U')]=$attData;
}
}
$returnData=array(
'page_title' => 'Attendance Amendment',
'existingData' => $existingData,
'startDateTs' => $startDateTs,
'extDocData' => $extDocData,
'endDateTs' => $endDateTs,
);
return new JsonResponse($returnData);
}
else
return $this->render('ApplicationBundle:pages/human_resource/attendance:create_attendance_amendment.html.twig', $returnData);
}
public function AttendanceAmendmentListAction(Request $request)
{
$data = [];
return $this->render('ApplicationBundle:pages/human_resource/list:attendance_amendment_list.html.twig',
array(
'page_title' => 'Attendance Amendment List',
'data' => $data
)
);
}
public function ViewAttendanceAmendmentAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$dt = HumanResource::GetAttendanceAmendmentDetails($em, $id);
return $this->render('ApplicationBundle:pages/human_resource/views:view_attendance_amendment.html.twig',
array(
'page_title' => 'Attendance Amendment',
'data' => $dt,
'approval_data' => System::checkIfApprovalExists($em, array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
$id, $request->getSession()->get(UserConstants::USER_LOGIN_ID)),
'document_log' => System::getDocumentLog($this->getDoctrine()->getManager(),
array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
$id,
$dt['created_by'],
$dt['edited_by'])
)
);
}
public function PrintAttendanceAmendmentAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$dt = HumanResource::GetAttendanceAmendmentDetails($em, $id);
$company_data = Company::getCompanyData($em, 1);
$document_mark = array(
'original' => '/images/Original-Stamp-PNG-Picture.png',
'copy' => ''
);
if ($request->query->has('pdf') && $this->get('knp_snappy.pdf')) {
$html = $this->renderView('ApplicationBundle:pages/inventory/print:print_stock_received_note.html.twig',
array(
//full array here
'pdf' => true,
'page_title' => 'Stock Received Note',
'export' => 'pdf,print',
'data' => $dt,
'approval_data' => System::checkIfApprovalExists($em, array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
$id, $request->getSession()->get(UserConstants::USER_LOGIN_ID)),
'document_log' => System::getDocumentLog($this->getDoctrine()->getManager(),
array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
$id,
$dt['created_by'],
$dt['edited_by']),
'document_mark_image' => $document_mark['original'],
'company_name' => $company_data->getName(),
'company_data' => $company_data,
'company_address' => $company_data->getAddress(),
'company_image' => $company_data->getImage(),
'invoice_footer' => $company_data->getInvoiceFooter(),
'red' => 0
)
);
$pdf_response = $this->get('knp_snappy.pdf')->getOutputFromHtml($html, array(
// 'orientation' => 'landscape',
// 'enable-javascript' => true,
// 'javascript-delay' => 1000,0
'no-stop-slow-scripts' => false,
'no-background' => false,
'lowquality' => false,
'encoding' => 'utf-8',
// 'images' => true,
// 'cookie' => array(),
'dpi' => 300,
'image-dpi' => 300,
// 'enable-external-links' => true,
// 'enable-internal-links' => true
));
return new Response(
$pdf_response,
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="stock_received_note_' . $id . '.pdf"'
)
);
}
return $this->render('ApplicationBundle:pages/human_resource/views:view_attendance_amendment.html.twig',
array(
'page_title' => 'Attendance Amendment',
'data' => $dt,
'approval_data' => System::checkIfApprovalExists($em, array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
$id, $request->getSession()->get(UserConstants::USER_LOGIN_ID)),
'document_log' => System::getDocumentLog($this->getDoctrine()->getManager(),
array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
$id,
$dt['created_by'],
$dt['edited_by'])
)
);
}
public function createRoomAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$companyId = $this->getLoggedUserCompanyId($request);
if ($request->isMethod('POST')) {
$loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
$room = new Room;
$room->setRoomNo($request->request->get('RoomNo'));
//$room->setRoomName($request->request->get('RoomName'));
$room->setBuilding($request->request->get('buildingName'));
$room->setFloor($request->request->get('floor'));
$room->setCapacity($request->request->get('capacity'));
$room->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
$em->persist($room);
$em->flush();
}
return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_room.html.twig', array(
'page_title' => 'Add Room',
));
}
public function ExpenseTypeAction()
{
$expenseType = HumanResourceConstant::$employeeExpenseAllowanceTypes;
$expenseTypeArray = [];
foreach ($expenseType as $k => $dt) {
$dt['id'] = $k;
$newSegs = [];
foreach ($dt['segregations'] as $l => $s) {
$newOptions = [];
foreach ($s['options'] as $l2 => $s2) {
$s3 = array(
'value' => $l2,
'text' => $s2,
);
$newOptions[] = $s3;
}
$s['options'] = $newOptions;
if (is_string($s['defaultVal'])) $s['defaultVal'] = [$s['defaultVal']];
$newSegs[] = $s;
}
$dt['segregations'] = $newSegs;
$expenseTypeArray[] = $dt;
}
return new JsonResponse(
array(
'success' => true,
'expenseType' => $expenseType,
'expenseTypeArray' => $expenseTypeArray,
)
);
}
public function DemoDataTableAction()
{
return $this->render('ApplicationBundle:pages/human_resource/list:demo_data_table.html.twig', array(
'page_title' => 'Add Room',
));
}
public function workEnrtyAction(Request $request)
{
// $em = $this->getDoctrine()->getManager();
// $companyId = $this->getLoggedUserCompanyId($request);
// if ($request->isMethod('POST')) {
// $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
// $labour = new Labour();
// $labour->setLabourName($request->request->get('labourName'));
// $labour->setNidNumber($request->request->get('nidNumber'));
// $em->persist($labour);
// $em->flush();
// $this->addFlash(
// 'success',
// 'Labour Added'
// );
// }
return $this->render('ApplicationBundle:pages/human_resource/input_forms:work_entry.html.twig', array(
'page_title' => 'Work Entry',
));
}
public function ViewContractLetterAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$employeeDetail = $em->getRepository('ApplicationBundle:EmployeeDetails')->find($id);
// $employeeData = [];
// foreach ($employeeDetails as $employeeDetail) {
// $data = array(
// 'firstName' => $employeeDetail->getNid(),
//
//
//
// );
//
//
// $employeeData[] = $data;
// }
return $this->render('ApplicationBundle:pages/human_resource/views:viewContractLetter.html.twig', array(
'page_title' => 'Contract Letter',
'employeeDetail' => $employeeDetail
));
}
}