public function testCallGetCorporateDirectoryEmployeeDetailsMethod()
 {
     TestDataService::populate($this->fixture);
     $employeeService = new EmployeeService();
     $empPicture = $employeeService->getEmployeePicture(2);
     $base64TestStringForEmp1 = 'R0lGODlhCgAKALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD//////ywAAAAACgAKAAAEClDJSau9OOvNe44AOw==';
     $decodedBase64String = base64_decode($base64TestStringForEmp1);
     $empPicture->setPicture($decodedBase64String);
     $empPicture->save();
     $empPicture = $employeeService->getEmployeePicture(3);
     $base64TestStringForEmp2 = '/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBwgHBgkIBwgKCgkLDRYPDQwMDRsUFRAWIB0iIiAdHx8kKDQsJCYxJx8fLT0tMTU3Ojo6Iys/RD84QzQ5OjcBCgoKDQwNGg8PGjclHyU3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3N//AABEIAHcAdwMBEQACEQEDEQH/xAAbAAEBAQEAAwEAAAAAAAAAAAAABAUGAQIDB//EAD8QAAEDAwAEBw8DAwUAAAAAAAECAwQABREGEiGTExQVMTNBUSIyNVNUZHFzdIGxsrPR4QdhciORoSQ0UmKC/8QAGAEBAQEBAQAAAAAAAAAAAAAAAAQDAQL/xAAqEQEAAQIDCAMBAAMBAAAAAAAAAQIDBBOxMTNRYnGBkcERFKEhImHREv/aAAwDAQACEQMRAD8A/bq6FAoFAoFAoMuBf4NwvEu2RFKcciNpW44kdxtUpOqD1kFBz2c3PmuC96VHYU2l99ptTh1UBawkqPYM85oPRU6IlwtqlMBwAkoLgBAHOcZ6qD6sutvtpcZcQ42ralaFZB99dHvQKBQKBQKBQZV40lsdkBN2usSKf+Djo1j6E85/tQR6PaY2fSBpyRAeIiJOql9/DQcPXqpUdbZ2kAf5rg1+UoHl0XfJ+9dDlKB5dF3yfvQYzLrCNMZlwMqKIrltY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U36JenLmlq3pk2t6HEtjcnhUFxaSOEcXgDO0AY6qBedF7lM/S2Ho6ylnlBmPEbUCvCMtqQVbf8AyaDW0rs8u6ztHnooQUQLmiS9rKx3ASoHHadtB0VdCgUENk8HJ9Y79RVb4nedo0hTi972jSF1YJkN98CXH2V35TQWN9Gn+I+FBLbukm+0n5U1rd2UdPcqL+yjp7lZWScoFAoFAoFAoFAoIbJ4OT6x36iq3xO87RpCnF73tGkLqwTIb74DuPsrvymgsb6NP8R8KCW3dJN9pPyprW7so6e5UX9lHT3Kysk5QKBQKBQKBQKBQQ2Twcn1jv1FVvid52jSFOL3vaNIXVgmZ9+dQm0TW1LSFuRnQhJO1RCCdnbXBWw824FIbWlSm8JWEnOqrAOD++CD766Phbukm+0n5U1rd2UdPcqL+yjp7lZWScoFAoFAoFAoFAoIbJ4OT6x36iq3xO87RpCnF73tGkLqwTOR/Va3uztBriuItbcqGnjTS0EhSSjacelOsPfXBX+ntudtmhtsalKWuU61xiQpZyouOHXVk++g17d0k32k/Kmtruyjp7lvfn+UdPcrKxYFAoFAoFAoFAoHNQQ2Twcn1jv1FVRid52jSFOL3vaNIXVgmejzTb7LjLyAttxJStJ5lA7CKD2AATqgYAGMCgmVb4qnFuFrulnKiFEZPuNaReriPj5bRiLkRERP8g5OieLO8V967n3OOjv2bvH8g5OieLO8V96Z9zjofZu8fyDk6J4s7xX3pn3OOh9m7x/IOTonizvFfemfc46H2bvH8g5OieLO8V96Z9zjofZu8fyDk6J4s7xX3pn3OOh9m7x/IOTonizvFfemfc46H2bvH8g5OieLO8V96Z9zjofZu8fyDk6J4s7xX3pn3OOh9m7x/IeOTYni1bxX3pn3OOh9i5x/IfdhluO0lplAQ2nmSKzqqmqfmWVddVdX/qqfmX//2Q==';
     $decodedBase64String = base64_decode($base64TestStringForEmp2);
     $empPicture->setPicture($decodedBase64String);
     $empPicture->save();
     $paramObj = new WSRequestParameters();
     $paramObj->setAppId(1);
     $paramObj->setAppToken('1234567890');
     $paramObj->setMethod('getCorporateDirectoryEmployeeDetails');
     $paramObj->setSessionToken(uniqid('ohrm_ws_session_'));
     $paramObj->setParameters(array('includeTerminate' => 0));
     $paramObj->setRequestMethod('GET');
     $result = $this->manager->callMethod($paramObj);
     $this->assertNotNull($result);
     $this->assertEquals(6, count($result));
     $expectedEmployeeList = $this->getExpectedEmployeeList($base64TestStringForEmp1, $base64TestStringForEmp2);
     foreach ($expectedEmployeeList as $key => $testCase) {
         $this->assertEquals($result[$key], $expectedEmployeeList[$key]);
     }
 }
 protected function setUp()
 {
     TestDataService::truncateSpecificTables(array('Employee', 'Leave', 'LeaveRequest', 'LeaveType', 'EmployeeLeaveEntitlement', 'LeavePeriod'));
     // Save leave type
     $leaveTypeData = sfYaml::load(sfConfig::get('sf_plugins_dir') . '/orangehrmCoreLeavePlugin/test/fixtures/leaveType.yml');
     $leaveTypeDao = new LeaveTypeDao();
     $leaveType = new LeaveType();
     $leaveType->setLeaveTypeName($leaveTypeData['leaveType']['LT_001']['name']);
     //                $leaveType->setLeaveRules($leaveTypeData['leaveType']['LT_001']['rule']);
     $leaveTypeDao->saveLeaveType($leaveType);
     $this->leaveType = $leaveType;
     $this->leaveTypeId = $leaveType->getLeaveTypeId();
     // Save leave Period
     $leavePeriodData = sfYaml::load(sfConfig::get('sf_plugins_dir') . '/orangehrmCoreLeavePlugin/test/fixtures/leavePeriod.yml');
     $leavePeriodService = new LeavePeriodService();
     $leavePeriodService->setLeavePeriodDao(new LeavePeriodDao());
     $leavePeriod = new LeavePeriod();
     $leavePeriod->setStartDate($leavePeriodData['leavePeriod']['1']['startDate']);
     $leavePeriod->setEndDate($leavePeriodData['leavePeriod']['1']['endDate']);
     $leavePeriodService->saveLeavePeriod($leavePeriod);
     $this->leavePeriod = $leavePeriod;
     $this->leavePeriodId = $leavePeriod->getLeavePeriodId();
     // Save Employee
     $employeeservice = new EmployeeService();
     $this->employee = new Employee();
     $employeeservice->saveEmployee($this->employee);
     $this->empNumber = $this->employee->getEmpNumber();
     // save leave quota
     $this->leaveEntitlement = sfYaml::load(sfConfig::get('sf_plugins_dir') . '/orangehrmCoreLeavePlugin/test/fixtures/leaveEntitlement.yml');
     $this->leaveEntitlementDao = new LeaveEntitlementDao();
 }
 /**
  * Delete employee memberships
  *
  * @param int $empNumber Employee number
  *
  * @return boolean true if successfully deleted, false otherwise
  */
 public function execute($request)
 {
     $empNumber = $request->getParameter('empNumber', false);
     $this->form = new EmployeeMembershipsDeleteForm(array(), array('empNumber' => $empNumber), true);
     $this->form->bind($request->getParameter($this->form->getName()));
     $membershipPermissions = $this->getDataGroupPermissions('membership', $empNumber);
     if ($membershipPermissions->canDelete()) {
         if ($this->form->isValid()) {
             if (!$empNumber) {
                 throw new PIMServiceException("No Employee ID given");
             }
             $selectedRecordIds = $request->getParameter('chkmemdel', array());
             if (count($selectedRecordIds) > 0) {
                 $membershipDetails = $this->_getSelectedMembershipDetails($request->getParameter('chkmemdel', array()));
                 $empNumber = $membershipDetails[0];
                 $membershipIds = $membershipDetails[1];
                 if (!empty($empNumber) && !empty($membershipIds)) {
                     $service = new EmployeeService();
                     $service->deleteEmployeeMemberships($empNumber, $membershipIds);
                     $this->getUser()->setFlash('memberships.success', __(TopLevelMessages::DELETE_SUCCESS));
                 }
             }
         }
     }
     $this->redirect('pim/viewMemberships?empNumber=' . $empNumber);
 }
 public function testBulkAssignLeaveEntitlements()
 {
     $this->fixture = sfConfig::get('sf_plugins_dir') . '/orangehrmLeavePlugin/test/fixtures/LeaveEntitlement.yml';
     TestDataService::populate($this->fixture);
     $dao = new LeaveEntitlementDao();
     $limit = 5000;
     $empList = array();
     $employeeService = new EmployeeService();
     $employeeService->setEmployeeDao(new EmployeeDao());
     for ($i = 0; $i < $limit; $i++) {
         $employee = new Employee();
         $employee->setFirstName($i);
         $employee = $employeeService->saveEmployee($employee);
         array_push($empList, $employee->getEmpNumber());
     }
     $start_time = microtime(true);
     $leaveEntitlement = new LeaveEntitlement();
     $leaveEntitlement->setLeaveTypeId(1);
     $leaveEntitlement->setCreditedDate(date('Y-m-d'));
     $leaveEntitlement->setEntitlementType(LeaveEntitlement::ENTITLEMENT_TYPE_ADD);
     $leaveEntitlement->setDeleted(0);
     $leaveEntitlement->setNoOfDays(2);
     $leaveEntitlement->setFromDate('2012-01-01');
     $leaveEntitlement->setToDate('2012-08-01');
     $result = $dao->bulkAssignLeaveEntitlements($empList, $leaveEntitlement);
     $deference = microtime(true) - $start_time;
     $this->assertEquals(count($empList), $result, "Time Deference - " . $deference);
     echo "Add Entitlement 5000 Time " . $deference;
 }
 public function setReportCriteriaInfoInRequest($formValues)
 {
     $employeeService = new EmployeeService();
     $jobService = new JobService();
     $empStatusService = new EmploymentStatusService();
     $companyStructureService = new CompanyStructureService();
     if (isset($formValues["employee"])) {
         $empNumber = $formValues["employee"];
         $employee = $employeeService->getEmployee($empNumber);
         $empName = $employee->getFirstAndLastNames();
         $this->getRequest()->setParameter('empName', $empName);
     }
     if (isset($formValues["employment_status"]) && $formValues["employment_status"] != 0) {
         $estatCode = $formValues["employment_status"];
         $estat = $empStatusService->getEmploymentStatusById($estatCode);
         $estatName = $estat->getName();
         $this->getRequest()->setParameter("empStatusName", $estatName);
     }
     if (isset($formValues["job_title"]) && $formValues["job_title"] != 0) {
         $jobTitCode = $formValues["job_title"];
         $jobTitle = $jobService->readJobTitle($jobTitCode);
         $jobTitName = $jobTitle->getJobTitName();
         $this->getRequest()->setParameter("jobTitName", $jobTitName);
     }
     if (isset($formValues["sub_unit"]) && $formValues["job_title"] != 0) {
         $value = $formValues["sub_unit"];
         $id = $value;
         $subunit = $companyStructureService->getSubunitById($id);
         $subUnitName = $subunit->getName();
         $this->getRequest()->setParameter("subUnit", $subUnitName);
     }
     $this->getRequest()->setParameter('attendanceDateRangeFrom', $formValues["attendance_date_range"]["from"]);
     $this->getRequest()->setParameter('attendanceDateRangeTo', $formValues["attendance_date_range"]["to"]);
 }
 public function execute($request)
 {
     $loggedInEmpNum = $this->getUser()->getEmployeeNumber();
     $loggedInUserName = $_SESSION['fname'];
     $job = $request->getParameter('job');
     $empNumber = isset($job['emp_number']) ? $job['emp_number'] : $request->getParameter('empNumber');
     /*
      * TODO: $empNumber gets empty when uploaded file size exceeds PHP max upload size.
      * Check for a better solution.
      */
     if (empty($empNumber)) {
         $this->getUser()->setFlash('templateMessage', array('warning', __(TopLevelMessages::FILE_SIZE_SAVE_FAILURE)));
         $this->redirect($request->getReferer());
     }
     $this->empNumber = $empNumber;
     $this->jobInformationPermission = $this->getDataGroupPermissions('job_details', $empNumber);
     $this->ownRecords = $loggedInEmpNum == $empNumber ? true : false;
     if (!$this->IsActionAccessible($empNumber)) {
         $this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action'));
     }
     if ($this->getUser()->hasFlash('templateMessage')) {
         list($this->messageType, $this->message) = $this->getUser()->getFlash('templateMessage');
     }
     $employee = $this->getEmployeeService()->getEmployee($empNumber);
     $param = array('empNumber' => $empNumber, 'ESS' => $this->essMode, 'employee' => $employee, 'loggedInUser' => $loggedInEmpNum, 'loggedInUserName' => $loggedInUserName);
     $this->form = new EmployeeJobDetailsForm(array(), $param, true);
     $this->employeeState = $employee->getState();
     if ($loggedInEmpNum == $empNumber) {
         $this->allowActivate = FALSE;
         $this->allowTerminate = FALSE;
     } else {
         $allowedActions = $this->getContext()->getUserRoleManager()->getAllowedActions(WorkflowStateMachine::FLOW_EMPLOYEE, $this->employeeState);
         $this->allowActivate = in_array(WorkflowStateMachine::EMPLOYEE_ACTION_REACTIVE, $allowedActions);
         $this->allowTerminate = in_array(WorkflowStateMachine::EMPLOYEE_ACTION_TERMINATE, $allowedActions);
     }
     $paramForTerminationForm = array('empNumber' => $empNumber, 'employee' => $employee, 'allowTerminate' => $this->allowTerminate, 'allowActivate' => $this->allowActivate);
     $this->employeeTerminateForm = new EmployeeTerminateForm(array(), $paramForTerminationForm, true);
     if ($this->getRequest()->isMethod('post')) {
         // Handle the form submission
         $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
         if ($this->form->isValid()) {
             // save data
             if ($this->jobInformationPermission->canUpdate()) {
                 $service = new EmployeeService();
                 $service->saveEmployee($this->form->getEmployee(), false);
             }
             $this->form->updateAttachment();
             $this->getUser()->setFlash('templateMessage', array('success', __(TopLevelMessages::UPDATE_SUCCESS)));
         } else {
             $validationMsg = '';
             foreach ($this->form->getWidgetSchema()->getPositions() as $widgetName) {
                 if ($this->form[$widgetName]->hasError()) {
                     $validationMsg .= $this->form[$widgetName]->getError()->getMessageFormat();
                 }
             }
             $this->getUser()->setFlash('templateMessage', array('warning', $validationMsg));
         }
         $this->redirect('pim/viewJobDetails?empNumber=' . $empNumber);
     }
 }
 public function configure()
 {
     // Note: Widget names were kept from old non-symfony version
     $this->setWidgets(array('txtEmployeeId' => new sfWidgetFormInputText(), 'txtEmpFirstName' => new sfWidgetFormInputText(), 'txtEmpMiddleName' => new sfWidgetFormInputText(), 'txtEmpLastName' => new sfWidgetFormInputText(), 'txtEmpNickName' => new sfWidgetFormInputText(), 'MAX_FILE_SIZE' => new sfWidgetFormInputHidden(), 'photofile' => new sfWidgetFormInputFile()));
     $employeeService = new EmployeeService();
     $this->setDefault('txtEmployeeId', $employeeService->getDefaultEmployeeId());
     $this->setValidators(array('txtEmployeeId' => new sfValidatorString(array('required' => false)), 'txtEmpFirstName' => new sfValidatorString(array('required' => true), array('required' => 'First Name Empty!')), 'txtEmpMiddleName' => new sfValidatorString(array('required' => false)), 'txtEmpLastName' => new sfValidatorString(array('required' => true), array('required' => 'Last Name Empty!')), 'txtEmpNickName' => new sfValidatorString(array('required' => false)), 'MAX_FILE_SIZE' => new sfValidatorString(array('required' => true)), 'photofile' => new sfValidatorFile(array('required' => false))));
 }
