respect project start and end dates in quick-entry form (#3642)
This commit is contained in:
@@ -63,13 +63,6 @@ class QuickEntryForm extends AbstractType
|
||||
}
|
||||
));
|
||||
|
||||
$startDate = new \DateTime();
|
||||
if ($builder->getData() !== null) {
|
||||
/** @var QuickEntryWeek $data */
|
||||
$data = $builder->getData();
|
||||
$startDate = $data->getDate();
|
||||
}
|
||||
|
||||
$builder->add('date', WeekPickerType::class, [
|
||||
'model_timezone' => $options['timezone'],
|
||||
'view_timezone' => $options['timezone'],
|
||||
@@ -83,7 +76,8 @@ class QuickEntryForm extends AbstractType
|
||||
'entry_options' => [
|
||||
'label' => false,
|
||||
'duration_minutes' => $this->configuration->getTimesheetIncrementDuration(),
|
||||
'start_date' => $startDate,
|
||||
'start_date' => $options['start_date'],
|
||||
'end_date' => $options['end_date'],
|
||||
'empty_data' => function (FormInterface $form) use ($options) {
|
||||
return clone $options['prototype_data'];
|
||||
},
|
||||
@@ -103,13 +97,21 @@ class QuickEntryForm extends AbstractType
|
||||
*/
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$start = new \DateTime();
|
||||
$start->setTime(0, 0, 0);
|
||||
|
||||
$end = clone $start;
|
||||
$end->add(new \DateInterval('P1W'));
|
||||
$end->setTime(23, 59, 59);
|
||||
|
||||
$resolver->setDefaults([
|
||||
'csrf_protection' => true,
|
||||
'csrf_field_name' => '_token',
|
||||
'csrf_token_id' => 'timesheet_quick_edit',
|
||||
'data_class' => QuickEntryWeek::class,
|
||||
'timezone' => date_default_timezone_get(),
|
||||
'start_date' => new \DateTime(),
|
||||
'start_date' => $start,
|
||||
'end_date' => $end,
|
||||
'prototype_data' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -24,10 +24,7 @@ use Symfony\Component\Validator\Constraints\Valid;
|
||||
|
||||
class QuickEntryWeekType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$projectOptions = [
|
||||
'label' => false,
|
||||
@@ -35,7 +32,9 @@ class QuickEntryWeekType extends AbstractType
|
||||
'join_customer' => true,
|
||||
'query_builder_for_user' => true,
|
||||
'placeholder' => '',
|
||||
'activity_enabled' => true
|
||||
'activity_enabled' => true,
|
||||
'project_date_start' => $options['start_date'],
|
||||
'project_date_end' => $options['end_date'],
|
||||
];
|
||||
|
||||
$builder->add('project', ProjectType::class, $projectOptions);
|
||||
@@ -47,13 +46,6 @@ class QuickEntryWeekType extends AbstractType
|
||||
return;
|
||||
}
|
||||
|
||||
$begin = clone $data->getFirstEntry()->getBegin();
|
||||
$begin->setTime(0, 0, 0);
|
||||
$projectOptions['project_date_start'] = $begin;
|
||||
|
||||
$end = clone $data->getLatestEntry()->getBegin();
|
||||
$end->setTime(23, 59, 59);
|
||||
$projectOptions['project_date_end'] = $begin;
|
||||
$projectOptions['projects'] = [$data->getProject()];
|
||||
|
||||
$event->getForm()->add('project', ProjectType::class, $projectOptions);
|
||||
@@ -177,10 +169,7 @@ class QuickEntryWeekType extends AbstractType
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => QuickEntryModel::class,
|
||||
@@ -188,6 +177,7 @@ class QuickEntryWeekType extends AbstractType
|
||||
'duration_minutes' => null,
|
||||
'duration_hours' => 10,
|
||||
'start_date' => new DateTime(),
|
||||
'end_date' => new DateTime(),
|
||||
'prototype_data' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user