当前位置: 首页>>代码示例>>PHP>>正文


PHP UserService::getLeaveApplicationsForUser方法代码示例

本文整理汇总了PHP中UserService::getLeaveApplicationsForUser方法的典型用法代码示例。如果您正苦于以下问题:PHP UserService::getLeaveApplicationsForUser方法的具体用法?PHP UserService::getLeaveApplicationsForUser怎么用?PHP UserService::getLeaveApplicationsForUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserService的用法示例。


在下文中一共展示了UserService::getLeaveApplicationsForUser方法的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::getLeaveApplicationsForUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。