當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserService::calculateLeave方法代碼示例

本文整理匯總了PHP中UserService::calculateLeave方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserService::calculateLeave方法的具體用法?PHP UserService::calculateLeave怎麽用?PHP UserService::calculateLeave使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UserService的用法示例。


在下文中一共展示了UserService::calculateLeave方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: calcAction

 /**
  * Calculates the leave left for a given user
  */
 public function calcAction()
 {
     $username = $this->_getParam('username');
     $user = $this->userService->getUserByField('username', $username);
     $type = $this->_getParam('type', 'Annual');
     $validTypes = array('Annual', 'Sick', 'Long Service');
     if (!in_array($type, $validTypes)) {
         return;
     }
     if ($user == null) {
         $this->log->warn("Invalid username");
         echo 0;
         return;
     }
     // Calculate how much is left
     $leave = $this->userService->getLeaveForUser($user);
     $accruedLeave = $this->userService->calculateLeave($user);
     $leaveApplications = $this->userService->getLeaveApplicationsForUser($user);
     $leaveTotal = 0;
     $leaveTotals = array();
     foreach ($leaveApplications as $app) {
         if ($app->status == LeaveApplication::LEAVE_APPROVED) {
             $current = ifset($leaveTotals, $app->leavetype, 0);
             $current += $app->days;
             $leaveTotals[$app->leavetype] = $current;
         }
     }
     if ($type == 'Annual') {
         echo "About " . sprintf("%d", floor($leave->days + $accruedLeave - ifset($leaveTotals, "Annual", 0))) . " days of annual leave available, " . ifset($leaveTotals, "Annual", 0) . " taken";
     } else {
         echo ifset($leaveTotals, $type, 0) . ' days of ' . $type . ' leave taken';
     }
 }
開發者ID:nyeholt,項目名稱:relapse,代碼行數:36,代碼來源:LeaveController.php

示例2: editAction

 /**
  * Edit a user object.
  *
  */
 public function editAction()
 {
     $id = (int) $this->_getParam('id');
     $userToEdit = za()->getUser();
     // If an ID is passed, we need to have a higher role than that user
     // to be able to edit them an admin to be
     // able to edit this user
     if ($id > 0) {
         $selectedUser = $this->userService->getUser($id);
         // now, if the selectedUser has a role less than mine, we can
         // edit them
         if ($selectedUser->getRoleValue() < za()->getUser()->getRoleValue() || za()->getUser()->isPower()) {
             $userToEdit = $selectedUser;
         }
     }
     // if the user's an admin, give them the list of contacts
     // to bind for this user
     if (za()->getUser()->hasRole(User::ROLE_USER)) {
         // get all the contacts
         $this->view->contacts = $this->clientService->getContacts();
     }
     $this->view->leave = $this->userService->getLeaveForUser($userToEdit);
     $this->view->accruedLeave = $this->userService->calculateLeave($userToEdit);
     $this->view->leaveApplications = $this->userService->getLeaveApplicationsForUser($userToEdit);
     $this->view->model = $userToEdit;
     $this->view->themes = $this->getThemes();
     $this->renderView('user/edit.php');
 }
開發者ID:nyeholt,項目名稱:relapse,代碼行數:32,代碼來源:UserController.php


注:本文中的UserService::calculateLeave方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。