/** * @param array $Group * * @return Stage */ public function frontendGroup($Group) { $Stage = new Stage('Personengruppen'); $tblGroupAll = Group::useService()->getGroupAll(); if ($tblGroupAll) { array_walk($tblGroupAll, function (TblGroup &$tblGroup) { $Content = array($tblGroup->getDescription() ? new Small(new Muted($tblGroup->getDescription())) : false, $tblGroup->getRemark() ? nl2br($tblGroup->getRemark()) : false); $Content = array_filter($Content); $Type = $tblGroup->getIsLocked() ? Panel::PANEL_TYPE_INFO : Panel::PANEL_TYPE_DEFAULT; $Footer = new PullLeft(new Standard('', '/People/Group/Edit', new Edit(), array('Id' => $tblGroup->getId()), 'Daten ändern') . new Standard('', '/People/Group/Manage', new GroupIcon(), array('Id' => $tblGroup->getId()), 'Personen ändern') . ($tblGroup->getIsLocked() ? '' : new Standard('', '/People/Group/Destroy', new Remove(), array('Id' => $tblGroup->getId()), 'Gruppe löschen'))); $Footer .= new PullRight(new Label(PeoplePerson::useService()->countPersonAllByGroup($tblGroup) . ' Personen', Label::LABEL_TYPE_INFO)); $tblGroup = new LayoutColumn(new Panel($tblGroup->getName(), $Content, $Type, new PullClear($Footer)), 4); }); $LayoutRowList = array(); $LayoutRowCount = 0; $LayoutRow = null; /** * @var LayoutColumn $tblGroup */ foreach ($tblGroupAll as $tblGroup) { if ($LayoutRowCount % 3 == 0) { $LayoutRow = new LayoutRow(array()); $LayoutRowList[] = $LayoutRow; } $LayoutRow->addColumn($tblGroup); $LayoutRowCount++; } } else { $LayoutRowList = new LayoutRow(new LayoutColumn(new Warning('Keine Gruppen vorhanden'))); } $Stage->setContent(new Layout(array(new LayoutGroup($LayoutRowList, new Title('Gruppen', 'Verfügbare Personengruppen')), new LayoutGroup(new LayoutRow(new LayoutColumn(Group::useService()->createGroup($this->formGroup()->appendFormButton(new Primary('Hinzufügen'))->setConfirm('Die neue Gruppe wurde noch nicht gespeichert'), $Group))), new Title('Gruppe hinzufügen'))))); return $Stage; }
/** * @return bool|TblSalutation */ public function getTblSalutation() { if (null === $this->tblSalutation) { return false; } else { return Person::useService()->getSalutationById($this->tblSalutation); } }
/** * @return bool|TblPerson */ public function getServiceTblPerson() { if (null === $this->serviceTblPerson) { return false; } else { return Person::useService()->getPersonById($this->serviceTblPerson); } }
/** * @param int $Id * @param string $Address * @param array $Type * * @return Stage */ public function frontendCreateToPerson($Id, $Address, $Type) { $Stage = new Stage('E-Mail Adresse', 'Hinzufügen'); $Stage->setMessage('Eine E-Mail Adresse zur gewählten Person hinzufügen'); $tblPerson = Person::useService()->getPersonById($Id); $Stage->setContent(new Layout(array(new LayoutGroup(array(new LayoutRow(new LayoutColumn(new Panel(new PersonIcon() . ' Person', $tblPerson->getFullName(), Panel::PANEL_TYPE_SUCCESS, new Standard('Zurück zur Person', '/People/Person', new ChevronLeft(), array('Id' => $tblPerson->getId()))))))), new LayoutGroup(array(new LayoutRow(new LayoutColumn(Mail::useService()->createMailToPerson($this->formAddress()->appendFormButton(new Primary('E-Mail Adresse hinzufügen'))->setConfirm('Eventuelle Änderungen wurden noch nicht gespeichert'), $tblPerson, $Address, $Type)))))))); return $Stage; }
/** * @return bool|TblPerson */ public function getServiceTblPersonAttendingDoctor() { if (null === $this->serviceTblPersonAttendingDoctor) { return false; } else { return Person::useService()->getPersonById($this->serviceTblPersonAttendingDoctor); } }
/** * @return Form */ private function formRelationship() { $tblTypeAll = Relationship::useService()->getTypeAll(); $tblPersonAll = Person::useService()->getPersonAll(); array_walk($tblPersonAll, function (TblPerson &$tblPerson) { $tblPerson = new PullClear(new PullLeft(new RadioBox('To', $tblPerson->getFullName(), $tblPerson->getId())) . new PullRight(new Standard('', '/People/Person/Relationship/Create', new PersonIcon(), array('Id' => $tblPerson->getId()), 'zu' . ' ' . $tblPerson->getSalutation() . ' ' . $tblPerson->getTitle() . ' ' . $tblPerson->getLastName() . ' wechseln'))); }); return new Form(new FormGroup(array(new FormRow(array(new FormColumn(array(new Panel('hat folgende Beziehung', array(new SelectBox('Type[Type]', 'Beziehungstyp', array('{{ Name }} {{ Description }}' => $tblTypeAll), new TileBig()), new TextArea('Type[Remark]', 'Bemerkungen - z.B: Mutter / Vater / ..', 'Bemerkungen', new Pencil()), new \SPHERE\Common\Frontend\Text\Repository\Danger(new Info() . ' Es dürfen ausschließlich für die Schulverwaltung notwendige Informationen gespeichert werden.')), Panel::PANEL_TYPE_INFO)), 6), new FormColumn(array(new Panel(new PullClear('zu folgender Person' . new PullRight(new Standard('Neue Person anlegen', '/People/Person', new PersonIcon(), array(), 'Die aktuell gewählte Person verlassen'))), $tblPersonAll, Panel::PANEL_TYPE_INFO, null, 15)), 6)))))); }
public static function registerCluster() { Search::registerApplication(); Person::registerApplication(); Group::registerApplication(); Meta::registerApplication(); Relationship::registerApplication(); Main::getDisplay()->addClusterNavigation(new Link(new Link\Route(__NAMESPACE__), new Link\Name('Personen'))); Main::getDispatcher()->registerRoute(Main::getDispatcher()->createRoute(__NAMESPACE__, __CLASS__ . '::frontendDashboard')); $tblGroupAll = Group::useService()->getGroupAll(); if ($tblGroupAll) { /** @var TblGroup $tblGroup */ foreach ((array) $tblGroupAll as $Index => $tblGroup) { $tblGroupAll[$tblGroup->getName()] = new Layout(new LayoutGroup(new LayoutRow(array(new LayoutColumn($tblGroup->getName() . new Muted(new Small('<br/>' . $tblGroup->getDescription())), array(9, 0, 7)), new LayoutColumn(new Muted(new Small(Group::useService()->countPersonAllByGroup($tblGroup) . ' Mitglieder')), 2, array(LayoutColumn::GRID_OPTION_HIDDEN_SM, LayoutColumn::GRID_OPTION_HIDDEN_XS)), new LayoutColumn(new PullRight(new Standard('', '/People/Search/Group', new \SPHERE\Common\Frontend\Icon\Repository\Group(), array('Id' => $tblGroup->getId()), 'zur Gruppe')), array(3, 0, 3)))))); $tblGroupAll[$Index] = false; } $tblGroupAll = array_filter($tblGroupAll); Main::getDispatcher()->registerWidget('Personen', new Panel('Personen in Gruppen', $tblGroupAll), 4, 6); } Main::getDispatcher()->registerWidget('Personen', new Panel('Anzahl an Personen', 'Insgesamt: ' . Person::useService()->countPersonAll())); }
/** * @return bool|TblPerson[] */ public function getPersonAllHavingNoGroup() { $Exclude = $this->Connection->getEntityManager()->getQueryBuilder()->select('M.serviceTblPerson')->from('\\SPHERE\\Application\\People\\Group\\Service\\Entity\\TblMember', 'M')->distinct()->getQuery()->getResult("COLUMN_HYDRATOR"); $tblPersonAll = Person::useService()->getPersonAll(); if ($tblPersonAll) { /** @noinspection PhpUnusedParameterInspection */ array_walk($tblPersonAll, function (TblPerson &$tblPerson, $Index, $Exclude) { if (in_array($tblPerson->getId(), $Exclude)) { $tblPerson = false; } }, $Exclude); $EntityList = array_filter($tblPersonAll); } else { $EntityList = null; } return null === $EntityList ? false : $EntityList; }
/** * @return Form */ private function formPerson() { $tblGroupList = Group::useService()->getGroupAll(); if ($tblGroupList) { // Sort by Name usort($tblGroupList, function (TblGroup $ObjectA, TblGroup $ObjectB) { return strnatcmp($ObjectA->getName(), $ObjectB->getName()); }); // Create CheckBoxes /** @noinspection PhpUnusedParameterInspection */ array_walk($tblGroupList, function (TblGroup &$tblGroup) { switch (strtoupper($tblGroup->getMetaTable())) { case 'COMMON': $Global = $this->getGlobal(); $Global->POST['Person']['Group'][$tblGroup->getId()] = $tblGroup->getId(); $Global->savePost(); $tblGroup = new RadioBox('Person[Group][' . $tblGroup->getId() . ']', $tblGroup->getName() . ' ' . new Muted(new Small($tblGroup->getDescription())), $tblGroup->getId()); break; default: $tblGroup = new CheckBox('Person[Group][' . $tblGroup->getId() . ']', $tblGroup->getName() . ' ' . new Muted(new Small($tblGroup->getDescription())), $tblGroup->getId()); } }); } else { $tblGroupList = array(new Warning('Keine Gruppen vorhanden')); } $tblSalutationAll = Person::useService()->getSalutationAll(); return new Form(new FormGroup(array(new FormRow(array(new FormColumn(new Panel('Anrede', array(new SelectBox('Person[Salutation]', 'Anrede', array('Salutation' => $tblSalutationAll), new Conversation()), new AutoCompleter('Person[Title]', 'Titel', 'Titel', array('Dipl.- Ing.'), new Conversation())), Panel::PANEL_TYPE_INFO), 4), new FormColumn(new Panel('Name', array(new TextField('Person[FirstName]', 'Rufname', 'Vorname'), new TextField('Person[SecondName]', 'weitere Vornamen', 'Zweiter Vorname'), new TextField('Person[LastName]', 'Nachname geb. Geburtsname', 'Nachname / Geburtsname')), Panel::PANEL_TYPE_INFO), 4), new FormColumn(new Panel('Gruppen', $tblGroupList, Panel::PANEL_TYPE_INFO), 4)))))); }
/** * @param IFormInterface $Form * @param array $Account * * @return IFormInterface */ public function createAccount(IFormInterface $Form, $Account) { if (null === $Account) { return $Form; } $Error = false; $Username = trim($Account['Name']); $Password = trim($Account['Password']); $PasswordSafety = trim($Account['PasswordSafety']); $tblConsumer = GatekeeperConsumer::useService()->getConsumerBySession(); if (!($tblToken = GatekeeperToken::useService()->getTokenById((int) $Account['Token']))) { $tblToken = null; } if (empty($Username)) { $Form->setError('Account[Name]', 'Bitte geben Sie einen Benutzernamen an'); $Error = true; } else { if (preg_match('!^[a-z0-9]{5,}$!is', $Username)) { $Username = $tblConsumer->getAcronym() . '-' . $Username; if (!GatekeeperAccount::useService()->getAccountByUsername($Username)) { $Form->setSuccess('Account[Name]', ''); } else { $Form->setError('Account[Name]', 'Der angegebene Benutzername ist bereits vergeben'); $Error = true; } } else { $Form->setError('Account[Name]', 'Der Benutzername darf nur Buchstaben und Zahlen enthalten und muss mindestens 5 Zeichen lang sein'); $Error = true; } } if (empty($Password)) { $Form->setError('Account[Password]', 'Bitte geben Sie ein Passwort an'); $Error = true; } else { if (strlen($Password) >= 8) { $Form->setSuccess('Account[Password]', ''); } else { $Form->setError('Account[Password]', 'Das Passwort muss mindestens 8 Zeichen lang sein'); $Error = true; } } if (empty($PasswordSafety)) { $Form->setError('Account[PasswordSafety]', 'Bitte geben Sie das Passwort erneut an'); $Error = true; } if ($Password != $PasswordSafety) { $Form->setError('Account[Password]', ''); $Form->setError('Account[PasswordSafety]', 'Die beiden Passworte stimmen nicht überein'); $Error = true; } else { if (!empty($Password) && !empty($PasswordSafety)) { $Form->setSuccess('Account[PasswordSafety]', ''); } else { $Form->setError('Account[PasswordSafety]', ''); } } if (!$Error) { $tblAccount = GatekeeperAccount::useService()->insertAccount($Username, $Password, $tblToken, $tblConsumer); if ($tblAccount) { $tblIdentification = GatekeeperAccount::useService()->getIdentificationById($Account['Identification']); GatekeeperAccount::useService()->addAccountAuthentication($tblAccount, $tblIdentification); if (isset($Account['Role'])) { foreach ((array) $Account['Role'] as $Role) { $tblRole = GatekeeperAccess::useService()->getRoleById($Role); GatekeeperAccount::useService()->addAccountAuthorization($tblAccount, $tblRole); } } if (isset($Account['User'])) { $tblPerson = Person::useService()->getPersonById($Account['User']); GatekeeperAccount::useService()->addAccountPerson($tblAccount, $tblPerson); } return new Success('Das Benutzerkonnto wurde erstellt') . new Redirect('/Setting/Authorization/Account', 3); } else { return new Danger('Das Benutzerkonnto konnte nicht erstellt werden') . new Redirect('/Setting/Authorization/Account', 3); } } return $Form; }
/** * @param IFormInterface $Form * @param TblPerson $tblPersonFrom * @param int $tblPersonTo * @param array $Type * * @return IFormInterface|string */ public function createRelationshipToPerson(IFormInterface $Form, TblPerson $tblPersonFrom, $tblPersonTo, $Type) { /** * Skip to Frontend */ if (null === $Type) { return $Form; } $Error = false; if (empty($tblPersonTo)) { $Form->appendGridGroup(new FormGroup(new FormRow(new FormColumn(new Danger('Bitte wählen Sie eine Person'))))); $Error = true; } else { $tblPersonTo = Person::useService()->getPersonById($tblPersonTo); if ($tblPersonFrom->getId() == $tblPersonTo->getId()) { $Form->appendGridGroup(new FormGroup(new FormRow(new FormColumn(new Danger('Eine Person kann nur mit einer anderen Person verknüpft werden'))))); $Error = true; } } if (!$Error) { $tblType = $this->getTypeById($Type['Type']); if ((new Data($this->Binding))->addPersonRelationshipToPerson($tblPersonFrom, $tblPersonTo, $tblType, $Type['Remark'])) { return new Success('Die Beziehung wurde erfolgreich hinzugefügt') . new Redirect('/People/Person', 1, array('Id' => $tblPersonFrom->getId())); } else { return new Danger('Die Beziehung konnte nicht hinzugefügt werden') . new Redirect('/People/Person', 10, array('Id' => $tblPersonFrom->getId())); } } return $Form; }