vibe
This commit is contained in:
parent
16533b1495
commit
ab0677c463
14 changed files with 705 additions and 38 deletions
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||
namespace App\Controller;
|
||||
|
||||
use App\Form\BulkEditDrinkTypeStockForm;
|
||||
use App\Form\BulkEditDrinkTypeWantedStockForm;
|
||||
use App\Repository\DrinkTypeRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
@ -38,7 +39,7 @@ final class DrinkTypeBulkController extends AbstractController
|
|||
|
||||
$entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Wanted stock levels updated successfully!');
|
||||
$this->addFlash('success', 'Current stock levels updated successfully!');
|
||||
|
||||
return $this->redirectToRoute('app_drink_type_bulk_edit_stock');
|
||||
}
|
||||
|
@ -48,4 +49,38 @@ final class DrinkTypeBulkController extends AbstractController
|
|||
'drinkTypes' => $drinkTypes,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/bulk-edit-wanted-stock', name: 'app_drink_type_bulk_edit_wanted_stock')]
|
||||
public function bulkEditWantedStock(
|
||||
Request $request,
|
||||
DrinkTypeRepository $drinkTypeRepository,
|
||||
EntityManagerInterface $entityManager
|
||||
): Response {
|
||||
$drinkTypes = $drinkTypeRepository->findAll();
|
||||
|
||||
$form = $this->createForm(BulkEditDrinkTypeWantedStockForm::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_wanted_stock');
|
||||
}
|
||||
|
||||
return $this->render('drink_type/bulk_edit_wanted_stock.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
'drinkTypes' => $drinkTypes,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue