<commit_before><?php
namespace SPHERE\Application\People\Search\Group;

use SPHERE\Application\Contact\Address\Address;
use SPHERE\Application\People\Group\Service\Entity\TblGroup;
use SPHERE\Application\People\Meta\Common\Common;
use SPHERE\Application\People\Person\Service\Entity\TblPerson;
use SPHERE\Common\Frontend\Icon\Repository\Pencil;
use SPHERE\Common\Frontend\Icon\Repository\PersonGroup;
use SPHERE\Common\Frontend\IFrontendInterface;
use SPHERE\Common\Frontend\Layout\Repository\Headline;
use SPHERE\Common\Frontend\Layout\Repository\Panel;
use SPHERE\Common\Frontend\Layout\Structure\Layout;
use SPHERE\Common\Frontend\Layout\Structure\LayoutColumn;
use SPHERE\Common\Frontend\Layout\Structure\LayoutGroup;
use SPHERE\Common\Frontend\Layout\Structure\LayoutRow;
use SPHERE\Common\Frontend\Link\Repository\Standard;
use SPHERE\Common\Frontend\Table\Structure\TableData;
use SPHERE\Common\Frontend\Text\Repository\Bold;
use SPHERE\Common\Frontend\Text\Repository\Danger;
use SPHERE\Common\Frontend\Text\Repository\Italic;
use SPHERE\Common\Frontend\Text\Repository\Muted;
use SPHERE\Common\Frontend\Text\Repository\Small;
use SPHERE\Common\Frontend\Text\Repository\Warning;
use SPHERE\Common\Window\Navigation\Link\Route;
use SPHERE\Common\Window\Stage;

/**
 * Class Frontend
 *
 * @package SPHERE\Application\People\Search\Group
 */
class Frontend implements IFrontendInterface
{

    /**
     * @param bool|false|int $Id
     *
     * @return Stage
     */
    public function frontendSearch($Id = false)
    {

        $Stage = new Stage('Suche', 'nach Gruppe');

        $tblGroupAll = Group::useService()->getGroupAll();
        if (!empty($tblGroupAll)) {
            /** @noinspection PhpUnusedParameterInspection */
            array_walk($tblGroupAll, function (TblGroup &$tblGroup, $Index, Stage $Stage) {

                $Stage->addButton(
                    new Standard(
                        $tblGroup->getName(),
                        new Route(__NAMESPACE__), new PersonGroup(),
                        array(
                            'Id' => $tblGroup->getId()
                        ), $tblGroup->getDescription())
                );
            }, $Stage);
        }

        $tblGroup = Group::useService()->getGroupById($Id);
        if ($tblGroup) {

            $tblPersonAll = Group::useService()->getPersonAllByGroup($tblGroup);

            if ($tblPersonAll) {
                array_walk($tblPersonAll, function (TblPerson &$tblPerson) {

                    $tblAddressAll = Address::useService()->getAddressAllByPerson($tblPerson);
                    if ($tblAddressAll) {
                        $tblToPerson = $tblAddressAll[0];
                        $tblAddressAll =
                            $tblToPerson->getTblAddress()->getStreetName() . ' '
                            . $tblToPerson->getTblAddress()->getStreetNumber() . ' '
                            . $tblToPerson->getTblAddress()->getTblCity()->getCode() . ' '
                            . $tblToPerson->getTblAddress()->getTblCity()->getName() . ' '
                            . ($tblToPerson->getTblAddress()->getTblState() ? $tblToPerson->getTblAddress()->getTblState()->getName() : '')
                            . ($tblToPerson->getRemark()
                                ? '<br/>' . new Small(new Muted($tblToPerson->getRemark()))
                                : ''
                            );
                    }

                    $tblPerson->FullName = $tblPerson->getFullName();
                    $tblPerson->Address = ($tblAddressAll
                        ? $tblAddressAll
                        : new Warning('Keine Adresse hinterlegt')
                    );
                    $tblPerson->Option = new Standard('', '/People/Person', new Pencil(),
                        array('Id' => $tblPerson->getId()), 'Bearbeiten');


                    $common = Common::useService()->getCommonById($tblPerson->getId());
                    if ($common)
                    {
                        $tblPerson->Remark = $common->getRemark();
                    }
                    else {
                        $tblPerson->Remark = '';
                    }
                });
            }
            $Stage->setContent(
                new Layout(new LayoutGroup(array(
                    new LayoutRow(new LayoutColumn(
                        new Panel(new PersonGroup() . ' Gruppe', array(
                            new Bold($tblGroup->getName()),
                            ($tblGroup->getDescription() ? new Small($tblGroup->getDescription()) : ''),
                            ($tblGroup->getRemark() ? new Danger(new Italic(nl2br($tblGroup->getRemark()))) : '')
                        ), Panel::PANEL_TYPE_SUCCESS
                        )
                    )),
                    new LayoutRow(new LayoutColumn(array(
                        new Headline('Verfügbare Personen', 'in dieser Gruppe'),
                        new TableData($tblPersonAll, null,
                            array(
                                'FullName' => 'Name',
                                'Address' => 'Adresse',<commit_msg>Transfer  Import FuxSchool -> Schüler Klassenzuordnung<commit_after><?php
namespace SPHERE\Application\People\Search\Group;

use SPHERE\Application\Contact\Address\Address;
use SPHERE\Application\People\Group\Service\Entity\TblGroup;
use SPHERE\Application\People\Meta\Common\Common;
use SPHERE\Application\People\Person\Service\Entity\TblPerson;
use SPHERE\Common\Frontend\Icon\Repository\Pencil;
use SPHERE\Common\Frontend\Icon\Repository\PersonGroup;
use SPHERE\Common\Frontend\IFrontendInterface;
use SPHERE\Common\Frontend\Layout\Repository\Headline;
use SPHERE\Common\Frontend\Layout\Repository\Panel;
use SPHERE\Common\Frontend\Layout\Structure\Layout;
use SPHERE\Common\Frontend\Layout\Structure\LayoutColumn;
use SPHERE\Common\Frontend\Layout\Structure\LayoutGroup;
use SPHERE\Common\Frontend\Layout\Structure\LayoutRow;
use SPHERE\Common\Frontend\Link\Repository\Standard;
use SPHERE\Common\Frontend\Table\Structure\TableData;
use SPHERE\Common\Frontend\Text\Repository\Bold;
use SPHERE\Common\Frontend\Text\Repository\Danger;
use SPHERE\Common\Frontend\Text\Repository\Italic;
use SPHERE\Common\Frontend\Text\Repository\Muted;
use SPHERE\Common\Frontend\Text\Repository\Small;
use SPHERE\Common\Frontend\Text\Repository\Warning;
use SPHERE\Common\Window\Navigation\Link\Route;
use SPHERE\Common\Window\Stage;

/**
 * Class Frontend
 *
 * @package SPHERE\Application\People\Search\Group
 */
class Frontend implements IFrontendInterface
{

    /**
     * @param bool|false|int $Id
     *
     * @return Stage
     */
    public function frontendSearch($Id = false)
    {

        $Stage = new Stage('Suche', 'nach Gruppe');

        $tblGroupAll = Group::useService()->getGroupAll();
        if (!empty($tblGroupAll)) {
            /** @noinspection PhpUnusedParameterInspection */
            array_walk($tblGroupAll, function (TblGroup &$tblGroup, $Index, Stage $Stage) {

                $Stage->addButton(
                    new Standard(
                        $tblGroup->getName(),
                        new Route(__NAMESPACE__), new PersonGroup(),
                        array(
                            'Id' => $tblGroup->getId()
                        ), $tblGroup->getDescription())
                );
            }, $Stage);
        }

        $tblGroup = Group::useService()->getGroupById($Id);
        if ($tblGroup) {

            $tblPersonAll = Group::useService()->getPersonAllByGroup($tblGroup);

            if ($tblPersonAll) {
                array_walk($tblPersonAll, function (TblPerson &$tblPerson) {

                    $tblAddressAll = Address::useService()->getAddressAllByPerson($tblPerson);
                    if ($tblAddressAll) {
                        $tblToPerson = $tblAddressAll[0];
                        $tblAddressAll =
                            $tblToPerson->getTblAddress()->getStreetName() . ' '
                            . $tblToPerson->getTblAddress()->getStreetNumber() . ' '
                            . $tblToPerson->getTblAddress()->getTblCity()->getCode() . ' '
                            . $tblToPerson->getTblAddress()->getTblCity()->getName() . ' '
                            . ($tblToPerson->getTblAddress()->getTblState() ? $tblToPerson->getTblAddress()->getTblState()->getName() : '')
                            . ($tblToPerson->getRemark()
                                ? '<br/>' . new Small(new Muted($tblToPerson->getRemark()))
                                : ''
                            );
                    }

                    $tblPerson->FullName = $tblPerson->getFullName();
                    $tblPerson->Address = ($tblAddressAll
                        ? $tblAddressAll
                        : new Warning('Keine Adresse hinterlegt')
                    );
                    $tblPerson->Option = new Standard('', '/People/Person', new Pencil(),
                        array('Id' => $tblPerson->getId()), 'Bearbeiten');


                    $common = Common::useService()->getCommonByPerson($tblPerson);
                    if ($common)
                    {
                        $tblPerson->Remark = $common->getRemark();
                    }
                    else {
                        $tblPerson->Remark = '';
                    }
                });
            }
            $Stage->setContent(
                new Layout(new LayoutGroup(array(
                    new LayoutRow(new LayoutColumn(
                        new Panel(new PersonGroup() . ' Gruppe', array(
                            new Bold($tblGroup->getName()),
                            ($tblGroup->getDescription() ? new Small($tblGroup->getDescription()) : ''),
                            ($tblGroup->getRemark() ? new Danger(new Italic(nl2br($tblGroup->getRemark()))) : '')
                        ), Panel::PANEL_TYPE_SUCCESS
                        )
                    )),
                    new LayoutRow(new LayoutColumn(array(
                        new Headline('Verfügbare Personen', 'in dieser Gruppe'),
                        new TableData($tblPersonAll, null,
                            array(
                                'FullName' => 'Name',
                                'Address' => 'Adresse',
{'fraction_non_alphanumeric': 0.1251201230059581, 'fraction_numerical': 0.0003843936190659235, 'mean_word_length': 1.7193624248758819, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 95, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5385516', 'n_tokens_mistral': 2800, 'n_tokens_neox': 2692, 'n_words': 387}