improved some bugs

This commit is contained in:
Luca Haid
2026-01-18 13:25:14 +01:00
parent b3bb4bb970
commit e99b0d4658
5 changed files with 158 additions and 77 deletions

View File

@@ -16,6 +16,66 @@ class ShippingNoteHandler extends MobileAppBaseHandler {
const OFFICE_LAT = 46.99552810791587;
const OFFICE_LNG = 15.7751923956463;
public function initializeAction() {
$db = $this->db();
$userId = $this->user->id;
$userCar = null;
$sql = "SELECT id, number_plate, brand, model
FROM TimerecordingCar
WHERE user_id = {$userId}
AND (retired IS NULL OR retired = 0)
LIMIT 1";
$result = $db->query($sql);
if ($result && $row = $result->fetch_assoc()) {
$carName = trim(($row['brand'] ?? '') . ' ' . ($row['model'] ?? ''));
if (!$carName) $carName = $row['number_plate'];
$userCar = [
'id' => intval($row['id']),
'name' => $carName,
'plate' => $row['number_plate'],
];
}
$allCars = [];
$sql = "SELECT id, number_plate, brand, model
FROM TimerecordingCar
WHERE (retired IS NULL OR retired = 0)
ORDER BY brand, model ASC";
$result = $db->query($sql);
while ($row = $result->fetch_assoc()) {
$carName = trim(($row['brand'] ?? '') . ' ' . ($row['model'] ?? ''));
if (!$carName) $carName = $row['number_plate'];
$allCars[] = [
'id' => intval($row['id']),
'name' => $carName,
'plate' => $row['number_plate'],
];
}
$hourTypes = [
['id' => '', 'name' => 'Normal'],
['id' => '50', 'name' => '+50%'],
['id' => '100', 'name' => '+100%'],
['id' => 'regie', 'name' => 'Regie'],
];
$currentUser = [
'id' => $this->user->id,
'name' => $this->user->name,
'firstname' => $this->user->firstname ?? '',
'lastname' => $this->user->lastname ?? '',
];
self::returnJson([
'success' => true,
'userCar' => $userCar,
'allCars' => $allCars,
'hourTypes' => $hourTypes,
'currentUser' => $currentUser,
]);
}
/**
* Get customer by GPS location (nearest within radius)
* GET /MobileApp/Lager/ShippingNote/getCustomerByLocation?lat=X&lng=Y