54736fa680
Herwig Birke 2 months ago
parent 54736fa680
commit b945b0894f

@ -41,12 +41,18 @@ class BookingApi {
if (code != null && code.isEmpty) code = null;
final starts = <String?>[
row['come1'] as String?, row['come2'] as String?,
row['come3'] as String?, row['come4'] as String?, row['come5'] as String?,
row['come1'] as String?,
row['come2'] as String?,
row['come3'] as String?,
row['come4'] as String?,
row['come5'] as String?,
];
final ends = <String?>[
row['leave1'] as String?, row['leave2'] as String?,
row['leave3'] as String?, row['leave4'] as String?, row['leave5'] as String?,
row['leave1'] as String?,
row['leave2'] as String?,
row['leave3'] as String?,
row['leave4'] as String?,
row['leave5'] as String?,
];
final intervals = <WorkInterval>[];
for (int i = 0; i < 5; i++) {
@ -78,7 +84,8 @@ class BookingApi {
);
final res = await client.get(uri);
if (res.statusCode != 200) {
throw Exception('monthlybooking/getList failed: ${res.statusCode} ${res.body}');
throw Exception(
'monthlybooking/getList failed: ${res.statusCode} ${res.body}');
}
final map = jsonDecode(res.body) as Map<String, dynamic>;
if (map['error'] == true) {
@ -95,10 +102,10 @@ class BookingApi {
final dateStr = '$y-$m-$d';
final starts = List<String?>.filled(5, null);
final ends = List<String?>.filled(5, null);
final ends = List<String?>.filled(5, null);
for (int i = 0; i < day.intervals.length && i < 5; i++) {
starts[i] = fmtTimeOfDay(day.intervals[i].start);
ends[i] = fmtTimeOfDay(day.intervals[i].end);
ends[i] = fmtTimeOfDay(day.intervals[i].end);
}
final lockCodes = {'G', 'U', 'SU', 'K'};
@ -165,7 +172,8 @@ class BookingApi {
);
if (res.statusCode != 200) {
throw Exception('monthlybooking/saveStart failed: ${res.statusCode} ${res.body}');
throw Exception(
'monthlybooking/saveStart failed: ${res.statusCode} ${res.body}');
}
final map = jsonDecode(res.body) as Map<String, dynamic>;
if (map['error'] == true) {
@ -191,7 +199,8 @@ class BookingApi {
}),
);
if (res.statusCode != 200) {
throw Exception('monthlybooking/hasDoc failed: ${res.statusCode} ${res.body}');
throw Exception(
'monthlybooking/hasDoc failed: ${res.statusCode} ${res.body}');
}
final map = jsonDecode(res.body) as Map<String, dynamic>;
if (map['error'] == true) {
@ -214,7 +223,8 @@ class BookingApi {
}
// Versuch, JSON-Fehler zu lesen
try {
final map = jsonDecode(utf8.decode(res.bodyBytes)) as Map<String, dynamic>;
final map =
jsonDecode(utf8.decode(res.bodyBytes)) as Map<String, dynamic>;
final msg = map['errmsg'] ?? res.reasonPhrase ?? 'Unknown';
throw Exception('getDoc error: $msg');
} catch (_) {
@ -229,12 +239,16 @@ class BookingApi {
String filename = 'document.pdf',
}) async {
final ymd = date.length == 7 ? '$date-01' : date;
final uri = Uri.parse(
'https://api.windesign.at/workinghours.php?module=monthlybooking&function=saveDoc',
);
// Wichtig: POST auf Basis-URL (ohne module/function in der Query!)
final uri = Uri.parse('https://api.windesign.at/workinghours.php');
final request = http.MultipartRequest('POST', uri)
// Router-Parameter als Felder mitsenden:
..fields['module'] = 'monthlybooking'
..fields['function'] = 'saveDoc' // oder 'replaceDoc', je nach Server
..fields['date'] = ymd
..fields['doctype'] = type;
..fields['doctype'] = type; // achte: 'doctype' vs. 'kind' wie am Server
request.files.add(
http.MultipartFile.fromBytes(
@ -247,8 +261,10 @@ class BookingApi {
final streamed = await request.send();
final res = await http.Response.fromStream(streamed);
if (res.statusCode != 200) {
throw Exception('monthlybooking/saveDoc failed: ${res.statusCode} ${res.body}');
throw Exception(
'monthlybooking/saveDoc failed: ${res.statusCode} ${res.body}');
}
final map = jsonDecode(res.body) as Map<String, dynamic>;
if (map['error'] == true) {
@ -273,7 +289,8 @@ class BookingApi {
}),
);
if (res.statusCode != 200) {
throw Exception('monthlybooking/deleteDoc failed: ${res.statusCode} ${res.body}');
throw Exception(
'monthlybooking/deleteDoc failed: ${res.statusCode} ${res.body}');
}
final map = jsonDecode(res.body) as Map<String, dynamic>;
if (map['error'] == true) {

Loading…
Cancel
Save