Example #8
0
 /**
  * Get Employee List As Json
  * This function should be available in EmployeeService, not here
  * Due to backward compatibility temporarily its made available. referencing places need to be pointed to employee service
  * and this should be removed
  */
 public function getEmployeeListAsJson()
 {
     try {
         $employeeService = new EmployeeService();
         return $employeeService->getEmployeeListAsJson();
     } catch (Exception $e) {
         throw new AdminServiceException($e->getMessage());
     }
 }
 public function getEmployeeName($employeeId)
 {
     $employeeService = new EmployeeService();
     $employee = $employeeService->getEmployee($employeeId);
     if ($employee->getMiddleName() != null) {
         return $employee->getFirstName() . " " . $employee->getMiddleName() . " " . $employee->getLastName();
     } else {
         return $employee->getFirstName() . " " . $employee->getLastName();
     }
 }
Example #10
0
 public function getProjectAdminListAsJson()
 {
     $jsonArray = array();
     $employeeService = new EmployeeService();
     $employeeService->setEmployeeDao(new EmployeeDao());
     $employeeList = $employeeService->getEmployeeList();
     foreach ($employeeList as $employee) {
         $jsonArray[] = array('name' => $employee->getFullName(), 'id' => $employee->getEmpNumber());
     }
     $jsonString = json_encode($jsonArray);
     return $jsonString;
 }
