mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-25 03:08:51 +02:00
Allow to specify an informational field during a part stock operation, where the user can specify, when this operation was really performed
Fixes issue #416
This commit is contained in:
parent
6cff19358a
commit
b447a69dae
6 changed files with 89 additions and 16 deletions
|
@ -401,22 +401,33 @@ class PartController extends AbstractController
|
|||
$comment = $request->request->get('comment');
|
||||
$action = $request->request->get('action');
|
||||
|
||||
$timestamp = null;
|
||||
$timestamp_str = $request->request->getString('timestamp', '');
|
||||
//Try to parse the timestamp
|
||||
if($timestamp_str !== '') {
|
||||
$timestamp = new DateTime($timestamp_str);
|
||||
}
|
||||
|
||||
//Ensure that the timestamp is not in the future
|
||||
if($timestamp !== null && $timestamp > new DateTime("+20min")) {
|
||||
throw new \LogicException("The timestamp must not be in the future!");
|
||||
}
|
||||
|
||||
try {
|
||||
switch ($action) {
|
||||
case "withdraw":
|
||||
case "remove":
|
||||
$this->denyAccessUnlessGranted('withdraw', $partLot);
|
||||
$withdrawAddHelper->withdraw($partLot, $amount, $comment);
|
||||
$withdrawAddHelper->withdraw($partLot, $amount, $comment, $timestamp);
|
||||
break;
|
||||
case "add":
|
||||
$this->denyAccessUnlessGranted('add', $partLot);
|
||||
$withdrawAddHelper->add($partLot, $amount, $comment);
|
||||
$withdrawAddHelper->add($partLot, $amount, $comment, $timestamp);
|
||||
break;
|
||||
case "move":
|
||||
$this->denyAccessUnlessGranted('move', $partLot);
|
||||
$this->denyAccessUnlessGranted('move', $targetLot);
|
||||
$withdrawAddHelper->move($partLot, $targetLot, $amount, $comment);
|
||||
$withdrawAddHelper->move($partLot, $targetLot, $amount, $comment, $timestamp);
|
||||
break;
|
||||
default:
|
||||
throw new \RuntimeException("Unknown action!");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue