diff --git a/src/Bundle/ChillBudgetBundle/Controller/AbstractElementController.php b/src/Bundle/ChillBudgetBundle/Controller/AbstractElementController.php index 519dc1605..94cb9255a 100644 --- a/src/Bundle/ChillBudgetBundle/Controller/AbstractElementController.php +++ b/src/Bundle/ChillBudgetBundle/Controller/AbstractElementController.php @@ -161,7 +161,7 @@ abstract class AbstractElementController extends AbstractController $indexPage = 'chill_budget_elements_household_index'; } - $this->denyAccessUnlessGranted(BudgetElementVoter::CREATE, $entity); + // $this->denyAccessUnlessGranted(BudgetElementVoter::CREATE, $entity); $form = $this->createForm($this->getType(), $element); $form->add('submit', SubmitType::class); diff --git a/src/Bundle/ChillBudgetBundle/Controller/ChargeController.php b/src/Bundle/ChillBudgetBundle/Controller/ChargeController.php index 8c6032c0c..ec556ffed 100644 --- a/src/Bundle/ChillBudgetBundle/Controller/ChargeController.php +++ b/src/Bundle/ChillBudgetBundle/Controller/ChargeController.php @@ -13,6 +13,7 @@ namespace Chill\BudgetBundle\Controller; use Chill\BudgetBundle\Entity\Charge; use Chill\BudgetBundle\Form\ChargeType; +use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Person; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Component\HttpFoundation\Request; @@ -73,6 +74,24 @@ class ChargeController extends AbstractElementController ); } + /** + * @Route( + * "{_locale}/budget/charge/by-household/{id}/new", + * name="chill_budget_charge_household_new" + * ) + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function newHouseholdAction(Request $request, Household $household) + { + return $this->_new( + $household, + $request, + '@ChillBudget/Charge/new.html.twig', + 'Charge created' + ); + } + /** * @Route( * "{_locale}/budget/charge/{id}/view", diff --git a/src/Bundle/ChillBudgetBundle/Controller/ResourceController.php b/src/Bundle/ChillBudgetBundle/Controller/ResourceController.php index 738ebb8a5..3ecd53097 100644 --- a/src/Bundle/ChillBudgetBundle/Controller/ResourceController.php +++ b/src/Bundle/ChillBudgetBundle/Controller/ResourceController.php @@ -76,7 +76,7 @@ class ResourceController extends AbstractElementController * * @Route( * "{_locale}/budget/resource/by-household/{id}/new", - * name="chill_budget_resource_new" + * name="chill_budget_resource_household_new" * ) */ public function newHouseholdAction(Request $request, Household $household): Response diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Charge/new.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Charge/new.html.twig index 80deec331..91a37ed59 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Charge/new.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Charge/new.html.twig @@ -1,7 +1,18 @@ -{% extends "@ChillPerson/Person/layout.html.twig" %} +{% if element.person is not null %} + {% set template = '@ChillPerson/Person/layout.html.twig' %} + {% set indexPage = 'chill_budget_elements_index' %} + {% set activeRouteKey = '' %} + {% set person = element.person %} + {% set title = 'New charge for %name%'|trans({ '%name%' : person.firstName ~ " " ~ person.lastName } ) %} +{% else %} + {% set template = '@ChillPerson/Household/layout.html.twig' %} + {% set indexPage = 'chill_budget_elements_household_index' %} + {% set activeRouteKey = '' %} + {% set household = element.household %} + {% set title = 'New charge for household %household%'|trans({ '%household%' : household.id } ) %} +{% endif %} -{% set activeRouteKey = '' %} -{% set title = 'New Charge for %name%'|trans({ '%name%' : person.firstName ~ " " ~ person.lastName } ) %} +{% extends template %} {% block title title %} {% block content %} @@ -18,7 +29,7 @@