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);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:get/get.dart';
|
||||
import '../../constant/links.dart';
|
||||
import '../../controller/functions/crud.dart';
|
||||
import '../../print.dart';
|
||||
import '../widgets/snackbar.dart';
|
||||
import 'add_invoice_page.dart';
|
||||
|
||||
// نفترض أن هذا الموديل موجود في مشروعك، إذا لم يكن موجوداً يرجى إضافته أو تعديل الاستيراد
|
||||
@@ -55,9 +56,7 @@ class _InvoiceListPageState extends State<InvoiceListPage> {
|
||||
} else {
|
||||
if (mounted) {
|
||||
setState(() => isLoading = false);
|
||||
Get.snackbar("تنبيه", "لا توجد فواتير لعرضها أو حدث خطأ",
|
||||
backgroundColor: Colors.orange.withOpacity(0.2),
|
||||
colorText: Colors.orange[900]);
|
||||
mySnackbarWarning("لا توجد فواتير لعرضها أو حدث خطأ");
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -325,8 +324,7 @@ class _InvoiceListPageState extends State<InvoiceListPage> {
|
||||
if (imageUrl != null && imageUrl.isNotEmpty) {
|
||||
_showImageDialog(context, imageUrl);
|
||||
} else {
|
||||
Get.snackbar("تنبيه", "لا توجد صورة مرفقة",
|
||||
backgroundColor: Colors.grey[200], colorText: Colors.black);
|
||||
mySnackbarWarning("لا توجد صورة مرفقة");
|
||||
}
|
||||
},
|
||||
child: Padding(
|
||||
@@ -407,7 +405,7 @@ class _InvoiceListPageState extends State<InvoiceListPage> {
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
"$amount",
|
||||
amount,
|
||||
style: TextStyle(
|
||||
color: moneyColor,
|
||||
fontWeight: FontWeight.w900,
|
||||
|
||||
Reference in New Issue
Block a user