Example #11
0
 public function getSupervisorListAsJson()
 {
     $jsonArray = array();
     $employeeService = new EmployeeService();
     $employeeService->setEmployeeDao(new EmployeeDao());
     $employeeList = $employeeService->getSupervisorList();
     foreach ($employeeList as $employee) {
         $name = $employee->getFirstName() . " " . $employee->getMiddleName();
         $name = trim(trim($name) . " " . $employee->getLastName());
         $jsonArray[] = array('name' => $name, 'id' => $employee->getEmpNumber());
     }
     $jsonString = json_encode($jsonArray);
     return $jsonString;
 }
 public function getEmployeeListAsJson()
 {
     $jsonArray = array();
     $employeeService = new EmployeeService();
     $employeeService->setEmployeeDao(new EmployeeDao());
     $employeeUnique = array();
     foreach ($this->employeeList as $employee) {
         if (!isset($employeeUnique[$employee->getEmpNumber()])) {
             $name = $employee->getFullName();
             $employeeUnique[$employee->getEmpNumber()] = $name;
             $jsonArray[] = array('name' => $name, 'id' => $employee->getEmpNumber());
         }
     }
     $jsonString = json_encode($jsonArray);
     return $jsonString;
 }
 public function execute($request)
 {
     $jsonArray = array();
     $employeeService = new EmployeeService();
     $employeeService->setEmployeeDao(new EmployeeDao());
     $employeeList = $employeeService->getSubordinateListForEmployee($request->getGetParameter('id'));
     foreach ($employeeList as $subordinate) {
         $employee = $subordinate->getSubordinate();
         $name = $employee->getFirstName() . " " . $employee->getMiddleName();
         $name = trim(trim($name) . " " . $employee->getLastName());
         $jsonArray[] = array('name' => $name, 'id' => $employee->getEmpNumber());
     }
     $jsonString = json_encode($jsonArray);
     echo $jsonString;
     exit;
 }
 public function execute($request)
 {
     $loggedInEmpNum = $this->getUser()->getEmployeeNumber();
     $loggedInUserName = $_SESSION['fname'];
     $job = $request->getParameter('job');
     $empNumber = isset($job['emp_number']) ? $job['emp_number'] : $request->getParameter('empNumber');
     $this->empNumber = $empNumber;
     $this->ownRecords = $loggedInEmpNum == $empNumber ? true : false;
     $this->allowEdit = $this->isAllowedAdminOnlyActions($loggedInEmpNum, $empNumber);
     $adminMode = $this->getUser()->hasCredential(Auth::ADMIN_ROLE);
     if (!$this->IsActionAccessible($empNumber)) {
         $this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action'));
     }
     $this->essMode = !$adminMode && !empty($loggedInEmpNum) && $empNumber == $loggedInEmpNum;
     if ($this->getUser()->hasFlash('templateMessage')) {
         list($this->messageType, $this->message) = $this->getUser()->getFlash('templateMessage');
     }
     $employee = $this->getEmployeeService()->getEmployee($empNumber);
     $param = array('empNumber' => $empNumber, 'ESS' => $this->essMode, 'employee' => $employee, 'loggedInUser' => $loggedInEmpNum, 'loggedInUserName' => $loggedInUserName);
     $paramForTerminationForm = array('empNumber' => $empNumber, 'employee' => $employee);
     $this->form = new EmployeeJobDetailsForm(array(), $param, true);
     $this->employeeTerminateForm = new EmployeeTerminateForm(array(), $paramForTerminationForm, true);
     if ($this->getRequest()->isMethod('post')) {
         if (!$this->allowEdit) {
             $this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action'));
         }
         // Handle the form submission
         $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
         if ($this->form->isValid()) {
             // save data
             $service = new EmployeeService();
             $service->saveJobDetails($this->form->getEmployee(), false);
             $this->form->updateAttachment();
             $this->getUser()->setFlash('templateMessage', array('success', __(TopLevelMessages::UPDATE_SUCCESS)));
         } else {
             $validationMsg = '';
             foreach ($this->form->getWidgetSchema()->getPositions() as $widgetName) {
                 if ($this->form[$widgetName]->hasError()) {
                     $validationMsg .= $this->form[$widgetName]->getError()->getMessageFormat();
                 }
             }
             $this->getUser()->setFlash('templateMessage', array('warning', $validationMsg));
         }
         $this->redirect('pim/viewJobDetails?empNumber=' . $empNumber);
     }
 }
