예제 #1
0
 public function indexAction()
 {
     /**
      * @var \DDD\Dao\Geolocation\Cities $cityDao
      * @var \DDD\Dao\Office\OfficeManager $officeDao
      * @var \Library\Authentication\BackofficeAuthenticationService $auth
      * @var \DDD\Dao\Team\TeamStaff $teamStaffDao
      */
     $cityDao = $this->getServiceLocator()->get('dao_geolocation_cities');
     $officeDao = $this->getServiceLocator()->get('dao_office_office_manager');
     $auth = $this->getServiceLocator()->get('library_backoffice_auth');
     $teamStaffDao = $this->getServiceLocator()->get('dao_team_team_staff');
     $cities = $cityDao->getBoUserCities();
     /**
      * @var Base $teamBaseUsageService
      */
     $teamBaseUsageService = $this->getServiceLocator()->get('service_team_usages_base');
     $teams = $teamBaseUsageService->getTeamsBySeveralUsages([Base::TEAM_USAGE_DEPARTMENT, Base::TEAM_USAGE_FRONTIER]);
     $myTeams = [];
     $teamsSelect = [];
     $myTeamRoles = [Team::STAFF_MEMBER, Team::STAFF_OFFICER, Team::STAFF_MANAGER, Team::STAFF_DIRECTOR];
     foreach ($teams as $team) {
         if ($teamStaffDao->isTeamStaff($auth->getIdentity()->id, $team->getId(), $myTeamRoles)) {
             $myTeams[$team->getId()] = $team->getName();
         } else {
             $teamsSelect[$team->getId()] = $team->getName();
         }
     }
     if (empty($myTeams)) {
         $allTeams = $teamsSelect;
     } else {
         $allTeams = $myTeams + ['disabled' => '-------'] + $teamsSelect;
     }
     $offices = $officeDao->getOfficeList(null, false);
     return new ViewModel(['cities' => $cities, 'teams' => $allTeams, 'offices' => iterator_to_array($offices), 'schedule_types' => Objects::getShift()]);
 }