added form to edit timesheet entries for all user #45 (#48)

* added form to administrate timesheet entries for all user #45
This commit is contained in:
Kevin Papst
2018-01-07 20:42:44 +01:00
committed by GitHub
parent 4e344dbe6e
commit c5c9f37de7
10 changed files with 299 additions and 68 deletions

View File

@@ -0,0 +1,40 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace TimesheetBundle\Form;
use AppBundle\Form\Type\UserType;
use Symfony\Component\Form\FormBuilderInterface;
/**
* Defines the form used to administrate Timesheet entries.
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class TimesheetAdminForm extends TimesheetEditForm
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);
$builder
// User
->add('user', UserType::class, [
'label' => 'label.user',
])
;
}
}

View File

@@ -34,12 +34,12 @@ class ActivityType extends AbstractType
$resolver->setDefaults([
'class' => 'TimesheetBundle:Activity',
'choice_label' => 'name',
'choice_value' => 'id',
'group_by' => function (Activity $activity, $key, $index) {
return $activity->getProject()->getName();
return '[' . $activity->getProject()->getId() . '] ' . $activity->getProject()->getName();
},
'query_builder' => function (ActivityRepository $repo) {
$query = new ActivityQuery();
$query->setVisibility(ActivityQuery::SHOW_BOTH);
$query->setResultType(ActivityQuery::RESULT_TYPE_QUERYBUILDER);
return $repo->findByQuery($query);
},

View File

@@ -14,6 +14,8 @@ namespace TimesheetBundle\Form\Type;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use TimesheetBundle\Repository\CustomerRepository;
use TimesheetBundle\Repository\Query\CustomerQuery;
/**
* Custom form field type to select a customer.
@@ -31,6 +33,12 @@ class CustomerType extends AbstractType
$resolver->setDefaults([
'class' => 'TimesheetBundle:Customer',
'choice_label' => 'name',
'query_builder' => function (CustomerRepository $repo) {
$query = new CustomerQuery();
$query->setVisibility(CustomerQuery::SHOW_BOTH);
$query->setResultType(CustomerQuery::RESULT_TYPE_QUERYBUILDER);
return $repo->findByQuery($query);
},
]);
}

View File

@@ -34,12 +34,12 @@ class ProjectType extends AbstractType
$resolver->setDefaults([
'class' => 'TimesheetBundle:Project',
'choice_label' => 'name',
'choice_value' => 'id',
'group_by' => function (Project $project, $key, $index) {
return $project->getCustomer()->getName();
return '[' . $project->getCustomer()->getId() . '] ' . $project->getCustomer()->getName();
},
'query_builder' => function (ProjectRepository $repo) {
$query = new ProjectQuery();
$query->setVisibility(ProjectQuery::SHOW_BOTH);
$query->setResultType(ProjectQuery::RESULT_TYPE_QUERYBUILDER);
return $repo->findByQuery($query);
},