Example #15
0
 public function getProjectAdminListAsJson()
 {
     $jsonArray = array();
     $employeeService = new EmployeeService();
     $employeeService->setEmployeeDao(new EmployeeDao());
     $properties = array("empNumber", "firstName", "middleName", "lastName", 'termination_id');
     $employeeList = $employeeService->getEmployeePropertyList($properties, 'empNumber', 'ASC');
     foreach ($employeeList as $employee) {
         $name = trim(trim($employee['firstName'] . ' ' . $employee['middleName'], ' ') . ' ' . $employee['lastName']);
         if ($employee['termination_id']) {
             $name = $name . ' (' . __('Past Employee') . ')';
         }
         $jsonArray[] = array('name' => $name, 'id' => $employee['empNumber']);
     }
     $jsonString = json_encode($jsonArray);
     return $jsonString;
 }
 /**
  * Delete employee memberships
  *
  * @param int $empNumber Employee number
  *
  * @return boolean true if successfully deleted, false otherwise
  */
 public function execute($request)
 {
     $empNumber = $request->getParameter('empNumber', false);
     $this->form = new EmployeeReportToSupervisorDeleteForm(array(), array('empNumber' => $empNumber), true);
     $this->form->bind($request->getParameter($this->form->getName()));
     if ($this->form->isValid()) {
         if (!$empNumber) {
             throw new PIMServiceException("No Employee ID given");
         }
         $supToDelete = $request->getParameter('chksupdel', array());
         if ($supToDelete) {
             $service = new EmployeeService();
             $count = $service->deleteReportToObject($supToDelete);
             $this->getUser()->setFlash('templateMessage', array('success', __(TopLevelMessages::DELETE_SUCCESS)));
         }
     }
     $this->redirect('pim/viewReportToDetails?empNumber=' . $empNumber);
 }
 public function execute($request)
 {
     $userObj = $this->getContext()->getUser()->getAttribute('user');
     $employeeIdOfTheUser = $userObj->getEmployeeNumber();
     $this->backAction = $request->getParameter('actionName');
     $this->timesheetId = $request->getParameter('timesheetId');
     $this->employeeId = $request->getParameter('employeeId');
     if ($this->employeeId == $employeeIdOfTheUser) {
         $this->employeeName == null;
     } else {
         $employeeService = new EmployeeService();
         $employee = $employeeService->getEmployee($this->employeeId);
         $this->employeeName = $employee->getFirstName() . " " . $employee->getLastName();
     }
     $timesheet = $this->getTimesheetService()->getTimesheetById($this->timesheetId);
     $this->date = $timesheet->getStartDate();
     $this->endDate = $timesheet->getEndDate();
     $this->startDate = $this->date;
     $this->noOfDays = $this->timesheetService->dateDiff($this->startDate, $this->endDate);
     $values = array('date' => $this->startDate, 'employeeId' => $this->employeeId, 'timesheetId' => $this->timesheetId, 'noOfDays' => $this->noOfDays);
     $this->timesheetForm = new TimesheetForm(array(), $values);
     $this->currentWeekDates = $this->timesheetForm->getDatesOfTheTimesheetPeriod($this->startDate, $this->endDate);
     $this->timesheetItemValuesArray = $this->timesheetForm->getTimesheet($this->startDate, $this->employeeId, $this->timesheetId);
     $this->messageData = array($request->getParameter('message[0]'), $request->getParameter('message[1]'));
     if ($this->timesheetItemValuesArray == null) {
         $this->totalRows = 0;
         $this->timesheetForm = new TimesheetForm(array(), $values);
     } else {
         $this->totalRows = sizeOf($this->timesheetItemValuesArray);
         $this->timesheetForm = new TimesheetForm(array(), $values);
     }
     if ($request->isMethod('post')) {
         if ($request->getParameter('btnSave')) {
             $backAction = $this->backAction;
             $this->getTimesheetService()->saveTimesheetItems($request->getParameter('initialRows'), $this->employeeId, $this->timesheetId, $this->currentWeekDates, $this->totalRows);
             $this->messageData = array('SUCCESS', __(TopLevelMessages::SAVE_SUCCESS));
             $startingDate = $this->timesheetService->getTimesheetById($this->timesheetId)->getStartDate();
             $this->redirect('time/' . $backAction . '?' . http_build_query(array('message' => $this->messageData, 'timesheetStartDate' => $startingDate, 'employeeId' => $this->employeeId)));
         }
         if ($request->getParameter('buttonRemoveRows')) {
             $this->messageData = array('SUCCESS', __('Successfully Removed'));
         }
     }
 }
 public function getEmployeeListAsJson()
 {
     $jsonArray = array();
     $employeeService = new EmployeeService();
     $employeeService->setEmployeeDao(new EmployeeDao());
     $employeeService instanceof EmployeeService;
     $employeeList = $employeeService->getEmployeePropertyList(array('empNumber', 'firstName', 'lastName', 'middleName', 'termination_id'), 'lastName', 'ASC');
     $terminationLabel = ' (' . __('Past Employee') . ')';
     $jsonArray[] = array('name' => __('All'), 'id' => '');
     foreach ($employeeList as $employee) {
         $name = $employee['firstName'] . " " . $employee['middleName'];
         $name = trim(trim($name) . " " . $employee['lastName']);
         if ($employee['termination_id']) {
             $name .= $terminationLabel;
         }
         $jsonArray[] = array('name' => $name, 'id' => $employee['empNumber']);
     }
     $jsonString = json_encode($jsonArray);
     return $jsonString;
 }
 public function getEmployeeListAsJson()
 {
     $jsonArray = array();
     $employeeService = new EmployeeService();
     $employeeService->setEmployeeDao(new EmployeeDao());
     $employeeUnique = array();
     foreach ($this->employeeList as $employee) {
         $empNumber = $employee['empNumber'];
         if (!isset($employeeUnique[$empNumber])) {
             $name = trim(trim($employee['firstName'] . ' ' . $employee['middleName'], ' ') . ' ' . $employee['lastName']);
             if ($employee['termination_id']) {
                 $name = $name . ' (' . __('Past Employee') . ')';
             }
             $employeeUnique[$empNumber] = $name;
             $jsonArray[] = array('name' => $name, 'id' => $empNumber);
         }
     }
     $jsonString = json_encode($jsonArray);
     return $jsonString;
 }
 /**
  * Delete employee emergencyContacts
  *
  * @param int $empNumber Employee number
  *
  * @return boolean true if successfully deleted, false otherwise
  */
 public function execute($request)
 {
     $empNumber = $request->getParameter('empNumber', false);
     $this->form = new EmployeeEmergencyContactsDeleteForm(array(), array('empNumber' => $empNumber), true);
     $this->form->bind($request->getParameter($this->form->getName()));
     if (!$this->IsActionAccessible($empNumber)) {
         $this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action'));
     }
     if ($this->form->isValid()) {
         if (!$empNumber) {
             throw new PIMServiceException("No Employee ID given");
         }
         $emergencyContactsToDelete = $request->getParameter('chkecontactdel', array());
         if ($emergencyContactsToDelete) {
             $service = new EmployeeService();
             $count = $service->deleteEmployeeEmergencyContacts($empNumber, $emergencyContactsToDelete);
             $this->getUser()->setFlash('templateMessage', array('success', __(TopLevelMessages::DELETE_SUCCESS)));
         }
     }
     $this->redirect('pim/viewEmergencyContacts?empNumber=' . $empNumber);
 }
 /**
  * Delete employee attachments
  *
  * @param int $empNumber Employee number
  *
  * @return boolean true if successfully deleted, false otherwise
  */
 public function execute($request)
 {
     $this->form = new EmployeeAttachmentDeleteForm(array(), array('name' => 'visita'), true);
     $this->form->bind($request->getParameter($this->form->getName()));
     if ($this->form->isValid()) {
         $empId = $request->getParameter('EmpID', false);
         if (!$empId) {
             throw new PIMServiceException("No Employee ID given");
         }
         if (!$this->IsActionAccessible($empId)) {
             $this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action'));
         }
         $attachmentsToDelete = $request->getParameter('chkattdelvc', array());
         if ($attachmentsToDelete) {
             $service = new EmployeeService();
             $service->deleteEmployeeAttachments($empId, $attachmentsToDelete);
             $this->getUser()->setFlash('visita.success', __(TopLevelMessages::DELETE_SUCCESS));
         }
     }
     $this->redirect($this->getRequest()->getReferer() . '#attachments');
 }
 public function setReportCriteriaInfoInRequest($formValues)
 {
     $employeeService = new EmployeeService();
     $empStatusService = new EmploymentStatusService();
     $jobTitleService = new JobTitleService();
     $companyStructureService = new CompanyStructureService();
     if (isset($formValues["employeeId"]) || $formValues["employeeId"] == '-1') {
         if ($formValues["employeeId"] != '-1') {
             $empNumber = $formValues["employeeId"];
             $employee = $employeeService->getEmployee($empNumber);
             $empName = $employee->getFirstAndLastNames();
         } else {
             $empName = __("All");
         }
         $this->getRequest()->setParameter('empName', $empName);
     }
     if (isset($formValues["employeeStatus"]) && $formValues["employeeStatus"] != 0) {
         $estatCode = $formValues["employeeStatus"];
         $estat = $empStatusService->getEmploymentStatusById($estatCode);
         $estatName = $estat->getName();
         $this->getRequest()->setParameter("employeeStatus", $estatName);
     }
     if (isset($formValues["jobTitle"]) && $formValues["jobTitle"] != 0) {
         $jobTitCode = $formValues["jobTitle"];
         $jobTitle = $jobTitleService->getJobTitleById($jobTitCode);
         $jobTitName = $jobTitle->getJobTitleName();
         $this->getRequest()->setParameter("jobTitle", $jobTitName);
     }
     if (isset($formValues["subUnit"]) && $formValues["subUnit"] != 0) {
         $value = $formValues["subUnit"];
         $id = $value;
         $subunit = $companyStructureService->getSubunitById($id);
         $subUnitName = $subunit->getName();
         $this->getRequest()->setParameter("subUnit", $subUnitName);
     }
     $this->getRequest()->setParameter('attendanceDateRangeFrom', $formValues["fromDate"]);
     $this->getRequest()->setParameter('attendanceDateRangeTo', $formValues["toDate"]);
 }
 public function execute($request)
 {
     $this->isAdmin = $this->getUser()->getAttribute('auth.isAdmin') == 'Yes' ? true : false;
     $this->aboutEnabled = true;
     $organizationService = new OrganizationService();
     $companyInfo = $organizationService->getOrganizationGeneralInformation();
     $employeeService = new EmployeeService();
     $configurationService = new BeaconConfigurationService();
     $this->beaconAcceptance = $configurationService->getBeaconActivationAcceptanceStatus();
     if ($companyInfo) {
         $this->companyName = $companyInfo->getName();
     }
     $this->version = 'Orangehrm OS 3.3.2';
     $totalEmployeeCount = $employeeService->getEmployeeCount(true);
     $this->activeEmployeeCount = $employeeService->getEmployeeCount(false);
     $this->terminatedEmployeeCount = $totalEmployeeCount - $this->activeEmployeeCount;
     $this->setForm(new BeaconRegistrationForm());
     if (!$this->getUser()->hasAttribute(BeaconCommunicationsService::BEACON_ACTIVATION_SET) && !$this->getUser()->getAttribute(BeaconCommunicationsService::BEACON_ACTIVATION_SET)) {
         $beaconCommunicationService = new BeaconCommunicationsService();
         $beaconCommunicationService->setBeaconActivation();
     }
     $this->beaconRequired = $this->getUser()->hasAttribute(BeaconCommunicationsService::BEACON_ACTIVATION_REQUIRED) && $this->getUser()->getAttribute(BeaconCommunicationsService::BEACON_ACTIVATION_REQUIRED) || $this->getUser()->hasAttribute(BeaconCommunicationsService::BEACON_FLASH_REQUIRED) && $this->getUser()->getAttribute(BeaconCommunicationsService::BEACON_FLASH_REQUIRED);
 }
 public function execute($request)
 {
     $usrObj = $this->getUser()->getAttribute('user');
     if (!$usrObj->isAdmin()) {
         $this->redirect('pim/viewPersonalDetails');
     }
     $this->setForm(new OrganizationGeneralInformationForm());
     $employeeService = new EmployeeService();
     $this->employeeCount = $employeeService->getEmployeeCount();
     if ($this->getUser()->hasFlash('templateMessage')) {
         list($this->messageType, $this->message) = $this->getUser()->getFlash('templateMessage');
     }
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $result = $this->form->save();
             $name = $this->form->getValue('name');
             $organizationName = !empty($name) ? $name : __("Organization");
             $companyStructureService = new CompanyStructureService();
             $companyStructureService->setOrganizationName($organizationName);
             list($this->messageType, $this->message) = array('success', __(TopLevelMessages::SAVE_SUCCESS));
         }
     }
 }
 /**
  *
  * @return <type>
  */
 public function getHiringManagerListAsJson()
 {
     $jsonArray = array();
     $employeeService = new EmployeeService();
     $employeeService->setEmployeeDao(new EmployeeDao());
     $properties = array("empNumber", "firstName", "middleName", "lastName", "termination_id");
     $employeeList = $employeeService->getEmployeePropertyList($properties, 'lastName', 'ASC', true);
     foreach ($employeeList as $employee) {
         $empNumber = $employee['empNumber'];
         $name = trim(trim($employee['firstName'] . ' ' . $employee['middleName'], ' ') . ' ' . $employee['lastName']);
         $jsonArray[] = array('name' => $name, 'id' => $empNumber);
     }
     $jsonString = json_encode($jsonArray);
     return $jsonString;
 }
 private function getEmployeeName($employeeId)
 {
     $employeeService = new EmployeeService();
     $employee = $employeeService->getEmployee($employeeId);
     $name = $employee->getFirstName() . " " . $employee->getLastName();
     if ($employee->getTerminationId()) {
         $name = $name . ' (' . __('Past Employee') . ')';
     }
     return $name;
 }
