Update: 2026-06-26 17:36:57

This commit is contained in:
Hamza-Ayed
2026-06-26 17:36:57 +03:00
parent 9ded734e38
commit ae21389240
3 changed files with 24 additions and 18 deletions

View File

@@ -1,7 +1,7 @@
<?php <?php
// Admin/v2/quality/blacklist_manager.php // Admin/v2/quality/blacklist_manager.php
require_once __DIR__ . '/../../../connect.php'; require_once __DIR__ . '/../../../connect.php';
// require_once __DIR__ . '/../../../encrypt_decrypt.php'; require_once __DIR__ . '/../../../encrypt_decrypt.php';
require_once __DIR__ . '/../security/audit_logs_helper.php'; // إذا كان متاحاً، وإلا سننفذ الإدخال مباشرة require_once __DIR__ . '/../security/audit_logs_helper.php'; // إذا كان متاحاً، وإلا سننفذ الإدخال مباشرة
if ($role !== 'admin' && $role !== 'super_admin') { if ($role !== 'admin' && $role !== 'super_admin') {

View File

@@ -7,7 +7,7 @@ import '../functions/crud.dart';
class KazanController extends GetxController { class KazanController extends GetxController {
var kazanData = {}.obs; var kazanData = {}.obs;
var isLoading = false.obs; var isLoading = false.obs;
var selectedCountry = 'Syria'.obs; var selectedCountry = 'سوريا'.obs;
final CRUD _crud = CRUD(); final CRUD _crud = CRUD();
final List<Map<String, String>> countries = [ final List<Map<String, String>> countries = [
@@ -16,6 +16,12 @@ class KazanController extends GetxController {
{'code': 'egypt', 'name': 'مصر', 'flag': '🇪🇬'}, {'code': 'egypt', 'name': 'مصر', 'flag': '🇪🇬'},
]; ];
String get selectedCountryCode =>
countries.firstWhere(
(c) => c['name'] == selectedCountry.value,
orElse: () => countries.first,
)['code']!;
@override @override
void onInit() { void onInit() {
super.onInit(); super.onInit();
@@ -30,7 +36,7 @@ class KazanController extends GetxController {
Future<void> getKazan() async { Future<void> getKazan() async {
isLoading.value = true; isLoading.value = true;
try { try {
final countryParam = selectedCountry.value.toLowerCase(); final countryParam = selectedCountryCode;
var response = await _crud.get(link: "${AppLink.getKazanPercent}?country=$countryParam"); var response = await _crud.get(link: "${AppLink.getKazanPercent}?country=$countryParam");
if (response != null && response != 'failure' && response != 'token_expired') { if (response != null && response != 'failure' && response != 'token_expired') {
var decoded = response is String ? jsonDecode(response) : response; var decoded = response is String ? jsonDecode(response) : response;

View File

@@ -47,12 +47,13 @@ class _AddInvoicePageState extends State<AddInvoicePage> {
setState(() => _isLoading = true); setState(() => _isLoading = true);
try { try {
// إعداد الترويسة (Headers) final rawJwt = box.read(BoxName.jwt);
final headers = { if (rawJwt == null) {
'Authorization': mySnackbarError('الرجاء تسجيل الدخول أولاً');
'Bearer ${r(box.read(BoxName.jwt)).split(AppInformation.addd)[0]}', return;
'X-HMAC-Auth': '${box.read(BoxName.hmac)}', }
}; final token = r(rawJwt.toString()).split(AppInformation.addd)[0];
final fingerprint = box.read(BoxName.fingerPrint) ?? '';
final uri = Uri.parse(AppLink.addInvoice); final uri = Uri.parse(AppLink.addInvoice);
final request = http.MultipartRequest('POST', uri) final request = http.MultipartRequest('POST', uri)
@@ -60,9 +61,9 @@ class _AddInvoicePageState extends State<AddInvoicePage> {
..fields['amount'] = amount ..fields['amount'] = amount
..fields['name'] = itemName ..fields['name'] = itemName
..fields['date'] = date ..fields['date'] = date
..headers.addAll(headers); ..headers['Authorization'] = 'Bearer $token'
..headers['X-Device-FP'] = fingerprint;
// إضافة الصورة إذا وجدت
if (_imageFile != null) { if (_imageFile != null) {
final multipartFile = await http.MultipartFile.fromPath( final multipartFile = await http.MultipartFile.fromPath(
'image', 'image',
@@ -71,25 +72,24 @@ class _AddInvoicePageState extends State<AddInvoicePage> {
request.files.add(multipartFile); request.files.add(multipartFile);
} }
final response = await request.send(); final streamed = await request.send();
final respStr = await response.stream.bytesToString(); final respStr = await streamed.stream.bytesToString();
// محاولة تحليل الاستجابة
Map<String, dynamic> data; Map<String, dynamic> data;
try { try {
data = jsonDecode(respStr); data = jsonDecode(respStr);
} catch (e) { } catch (e) {
data = {'status': 'error', 'message': 'Invalid server response'}; data = {
'status': 'error',
'message': 'خطأ في تحليل استجابة السيرفر: $respStr'
};
} }
if (data['status'] == 'success') { if (data['status'] == 'success') {
mySnackbarSuccess('تم حفظ الفاتورة بنجاح'); mySnackbarSuccess('تم حفظ الفاتورة بنجاح');
_itemNameController.clear(); _itemNameController.clear();
_amountController.clear(); _amountController.clear();
setState(() => _imageFile = null); setState(() => _imageFile = null);
// تأخير بسيط قبل العودة لتحديث الصفحة السابقة
Future.delayed(const Duration(seconds: 1), () { Future.delayed(const Duration(seconds: 1), () {
Get.back(result: true); Get.back(result: true);
}); });