get ready
This commit is contained in:
parent
ca9819a436
commit
6b0a478ca5
16 changed files with 395 additions and 124 deletions
51
src/Controller/DrinkTypeBulkController.php
Normal file
51
src/Controller/DrinkTypeBulkController.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Form\BulkEditDrinkTypeStockForm;
|
||||
use App\Repository\DrinkTypeRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
#[Route('/drink-types')]
|
||||
final class DrinkTypeBulkController extends AbstractController
|
||||
{
|
||||
#[Route('/bulk-edit-stock', name: 'app_drink_type_bulk_edit_stock')]
|
||||
public function bulkEditStock(
|
||||
Request $request,
|
||||
DrinkTypeRepository $drinkTypeRepository,
|
||||
EntityManagerInterface $entityManager
|
||||
): Response {
|
||||
$drinkTypes = $drinkTypeRepository->findAll();
|
||||
|
||||
$form = $this->createForm(BulkEditDrinkTypeStockForm::class, [
|
||||
'drinkTypes' => $drinkTypes,
|
||||
]);
|
||||
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$data = $form->getData();
|
||||
|
||||
foreach ($data['drinkTypes'] as $drinkType) {
|
||||
$entityManager->persist($drinkType);
|
||||
}
|
||||
|
||||
$entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Wanted stock levels updated successfully!');
|
||||
|
||||
return $this->redirectToRoute('app_drink_type_bulk_edit_stock');
|
||||
}
|
||||
|
||||
return $this->render('drink_type/bulk_edit_stock.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
'drinkTypes' => $drinkTypes,
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -8,10 +8,8 @@ use App\Entity\DrinkType;
|
|||
use App\Form\DrinkTypeForm;
|
||||
use App\Form\DrinkTypeFormCurrentStockForm;
|
||||
use App\Repository\DrinkTypeRepository;
|
||||
use App\Repository\PropertyChangeLogRepository;
|
||||
use App\Service\DrinkType\GetStockHistory;
|
||||
use App\Service\DrinkType\GetWantedHistory;
|
||||
use App\Service\InventoryService;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
@ -54,8 +52,7 @@ final class DrinkTypeController extends AbstractController
|
|||
DrinkType $drinkType,
|
||||
GetStockHistory $getStockHistory,
|
||||
GetWantedHistory $getWantedHistory,
|
||||
): Response
|
||||
{
|
||||
): Response {
|
||||
// Get orders that contain this drink type
|
||||
$orderItems = $drinkType->getOrderItems();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue