Update: 2026-05-07 03:50:16

This commit is contained in:
Hamza-Ayed
2026-05-07 03:50:16 +03:00
parent 209f721cd6
commit bd7164ed23
9 changed files with 464 additions and 146 deletions

View File

@@ -1,3 +1,4 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../core/network/dio_client.dart';
import '../../../core/utils/app_snackbar.dart';
@@ -22,8 +23,10 @@ class InvoiceDetailController extends GetxController {
Future<void> fetchInvoiceDetails() async {
try {
isLoading.value = true;
final res = await DioClient().client.get('invoices/view', queryParameters: {'id': invoiceId});
final res = await DioClient()
.client
.get('invoices/view', queryParameters: {'id': invoiceId});
if (res.data['success'] == true && res.data['data'] != null) {
invoice.value = res.data['data'];
} else {
@@ -41,7 +44,9 @@ class InvoiceDetailController extends GetxController {
Future<void> approveInvoice() async {
try {
final res = await DioClient().client.post('invoices/approve', data: {'invoice_id': invoiceId});
final res = await DioClient()
.client
.post('invoices/approve', data: {'invoice_id': invoiceId});
if (res.data['success'] == true) {
AppSnackbar.showSuccess('تم الاعتماد', 'تم اعتماد الفاتورة بنجاح');
// Refresh the detail view
@@ -56,10 +61,30 @@ class InvoiceDetailController extends GetxController {
}
void viewOriginalImage() {
final imagePath = invoice['file_path'];
if (imagePath != null && imagePath.isNotEmpty) {
// In a real app, you would download/show the image. For now, just a snackbar or open URL.
AppSnackbar.showInfo('قريباً', 'سيتم عرض الصورة قريباً');
final fileUrl = invoice['file_url'];
if (fileUrl != null && fileUrl.isNotEmpty) {
// Navigate to a dedicated image viewer or show in a dialog
final fullUrl = 'https://musadaq.intaleqapp.com/api$fileUrl';
Get.to(() => Scaffold(
appBar: AppBar(
title: const Text('صورة الفاتورة'),
backgroundColor: const Color(0xFF0F4C81)),
body: Center(
child: InteractiveViewer(
child: Image.network(
fullUrl,
loadingBuilder: (context, child, loadingProgress) {
if (loadingProgress == null) return child;
return const CircularProgressIndicator();
},
errorBuilder: (context, error, stackTrace) {
return const Text(
'فشل تحميل الصورة. قد يكون الملف مفقوداً على الخادم.');
},
),
),
),
));
} else {
AppSnackbar.showWarning('عذراً', 'لا توجد صورة مرتبطة بهذه الفاتورة');
}