From ae693f8036cab00a4dcaaaeae27ba1b5fac73282 Mon Sep 17 00:00:00 2001 From: GitHubJanHave <147205074+GitHubJanHave@users.noreply.github.com> Date: Wed, 22 Nov 2023 17:14:55 +0100 Subject: [PATCH] admin groups created (#1117) Co-authored-by: Jan Havelka --- .../Forms/GroupFormFactory.php | 119 +++++++++++ .../Presenters/GroupPresenter.php | 37 ++++ .../Presenters/templates/Group/default.latte | 6 + .../Presenters/templates/sidebar.latte | 3 + .../Components/GroupsGridControl.php | 166 +++++++++++++++ .../Components/IGroupsGridControlFactory.php | 16 ++ .../Components/IStatusGridControlFactory.php | 16 ++ .../Components/StatusGridControl.php | 148 +++++++++++++ .../Components/templates/groups_grid.latte | 1 + .../Components/templates/status_grid.latte | 1 + .../Presenters/GroupsBasePresenter.php | 26 +++ .../Presenters/GroupsPresenter.php | 45 ++++ .../Presenters/StatusPresenter.php | 33 +++ .../Presenters/templates/@layout.latte | 2 + .../Presenters/templates/Groups/default.latte | 4 + .../Presenters/templates/Groups/detail.latte | 6 + .../Presenters/templates/Status/default.latte | 4 + .../Presenters/templates/sidebar.latte | 12 ++ .../Presenters/AdminBasePresenter.php | 1 + .../templates/Dashboard/default.latte | 20 ++ .../templates/includes/main_menu.latte | 6 + app/Model/Acl/SrsResource.php | 6 + .../Commands/Handlers/RemoveGroupHandler.php | 32 +++ .../Commands/Handlers/RemoveStatusHandler.php | 31 +++ .../Commands/Handlers/SaveGroupHandler.php | 21 ++ .../Commands/Handlers/SaveStatusHandler.php | 59 ++++++ app/Model/Group/Commands/RemoveGroup.php | 19 ++ app/Model/Group/Commands/RemoveStatus.php | 19 ++ app/Model/Group/Commands/SaveGroup.php | 19 ++ app/Model/Group/Commands/SaveStatus.php | 20 ++ app/Model/Group/Events/GroupUpdatedEvent.php | 24 +++ app/Model/Group/Events/StatusUpdatedEvent.php | 28 +++ .../Subscribers/GroupUpdatedEventListener.php | 22 ++ .../StatusUpdatedEventListener.php | 75 +++++++ app/Model/Group/Group.php | 186 +++++++++++++++++ .../Group/Repositories/GroupRepository.php | 194 ++++++++++++++++++ .../Group/Repositories/StatusRepository.php | 124 +++++++++++ app/Model/Group/Status.php | 49 +++++ app/Model/Settings/Settings.php | 15 ++ app/Router/RouterFactory.php | 7 + app/lang/admin.cs_CZ.neon | 16 ++ migrations/Version20231122111334.php | 38 ++++ 42 files changed, 1676 insertions(+) create mode 100644 app/AdminModule/ConfigurationModule/Forms/GroupFormFactory.php create mode 100644 app/AdminModule/ConfigurationModule/Presenters/GroupPresenter.php create mode 100644 app/AdminModule/ConfigurationModule/Presenters/templates/Group/default.latte create mode 100644 app/AdminModule/GroupsModule/Components/GroupsGridControl.php create mode 100644 app/AdminModule/GroupsModule/Components/IGroupsGridControlFactory.php create mode 100644 app/AdminModule/GroupsModule/Components/IStatusGridControlFactory.php create mode 100644 app/AdminModule/GroupsModule/Components/StatusGridControl.php create mode 100644 app/AdminModule/GroupsModule/Components/templates/groups_grid.latte create mode 100644 app/AdminModule/GroupsModule/Components/templates/status_grid.latte create mode 100644 app/AdminModule/GroupsModule/Presenters/GroupsBasePresenter.php create mode 100644 app/AdminModule/GroupsModule/Presenters/GroupsPresenter.php create mode 100644 app/AdminModule/GroupsModule/Presenters/StatusPresenter.php create mode 100644 app/AdminModule/GroupsModule/Presenters/templates/@layout.latte create mode 100644 app/AdminModule/GroupsModule/Presenters/templates/Groups/default.latte create mode 100644 app/AdminModule/GroupsModule/Presenters/templates/Groups/detail.latte create mode 100644 app/AdminModule/GroupsModule/Presenters/templates/Status/default.latte create mode 100644 app/AdminModule/GroupsModule/Presenters/templates/sidebar.latte create mode 100644 app/Model/Group/Commands/Handlers/RemoveGroupHandler.php create mode 100644 app/Model/Group/Commands/Handlers/RemoveStatusHandler.php create mode 100644 app/Model/Group/Commands/Handlers/SaveGroupHandler.php create mode 100644 app/Model/Group/Commands/Handlers/SaveStatusHandler.php create mode 100644 app/Model/Group/Commands/RemoveGroup.php create mode 100644 app/Model/Group/Commands/RemoveStatus.php create mode 100644 app/Model/Group/Commands/SaveGroup.php create mode 100644 app/Model/Group/Commands/SaveStatus.php create mode 100644 app/Model/Group/Events/GroupUpdatedEvent.php create mode 100644 app/Model/Group/Events/StatusUpdatedEvent.php create mode 100644 app/Model/Group/Events/Subscribers/GroupUpdatedEventListener.php create mode 100644 app/Model/Group/Events/Subscribers/StatusUpdatedEventListener.php create mode 100644 app/Model/Group/Group.php create mode 100644 app/Model/Group/Repositories/GroupRepository.php create mode 100644 app/Model/Group/Repositories/StatusRepository.php create mode 100644 app/Model/Group/Status.php create mode 100644 migrations/Version20231122111334.php diff --git a/app/AdminModule/ConfigurationModule/Forms/GroupFormFactory.php b/app/AdminModule/ConfigurationModule/Forms/GroupFormFactory.php new file mode 100644 index 000000000..dc7f7681c --- /dev/null +++ b/app/AdminModule/ConfigurationModule/Forms/GroupFormFactory.php @@ -0,0 +1,119 @@ +baseFormFactory->create(); + + $renderer = $form->getRenderer(); + assert($renderer instanceof Bs4FormRenderer); + $renderer->wrappers['control']['container'] = 'div class="col-7"'; + $renderer->wrappers['label']['container'] = 'div class="col-5 col-form-label"'; + + $form->addText('groupMinMembers', 'admin.configuration.group_min_members') + ->addRule(Form::FILLED, 'admin.configuration.group_min_members_empty'); + + $form->addText('groupMaxMembers', 'admin.configuration.group_max_members') + ->addRule(Form::FILLED, 'admin.configuration.group_max_members_empty'); + + $groupFillTerm = new DateControl('admin.configuration.group_fill_term'); + $groupFillTerm->addRule(Form::FILLED, 'admin.configuration.group_fill_term_empty'); + $form->addComponent($groupFillTerm, 'groupFillTerm'); + + + + $form->addSubmit('submit', 'admin.common.save'); + + $form->setDefaults([ + 'groupMinMembers' => $this->queryBus->handle(new SettingStringValueQuery(Settings::GROUP_MIN_MEMBERS)), + 'groupMaxMembers' => $this->queryBus->handle(new SettingStringValueQuery(Settings::GROUP_MAX_MEMBERS)), + 'groupFillTerm' => $this->queryBus->handle(new SettingDateValueQuery(Settings::GROUP_FILL_TERM)), + ]); + + $form->onSuccess[] = [$this, 'processForm']; + + return $form; + } + + /** + * Zpracuje formulář. + * + * @throws Throwable + */ + public function processForm(Form $form, stdClass $values): void + { + $this->commandBus->handle(new SetSettingStringValue(Settings::GROUP_MIN_MEMBERS, $values->groupMinMembers)); + $this->commandBus->handle(new SetSettingStringValue(Settings::GROUP_MAX_MEMBERS, $values->groupMaxMembers)); + $this->commandBus->handle(new SetSettingDateValue(Settings::GROUP_FILL_TERM, $values->groupFillTerm)); + } + + /** + * Ověří, že datum začátku semináře je dříve než konce. + * + * @param DateTime[] $args + */ + public function validateSeminarFromDate(DateControl $field, array $args): bool + { + return $args[0] <= $args[1]; + } + + /** + * Ověří, že datum konce semináře je později než začátku. + * + * @param DateTime[] $args + */ + public function validateSeminarToDate(DateControl $field, array $args): bool + { + return $args[0] >= $args[1]; + } + + /** + * Ověří, že datum uzavření registrace je dříve než začátek semináře. + * + * @param DateTime[] $args + */ + public function validateEditRegistrationTo(DateControl $field, array $args): bool + { + return $args[0] < $args[1]; + } +} diff --git a/app/AdminModule/ConfigurationModule/Presenters/GroupPresenter.php b/app/AdminModule/ConfigurationModule/Presenters/GroupPresenter.php new file mode 100644 index 000000000..214815ace --- /dev/null +++ b/app/AdminModule/ConfigurationModule/Presenters/GroupPresenter.php @@ -0,0 +1,37 @@ +groupFormFactory->create(); + + $form->onSuccess[] = function (Form $form, stdClass $values): void { + $this->flashMessage('admin.configuration.configuration_saved', 'success'); + $this->redirect('this'); + }; + + return $form; + } +} diff --git a/app/AdminModule/ConfigurationModule/Presenters/templates/Group/default.latte b/app/AdminModule/ConfigurationModule/Presenters/templates/Group/default.latte new file mode 100644 index 000000000..15324a3ce --- /dev/null +++ b/app/AdminModule/ConfigurationModule/Presenters/templates/Group/default.latte @@ -0,0 +1,6 @@ +{block main} +

{_admin.configuration.group_heading}

+
+ {control groupForm} +
+{/block} \ No newline at end of file diff --git a/app/AdminModule/ConfigurationModule/Presenters/templates/sidebar.latte b/app/AdminModule/ConfigurationModule/Presenters/templates/sidebar.latte index e992fd693..cd16a581e 100644 --- a/app/AdminModule/ConfigurationModule/Presenters/templates/sidebar.latte +++ b/app/AdminModule/ConfigurationModule/Presenters/templates/sidebar.latte @@ -31,6 +31,9 @@ {_admin.configuration.menu.skautis} + + {_admin.configuration.menu.group} + {_admin.configuration.menu.web} diff --git a/app/AdminModule/GroupsModule/Components/GroupsGridControl.php b/app/AdminModule/GroupsModule/Components/GroupsGridControl.php new file mode 100644 index 000000000..0ca28d3f3 --- /dev/null +++ b/app/AdminModule/GroupsModule/Components/GroupsGridControl.php @@ -0,0 +1,166 @@ +sessionSection = $session->getSection('srs'); + } + + /** + * Vykreslí komponentu. + */ + public function render(): void + { + $this->template->setFile(__DIR__ . '/templates/groups_grid.latte'); + $this->template->render(); + } + + /** + * Vytvoří komponentu. + * + * @throws DataGridException + */ + public function createComponentGroupsGrid(string $name): void + { + $grid = new DataGrid($this, $name); + $grid->setTranslator($this->translator); + $grid->setDataSource($this->groupRepository->createQueryBuilder('g')); + $grid->setDefaultSort(['name' => 'ASC']); + $grid->setPagination(false); + + + $grid->addColumnText('name', 'admin.program.groups.column.name'); + + $grid->addColumnText('leader_email', 'admin.program.groups.column.name'); + $grid->addColumnText('places', 'admin.program.groups.column.name'); + $grid->addColumnText('price', 'admin.program.groups.column.name'); + + $grid->addInlineAdd()->setPositionTop()->onControlAdd[] = function (Container $container): void { + $container->addText('name', '') + ->addRule(Form::FILLED, 'admin.program.groups.column.name_empty') + ->addRule(Form::IS_NOT_IN, 'admin.program.groups.column.name_exists', $this->groupRepository->findAll()); + + $container->addText('places', '') + ->addCondition(Form::FILLED) + ->addRule(Form::INTEGER, 'admin.program.groups.column.capacity_format'); + }; + $grid->getInlineAdd()->onSubmit[] = [$this, 'add']; + + $grid->addInlineEdit()->onControlAdd[] = static function (Container $container): void { + $container->addText('name', '') + ->addRule(Form::FILLED, 'admin.program.groups.column.name_empty'); + + $container->addText('places', '') + ->addCondition(Form::FILLED) + ->addRule(Form::INTEGER, 'admin.program.groups.column.capacity_format'); + }; + $grid->getInlineEdit()->onSetDefaults[] = function (Container $container, Group $item): void { + $nameText = $container['name']; + assert($nameText instanceof TextInput); + $nameText->addRule(Form::IS_NOT_IN, 'admin.program.groups.column.name_exists', $this->groupRepository->findOthersNames($item->getId())); + + $container->setDefaults([ + 'name' => $item->getName(), + 'places' => $item->getPlaces(), + ]); + }; + $grid->getInlineEdit()->onSubmit[] = [$this, 'edit']; + + $grid->addAction('detail', 'admin.common.detail', 'Groups:detail') + ->setClass('btn btn-xs btn-primary'); + + $grid->addAction('delete', '', 'delete!') + ->setIcon('trash') + ->setTitle('admin.common.delete') + ->setClass('btn btn-xs btn-danger') + ->addAttributes([ + 'data-toggle' => 'confirmation', + 'data-content' => $this->translator->translate('admin.program.groups.action.delete_confirm'), + ]); + } + + /** + * Zpracuje přidání místnosti. + */ + public function add(stdClass $values): void + { + $group = new Group($values->name, $values->capacity !== '' ? $values->capacity : null); + + $this->commandBus->handle(new SaveGroup($group)); + + $p = $this->getPresenter(); + $p->flashMessage('admin.program.groups.message.save_success', 'success'); + $p->redrawControl('flashes'); + } + + /** + * Zpracuje úpravu místnosti. + */ + public function edit(string $id, stdClass $values): void + { + $group = $this->groupRepository->findById((int) $id); + + $group->setName($values->name); + $group->setCapacity($values->capacity !== '' ? $values->capacity : null); + + $this->commandBus->handle(new SaveGroup($group)); + + $p = $this->getPresenter(); + $p->flashMessage('admin.program.groups.message.save_success', 'success'); + $p->redrawControl('flashes'); + } + + /** + * Odstraní místnost. + * + * @throws AbortException + */ + public function handleDelete(int $id): void + { + $group = $this->groupRepository->findById($id); + + $this->commandBus->handle(new RemoveGroup($group)); + + $p = $this->getPresenter(); + $p->flashMessage('admin.program.groups.message.delete_success', 'success'); + $p->redirect('this'); + } + + +} diff --git a/app/AdminModule/GroupsModule/Components/IGroupsGridControlFactory.php b/app/AdminModule/GroupsModule/Components/IGroupsGridControlFactory.php new file mode 100644 index 000000000..af0adfb4b --- /dev/null +++ b/app/AdminModule/GroupsModule/Components/IGroupsGridControlFactory.php @@ -0,0 +1,16 @@ +template->setFile(__DIR__ . '/templates/status_grid.latte'); + $this->template->render(); + } + + /** + * Vytvoří komponentu. + * + * @throws DataGridException + */ + public function createComponentStatusGrid(string $name): void + { + $grid = new DataGrid($this, $name); + $grid->setTranslator($this->translator); + $grid->setDataSource($this->statusRepository->createQueryBuilder('c')); + $grid->setDefaultSort(['name' => 'ASC']); + $grid->setPagination(false); + + $grid->addColumnText('name', 'admin.groups.status.column.name'); + + $grid->addInlineAdd()->setPositionTop()->onControlAdd[] = function (Container $container): void { + $container->addText('name', '') + ->addRule(Form::FILLED, 'admin.groups.status.column.name_empty') + ->addRule(Form::IS_NOT_IN, 'admin.groups.status.column.name_exists', $this->statusRepository->findAllNames()); + + }; + $grid->getInlineAdd()->onSubmit[] = [$this, 'add']; + + $grid->addInlineEdit()->onControlAdd[] = static function (Container $container): void { + $container->addText('name', '') + ->addRule(Form::FILLED, 'admin.groups.status.column.name_empty'); + + }; + $grid->getInlineEdit()->onSetDefaults[] = function (Container $container, Status $item): void { + $nameText = $container['name']; + assert($nameText instanceof TextInput); + $nameText->addRule(Form::IS_NOT_IN, 'admin.groups.status.column.name_exists', $this->statusRepository->findOthersNames($item->getId())); + + $container->setDefaults([ + 'name' => $item->getName(), + ]); + }; + $grid->getInlineEdit()->onSubmit[] = [$this, 'edit']; + + $grid->addAction('delete', '', 'delete!') + ->setIcon('trash') + ->setTitle('admin.common.delete') + ->setClass('btn btn-xs btn-danger') + ->addAttributes([ + 'data-toggle' => 'confirmation', + 'data-content' => $this->translator->translate('admin.groups.status.action.delete_confirm'), + ]); + } + + /** + * Zpracuje přidání kategorie. + */ + public function add(stdClass $values): void + { + $status = new Status($values->name); + + + $this->commandBus->handle(new SaveStatus($status)); + + $this->getPresenter()->flashMessage('admin.groups.status.message.save_success', 'success'); + $this->getPresenter()->redrawControl('flashes'); + } + + /** + * Zpracuje úpravu kategorie. + * + * @throws Throwable + */ + public function edit(string $id, stdClass $values): void + { + $status = $this->statusRepository->findById((int) $id); + $statusOld = clone $status; + + $status->setName($values->name); + + $this->commandBus->handle(new SaveStatus($status)); + + $this->getPresenter()->flashMessage('admin.groups.status.message.save_success', 'success'); + $this->getPresenter()->redrawControl('flashes'); + } + + /** + * Odstraní kategorii. + * + * @throws AbortException + * @throws Throwable + */ + public function handleDelete(int $id): void + { + $status = $this->statusRepository->findById($id); + + $p = $this->getPresenter(); + + if ($status->getBlocks()->isEmpty()) { + $this->commandBus->handle(new RemoveStatus($status)); + $p->flashMessage('admin.groups.status.message.delete_success', 'success'); + } else { + $p->flashMessage('admin.groups.status.message.delete_failed', 'danger'); + } + + $p->redirect('this'); + } +} diff --git a/app/AdminModule/GroupsModule/Components/templates/groups_grid.latte b/app/AdminModule/GroupsModule/Components/templates/groups_grid.latte new file mode 100644 index 000000000..b84b0d0e4 --- /dev/null +++ b/app/AdminModule/GroupsModule/Components/templates/groups_grid.latte @@ -0,0 +1 @@ +{control groupsGrid} \ No newline at end of file diff --git a/app/AdminModule/GroupsModule/Components/templates/status_grid.latte b/app/AdminModule/GroupsModule/Components/templates/status_grid.latte new file mode 100644 index 000000000..cb03db51c --- /dev/null +++ b/app/AdminModule/GroupsModule/Components/templates/status_grid.latte @@ -0,0 +1 @@ +{control statusGrid} \ No newline at end of file diff --git a/app/AdminModule/GroupsModule/Presenters/GroupsBasePresenter.php b/app/AdminModule/GroupsModule/Presenters/GroupsBasePresenter.php new file mode 100644 index 000000000..180535821 --- /dev/null +++ b/app/AdminModule/GroupsModule/Presenters/GroupsBasePresenter.php @@ -0,0 +1,26 @@ +checkPermission(Permission::MANAGE); + } +} diff --git a/app/AdminModule/GroupsModule/Presenters/GroupsPresenter.php b/app/AdminModule/GroupsModule/Presenters/GroupsPresenter.php new file mode 100644 index 000000000..d1e233206 --- /dev/null +++ b/app/AdminModule/GroupsModule/Presenters/GroupsPresenter.php @@ -0,0 +1,45 @@ +checkPermission(Permission::MANAGE); + } + + public function renderDetail(int $id): void + { + $group = $this->groupRepository->findById($id); + + $this->template->group = $group; + } + + protected function createComponentGroupsGrid(): GroupsGridControl + { + return $this->groupsGridControlFactory->create(); + } +} diff --git a/app/AdminModule/GroupsModule/Presenters/StatusPresenter.php b/app/AdminModule/GroupsModule/Presenters/StatusPresenter.php new file mode 100644 index 000000000..cb706769c --- /dev/null +++ b/app/AdminModule/GroupsModule/Presenters/StatusPresenter.php @@ -0,0 +1,33 @@ +checkPermission(Permission::MANAGE); + } + + protected function createComponentStatusGrid(): StatusGridControl + { + return $this->statusGridControlFactory->create(); + } +} diff --git a/app/AdminModule/GroupsModule/Presenters/templates/@layout.latte b/app/AdminModule/GroupsModule/Presenters/templates/@layout.latte new file mode 100644 index 000000000..1cc7452c7 --- /dev/null +++ b/app/AdminModule/GroupsModule/Presenters/templates/@layout.latte @@ -0,0 +1,2 @@ +{layout '../../../Presenters/templates/@layout.latte'} +{import 'sidebar.latte'} \ No newline at end of file diff --git a/app/AdminModule/GroupsModule/Presenters/templates/Groups/default.latte b/app/AdminModule/GroupsModule/Presenters/templates/Groups/default.latte new file mode 100644 index 000000000..e3374c03a --- /dev/null +++ b/app/AdminModule/GroupsModule/Presenters/templates/Groups/default.latte @@ -0,0 +1,4 @@ +{block main} +

