public function getPinnedReservationsAction() { /** * @var $pinnedResWidgetService \DDD\Service\UniversalDashboard\Widget\PinnedReservation */ $auth = $this->getServiceLocator()->get('library_backoffice_auth'); $pinnedResWidgetService = $this->getServiceLocator()->get('service_universal_dashboard_widget_pinned_reservation'); $preparedData = array(); $loggedInUserID = $auth->getIdentity()->id; $dataSet = $pinnedResWidgetService->getAllPinnedReservation($loggedInUserID); if ($dataSet && count($dataSet)) { foreach ($dataSet as $row) { $bookingDao = new \DDD\Dao\Booking\Booking($this->getServiceLocator(), 'DDD\\Domain\\UniversalDashboard\\Widget\\PinnedReservation'); /** @var \DDD\Domain\UniversalDashboard\Widget\PinnedReservation $resInfo */ $resInfo = $bookingDao->searchReservationByResNum($row->getResNum()); $actionsColumn = "<a href='javascript:void(0)' class='btn " . "btn-xs btn-success' onclick='unpin(\"" . $row->getResNum() . "\", " . $loggedInUserID . ")' id=" . $row->getResNum() . ">Unpin</a>\n\t\t\t\t\t<a href='//" . DomainConstants::BO_DOMAIN_NAME . "/booking/edit/" . $row->getResNum() . "' class='btn btn-xs btn-primary' target='_blank' data-html-content='View'></a>"; $preparedData[] = ["0" => $resInfo->getResNum(), "1" => $resInfo->getGuestFirstName() . ' ' . $resInfo->getGuestLastName(), "2" => $resInfo->getApartmentName(), "3" => $actionsColumn]; } return new JsonModel(["aaData" => $preparedData]); } else { return new JsonModel(["aaData" => []]); } }
/** * @param int|bool $reservationId * @return array */ public function getSendReceipt($reservationId = false, $customEmail = null) { /** * @var Logger $logger */ $logger = $this->getServiceLocator()->get('ActionLogger'); $result = ['status' => 'error', 'msg' => TextConstants::ERROR_SEND_MAIL]; try { if ($reservationId) { $bookingTicketDao = new \DDD\Dao\Booking\Booking($this->getServiceLocator(), '\\ArrayObject'); $ticketResult = $bookingTicketDao->fetchOne(['id' => $reservationId], ['guest_first_name', 'guest_last_name', 'guest_email']); if ($ticketResult) { $guestEmail = !empty($customEmail) ? $customEmail : $ticketResult['guest_email']; $output = shell_exec('ginosole reservation-email send-receipt --id=' . $reservationId . ' --email=' . $guestEmail . ' -v'); if (!strstr(strtolower($output), 'error')) { $guestName = $ticketResult['guest_first_name'] . ' ' . $ticketResult['guest_last_name']; $logger->save(Logger::MODULE_BOOKING, $reservationId, Logger::ACTION_RESERVATION_EMAIL_RECEIPT, "Receipt has been sent to {$guestName} <{$guestEmail}>"); $result = ['status' => 'success', 'msg' => TextConstants::SUCCESS_SEND_MAIL]; } } } } catch (\Exception $ex) { // do nothing } return $result; }
public function indexAction() { /** @var UserManager $managerDao */ $managerDao = $this->getServiceLocator()->get('dao_user_user_manager'); $teamService = $this->getServiceLocator()->get('service_team_team'); $auth = $this->getServiceLocator()->get('library_backoffice_auth'); /** @var \DDD\Service\User\Schedule $scheduleService */ $scheduleService = $this->getServiceLocator()->get('service_user_schedule'); $userId = $this->params()->fromRoute('id'); $userSessionId = $auth->getIdentity()->id; $isLoggedInUserGlobalManager = false; $profileViewer = false; $isManager = false; $itsMe = false; if ($auth->hasRole(Roles::ROLE_PROFILE_VIEWER)) { $profileViewer = true; } if ($auth->hasRole(Roles::ROLE_PEOPLE_MANAGEMENT)) { $isLoggedInUserGlobalManager = true; } $hasHRole = $auth->hasRole(Roles::ROLE_PEOPLE_MANAGEMENT_HR); if ($userId === null || $userId == $userSessionId) { $userId = $userSessionId; $itsMe = true; } $rUserDao = $this->getServiceLocator()->get('dao_user_user_manager'); $rUser = $rUserDao->findUserById((int) $userId); if (!$rUser) { return $this->redirect()->toUrl('/'); } if ($rUser->getStartDate() && $rUser->getStartDate() != '0000-00-00') { //604800 is the number of seconds in one week //31536000 is the number of seconds in one year $weeksWorked = floor((time() - strtotime($rUser->getStartDate())) % 31536000 / 604800); $yearsWorked = floor((time() - strtotime($rUser->getStartDate())) / 31536000); if ($weeksWorked < 0 && $yearsWorked < 0) { $weeksWorked = 0; $yearsWorked = 0; } } else { $weeksWorked = 0; $yearsWorked = 0; } // get User Manager id $managerId = $rUser->getManager_id(); if ($managerId === '0') { $managerId = 64; } // get Manager Profile $myManager = $managerDao->getUserById((int) $managerId); if ($auth->hasRole(Roles::ROLE_PEOPLE_DIRECTORY) && $userSessionId == $managerId) { $isManager = true; } /** * @var \DDD\Service\User $userService */ $userService = $this->getServiceLocator()->get('service_user'); /** @var \DDD\Service\Profile $profileService */ $profileService = $this->getProfileService(); $cityDao = $this->getServiceLocator()->get('dao_geolocation_city'); $userDao = $userService->getUsersById((int) $userId, $isManager || $isLoggedInUserGlobalManager || $hasHRole); if (!$userDao) { $view = new ViewModel(); $view->setTemplate('backoffice/profile/disabled.phtml'); return $view; } $userProfile = $userDao->get('user_main'); $userOptions = $userService->getUserOptions((int) $userId); $countryId = $userProfile->getCountry_id(); $cities = $cityDao->getCityByCountryId((int) $countryId); // Get user schedule for 3 weeks $userSchedule = $scheduleService->getUserScheduleInRange($userId, date('Y-m-d'), date('Y-m-d', strtotime('+20 day'))); $userSubordinates = $profileService->getUserSubordinates($userId); $vacationRequest = $userService->getUserVacationRequest((int) $userId); $detailsForm = new ProfileDetailsForm('changeDetails'); $passwordForm = new ProfilePasswordForm('changePassword'); // reservation ginosik $resevations = []; $stayedDays = 0; $bookingDao = new \DDD\Dao\Booking\Booking($this->getServiceLocator(), 'DDD\\Domain\\Booking\\BookingProfile'); $resevationsResult = $bookingDao->getGinosikResevations($userProfile->getEmail(), $userProfile->getAlt_email()); foreach ($resevationsResult as $row) { $days = Helper::getDaysFromTwoDate($row->getDate_from(), $row->getDate_to()); $stayedDays += $days; array_push($resevations, sprintf(TextConstants::PROFILE_GINOSI_RESERVATION, '/booking/edit/' . $row->getReservationNumber(), $row->getReservationNumber(), $row->getApartmentName(), $row->getDate_from(), $row->getDate_to(), $days, $row->getGuestEmail())); } /** * @var UserMainService $userMainService */ $userMainService = $this->getServiceLocator()->get('service_user_main'); $userDepartmentId = $userMainService->getUserDepartmentId($userId); $isDepartment = 1; $departments = $teamService->getTeamList(null, $isDepartment); $coDepartments = []; $coDepartments[-1] = '-- Departments --'; foreach ($departments as $department) { $coDepartments[$department->getId()] = $department->getName(); } $userTeams = $teamService->getUserTeams($userId); $vacationDaysCountUsedInThisYear = $userService->getVacationDaysCountUsedInThisYear($userId); $cashingDays = $userService->calculateVacationCashableDaysCount($userDao->get('user_main')->getVacation_days_per_year(), $userDao->get('user_main')->getVacation_days(), true); $datetime = new \DateTime('now'); $datetime->setTimezone(new \DateTimeZone($userProfile->getTimezone())); $dateTimeNow = $datetime->format(Constants::GLOBAL_DATE_TIME_FORMAT); $goodTimeToCall = $scheduleService->isUserWorking($userProfile->getId(), $datetime); $hasAccessToManage = $auth->hasRole(Roles::ROLE_PEOPLE_DIRECTORY) && ($auth->hasRole(Roles::ROLE_PEOPLE_MANAGEMENT) || $auth->hasRole(Roles::ROLE_PEOPLE_MANAGEMENT_HR) || $isManager); $userCurrencyId = $userDao->get('user_main')->getCurrencyId(); $ginocoinSpentSoFar = false; if ($itsMe) { $ginocoinSpentSoFar = $this->calculateGinocoinSpentSoFar($auth->getIdentity()->id, $userCurrencyId); } return new ViewModel(['user' => $userDao, 'userOptions' => $userOptions, 'resevations' => $resevations, 'stayedDays' => $stayedDays, 'cities' => $cities, 'myManager' => $myManager, 'itsMe' => $itsMe, 'isManager' => $isManager, 'hasAccessToManage' => $hasAccessToManage, 'profileViewer' => $profileViewer, 'changeDetailsForm' => $detailsForm, 'changePasswordForm' => $passwordForm, 'schedule' => $userSchedule, 'local_datetime' => $dateTimeNow, 'good_time_to_call' => $goodTimeToCall, 'manager_subordinates' => $userSubordinates, 'vacationRequestOld' => $vacationRequest['old'], 'vacationRequestNew' => $vacationRequest['new'], 'vacationDaysUsedThisYesr' => $vacationDaysCountUsedInThisYear, 'cashingDays' => $cashingDays, 'weeksWorked' => $weeksWorked, 'yearsWorked' => $yearsWorked, 'userTeams' => $userTeams, 'userDepartment' => $userDepartmentId, 'departments' => $coDepartments, 'hasHRole' => $hasHRole, 'hasHRoleHrVacationEditor' => $auth->hasRole(Roles::ROLE_HR_VACATION_EDITOR), 'ginocoinSpentSoFar' => $ginocoinSpentSoFar]); }