feat: استيراد كود سيرو إلى تريبز (سيرو @ecfe7568) — بلا تعديل

قرار المالك 2026-07-27: باك إند سيرو PHP هو المعتمد، وتطبيقاته المجرّبة
ميدانياً تحل محل إعادة البناء المؤرشفة. سيرو نفسه لم يُمسّ.

الخريطة:
  backend · payment_server · loction_server · ride_server ·
  passenger_server · docker · dashboard · stress_test  → الجذر
  siro_rider  → apps/rider          siro_driver  → apps/driver
  siro_admin  → dashboards/admin    siro_service → dashboards/service
  android_bot → apps/android_bot    socialBot    → apps/socialBot

نُسخ المتعقَّب في git سيرو فقط عبر `git archive` (3,198 ملفاً / ~169 م.ب)
لا `cp -r` — فاستُثنيت مخلفات البناء تلقائياً. بلا أي تعديل محتوى عمداً:
كل ما يلي يصير فرقاً مقروءاً مقابل المصدر.

لم يُستورد وسببه: siromove.com (الموقع التسويقي يبقى marketing/ في تريبز،
سيرو فيه 8 ملفات) · docs و planning (تريبز له docs/ الخاص) · deploy.sh
(ليس نشراً على سيرفر بل `git add . && git push origin --all` — فخّ في
مستودع آخر) · transit_dashboard (بانتظار قرار مصير backend-transit و
dashboards/transit-web).

⚠️ لا يبني بعد — ثلاثة نواقص متوقعة ومقصودة:
1. `.env` و `lib/env/env.g.dart` غير متعقَّبين في سيرو (أسرار لكل مستأجر):
   كل تطبيق فلاتر يحتاج .env خاصاً ثم توليد env.g.dart بـ build_runner.
2. إعدادات Firebase (9 ملفات google-services.json و GoogleService-Info.plist)
   يستبعدها .gitignore تريبز — ولكل مستأجر مشروع Firebase خاص أصلاً.
3. apps/driver في سيرو يشير إلى `../../Intaleq/packages/get` خارج المستودع →
   يجب ضمّ الحزم داخله أسوة بـ apps/rider.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Hamza-Ayed
