From e4ffcc0c9dcd199bcb46c0a983fdc40a7fe7c136 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Wed, 27 Dec 2023 22:15:44 -0500 Subject: [PATCH] Add controller for item pricing. #780 --- config/packages/catalyst_auth.yaml | 5 + config/packages/catalyst_menu.yaml | 4 + config/routes/item_pricing.yaml | 14 +++ src/Controller/ItemPricingController.php | 76 +++++++++++++ templates/item-pricing/form.html.twig | 129 +++++++++++++++++++++++ 5 files changed, 228 insertions(+) create mode 100644 config/routes/item_pricing.yaml create mode 100644 src/Controller/ItemPricingController.php create mode 100644 templates/item-pricing/form.html.twig diff --git a/config/packages/catalyst_auth.yaml b/config/packages/catalyst_auth.yaml index f63c5bc0..7e02d5c0 100644 --- a/config/packages/catalyst_auth.yaml +++ b/config/packages/catalyst_auth.yaml @@ -675,6 +675,11 @@ catalyst_auth: label: Update - id: item.delete label: Delete + - id: item_pricing + label: Item Pricing + acls: + - id: item_pricing.update + label: Update api: user_entity: "App\\Entity\\ApiUser" diff --git a/config/packages/catalyst_menu.yaml b/config/packages/catalyst_menu.yaml index 1c4f7417..c861471d 100644 --- a/config/packages/catalyst_menu.yaml +++ b/config/packages/catalyst_menu.yaml @@ -302,6 +302,10 @@ catalyst_menu: acl: price_tier.list label: Price Tiers parent: item + - id: item_pricing + acl: item_pricing.update + label: Item Pricing + parent: item - id: item_list acl: item.list label: Items diff --git a/config/routes/item_pricing.yaml b/config/routes/item_pricing.yaml new file mode 100644 index 00000000..df289902 --- /dev/null +++ b/config/routes/item_pricing.yaml @@ -0,0 +1,14 @@ +item_pricing: + path: /item-pricing + controller: App\Controller\ItemPricingController::index + methods: [GET] + +item_pricing_update: + path: /item-pricing + controller: App\Controller\ItemPricingController::formSubmit + methods: [POST] + +item_pricing_prices: + path: /item-pricing/{id}/prices + controller: App\Controller\ItemPricingController::itemPrices + methods: [GET] diff --git a/src/Controller/ItemPricingController.php b/src/Controller/ItemPricingController.php new file mode 100644 index 00000000..9aba9f68 --- /dev/null +++ b/src/Controller/ItemPricingController.php @@ -0,0 +1,76 @@ +getRepository(PriceTier::class)->findAll(); + + // get all the items/batteries + $items = $em->getRepository(Battery::class)->findBy(['flag_active' => true]); + + $params = [ + 'sets' => [ + 'price_tiers' => $price_tiers + ], + 'items' => $items, + ]; + + return $this->render('item-pricing/form.html.twig', $params); + } + + /** + * @Menu(selected="item_pricing") + * @IsGranted("item_pricing.update") + */ + public function formSubmit(Request $req, EntityManagerInterface $em) + { + } + + /** + * @IsGranted("item_pricing.update") + */ + public function (EntityManagerInterface $em, $id) + { + $pt_prices = []; + // check if default prices are needed + if ($id != 0) + { + // get the price tier prices + } + else + { + // get the prices from battery + } + + $data_items = []; + + // response + return new JsonResponse([ + 'items' => $data_items, + ]); + } + diff --git a/templates/item-pricing/form.html.twig b/templates/item-pricing/form.html.twig new file mode 100644 index 00000000..cde71ae6 --- /dev/null +++ b/templates/item-pricing/form.html.twig @@ -0,0 +1,129 @@ +{% extends 'base.html.twig' %} + +{% block body %} + +
+
+
+

Item Pricing

+
+
+
+ +
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+ +
+ + + + + + + + + + {% for item in items %} + + + + + + {% endfor %} + +
IDNamePrice
{{ item.getID }}{{ item.getModel.getName ~ ' ' ~ item.getSize.getName}} + +
+
+ +
+
+
+
+
+
+
+
+{% endblock %} + +{% block js_end %} + +{% endblock %}