Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #166 from itk-dev/release/3.2.0
Browse files Browse the repository at this point in the history
Release/3.2.0
  • Loading branch information
samilesma authored Dec 3, 2023
2 parents 023b493 + 6813f02 commit 8ea673d
Show file tree
Hide file tree
Showing 48 changed files with 839 additions and 290 deletions.
25 changes: 24 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,28 @@ Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [3.2.0] - 2023-11-20

### Changed

#### Features

- Show PNumbers on create case page for company clients
- Open existing cases in new tab.
- Show phone number for person clients
- Form in edit client page updated
- Show relations in metadata table for company clients
- Print function in multiple pages.
- Multiple design fixes

#### Bugfixes

- Correct icons are showed in tables, depending on folded/unfolded
- Correct table opens when unfolding a table
- Journal entry opens in the dashboard
- Don't show Load more button in P Numbers, if company has less than 5
- Able to add channels and benefits when creating a case

## [3.1.1] - 2023-11-20

### Changed
Expand Down Expand Up @@ -242,7 +264,8 @@ Versioning](https://semver.org/spec/v2.0.0.html).

- [KON-361](https://github.com/aakb/kontrolgruppen/pull/81): Changed datepicker

[Unreleased]: https://github.com/itk-dev/kontrolgruppen/compare/3.1.1...HEAD
[Unreleased]: https://github.com/itk-dev/kontrolgruppen/compare/3.2.0...HEAD
[3.2.0]: https://github.com/itk-dev/kontrolgruppen/compare/3.1.1...3.2.0
[3.1.1]: https://github.com/itk-dev/kontrolgruppen/compare/3.1.0...3.1.1
[3.1.0]: https://github.com/itk-dev/kontrolgruppen/compare/3.0.0...3.1.0
[3.0.0]: https://github.com/itk-dev/kontrolgruppen/compare/2.0.3...3.0.0
Expand Down
7 changes: 6 additions & 1 deletion UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ All upgrade notes for this project will be documented in this file.

## [Unreleased]

## [3.2.0] - 2023-12-03

Nothing has been changed

## [3.1.1] - 2023-11-20

Nothing has been changed
Expand Down Expand Up @@ -37,7 +41,8 @@ Nothing has been changed
DEFAULT_URI=''
```

[Unreleased]: https://github.com/itk-dev/kontrolgruppen/compare/3.1.1...HEAD
[Unreleased]: https://github.com/itk-dev/kontrolgruppen/compare/3.2.0...HEAD
[3.2.0]: https://github.com/itk-dev/kontrolgruppen/compare/3.1.1...3.2.0
[3.1.1]: https://github.com/itk-dev/kontrolgruppen/compare/3.1.0...3.1.1
[3.1.0]: https://github.com/itk-dev/kontrolgruppen/compare/3.0.0...3.1.0
[3.0.0]: https://github.com/itk-dev/kontrolgruppen/compare/2.0.3...3.0.0
2 changes: 1 addition & 1 deletion core/Controller/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function createChangeProcessStatusForm(Process $process)
'label' => 'process.form.process_status',
'label_attr' => ['class' => 'sr-only'],
'placeholder' => 'process.form.change_process_status.placeholder',
'attr' => ['class' => 'form-control-lg process-type-select'],
'attr' => ['class' => 'form-control-md process-type-select no-print'],
])
->add(
'save',
Expand Down
42 changes: 39 additions & 3 deletions core/Controller/ProcessController.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ public function index(Request $request, ProcessRepository $processRepository, Fi
*/
public function new(Request $request, ProcessManager $processManager, ProcessClientManager $clientManager, UserRepository $userRepository, DatafordelerService $datafordelerService): Response
{
$session = $request->getSession();
$process = new Process();
$this->denyAccessUnlessGranted('edit', $process);

Expand All @@ -207,19 +208,44 @@ public function new(Request $request, ProcessManager $processManager, ProcessCli
}
$caseWorker = $request->get('case_worker');
$identifier = $request->get('identifier');
if (null !== $identifier) {
$session->set('identifier', $identifier);
}

if ($session->has('identifier') && null !== $session->get('identifier')) {
$identifier = $session->get('identifier');
} else {
$identifier = null;
}

$caseWorker = $userRepository->findOneBy(['username' => $caseWorker]);
$process->setProcessClient($client);
$process->setCaseWorker($caseWorker);

$pNumbers = [];
if (ProcessClientCompany::COMPANY === $request->get('clientType')) {
$virksomhedData = $datafordelerService->getVirksomhedData($identifier);
// Extracting pNumbers from the response
if (!empty($virksomhedData['produktionsenheder'])) {
foreach ($virksomhedData['produktionsenheder'] as $produktionsenhed) {
$pNumbers[] = $produktionsenhed['pNummer'];
}
}
}
$session->set('pNumbers', $pNumbers);
if ($session->has('pNumbers')) {
$pNumbers = $session->get('pNumbers');
} else {
$pNumbers = [];
}
$form = $this->createForm(ProcessType::class, $process, [
// Add the `personnummer` option to the form.
'identifier' => $identifier,
'pNumbers' => $pNumbers,
]);

$this->handleTaxonomyCallback($form, $request, $process);

$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {
// Get unmapped client data from request.
$data = $request->get('process');
Expand All @@ -238,15 +264,22 @@ public function new(Request $request, ProcessManager $processManager, ProcessCli
if (ProcessClientPerson::PERSON === $clientType) {
$processClientIdentifier = preg_replace('/\D+/', '', $processClientIdentifier);
$dataFordelerData = $datafordelerService->getPersonData($processClientIdentifier);
$client->setName($dataFordelerData['stamdata']['navn'] ?? null);
$this->em->persist($client);
$this->em->flush();
} elseif (ProcessClientCompany::COMPANY === $clientType) {
$dataFordelerData = $datafordelerService->getVirksomhedData($processClientIdentifier);
$client->setAddress($dataFordelerData['beliggenhedsadresse']['CVRAdresse_vejnavn'].' '.$dataFordelerData['beliggenhedsadresse']['CVRAdresse_husnummerFra'] ?? null);
$client->setPostalCode($dataFordelerData['beliggenhedsadresse']['CVRAdresse_postnummer'] ?? null);
$client->setCity($dataFordelerData['beliggenhedsadresse']['CVRAdresse_postdistrikt'] ?? null);
$client->setName($dataFordelerData['virksomhedsnavn']['vaerdi'] ?? null);

// SAVE DATA
$this->em->persist($client);
$this->em->flush();
// remove identifier and pNumbers from session
$session->remove('identifier');
$session->remove('pNumbers');
}

$processCreated = true;
Expand Down Expand Up @@ -410,12 +443,15 @@ public function edit(Request $request, Process $process, DatafordelerService $da
$processClientIdentifier = $process->getProcessClient()->getIdentifier();
// Get client type
$clientType = $process->getProcessClient()->getType();
$client = $process->getProcessClient();

if (ProcessClientPerson::PERSON === $clientType) {
$processClientIdentifier = preg_replace('/\D+/', '', $processClientIdentifier);
$data = $datafordelerService->getPersonData($processClientIdentifier);
$client->setName($data['stamdata']['navn'] ?? null);
} elseif (ProcessClientCompany::COMPANY === $clientType) {
$data = $datafordelerService->getVirksomhedData($processClientIdentifier);
$client->setName($data['virksomhedsnavn']['vaerdi'] ?? null);
}
if ($form->isSubmitted() && $form->isValid()) {
$this->em->flush();
Expand Down Expand Up @@ -646,7 +682,7 @@ public function searchTaxonomy(Request $request, string $taxonomy, EntityManager
private function handleTaxonomyCallback(FormInterface $form, Request $request, Process $process)
{
if ('GET' === $request->getMethod()
&& null !== ($processData = $request->query->get('process'))
&& null !== ($processData = $request->get('process'))
&& isset($processData['processType'])) {
$form->submit($processData);
}
Expand Down
2 changes: 2 additions & 0 deletions core/DependencyInjection/KontrolgruppenCoreExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public function load(array $configs, ContainerBuilder $container)
public function prepend(ContainerBuilder $container)
{
$container->setParameter('site_name', '%env(SITE_NAME)%');
$container->setParameter('env', '%env(APP_ENV)%');

$container->loadFromExtension(
'twig',
Expand All @@ -73,6 +74,7 @@ public function prepend(ContainerBuilder $container)
],
'globals' => [
'site_name' => '%site_name%',
'env' => '%env%',
],
]
);
Expand Down
30 changes: 30 additions & 0 deletions core/Entity/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -946,4 +946,34 @@ public function setOriginallyCompletedAt(?\DateTimeInterface $originallyComplete

return $this;
}

/**
* @param int $processId
*
* @return array
*/
public function getProcessGroupsByAssociation(int $processId): array
{
$processGroups = [];

foreach ($this->getProcessGroups() as $processGroup) {
foreach ($processGroup->getProcesses() as $process) {
if ($process->getId() !== $processId) {
if (null !== $process->getProcessClient()->getName() && '' !== $process->getProcessClient()->getName()) {
$processGroups[] = [
'processId' => $process->getId(),
'processName' => $process->getProcessClient()->getName(),
];
} else {
$processGroups[] = [
'processId' => $process->getId(),
'processName' => $process->getCaseNumber(),
];
}
}
}
}

return $processGroups;
}
}
11 changes: 10 additions & 1 deletion core/Form/Process/ClientCompanyType.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
Expand Down Expand Up @@ -45,6 +46,7 @@ public function __construct(RouterInterface $router, TranslatorInterface $transl
public function buildForm(FormBuilderInterface $builder, array $options)
{
$identifier = $options['identifier'] ?? null; // Get the identifier
$pNumbers = $options['pNumbers'] ?? [];

$builder
->add('cvr', TextType::class, [
Expand All @@ -67,6 +69,12 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'data-search-text' => $this->translator->trans('process.form.search_client_cvr.search'),
'data-loading-text' => $this->translator->trans('process.form.search_client_cvr.loading'),
],
])
->add('pNumber', ChoiceType::class, [
'label' => 'process.form.p_number',
'choices' => array_combine($pNumbers, $pNumbers),
'placeholder' => 'process.form.p_number_placeholder',
'required' => false,
]);
}

Expand All @@ -75,6 +83,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefined(['identifier']);
// $resolver->setDefined(['identifier']);
$resolver->setDefined(['identifier', 'pNumbers']);
}
}
5 changes: 4 additions & 1 deletion core/Form/ProcessType.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public function buildForm(FormBuilderInterface $builder, array $options)
/** @var Process $process */
$process = $builder->getData();
$identifier = $options['identifier'] ?? null;
$pNumbers = $options['pNumbers'] ?? null;

$builder
->add('processType', null, [
'choices' => $this->processTypeRepository->findByProcess($process),
Expand All @@ -88,6 +90,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'identifier' => $identifier,
'label' => false,
'mapped' => false,
'pNumbers' => $pNumbers,
]);
break;

Expand Down Expand Up @@ -195,6 +198,6 @@ public function configureOptions(OptionsResolver $resolver)
$resolver->setDefaults([
'data_class' => Process::class,
]);
$resolver->setDefined(['identifier']);
$resolver->setDefined(['identifier', 'pNumbers']);
}
}
2 changes: 2 additions & 0 deletions core/Resources/translations/messages.da.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,8 @@ process:
client_type.company: Virksomhed
client_type.person: Person
court_decision: Rettens afgørelse
p_number: P-nummer
p_number_placeholder: Vælg relateret p-nummer
police_report: Er sagen politianmeldt?
process_status: Sagsstatus
process_type: Sagstype
Expand Down
46 changes: 33 additions & 13 deletions core/Resources/views/client/company/show.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,8 @@
{% block title %}{{ 'client.show.title'|trans }}{% endblock %}

{% block content %}
{% if canEdit %}
{% if is_granted('edit', client.process) %}
{% if newClientInfoAvailable %}
<div class="alert alert-info" role="alert">
{{ 'client.show.new_info_available'|trans }} <a href="{{ path('client_update', {'process': process}) }}" class="alert-link">{{ 'client.show.update_client'|trans }}</a>
</div>
{% endif %}
{% endif %}
{% endif %}

<h1 class="mt-5">{{ 'client.show.title'|trans }}</h1>
<h1 class="mt-5 title-client">{{ 'client.show.title'|trans }}</h1>

{% if process.completedAt %}
<div class="alert alert-warning">{{ 'process.completed_message'|trans }}</div>
Expand All @@ -26,7 +17,8 @@
<div class="form-group col-md-6">
<div class="form-group">
<label for="pNumber">{{ 'visitation.company.p_numbers'|trans }}</label>
<select name="pNumber" id="pNumber" class="form-control" placeholder="{{ 'common.enter_p_numbers'|trans }}">
<select name="pNumber" id="pNumber" class="form-control">
<option value="" {% if client.pNumber == "" %}selected{% endif %}>{{ 'process.form.p_number_placeholder'|trans }}</option>
{% for all_pnumbers in data.produktionsenheder %}
<option value="{{ all_pnumbers.pNummer|e }}" {% if client.pNumber is not empty and client.pNumber == all_pnumbers.pNummer %}selected{% endif %}>{{ all_pnumbers.pNummer|e }}</option>
{% endfor %}
Expand All @@ -52,7 +44,7 @@
</form>
</div>
</div>
<hr class="mt-2">
<hr style="margin-top: -20px">

{% endif %}
<div class="row col-md-12">
Expand Down Expand Up @@ -81,18 +73,43 @@
{% block javascripts %}
{{ parent() }}
<script>
function debounce(func, wait) {
var timeout;
return function() {
var context = this, args = arguments;
clearTimeout(timeout);
timeout = setTimeout(function() {
func.apply(context, args);
}, wait);
};
}
$(document).ready(function() {
// Function to check the state of inputs and toggle the button's disabled state
function toggleSubmitButtonState() {
var ispNumber = $('#pNumber').val() === '';
var isContactPersonName = $('#contactPersonName').val() === '';
// If either input is empty, disable the button, else enable it
$('#submit-button').prop('disabled', ispNumber || isContactPersonName);
$('#submit-button').prop('disabled', ispNumber && isContactPersonName);
}
// Call the function to set the initial state of the button
toggleSubmitButtonState();
$(".btn-header").click(handleToggle);
var handleToggle = debounce(function() {
var btn = $(this);
var cardHeader = btn.closest(".card-header");
var icon = cardHeader.find('.iconClass');
cardHeader.toggleClass("collapsed active");
if (cardHeader.hasClass('collapsed')) {
icon.removeClass('fa-sort-down').addClass('fa-sort-up');
} else {
icon.removeClass('fa-sort-up').addClass('fa-sort-down');
}
}, 300); // 300 milliseconds debounce time
$(".btn-header").click(handleToggle);
// Bind the input fields to the keyup event to check their state every time the user types
$('#pNumber, #contactPersonName').on('keyup', toggleSubmitButtonState);
Expand All @@ -115,6 +132,9 @@
hr{
border-top: 1px solid #000000;
}
.title-client{
font-size: 25px !important;
}
</style>
{% endblock %}

Loading

0 comments on commit 8ea673d

Please sign in to comment.