2026-07-27 05:14:13 +03:00
co-authored by Claude Opus 5
parent 9909d9b4c1
commit 4d8414c96b
3198 changed files with 766859 additions and 0 deletions
@@ -0,0 +1,392 @@
import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:http/http.dart' as http;
import 'package:image_picker/image_picker.dart';
import 'package:siro_admin/constant/links.dart';
import '../../constant/box_name.dart';
import '../../constant/info.dart';
import '../../controller/functions/encrypt_decrypt.dart';
import '../../main.dart';
import '../../print.dart';
import '../../views/widgets/snackbar.dart';
class AddInvoicePage extends StatefulWidget {
const AddInvoicePage({super.key});
@override
State<AddInvoicePage> createState() => _AddInvoicePageState();
}
class _AddInvoicePageState extends State<AddInvoicePage> {
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final TextEditingController _itemNameController = TextEditingController();
final TextEditingController _amountController = TextEditingController();
File? _imageFile;
bool _isLoading = false;
// الألوان المستخدمة في الثيم
final Color primaryColor = const Color(0xFF4F46E5); // Indigo
final Color secondaryColor = const Color(0xFF818CF8); // Lighter Indigo
final Color bgColor = const Color(0xFFF3F4F6); // Light Gray Background
String generateInvoiceNumber() {
final now = DateTime.now();
return "INV-${now.year}${now.month.toString().padLeft(2, '0')}${now.day.toString().padLeft(2, '0')}-${now.microsecond}";
}
Future<void> uploadInvoice() async {
if (!_formKey.currentState!.validate()) return;
final invoiceNumber = generateInvoiceNumber();
final amount = _amountController.text.trim();
final itemName = _itemNameController.text.trim();
final date = DateTime.now().toIso8601String().split('T').first;
setState(() => _isLoading = true);
try {
final rawJwt = box.read(BoxName.jwt);
if (rawJwt == null) {
mySnackbarError('الرجاء تسجيل الدخول أولاً');
return;
}
final token = r(rawJwt.toString()).split(AppInformation.addd)[0];
final fingerprint = box.read(BoxName.fingerPrint) ?? '';
final uri = Uri.parse(AppLink.addInvoice);
Log.print('--- [INVOICE UPLOAD] ---');
Log.print('URL: $uri');
Log.print('Fields: invoiceNumber=$invoiceNumber, amount=$amount, name=$itemName, date=$date');
Log.print('Has image: ${_imageFile != null}');
final request = http.MultipartRequest('POST', uri)
..fields['driverID'] = '0'
..fields['invoiceNumber'] = invoiceNumber
..fields['amount'] = amount
..fields['name'] = itemName
..fields['date'] = date
..headers['Authorization'] = 'Bearer $token'
..headers['X-Device-FP'] = fingerprint;
if (_imageFile != null) {
final multipartFile = await http.MultipartFile.fromPath(
'image',
_imageFile!.path,
);
request.files.add(multipartFile);
}
final streamed = await request.send();
Log.print('Status Code: ${streamed.statusCode}');
final respStr = await streamed.stream.bytesToString();
Log.print('Response Body: $respStr');
Log.print('-------------------');
Map<String, dynamic> data;
try {
data = jsonDecode(respStr);
} catch (e) {
data = {
'status': 'error',
'message': 'خطأ في تحليل استجابة السيرفر: $respStr'
};
}
if (data['status'] == 'success') {
mySnackbarSuccess('تم حفظ الفاتورة بنجاح');
_itemNameController.clear();
_amountController.clear();
setState(() => _imageFile = null);
Future.delayed(const Duration(seconds: 1), () {
Get.back(result: true);
});
} else {
mySnackbarWarning(data['message'] ?? 'حدث خطأ غير معروف');
}
} catch (e) {
mySnackbarError(e.toString());
} finally {
if (mounted) setState(() => _isLoading = false);
}
}
Future<void> pickInvoiceImage() async {
final picker = ImagePicker();
final picked = await picker.pickImage(source: ImageSource.gallery);
if (picked != null) {
setState(() => _imageFile = File(picked.path));
}
}
@override
void dispose() {
_itemNameController.dispose();
_amountController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: bgColor,
appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
centerTitle: true,
title: const Text(
'إضافة فاتورة جديدة',
style:
TextStyle(color: Color(0xFF1F2937), fontWeight: FontWeight.bold),
),
leading: IconButton(
icon: const Icon(Icons.arrow_back_ios_new, color: Color(0xFF1F2937)),
onPressed: () => Get.back(),
),
flexibleSpace: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Colors.white, bgColor],
),
),
),
),
body: SingleChildScrollView(
padding: const EdgeInsets.all(20.0),
child: Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// قسم البيانات الأساسية
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.05),
blurRadius: 15,
offset: const Offset(0, 5),
),
],
),
child: Column(
children: [
_buildModernTextField(
controller: _itemNameController,
label: 'اسم البضاعة / الخدمة',
icon: Icons.inventory_2_outlined,
hint: 'مثال: صيانة سيارة',
),
const SizedBox(height: 20),
_buildModernTextField(
controller: _amountController,
label: 'قيمة الفاتورة (د.أ)',
icon: Icons.attach_money,
hint: '0.00',
isNumber: true,
),
],
),
),
const SizedBox(height: 25),
// قسم الصورة
Text(
'صورة الفاتورة',
style: TextStyle(
color: Colors.grey[700],
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
const SizedBox(height: 10),
InkWell(
onTap: pickInvoiceImage,
borderRadius: BorderRadius.circular(20),
child: Container(
height: 200,
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
border: Border.all(
color: _imageFile != null
? primaryColor
: Colors.grey.shade300,
width: 2,
style: _imageFile != null
? BorderStyle.solid
: BorderStyle.solid,
),
image: _imageFile != null
? DecorationImage(
image: FileImage(_imageFile!),
fit: BoxFit.cover,
)
: null,
),
child: _imageFile == null
? Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: const EdgeInsets.all(15),
decoration: BoxDecoration(
color: primaryColor.withOpacity(0.05),
shape: BoxShape.circle,
),
child: Icon(Icons.add_a_photo_rounded,
size: 40, color: primaryColor),
),
const SizedBox(height: 10),
Text(
'اضغط لرفع صورة الفاتورة',
style: TextStyle(
color: Colors.grey[500],
fontWeight: FontWeight.w500,
),
),
],
)
: Stack(
children: [
Positioned(
top: 10,
right: 10,
child: Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.9),
shape: BoxShape.circle,
),
child: Icon(Icons.edit,
color: primaryColor, size: 20),
),
),
],
),
),
),
const SizedBox(height: 40),
// زر الحفظ
SizedBox(
height: 55,
child: ElevatedButton(
onPressed: _isLoading ? null : uploadInvoice,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.transparent,
shadowColor: Colors.transparent,
padding: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15),
),
),
child: Ink(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: _isLoading
? [Colors.grey, Colors.grey]
: [primaryColor, secondaryColor],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
borderRadius: BorderRadius.circular(15),
boxShadow: [
if (!_isLoading)
BoxShadow(
color: primaryColor.withOpacity(0.4),
blurRadius: 10,
offset: const Offset(0, 4),
),
],
),
child: Container(
alignment: Alignment.center,
child: _isLoading
? const SizedBox(
width: 24,
height: 24,
child: CircularProgressIndicator(
color: Colors.white,
strokeWidth: 2,
),
)
: const Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.save_rounded, color: Colors.white),
SizedBox(width: 10),
Text(
'حفظ الفاتورة',
style: TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
],
),
),
),
),
),
],
),
),
),
);
}
Widget _buildModernTextField({
required TextEditingController controller,
required String label,
required IconData icon,
required String hint,
bool isNumber = false,
}) {
return TextFormField(
controller: controller,
keyboardType: isNumber
? const TextInputType.numberWithOptions(decimal: true)
: TextInputType.text,
validator: (val) {
if (val == null || val.isEmpty) {
return 'هذا الحقل مطلوب';
}
return null;
},
decoration: InputDecoration(
labelText: label,
hintText: hint,
prefixIcon: Icon(icon, color: primaryColor.withOpacity(0.7)),
filled: true,
fillColor: Colors.grey[50],
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide.none,
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(color: Colors.grey.shade200),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(color: primaryColor, width: 1.5),
),
contentPadding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
),
);
}
}
@@ -0,0 +1,472 @@
import 'package:flutter/material.dart';
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';
class InvoiceListPage extends StatefulWidget {
const InvoiceListPage({super.key});
@override
_InvoiceListPageState createState() => _InvoiceListPageState();
}
class _InvoiceListPageState extends State<InvoiceListPage> {
List<dynamic> invoices = [];
int totalCount = 0;
double totalAmount = 0.0;
bool isLoading = true;
@override
void initState() {
super.initState();
fetchInvoices();
}
Future<void> fetchInvoices() async {
if (!mounted) return;
setState(() => isLoading = true);
try {
final response =
await CRUD().post(link: AppLink.getInvoices, payload: {});
if (response != 'failure' && response['status'] == 'success') {
final data = response;
if (mounted) {
setState(() {
invoices = data['data'];
totalCount = int.tryParse(data['summary']['count'].toString()) ?? 0;
totalAmount =
double.tryParse(data['summary']['total'].toString()) ?? 0.0;
isLoading = false;
});
}
} else {
if (mounted) {
setState(() => isLoading = false);
mySnackbarWarning("لا توجد فواتير لعرضها أو حدث خطأ");
}
}
} catch (e) {
Log.print('Error fetching invoices: $e');
if (mounted) setState(() => isLoading = false);
}
}
void _showImageDialog(BuildContext context, String imageUrl) {
final cs = Theme.of(context).colorScheme;
showDialog(
context: context,
builder: (_) => Dialog(
backgroundColor: Colors.transparent,
child: Stack(
alignment: Alignment.center,
children: [
Container(
decoration: BoxDecoration(
color: cs.surface,
borderRadius: BorderRadius.circular(20),
border: Border.all(color: cs.outline),
),
padding: const EdgeInsets.all(5),
child: ClipRRect(
borderRadius: BorderRadius.circular(15),
child: InteractiveViewer(
panEnabled: true,
minScale: 0.5,
maxScale: 4,
child: Image.network(
imageUrl,
loadingBuilder: (context, child, loadingProgress) {
if (loadingProgress == null) return child;
return SizedBox(
height: 200,
width: 200,
child: Center(
child: CircularProgressIndicator(color: cs.primary),
),
);
},
errorBuilder: (context, error, stackTrace) {
return SizedBox(
height: 150,
width: 150,
child: Icon(Icons.broken_image_rounded,
size: 60, color: cs.onSurfaceVariant),
);
},
),
),
),
),
Positioned(
top: 0,
right: 0,
child: GestureDetector(
onTap: () => Navigator.pop(context),
child: Container(
padding: const EdgeInsets.all(6),
decoration: BoxDecoration(
color: cs.surfaceContainerHighest,
shape: BoxShape.circle,
border: Border.all(color: cs.outline),
),
child: Icon(Icons.close_rounded,
color: cs.onSurfaceVariant, size: 18),
),
),
),
],
),
),
);
}
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
return Scaffold(
backgroundColor: cs.surface,
floatingActionButton: Container(
decoration: BoxDecoration(
gradient: LinearGradient(colors: [cs.primary, cs.primary.withValues(alpha: 0.7)]),
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: cs.primary.withValues(alpha: 0.3),
blurRadius: 12,
offset: const Offset(0, 4))
],
),
child: FloatingActionButton.extended(
onPressed: () => Get.to(() => AddInvoicePage()),
label: const Text('إضافة فاتورة',
style: TextStyle(fontWeight: FontWeight.bold)),
icon: const Icon(Icons.add_rounded),
backgroundColor: Colors.transparent,
elevation: 0,
),
),
body: Column(
children: [
_buildHeader(cs),
Expanded(
child: isLoading
? _buildLoadingState(cs)
: invoices.isEmpty
? _buildEmptyState(cs)
: RefreshIndicator(
onRefresh: fetchInvoices,
color: cs.primary,
child: ListView.builder(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 80),
itemCount: invoices.length,
physics: const BouncingScrollPhysics(),
itemBuilder: (context, index) {
final invoice = invoices[index];
return _buildInvoiceCard(invoice, cs);
},
),
),
),
],
),
);
}
Widget _buildHeader(ColorScheme cs) {
return Container(
width: double.infinity,
padding: EdgeInsets.only(
top: MediaQuery.of(context).padding.top + 20,
bottom: 24,
left: 20,
right: 20,
),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [cs.primary, cs.primary.withValues(alpha: 0.7)],
),
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(24),
bottomRight: Radius.circular(24),
),
boxShadow: [
BoxShadow(
color: cs.primary.withValues(alpha: 0.2),
blurRadius: 20,
offset: const Offset(0, 10),
),
],
),
child: Column(
children: [
Row(
children: [
GestureDetector(
onTap: () => Get.back(),
child: Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.white.withValues(alpha: 0.2),
borderRadius: BorderRadius.circular(10),
),
child: const Icon(Icons.arrow_back_ios_new_rounded,
color: Colors.white, size: 16),
),
),
const Spacer(),
const Text(
"سجل الفواتير",
style: TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.w700,
),
),
const Spacer(),
const SizedBox(width: 34),
],
),
const SizedBox(height: 20),
Row(
children: [
Expanded(
child: _buildSummaryItem(
title: "الإجمالي",
value: "${totalAmount.toStringAsFixed(1)} د.أ",
icon: Icons.attach_money_rounded,
isMoney: true,
),
),
Container(width: 1, height: 40, color: Colors.white24),
Expanded(
child: _buildSummaryItem(
title: "عدد الفواتير",
value: "$totalCount",
icon: Icons.receipt_long_rounded,
isMoney: false,
),
),
],
),
],
),
);
}
Widget _buildSummaryItem({
required String title,
required String value,
required IconData icon,
required bool isMoney,
}) {
return Column(
children: [
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.white.withValues(alpha: 0.2),
shape: BoxShape.circle,
),
child: Icon(icon, color: Colors.white, size: 20),
),
const SizedBox(height: 8),
Text(
value,
style: TextStyle(
color: isMoney ? const Color(0xFFD1FAE5) : Colors.white,
fontSize: 20,
fontWeight: FontWeight.w800,
),
),
Text(
title,
style: const TextStyle(
color: Colors.white, fontSize: 11, fontWeight: FontWeight.w500),
),
],
);
}
Widget _buildLoadingState(ColorScheme cs) {
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
width: 40,
height: 40,
child: CircularProgressIndicator(
color: cs.primary,
strokeWidth: 2,
backgroundColor: cs.primary.withValues(alpha: 0.1),
),
),
const SizedBox(height: 16),
Text('جاري تحميل الفواتير...',
style: TextStyle(color: cs.onSurfaceVariant, fontSize: 13)),
],
),
);
}
Widget _buildEmptyState(ColorScheme cs) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: cs.surfaceContainerHighest,
shape: BoxShape.circle,
),
child: Icon(Icons.receipt_long_rounded,
size: 48, color: cs.onSurfaceVariant),
),
const SizedBox(height: 16),
Text("لا توجد فواتير حالياً",
style: TextStyle(color: cs.onSurfaceVariant, fontSize: 14)),
const SizedBox(height: 8),
TextButton.icon(
onPressed: fetchInvoices,
icon: const Icon(Icons.refresh_rounded),
label: const Text("تحديث"),
),
],
),
);
}
Widget _buildInvoiceCard(dynamic invoice, ColorScheme cs) {
String name = invoice['name'] ?? 'بدون اسم';
String amount = invoice['amount']?.toString() ?? '0';
String date = invoice['date'] ?? '';
String invNumber = invoice['invoiceNumber']?.toString() ?? '#';
String? imageUrl = invoice['imageLink'];
return Container(
margin: const EdgeInsets.only(bottom: 10),
decoration: BoxDecoration(
color: cs.surfaceContainerHighest,
borderRadius: BorderRadius.circular(16),
border: Border.all(color: cs.outline),
),
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(16),
onTap: () {
if (imageUrl != null && imageUrl.isNotEmpty) {
_showImageDialog(context, imageUrl);
} else {
mySnackbarWarning("لا توجد صورة مرفقة");
}
},
child: Padding(
padding: const EdgeInsets.all(14),
child: Row(
children: [
Container(
width: 48,
height: 48,
decoration: BoxDecoration(
color: cs.primary.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(14),
border: Border.all(color: cs.primary.withValues(alpha: 0.15)),
),
child: imageUrl != null && imageUrl.isNotEmpty
? ClipRRect(
borderRadius: BorderRadius.circular(14),
child: Image.network(
imageUrl,
fit: BoxFit.cover,
errorBuilder: (_, __, ___) =>
Icon(Icons.receipt_rounded, color: cs.primary, size: 22),
),
)
: Icon(Icons.receipt_outlined, color: cs.primary, size: 22),
),
const SizedBox(width: 14),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Text(
name,
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 15,
color: cs.onSurface,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
Container(
padding: const EdgeInsets.symmetric(
horizontal: 8, vertical: 3),
decoration: BoxDecoration(
color: cs.surface,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: cs.outline),
),
child: Text(
"#$invNumber",
style: TextStyle(
fontSize: 10,
color: cs.onSurfaceVariant,
fontWeight: FontWeight.w600),
),
),
],
),
const SizedBox(height: 4),
Text(
date,
style: TextStyle(
color: cs.onSurfaceVariant, fontSize: 11),
),
],
),
),
const SizedBox(width: 12),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
amount,
style: TextStyle(
color: const Color(0xFF10B981),
fontWeight: FontWeight.w800,
fontSize: 18,
),
),
Text(
"د.أ",
style: TextStyle(
color: const Color(0xFF10B981).withValues(alpha: 0.6),
fontWeight: FontWeight.w500,
fontSize: 10,
),
),
],
),
],
),
),
),
),
);
}
}