예제 #1
0
 /**
  * @return bool|TblGroup
  */
 public function getTblGroup()
 {
     if (null === $this->tblGroup) {
         return false;
     } else {
         return Group::useService()->getGroupById($this->tblGroup);
     }
 }
예제 #2
0
 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) . '&nbsp;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()));
 }
예제 #3
0
 /**
  * @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))))));
 }
예제 #4
0
 /**
  * @param IFormInterface $Form
  * @param TblPerson      $tblPerson
  * @param array          $Person
  *
  * @return IFormInterface|Redirect
  */
 public function updatePerson(IFormInterface $Form = null, TblPerson $tblPerson, $Person)
 {
     /**
      * Skip to Frontend
      */
     if (null === $Person) {
         return $Form;
     }
     $Error = false;
     if (isset($Person['FirstName']) && empty($Person['FirstName'])) {
         $Form->setError('Person[FirstName]', 'Bitte geben Sie einen Vornamen an');
         $Error = true;
     }
     if (isset($Person['LastName']) && empty($Person['LastName'])) {
         $Form->setError('Person[LastName]', 'Bitte geben Sie einen Nachnamen an');
         $Error = true;
     }
     if (!$Error) {
         if ((new Data($this->Binding))->updatePerson($tblPerson, $this->getSalutationById($Person['Salutation']), $Person['Title'], $Person['FirstName'], $Person['SecondName'], $Person['LastName'])) {
             // Change Groups
             if (isset($Person['Group'])) {
                 // Remove all Groups
                 $tblGroupList = Group::useService()->getGroupAllByPerson($tblPerson);
                 foreach ($tblGroupList as $tblGroup) {
                     Group::useService()->removeGroupPerson($tblGroup, $tblPerson);
                 }
                 // Add current Groups
                 foreach ((array) $Person['Group'] as $tblGroup) {
                     Group::useService()->addGroupPerson(Group::useService()->getGroupById($tblGroup), $tblPerson);
                 }
             } else {
                 // Remove all Groups
                 $tblGroupList = Group::useService()->getGroupAllByPerson($tblPerson);
                 foreach ($tblGroupList as $tblGroup) {
                     Group::useService()->removeGroupPerson($tblGroup, $tblPerson);
                 }
             }
             return new Success('Die Person wurde erfolgreich aktualisiert') . new Redirect('/People/Person', 1, array('Id' => $tblPerson->getId()));
         } else {
             return new Danger('Die Person konnte nicht aktualisiert werden') . new Redirect('/People/Person', 10);
         }
     }
     return $Form;
 }
예제 #5
0
 /**
  * @param int  $Id
  * @param bool $Confirm
  *
  * @return Stage
  */
 public function frontendDestroyGroup($Id, $Confirm = false)
 {
     $Stage = new Stage('Personengruppe', 'Löschen');
     if ($Id) {
         $tblGroup = Group::useService()->getGroupById($Id);
         if (!$Confirm) {
             $Stage->setContent(new Layout(new LayoutGroup(new LayoutRow(new LayoutColumn(array(new Panel(new Question() . ' Diese Gruppe wirklich löschen?', array($tblGroup->getName() . ' ' . $tblGroup->getDescription(), new Muted(new Small($tblGroup->getRemark()))), Panel::PANEL_TYPE_DANGER, new Standard('Ja', '/People/Group/Destroy', new Ok(), array('Id' => $Id, 'Confirm' => true)) . new Standard('Nein', '/People/Group', new Disable()))))))));
         } else {
             $tblPersonAll = Group::useService()->getPersonAllByGroup($tblGroup);
             /** @noinspection PhpUnusedParameterInspection */
             array_walk($tblPersonAll, function (TblPerson $tblPerson, $Index, TblGroup $tblGroup) {
                 Group::useService()->removeGroupPerson($tblGroup, $tblPerson);
             }, $tblGroup);
             $Stage->setContent(new Layout(new LayoutGroup(array(new LayoutRow(new LayoutColumn(array(Group::useService()->destroyGroup($tblGroup) ? new Success('Die Gruppe wurde gelöscht') : new Danger('Die Gruppe konnte nicht gelöscht werden'), new Redirect('/People/Group', 1))))))));
         }
     } else {
         $Stage->setContent(new Layout(new LayoutGroup(array(new LayoutRow(new LayoutColumn(array(new Danger('Die Gruppe konnte nicht gefunden werden'), new Redirect('/People/Group'))))))));
     }
     return $Stage;
 }
예제 #6
0
 /**
  * @return \SPHERE\Application\People\Group\Service
  */
 public static function useService()
 {
     return \SPHERE\Application\People\Group\Group::useService();
 }
예제 #7
0
 public function frontendGroup($Id = false)
 {
     $Stage = new Stage('Personensuche', 'nach Personengruppe');
     $tblGroup = Group::useService()->getGroupById($Id);
     $tblGroupAll = Group::useService()->getGroupAll();
     /** @noinspection PhpUnusedParameterInspection */
     array_walk($tblGroupAll, function (TblGroup &$tblGroup, $Index, Stage $Stage) {
         $Stage->addButton(new Standard($tblGroup->getName(), new Link\Route(__NAMESPACE__ . '/Group'), null, array('Id' => $tblGroup->getId()), $tblGroup->getDescription()));
     }, $Stage);
     if ($tblGroup) {
         $Stage->setMessage(new PullClear(new Bold($tblGroup->getName()) . ' ' . new Small($tblGroup->getDescription())) . new PullClear(new Danger(new Italic(nl2br($tblGroup->getRemark())))));
         $tblPersonAll = Group::useService()->getPersonAllByGroup($tblGroup);
     } else {
         $Stage->setMessage('Bitte wählen Sie eine Personengruppe');
         $tblPersonAll = Group::useService()->getPersonAllHavingNoGroup();
     }
     if ($tblPersonAll) {
         array_walk($tblPersonAll, function (TblPerson &$tblPerson) {
             $tblPerson->FullName = $tblPerson->getFullName();
             $tblPerson->Option = new Standard('', '/People/Person', new Pencil(), array('Id' => $tblPerson->getId()), 'Bearbeiten');
         });
         $Layout = array(new LayoutRow(new LayoutColumn(new TableData($tblPersonAll, null, array('FullName' => 'Name', 'Option' => 'Optionen')))));
         if (!$tblGroup) {
             array_unshift($Layout, new LayoutRow(new LayoutColumn(new DangerMessage('Folgende Personen sind keiner Gruppe zugewiesen'))));
         }
         $Stage->setContent(new Layout(new LayoutGroup($Layout)));
     }
     return $Stage;
 }