Example #27
0
 protected function _isCorrectEmployee($id, $name)
 {
     $flag = true;
     if (!empty($name) && $id == 0) {
         $flag = false;
     }
     if (!empty($name) && !empty($id)) {
         $employeeService = new EmployeeService();
         $employee = $employeeService->getEmployee($id);
         $nameArray = explode(' ', $name);
         if (count($nameArray) == 2 && strtolower($employee->getFirstName() . ' ' . $employee->getLastName()) != strtolower($name)) {
             $flag = false;
         } elseif (count($nameArray) == 3 && strtolower($employee->getFullName()) != strtolower($name)) {
             $flag = false;
         }
     }
     if ($flag) {
         return true;
     } else {
         return false;
     }
 }
 public function getEmployeeListAsJson()
 {
     $employeeService = new EmployeeService();
     return $employeeService->getEmployeeListAsJson();
 }
 public function getEmployeeName($employeeId)
 {
     $employeeService = new EmployeeService();
     $employee = $employeeService->getEmployee($employeeId);
     return $employee->getFirstName() . " " . $employee->getLastName();
 }
Example #30
0
 /**
  * Saving/Updating Employee Picture
  * @param EmpPicture $empPicture
  */
 public function setEmployeePicture(EmpPicture $empPicture)
 {
     if ($this->getEmpNumber() != "") {
         $service = new EmployeeService();
         $currentEmpPicture = $service->readEmployeePicture($this->getEmpNumber());
         if ($currentEmpPicture instanceof EmpPicture) {
             $currentEmpPicture->setPicture($empPicture->getPicture());
             $currentEmpPicture->setFilename($empPicture->getFilename());
             $currentEmpPicture->setFileType($empPicture->getFileType());
             $currentEmpPicture->setSize($empPicture->getSize());
         } else {
             $currentEmpPicture = $empPicture;
         }
         $service->saveEmployeePicture($currentEmpPicture);
     }
 }