{_admin.groups.group.heading}

+ {control groupsGrid} +{/block} \ No newline at end of file diff --git a/app/AdminModule/GroupsModule/Presenters/templates/Groups/detail.latte b/app/AdminModule/GroupsModule/Presenters/templates/Groups/detail.latte new file mode 100644 index 000000000..ffa3bba41 --- /dev/null +++ b/app/AdminModule/GroupsModule/Presenters/templates/Groups/detail.latte @@ -0,0 +1,6 @@ +{block main} +

{_admin.program.groups.detail.heading, ['name' => $room->getName()]}

+ +

{_admin.program.groups.schedule.heading}

+ {control groupscheduleGrid} +{/block} \ No newline at end of file diff --git a/app/AdminModule/GroupsModule/Presenters/templates/Status/default.latte b/app/AdminModule/GroupsModule/Presenters/templates/Status/default.latte new file mode 100644 index 000000000..c81cb73a3 --- /dev/null +++ b/app/AdminModule/GroupsModule/Presenters/templates/Status/default.latte @@ -0,0 +1,4 @@ +{block main} +

{_admin.groups.status.heading}

+ {control statusGrid} +{/block} \ No newline at end of file diff --git a/app/AdminModule/GroupsModule/Presenters/templates/sidebar.latte b/app/AdminModule/GroupsModule/Presenters/templates/sidebar.latte new file mode 100644 index 000000000..05f1d9ac9 --- /dev/null +++ b/app/AdminModule/GroupsModule/Presenters/templates/sidebar.latte @@ -0,0 +1,12 @@ +{block sidebar} +
+ +
+{/block} \ No newline at end of file diff --git a/app/AdminModule/Presenters/AdminBasePresenter.php b/app/AdminModule/Presenters/AdminBasePresenter.php index d311660ac..5ec80872d 100644 --- a/app/AdminModule/Presenters/AdminBasePresenter.php +++ b/app/AdminModule/Presenters/AdminBasePresenter.php @@ -91,6 +91,7 @@ public function beforeRender(): void $this->template->resourcePayments = SrsResource::PAYMENTS; $this->template->resourceMailing = SrsResource::MAILING; $this->template->resourceProgram = SrsResource::PROGRAM; + $this->template->resourceGroups = SrsResource::GROUPS; $this->template->permissionAccess = Permission::ACCESS; $this->template->permissionManage = Permission::MANAGE; diff --git a/app/AdminModule/Presenters/templates/Dashboard/default.latte b/app/AdminModule/Presenters/templates/Dashboard/default.latte index 079890a8d..824a60db1 100644 --- a/app/AdminModule/Presenters/templates/Dashboard/default.latte +++ b/app/AdminModule/Presenters/templates/Dashboard/default.latte @@ -106,6 +106,26 @@ +
+ +
+
diff --git a/app/AdminModule/Presenters/templates/includes/main_menu.latte b/app/AdminModule/Presenters/templates/includes/main_menu.latte index 6c9ed73f0..dd52f5150 100644 --- a/app/AdminModule/Presenters/templates/includes/main_menu.latte +++ b/app/AdminModule/Presenters/templates/includes/main_menu.latte @@ -42,6 +42,12 @@ {_admin.menu.mailing} +
  • + {_admin.menu.groups} +
  • +
  • abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('CREATE TABLE `group` (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, leader_id INT NOT NULL, leader_email VARCHAR(255) NOT NULL, create_date DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', group_status_id INT NOT NULL, places VARCHAR(255) NOT NULL, price INT NOT NULL, note LONGTEXT DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE status (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_7B00651C5E237E06 (name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('INSERT INTO `settings` (`item`, `value`) VALUES (\'group_fill_term\', \'2023-10-20\')'); + $this->addSql('INSERT INTO `settings` (`item`, `value`) VALUES (\'group_max_members\', \'11\')'); + $this->addSql('INSERT INTO `settings` (`item`, `value`) VALUES (\'group_min_members\', \'5\')'); + $this->addSql('INSERT INTO `permission` (`id`, `resource_id`, `name`) VALUES (15, 9, \'manage\')'); + $this->addSql('INSERT INTO `resource` (`name`) VALUES (\'groups\')'); + $this->addSql('INSERT INTO `role_permission` (`role_id`, `permission_id`) VALUES (8, 15)'); + $this->addSql('INSERT INTO `status` (`name`) VALUES (\'čeká na naplnění\')'); + $this->addSql('INSERT INTO `status` (`name`) VALUES (\'čeká na zaplacení\')'); + $this->addSql('INSERT INTO `status` (`name`) VALUES (\'zaplacená\')'); + $this->addSql('INSERT INTO `status` (`name`) VALUES (\'zrušená\')'); + } + + public function down(Schema $schema): void + { + } +}