mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-12-22 02:49:31 +00:00
Add a button to automatically add the ordered amount once delivered
This commit is contained in:
parent
b62d4aaeb7
commit
e6b1b533a8
5 changed files with 47 additions and 0 deletions
|
|
@ -135,6 +135,27 @@ class PartController extends AbstractController
|
|||
return $this->renderPartForm('edit', $request, $part);
|
||||
}
|
||||
|
||||
#[Route(path: '/{id}/delivered', name: 'part_delivered')]
|
||||
public function delivered(Part $part, Request $request): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted('edit', $part);
|
||||
|
||||
$partLot = $part->getPartLots()[0] ?? null;
|
||||
if (!$partLot instanceof PartLot) {
|
||||
$this->addFlash('error', 'part.delivered.error.no_lot');
|
||||
return $this->redirectToRoute('part_info', ['id' => $part->getID()]);
|
||||
}
|
||||
|
||||
$partLot->setAmount($partLot->getAmount() + $part->getOrderAmount());
|
||||
$part->setOrderAmount(0);
|
||||
$part->setOrderDelivery(null);
|
||||
|
||||
$this->em->persist($part);
|
||||
$this->em->flush();
|
||||
|
||||
return $this->redirectToRoute('part_info', ['id' => $part->getID()]);
|
||||
}
|
||||
|
||||
#[Route(path: '/{id}/delete', name: 'part_delete', methods: ['DELETE'])]
|
||||
public function delete(Request $request, Part $part): RedirectResponse
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue