Update: 2026-06-26 17:29:23
This commit is contained in:
@@ -10,6 +10,7 @@ import '../../constant/box_name.dart';
|
||||
import '../../constant/info.dart';
|
||||
import '../../controller/functions/encrypt_decrypt.dart';
|
||||
import '../../main.dart';
|
||||
import '../../views/widgets/snackbar.dart';
|
||||
|
||||
class AddInvoicePage extends StatefulWidget {
|
||||
const AddInvoicePage({super.key});
|
||||
@@ -38,7 +39,6 @@ class _AddInvoicePageState extends State<AddInvoicePage> {
|
||||
Future<void> uploadInvoice() async {
|
||||
if (!_formKey.currentState!.validate()) return;
|
||||
|
||||
final driverID = '123'; // قيمة افتراضية أو يمكن جلبها من الكونترولر
|
||||
final invoiceNumber = generateInvoiceNumber();
|
||||
final amount = _amountController.text.trim();
|
||||
final itemName = _itemNameController.text.trim();
|
||||
@@ -56,7 +56,6 @@ class _AddInvoicePageState extends State<AddInvoicePage> {
|
||||
|
||||
final uri = Uri.parse(AppLink.addInvoice);
|
||||
final request = http.MultipartRequest('POST', uri)
|
||||
..fields['driverID'] = driverID
|
||||
..fields['invoiceNumber'] = invoiceNumber
|
||||
..fields['amount'] = amount
|
||||
..fields['name'] = itemName
|
||||
@@ -84,15 +83,7 @@ class _AddInvoicePageState extends State<AddInvoicePage> {
|
||||
}
|
||||
|
||||
if (data['status'] == 'success') {
|
||||
Get.snackbar(
|
||||
'نجاح',
|
||||
'تم حفظ الفاتورة بنجاح',
|
||||
backgroundColor: Colors.green.withOpacity(0.1),
|
||||
colorText: Colors.green[800],
|
||||
snackPosition: SnackPosition.TOP,
|
||||
margin: const EdgeInsets.all(10),
|
||||
borderRadius: 20,
|
||||
);
|
||||
mySnackbarSuccess('تم حفظ الفاتورة بنجاح');
|
||||
|
||||
_itemNameController.clear();
|
||||
_amountController.clear();
|
||||
@@ -103,20 +94,10 @@ class _AddInvoicePageState extends State<AddInvoicePage> {
|
||||
Get.back(result: true);
|
||||
});
|
||||
} else {
|
||||
Get.snackbar(
|
||||
'تنبيه',
|
||||
data['message'] ?? 'حدث خطأ غير معروف',
|
||||
backgroundColor: Colors.red.withOpacity(0.1),
|
||||
colorText: Colors.red[800],
|
||||
);
|
||||
mySnackbarWarning(data['message'] ?? 'حدث خطأ غير معروف');
|
||||
}
|
||||
} catch (e) {
|
||||
Get.snackbar(
|
||||
'خطأ في الاتصال',
|
||||
e.toString(),
|
||||
backgroundColor: Colors.red.withOpacity(0.1),
|
||||
colorText: Colors.red[800],
|
||||
);
|
||||
mySnackbarError(e.toString());
|
||||
} finally {
|
||||
if (mounted) setState(() => _isLoading = false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user