fixed createLocations Action not working

This commit is contained in:
2024-10-10 09:34:24 +02:00
parent ea5a25ea03
commit 8fdab0a1bf
2 changed files with 10 additions and 5 deletions

View File

@@ -28,6 +28,7 @@ class WarehouseAdministrationController extends mfBaseController {
protected function createLocationsAction(): void { protected function createLocationsAction(): void {
$existingLocations = WarehouseLocationModel::getAll(); $existingLocations = WarehouseLocationModel::getAll();
$companyCars = TimerecordingCarModel::getAll(); $companyCars = TimerecordingCarModel::getAll();
$beforeCount = WarehouseLocationModel::count();
$wantedCarLocations = []; $wantedCarLocations = [];
@@ -73,7 +74,7 @@ class WarehouseAdministrationController extends mfBaseController {
"title" => $wantedCarLocation, "title" => $wantedCarLocation,
"description" => "Automatisch erstellt", "description" => "Automatisch erstellt",
"assignedTo" => $assignedTo, "assignedTo" => $assignedTo,
"createdBy" => $this->me->id, "createBy" => $this->me->id,
"create" => time() "create" => time()
]); ]);
} }
@@ -97,14 +98,18 @@ class WarehouseAdministrationController extends mfBaseController {
"title" => $user->name . "'s Lagerort", "title" => $user->name . "'s Lagerort",
"description" => "Automatisch erstellt", "description" => "Automatisch erstellt",
"assignedTo" => $user->id, "assignedTo" => $user->id,
"createdBy" => $this->me->id, "createBy" => $this->me->id,
"create" => time() "create" => time()
]); ]);
} }
} }
var_dump($existingLocations); $afterCount = WarehouseLocationModel::count();
die();
if ($afterCount - $beforeCount === 0) {
$this->returnJSON(["success" => true, "message" => "Alle Lagerorte existieren bereits"]);
} else {
$this->returnJSON(["success" => true, "message" => "Es wurden " . ($afterCount - $beforeCount) . " neue Lagerorte erstellt"]);
}
} }
} }

View File

@@ -5,6 +5,6 @@ class WarehouseLocationModel extends TTCrudBaseModel {
public string $title; public string $title;
public string $description; public string $description;
public int $assignedTo; public int $assignedTo;
public int $createdBy; public int $createBy;
public int $create; public int $create;
} }