public function execute($dataContainer) { $this->entryPoint($dataContainer); $this->_settingsRepo = $this->_em->getRepository('DM:SystemGlobalSettings'); $data = $this->fetchData(); dieJson($data); }
public function execute($dataContainer) { $this->entryPoint($dataContainer); $gradelevel = filter_input(INPUT_GET, 'gradelevel'); if ($gradelevel !== false) { dieJson($this->searchGradelevel($gradelevel, 20)); } else { dieHttp('Such-parameter fehlt', 400); } }
public function execute($dataContainer) { $this->entryPoint($dataContainer); $title = filter_input(INPUT_GET, 'title'); if ($title) { dieJson($this->searchByTitle($title, 20)); } else { dieHttp('Such-parameter fehlt', 400); } }
public function execute($dataContainer) { $this->entryPoint($dataContainer); $username = filter_input(INPUT_GET, 'username'); $schoolyearId = filter_input(INPUT_GET, 'schoolyearId'); if ($username && $schoolyearId) { $schoolyear = $this->_em->getReference('DM:SystemSchoolyears', $schoolyearId); dieJson($this->searchByUsernameAndSchoolyear($username, $schoolyear, 20)); } else { dieHttp('Such-parameter fehlt', 400); } }
protected function sendSingleUser($id) { $user = $this->_em->find('DM:SystemUsers', $id); if (!$user) { dieHttp('Konnte den Benutzer nicht finden', 400); } $activeGroups = $this->getSingleUserActiveGroups($user); $allGroups = $this->getSingleUserAllGroups(); $bookAssignments = $this->getSingleUserBookAssignments($user); $schoolyears = $this->getSingleUserSchoolyears(); $userdata = ['id' => $user->getId(), 'forename' => $user->getForename(), 'surname' => $user->getName(), 'username' => $user->getUsername(), 'email' => $user->getEmail(), 'telephone' => $user->getTelephone(), 'birthday' => $user->getBirthday(), 'locked' => $user->getLocked(), 'credit' => $user->getCredit(), 'soli' => $user->getSoli(), 'religion' => $user->getReligion(), 'foreignLanguage' => $user->getForeignLanguage(), 'specialCourse' => $user->getSpecialCourse(), 'activeGroups' => $activeGroups, 'bookAssignments' => $bookAssignments]; dieJson(['user' => $userdata, 'groups' => $allGroups, 'schoolyears' => $schoolyears]); }
protected function checkRooms() { $str = ""; $warning = false; $inString = array(); foreach ($this->_em->getRepository("DM:ElawaMeeting")->findAll() as $meeting) { if ($meeting->getRoom()->getId() == 0 && !in_array($meeting->getHost()->getId(), $inString)) { $str .= "Für " . $meeting->getHost()->getForename() . " " . $meeting->getHost()->getName() . " wurde noch kein Raum ausgewählt.<br>"; $warning = true; $inString[] = $meeting->getHost()->getId(); } } $str .= "Trotzdem fortfahren?"; dieJson(array($warning, $str)); }
public function execute($dataContainer) { $this->entryPoint($dataContainer); $selectors = $this->selectorQueryPartGet($_GET); $activeSchoolyear = $this->_em->getRepository('DM:SystemSchoolyears')->findOneByActive(true); if (!$activeSchoolyear) { dieHttp('Konnte aktives Schuljahr nicht finden.', 500); } try { $qb = $this->_em->createQueryBuilder()->select($selectors)->from('DM:SystemUsers', 'u'); //Additional data if (isset($_GET['includeShouldLendBooks'])) { $qb->leftJoin('u.booksToLend', 'btl'); $qb->leftJoin('btl.book', 'usb'); } if (isset($_GET['includeLendingBooks'])) { $qb->leftJoin('u.bookLending', 'bl'); $qb->leftJoin('bl.book', 'blb'); } //Filters if (isset($_GET['grade'])) { $grade = $this->_em->find('DM:SystemGrades', $_GET['grade']); if (!$grade) { dieHttp("Klasse mit Id {$_GET['grade']} nicht gefunden", 400); } $qb->innerJoin('u.attendances', 'grade_a', 'WITH', 'grade_a.schoolyear = :activeSchoolyear'); $qb->innerJoin('grade_a.grade', 'gg', 'WITH', 'gg = :grade'); $qb->setParameter('activeSchoolyear', $activeSchoolyear); $qb->setParameter('grade', $grade); } if (isset($_GET['gradelevel'])) { $gradelevel = filter_input(INPUT_GET, 'gradelevel', FILTER_VALIDATE_INT); if ($gradelevel === false || $gradelevel === null) { dieHttp("Klassenstufe '{$gradelevel}' nicht korrekt", 400); } $qb->innerJoin('u.attendances', 'gl_a', 'WITH', 'gl_a.schoolyear = :activeSchoolyear'); $qb->innerJoin('gl_a.grade', 'gl_g', 'WITH', 'gl_g.gradelevel = :gradelevel'); $qb->setParameter('activeSchoolyear', $activeSchoolyear); $qb->setParameter('gradelevel', $gradelevel); } $query = $qb->getQuery(); $users = $query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY); dieJson($users); } catch (\Exception $e) { $this->_logger->logO('Could not search for users', ['sev' => 'error', 'moreJson' => $e->getMessage()]); dieHttp('Fehler beim Suchen.', 500); } }
protected function bookDataSend($schoolyearId) { try { $schoolyears = $this->schoolyearDataGet($schoolyearId); } catch (Exception $e) { $this->_logger->logO('Could not fetch the schoolyears', ['sev' => 'error', 'moreJson' => $e->getMessage()]); dieHttp('Konnte die Schuljahre nicht abrufen', 500); } try { if (!$schoolyearId) { foreach ($schoolyears as $schoolyear) { if ($schoolyear['active']) { $schoolyearId = $schoolyear['id']; } } } $books = $this->bookDataGet($schoolyearId); } catch (Exception $e) { $this->_logger->logO('Could not fetch the books', ['sev' => 'error', 'moreJson' => $e->getMessage()]); dieHttp('Konnte die Buchzuweisungen nicht abrufen', 500); } dieJson(['schoolyears' => $schoolyears, 'books' => $books]); }
protected function sendIndex($sort, $filter, $activePage, $entriesPerPage, $displayColumns) { $this->sendIndexCheckInput($entriesPerPage); $qb = $this->_em->createQueryBuilder()->select(['i', 'b', 's'])->from('DM:SchbasInventory', 'i')->leftJoin('i.book', 'b')->leftJoin('b.subject', 's')->leftJoin('i.lending', 'l')->leftJoin('l.user', 'u'); $rowCountQb = $this->_em->createQueryBuilder()->select('COUNT(DISTINCT i.id)')->from('DM:SchbasInventory', 'i')->leftJoin('i.book', 'b')->leftJoin('b.subject', 's')->leftJoin('i.lending', 'l')->leftJoin('l.user', 'u'); if (!empty($filter)) { $this->sendIndexApplyFilter($filter, $qb, $displayColumns); $this->sendIndexApplyFilter($filter, $rowCountQb, $displayColumns); } $qb->setFirstResult(($activePage - 1) * $entriesPerPage)->setMaxResults($entriesPerPage); $result = $qb->getQuery()->getResult(); $rowCount = $rowCountQb->getQuery()->getSingleScalarResult(); $data = $this->sendIndexCreateAnswerData($result, $rowCount, $entriesPerPage); dieJson($data); }
public function execute($dataContainer) { $this->entryPoint($dataContainer); dieJson(['gradelevelLendStatistics' => $this->gradelevelLendFetch(), 'subjectLendStatistics' => $this->subjectLendFetch()]); }
/** * 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!'); } }
/** * Search for a username in all users with a specific conflict type * It searches with the good ol' Levenshtein-method, so be easy on it. * Rendering a 200 with json on success, a 204 if no users found or an * error on error. * @param string $username The username to search for * @param string $type The conflict-type. Has to be one of * CsvOnlyConflict and DbOnlyConflict */ private function searchForUsernameInConflictsOfType($username, $type) { $limit = 30; if ($type == 'CsvOnlyConflict') { $joinQuery = 'INNER JOIN UserUpdateTempUsers u ' . 'ON u.ID = c.tempUserId'; } else { if ($type == 'DbOnlyConflict') { $joinQuery = 'INNER JOIN SystemUsers u ON u.ID = c.origUserId'; } else { $this->_logger->logO('Type not recognized', ['sev' => 'warning', ['moreJson'] => ['type' => $type]]); $this->_interface->dieError('Ein Fehler ist aufgetreten'); } } $query = "SELECT c.ID as conflictId, u.birthday AS userBirthday,\n\t\t\t\t\tCONCAT(u.forename, ' ', u.name) AS username\n\t\t\t\tFROM UserUpdateTempConflicts c\n\t\t\t\t{$joinQuery}\n\t\t\t\tWHERE c.type = :conflictType\n\t\t\t\tORDER BY LEVENSHTEIN_RATIO(username, :username) DESC, u.ID\n\t\t\t\tLIMIT :limit"; try { $stmt = $this->_em->getConnection()->prepare($query); $stmt->bindParam('conflictType', $type); $stmt->bindParam('username', $username); $stmt->bindParam('limit', $limit, \PDO::PARAM_INT); $stmt->execute(); $result = $stmt->fetchAll(); } catch (\Exception $e) { $this->_logger->logO('Could not search usernames for conflicttype', ['sev' => 'error', 'moreJson' => ['msg' => $e->getMessage(), 'conflicttype' => $type]]); dieHttp('Fehler beim Suchen der ähnlichen Benutzer', 500); } if (count($result)) { $conflicts = []; foreach ($result as $row) { $formattedBirthday = date('d.m.Y', strtotime($row['userBirthday'])); $conflicts[] = ['id' => $row['conflictId'], 'label' => $row['username'] . " ({$formattedBirthday})"]; } dieJson($conflicts); } else { dieHttp('Keine ähnlichen Benutzer gefunden.', 204); } }