private function schbasAssignmentsGenerate($userIds) { require_once PATH_INCLUDE . '/Schbas/ShouldLendGeneration.php'; $syId = $this->_em->getRepository('DM:SystemGlobalSettings')->getSetting('userUpdateWithSchoolyearChangeNewSchoolyearId'); $schoolyear = $this->_em->getReference('DM:SystemSchoolyears', $syId); $generator = new \Babesk\Schbas\ShouldLendGeneration($this->_dataContainer); $users = array_map(function ($userId) { return $this->_em->getReference('DM:SystemUsers', $userId); }, $userIds); if (count($users)) { $generator->generate(['onlyForUsers' => $users, 'schoolyear' => $schoolyear]); } }
/** * Automatically create the assignments. * Dies with json. * * @param array $data An array containing options: * { * 'existingAssignmentsAction': '<action>', * 'addGradelevelToUsers': '<gradelevelIncrease?>' * } */ protected function assignmentsCreate($data) { if (empty($data) || !isset($data['existingAssignmentsAction'])) { $this->_logger->logO('missing parameters for ' . __METHOD__, ['sev' => 'warning']); } $loanBookMan = new \Babesk\Schbas\Loan($this->_dataContainer); $loanGenerator = new \Babesk\Schbas\ShouldLendGeneration($this->_dataContainer); $sy = $loanBookMan->schbasPreparationSchoolyearGet(); $assignmentsExist = $this->assignmentsForSchoolyearExistCheck($sy); if ($assignmentsExist && $data['existingAssignmentsAction'] == 'delete-existing') { $this->deleteExistingAssignmentsForSchoolyear($sy); } $res = $loanGenerator->generate(); if ($res) { dieJson('Die Zuweisungen wurden erfolgreich erstellt.'); } else { $this->_logger->log('Could not create the assignments', 'error'); http_response_code(500); dieJson('Konnte die Zuweisungen nicht erstellen!'); } }