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:
co-authored by
Claude Opus 5
parent
9909d9b4c1
commit
4d8414c96b
@@ -0,0 +1,187 @@
|
||||
// org_admins_page.dart — متابعة إدارة المؤسسة وإضافة المشرفين (لوحة إدارة سيرو)
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../constant/colors.dart';
|
||||
import '../../controller/transit/transit_admin_controller.dart';
|
||||
|
||||
class TransitOrgAdminsPage extends StatefulWidget {
|
||||
final int orgId;
|
||||
final String orgName;
|
||||
const TransitOrgAdminsPage({super.key, required this.orgId, required this.orgName});
|
||||
|
||||
@override
|
||||
State<TransitOrgAdminsPage> createState() => _TransitOrgAdminsPageState();
|
||||
}
|
||||
|
||||
class _TransitOrgAdminsPageState extends State<TransitOrgAdminsPage> {
|
||||
final _name = TextEditingController();
|
||||
final _phone = TextEditingController();
|
||||
String _role = 'transport_manager';
|
||||
|
||||
final _roles = const {
|
||||
'owner': 'مالك',
|
||||
'transport_manager': 'مدير نقل',
|
||||
'dispatcher': 'منسّق',
|
||||
};
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
Get.find<TransitAdminController>().fetchOrgAdmins(widget.orgId);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GetBuilder<TransitAdminController>(
|
||||
builder: (c) => Scaffold(
|
||||
backgroundColor: AppColor.bg,
|
||||
appBar: AppBar(
|
||||
backgroundColor: AppColor.bg,
|
||||
elevation: 0,
|
||||
title: Text('مشرفو ${widget.orgName}',
|
||||
style: const TextStyle(color: AppColor.textPrimary)),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
backgroundColor: AppColor.accent,
|
||||
onPressed: () => _showAddAdminSheet(context, c),
|
||||
child: const Icon(Icons.person_add_alt_1, color: Colors.white),
|
||||
),
|
||||
body: c.isLoadingAdmins
|
||||
? const Center(child: CircularProgressIndicator(color: AppColor.accent))
|
||||
: c.orgAdmins.isEmpty
|
||||
? const Center(
|
||||
child: Text('لا يوجد مشرفون بعد', style: TextStyle(color: AppColor.textSecondary)))
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
itemCount: c.orgAdmins.length,
|
||||
itemBuilder: (_, i) => _adminCard(c, c.orgAdmins[i]),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _adminCard(TransitAdminController c, Map<String, dynamic> admin) {
|
||||
final isActive = admin['is_active'].toString() == '1';
|
||||
return Card(
|
||||
color: AppColor.surface,
|
||||
margin: const EdgeInsets.only(bottom: 10),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)),
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: AppColor.accentSoft,
|
||||
child: Icon(Icons.person, color: isActive ? AppColor.accent : AppColor.textMuted),
|
||||
),
|
||||
title: Text(admin['name']?.toString() ?? '',
|
||||
style: const TextStyle(color: AppColor.textPrimary, fontWeight: FontWeight.bold)),
|
||||
subtitle: Text(
|
||||
'${admin['phone'] ?? ''} · ${_roles[admin['role']] ?? admin['role']}',
|
||||
style: const TextStyle(color: AppColor.textSecondary, fontSize: 12),
|
||||
),
|
||||
trailing: Switch(
|
||||
value: isActive,
|
||||
activeThumbColor: AppColor.success,
|
||||
onChanged: (v) => c.toggleOrgAdmin(widget.orgId, int.parse(admin['id'].toString()), v),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showAddAdminSheet(BuildContext context, TransitAdminController c) {
|
||||
_name.clear();
|
||||
_phone.clear();
|
||||
_role = 'transport_manager';
|
||||
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
backgroundColor: AppColor.surface,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
||||
),
|
||||
builder: (ctx) => StatefulBuilder(
|
||||
builder: (ctx, setSheetState) => GetBuilder<TransitAdminController>(
|
||||
builder: (c) => Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 20,
|
||||
right: 20,
|
||||
top: 20,
|
||||
bottom: MediaQuery.of(ctx).viewInsets.bottom + 20,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text('إضافة مشرف جديد',
|
||||
style: TextStyle(
|
||||
color: AppColor.textPrimary, fontSize: 18, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
controller: _name,
|
||||
style: const TextStyle(color: AppColor.textPrimary),
|
||||
decoration: _inputDecoration('اسم المشرف'),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
TextField(
|
||||
controller: _phone,
|
||||
keyboardType: TextInputType.phone,
|
||||
style: const TextStyle(color: AppColor.textPrimary),
|
||||
decoration: _inputDecoration('رقم الهاتف'),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
DropdownButtonFormField<String>(
|
||||
initialValue: _role,
|
||||
dropdownColor: AppColor.surface,
|
||||
style: const TextStyle(color: AppColor.textPrimary),
|
||||
decoration: _inputDecoration('الصلاحية'),
|
||||
items: _roles.entries
|
||||
.map((e) => DropdownMenuItem(value: e.key, child: Text(e.value)))
|
||||
.toList(),
|
||||
onChanged: (v) => setSheetState(() => _role = v!),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColor.accent,
|
||||
minimumSize: const Size.fromHeight(48),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
),
|
||||
onPressed: c.isSavingAdmin
|
||||
? null
|
||||
: () async {
|
||||
if (_name.text.trim().isEmpty || _phone.text.trim().isEmpty) {
|
||||
Get.snackbar('مواصلاتي', 'الرجاء تعبئة كل الحقول');
|
||||
return;
|
||||
}
|
||||
final ok = await c.addOrgAdmin(
|
||||
orgId: widget.orgId,
|
||||
name: _name.text.trim(),
|
||||
phone: _phone.text.trim(),
|
||||
role: _role,
|
||||
);
|
||||
if (ok && ctx.mounted) Navigator.pop(ctx);
|
||||
},
|
||||
child: c.isSavingAdmin
|
||||
? const SizedBox(
|
||||
height: 20, width: 20,
|
||||
child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white))
|
||||
: const Text('إضافة', style: TextStyle(color: Colors.white)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
InputDecoration _inputDecoration(String label) => InputDecoration(
|
||||
labelText: label,
|
||||
labelStyle: const TextStyle(color: AppColor.textSecondary),
|
||||
filled: true,
|
||||
fillColor: AppColor.surfaceElevated,
|
||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12), borderSide: BorderSide.none),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
// org_create_page.dart — إضافة مؤسسة جديدة (لوحة إدارة سيرو)
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../constant/colors.dart';
|
||||
import '../../controller/transit/transit_admin_controller.dart';
|
||||
|
||||
class TransitOrgCreatePage extends StatefulWidget {
|
||||
const TransitOrgCreatePage({super.key});
|
||||
|
||||
@override
|
||||
State<TransitOrgCreatePage> createState() => _TransitOrgCreatePageState();
|
||||
}
|
||||
|
||||
class _TransitOrgCreatePageState extends State<TransitOrgCreatePage> {
|
||||
final _nameAr = TextEditingController();
|
||||
final _nameEn = TextEditingController();
|
||||
final _city = TextEditingController();
|
||||
final _adminName = TextEditingController();
|
||||
final _adminPhone = TextEditingController();
|
||||
|
||||
String _type = 'university';
|
||||
String _country = 'JO';
|
||||
|
||||
final _types = const {
|
||||
'university': 'جامعة',
|
||||
'school': 'مدرسة',
|
||||
'hotel': 'فندق',
|
||||
'company': 'شركة',
|
||||
'transporter': 'ناقل',
|
||||
};
|
||||
final _countries = const {'JO': 'الأردن', 'SY': 'سوريا', 'EG': 'مصر'};
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GetBuilder<TransitAdminController>(
|
||||
builder: (c) => Scaffold(
|
||||
backgroundColor: AppColor.bg,
|
||||
appBar: AppBar(
|
||||
backgroundColor: AppColor.bg,
|
||||
elevation: 0,
|
||||
title: const Text('إضافة مؤسسة', style: TextStyle(color: AppColor.textPrimary)),
|
||||
),
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
_dropdown('نوع المؤسسة', _type, _types, (v) => setState(() => _type = v!)),
|
||||
const SizedBox(height: 12),
|
||||
_dropdown('الدولة', _country, _countries, (v) => setState(() => _country = v!)),
|
||||
const SizedBox(height: 12),
|
||||
_field(_nameAr, 'اسم المؤسسة (عربي)'),
|
||||
const SizedBox(height: 12),
|
||||
_field(_nameEn, 'اسم المؤسسة (إنجليزي)'),
|
||||
const SizedBox(height: 12),
|
||||
_field(_city, 'المدينة'),
|
||||
const SizedBox(height: 20),
|
||||
const Divider(color: AppColor.surfaceElevated),
|
||||
const SizedBox(height: 8),
|
||||
const Text('أول مشرف (owner) لهذه المؤسسة',
|
||||
style: TextStyle(color: AppColor.textSecondary)),
|
||||
const SizedBox(height: 12),
|
||||
_field(_adminName, 'اسم المشرف'),
|
||||
const SizedBox(height: 12),
|
||||
_field(_adminPhone, 'هاتف المشرف', keyboardType: TextInputType.phone),
|
||||
const SizedBox(height: 24),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColor.accent,
|
||||
minimumSize: const Size.fromHeight(50),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
),
|
||||
onPressed: c.isCreating ? null : _submit,
|
||||
child: c.isCreating
|
||||
? const SizedBox(
|
||||
height: 20, width: 20,
|
||||
child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white))
|
||||
: const Text('إنشاء', style: TextStyle(color: Colors.white)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _field(TextEditingController ctrl, String label, {TextInputType? keyboardType}) {
|
||||
return TextField(
|
||||
controller: ctrl,
|
||||
keyboardType: keyboardType,
|
||||
style: const TextStyle(color: AppColor.textPrimary),
|
||||
decoration: InputDecoration(
|
||||
labelText: label,
|
||||
labelStyle: const TextStyle(color: AppColor.textSecondary),
|
||||
filled: true,
|
||||
fillColor: AppColor.surface,
|
||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12), borderSide: BorderSide.none),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _dropdown(String label, String value, Map<String, String> options,
|
||||
void Function(String?) onChanged) {
|
||||
return DropdownButtonFormField<String>(
|
||||
initialValue: value,
|
||||
dropdownColor: AppColor.surface,
|
||||
style: const TextStyle(color: AppColor.textPrimary),
|
||||
decoration: InputDecoration(
|
||||
labelText: label,
|
||||
labelStyle: const TextStyle(color: AppColor.textSecondary),
|
||||
filled: true,
|
||||
fillColor: AppColor.surface,
|
||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12), borderSide: BorderSide.none),
|
||||
),
|
||||
items: options.entries
|
||||
.map((e) => DropdownMenuItem(value: e.key, child: Text(e.value)))
|
||||
.toList(),
|
||||
onChanged: onChanged,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _submit() async {
|
||||
if (_nameAr.text.trim().isEmpty ||
|
||||
_nameEn.text.trim().isEmpty ||
|
||||
_city.text.trim().isEmpty ||
|
||||
_adminName.text.trim().isEmpty ||
|
||||
_adminPhone.text.trim().isEmpty) {
|
||||
Get.snackbar('مواصلاتي', 'الرجاء تعبئة كل الحقول');
|
||||
return;
|
||||
}
|
||||
|
||||
final c = Get.find<TransitAdminController>();
|
||||
final ok = await c.createOrg(
|
||||
type: _type,
|
||||
country: _country,
|
||||
city: _city.text.trim(),
|
||||
nameAr: _nameAr.text.trim(),
|
||||
nameEn: _nameEn.text.trim(),
|
||||
adminName: _adminName.text.trim(),
|
||||
adminPhone: _adminPhone.text.trim(),
|
||||
);
|
||||
|
||||
if (ok && mounted) Get.back(result: true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,251 @@
|
||||
// org_details_page.dart — تفاصيل وتحليلات مؤسسة (لوحة إدارة سيرو)
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../constant/colors.dart';
|
||||
import '../../controller/transit/transit_admin_controller.dart';
|
||||
import 'org_admins_page.dart';
|
||||
|
||||
class TransitOrgDetailsPage extends StatefulWidget {
|
||||
final int orgId;
|
||||
final String orgName;
|
||||
const TransitOrgDetailsPage({super.key, required this.orgId, required this.orgName});
|
||||
|
||||
@override
|
||||
State<TransitOrgDetailsPage> createState() => _TransitOrgDetailsPageState();
|
||||
}
|
||||
|
||||
class _TransitOrgDetailsPageState extends State<TransitOrgDetailsPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
Get.find<TransitAdminController>().loadOrgDetails(widget.orgId);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GetBuilder<TransitAdminController>(
|
||||
builder: (c) => Scaffold(
|
||||
backgroundColor: AppColor.bg,
|
||||
appBar: AppBar(
|
||||
backgroundColor: AppColor.bg,
|
||||
elevation: 0,
|
||||
title: Text(widget.orgName, style: const TextStyle(color: AppColor.textPrimary)),
|
||||
actions: [
|
||||
IconButton(
|
||||
tooltip: 'إدارة المشرفين',
|
||||
icon: const Icon(Icons.admin_panel_settings_outlined, color: AppColor.accent),
|
||||
onPressed: () => Get.to(
|
||||
() => TransitOrgAdminsPage(orgId: widget.orgId, orgName: widget.orgName),
|
||||
),
|
||||
),
|
||||
PopupMenuButton<String>(
|
||||
icon: const Icon(Icons.more_vert, color: AppColor.textSecondary),
|
||||
color: AppColor.surface,
|
||||
onSelected: (action) => _handleContractAction(action),
|
||||
itemBuilder: (_) => [
|
||||
_menuItem('active', 'تفعيل العقد', Icons.check_circle_outline, AppColor.success),
|
||||
_menuItem('trial', 'وضع تجريبي', Icons.science_outlined, AppColor.info),
|
||||
_menuItem('suspended', 'تعليق العقد', Icons.pause_circle_outline, AppColor.warning),
|
||||
_menuItem('terminated', 'إنهاء العقد', Icons.cancel_outlined, AppColor.danger),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
body: c.isLoadingDetails
|
||||
? const Center(child: CircularProgressIndicator(color: AppColor.accent))
|
||||
: c.selectedOrgDetails == null
|
||||
? const Center(
|
||||
child: Text('تعذّر تحميل البيانات', style: TextStyle(color: AppColor.textSecondary)))
|
||||
: _content(c),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
PopupMenuItem<String> _menuItem(String value, String label, IconData icon, Color color) {
|
||||
return PopupMenuItem<String>(
|
||||
value: value,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(icon, color: color, size: 18),
|
||||
const SizedBox(width: 10),
|
||||
Text(label, style: TextStyle(color: color, fontSize: 13)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _handleContractAction(String contractStatus) async {
|
||||
final labels = {
|
||||
'active': 'تفعيل العقد',
|
||||
'trial': 'وضع تجريبي',
|
||||
'suspended': 'تعليق العقد',
|
||||
'terminated': 'إنهاء العقد',
|
||||
};
|
||||
final confirm = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (_) => AlertDialog(
|
||||
backgroundColor: AppColor.surface,
|
||||
title: Text(labels[contractStatus] ?? contractStatus,
|
||||
style: const TextStyle(color: AppColor.textPrimary)),
|
||||
content: Text(
|
||||
contractStatus == 'terminated'
|
||||
? 'سيتم إنهاء العقد وإبطال جميع جلسات المشرفين. هذا الإجراء خطير.'
|
||||
: 'هل أنت متأكد من تغيير حالة العقد إلى "${labels[contractStatus]}"؟',
|
||||
style: const TextStyle(color: AppColor.textSecondary),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: const Text('إلغاء', style: TextStyle(color: AppColor.textSecondary)),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
child: Text(
|
||||
labels[contractStatus] ?? contractStatus,
|
||||
style: TextStyle(
|
||||
color: contractStatus == 'terminated' ? AppColor.danger : AppColor.accent,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
if (confirm != true) return;
|
||||
|
||||
final c = Get.find<TransitAdminController>();
|
||||
final ok = await c.updateContractStatus(widget.orgId, contractStatus);
|
||||
if (ok && mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text('تم تحديث حالة العقد إلى: ${labels[contractStatus]}'),
|
||||
backgroundColor: contractStatus == 'terminated'
|
||||
? AppColor.danger
|
||||
: contractStatus == 'suspended'
|
||||
? AppColor.warning
|
||||
: AppColor.success,
|
||||
));
|
||||
c.loadOrgDetails(widget.orgId);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _content(TransitAdminController c) {
|
||||
final d = c.selectedOrgDetails!;
|
||||
final counts = d.counts;
|
||||
final trips = d.trips;
|
||||
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
_sectionTitle('الأسطول'),
|
||||
Row(
|
||||
children: [
|
||||
_statCard('السائقون', '${counts['drivers_active'] ?? 0}/${counts['drivers_total'] ?? 0}',
|
||||
Icons.badge_outlined),
|
||||
const SizedBox(width: 10),
|
||||
_statCard('المركبات', '${counts['vehicles_active'] ?? 0}/${counts['vehicles_total'] ?? 0}',
|
||||
Icons.directions_bus_outlined),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
_statCard('الخطوط النشطة', '${counts['routes_active'] ?? 0}', Icons.route_outlined),
|
||||
const SizedBox(width: 10),
|
||||
_statCard('عضويات نشطة', '${counts['enrollments_active'] ?? 0}', Icons.people_outline),
|
||||
],
|
||||
),
|
||||
if ((int.tryParse(counts['enrollments_pending']?.toString() ?? '0') ?? 0) > 0) ...[
|
||||
const SizedBox(height: 10),
|
||||
_statCard('طلبات بانتظار الموافقة', '${counts['enrollments_pending']}',
|
||||
Icons.pending_actions_outlined, color: AppColor.warning),
|
||||
],
|
||||
const SizedBox(height: 24),
|
||||
_sectionTitle('الرحلات'),
|
||||
Row(
|
||||
children: [
|
||||
_statCard('اليوم', '${trips['today'] ?? 0}', Icons.today_outlined),
|
||||
const SizedBox(width: 10),
|
||||
_statCard('هذا الأسبوع', '${trips['this_week'] ?? 0}', Icons.date_range_outlined),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
_statCard('هذا الشهر', '${trips['this_month'] ?? 0}', Icons.calendar_month_outlined),
|
||||
const SizedBox(width: 10),
|
||||
_statCard('ساعات القيادة', '${trips['total_hours_driven'] ?? 0}', Icons.timer_outlined),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
_statCard('مكتملة', '${trips['completed'] ?? 0}', Icons.check_circle_outline,
|
||||
color: AppColor.success),
|
||||
const SizedBox(width: 10),
|
||||
_statCard('متوسط التأخير', '${trips['avg_delay_minutes'] ?? 0} د', Icons.timelapse,
|
||||
color: AppColor.warning),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
_sectionTitle('الخطوط'),
|
||||
...d.routes.map((r) => Card(
|
||||
color: AppColor.surface,
|
||||
margin: const EdgeInsets.only(bottom: 8),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
child: ListTile(
|
||||
title: Text(r['name_ar']?.toString() ?? '',
|
||||
style: const TextStyle(color: AppColor.textPrimary)),
|
||||
subtitle: Text(
|
||||
'${r['stops_count'] ?? 0} محطة · ${r['completed_trips'] ?? 0} رحلة مكتملة',
|
||||
style: const TextStyle(color: AppColor.textSecondary, fontSize: 12),
|
||||
),
|
||||
trailing: Text(
|
||||
r['status']?.toString() ?? '',
|
||||
style: TextStyle(
|
||||
color: r['status'] == 'active' ? AppColor.success : AppColor.textSecondary,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _sectionTitle(String text) => Padding(
|
||||
padding: const EdgeInsets.only(bottom: 10),
|
||||
child: Text(text,
|
||||
style: const TextStyle(
|
||||
color: AppColor.textPrimary, fontSize: 16, fontWeight: FontWeight.bold)),
|
||||
);
|
||||
|
||||
Widget _statCard(String label, String value, IconData icon, {Color? color}) {
|
||||
return Expanded(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.surface,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Icon(icon, color: color ?? AppColor.accent, size: 20),
|
||||
const SizedBox(height: 8),
|
||||
Text(value,
|
||||
style: TextStyle(
|
||||
color: color ?? AppColor.textPrimary,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 2),
|
||||
Text(label, style: const TextStyle(color: AppColor.textSecondary, fontSize: 11)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../controller/transit/transit_admin_controller.dart';
|
||||
import '../../controller/transit/transit_admin_models.dart';
|
||||
import 'org_create_page.dart';
|
||||
import 'org_details_page.dart';
|
||||
import 'route_approval_page.dart';
|
||||
|
||||
class TransitOrgListPage extends StatefulWidget {
|
||||
const TransitOrgListPage({super.key});
|
||||
|
||||
@override
|
||||
State<TransitOrgListPage> createState() => _TransitOrgListPageState();
|
||||
}
|
||||
|
||||
class _TransitOrgListPageState extends State<TransitOrgListPage> {
|
||||
final _searchCtrl = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
Get.put(TransitAdminController());
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cs = Theme.of(context).colorScheme;
|
||||
|
||||
return GetBuilder<TransitAdminController>(
|
||||
builder: (c) => Scaffold(
|
||||
backgroundColor: cs.surface,
|
||||
body: Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.fromLTRB(16, 50, 16, 16),
|
||||
child: Row(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () => Get.back(),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: cs.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: cs.outline),
|
||||
),
|
||||
child: Icon(Icons.arrow_back_ios_new_rounded, color: cs.onSurfaceVariant, size: 16),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Text('مواصلاتي — المؤسسات', style: TextStyle(color: cs.onSurface, fontSize: 18, fontWeight: FontWeight.w700)),
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
icon: Icon(Icons.route_rounded, color: cs.tertiary),
|
||||
tooltip: 'اعتماد الخطوط',
|
||||
onPressed: () => Get.to(() => const RouteApprovalPage()),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.add, color: cs.primary),
|
||||
onPressed: () async {
|
||||
final created = await Get.to(() => const TransitOrgCreatePage());
|
||||
if (created == true) c.fetchOrgs();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: TextField(
|
||||
controller: _searchCtrl,
|
||||
style: TextStyle(color: cs.onSurface),
|
||||
onSubmitted: (v) {
|
||||
c.searchQuery = v;
|
||||
c.fetchOrgs();
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
hintText: 'ابحث عن مؤسسة...',
|
||||
hintStyle: TextStyle(color: cs.onSurfaceVariant),
|
||||
prefixIcon: Icon(Icons.search, color: cs.onSurfaceVariant),
|
||||
filled: true,
|
||||
fillColor: cs.surfaceContainerHighest,
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: c.isLoadingList
|
||||
? Center(child: CircularProgressIndicator(color: cs.primary))
|
||||
: c.orgs.isEmpty
|
||||
? Center(
|
||||
child: Text('لا توجد مؤسسات',
|
||||
style: TextStyle(color: cs.onSurfaceVariant)),
|
||||
)
|
||||
: RefreshIndicator(
|
||||
onRefresh: c.fetchOrgs,
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
itemCount: c.orgs.length,
|
||||
itemBuilder: (_, i) => _orgCard(c.orgs[i], cs),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _orgCard(TransitOrgSummary org, ColorScheme cs) {
|
||||
Color statusColor;
|
||||
switch (org.contractStatus) {
|
||||
case 'active':
|
||||
statusColor = const Color(0xFF10B981);
|
||||
break;
|
||||
case 'trial':
|
||||
statusColor = cs.tertiary;
|
||||
break;
|
||||
case 'suspended':
|
||||
statusColor = cs.tertiary;
|
||||
break;
|
||||
default:
|
||||
statusColor = cs.error;
|
||||
}
|
||||
|
||||
return Card(
|
||||
color: cs.surfaceContainerHighest,
|
||||
margin: const EdgeInsets.only(bottom: 10),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)),
|
||||
child: ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
title: Text(org.nameAr,
|
||||
style: TextStyle(color: cs.onSurface, fontWeight: FontWeight.bold)),
|
||||
subtitle: Padding(
|
||||
padding: const EdgeInsets.only(top: 6),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: statusColor.withValues(alpha: 0.15),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Text(org.contractStatus,
|
||||
style: TextStyle(color: statusColor, fontSize: 11)),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text('${org.city} · ${org.country}',
|
||||
style: TextStyle(color: cs.onSurfaceVariant, fontSize: 12)),
|
||||
const Spacer(),
|
||||
Icon(Icons.directions_bus, size: 14, color: cs.onSurfaceVariant),
|
||||
const SizedBox(width: 2),
|
||||
Text('${org.vehiclesCount}',
|
||||
style: TextStyle(color: cs.onSurfaceVariant, fontSize: 12)),
|
||||
const SizedBox(width: 10),
|
||||
Icon(Icons.people, size: 14, color: cs.onSurfaceVariant),
|
||||
const SizedBox(width: 2),
|
||||
Text('${org.activeEnrollments}',
|
||||
style: TextStyle(color: cs.onSurfaceVariant, fontSize: 12)),
|
||||
],
|
||||
),
|
||||
),
|
||||
trailing: Icon(Icons.arrow_forward_ios, size: 14, color: cs.onSurfaceVariant),
|
||||
onTap: () => Get.to(() => TransitOrgDetailsPage(orgId: org.id, orgName: org.nameAr)),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,310 @@
|
||||
// route_approval_page.dart — اعتماد خطوط مواصلاتي المسودة (لوحة سيرو آدمن)
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../constant/colors.dart';
|
||||
import '../../controller/transit/transit_admin_controller.dart';
|
||||
|
||||
class RouteApprovalPage extends StatefulWidget {
|
||||
const RouteApprovalPage({super.key});
|
||||
|
||||
@override
|
||||
State<RouteApprovalPage> createState() => _RouteApprovalPageState();
|
||||
}
|
||||
|
||||
class _RouteApprovalPageState extends State<RouteApprovalPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
Get.find<TransitAdminController>().fetchPendingRoutes();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColor.bg,
|
||||
appBar: AppBar(
|
||||
backgroundColor: AppColor.bg,
|
||||
elevation: 0,
|
||||
title: const Text(
|
||||
'مواصلاتي — اعتماد الخطوط',
|
||||
style: TextStyle(color: AppColor.textPrimary, fontWeight: FontWeight.bold),
|
||||
),
|
||||
iconTheme: const IconThemeData(color: AppColor.textPrimary),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.refresh_rounded, color: AppColor.accent),
|
||||
onPressed: () =>
|
||||
Get.find<TransitAdminController>().fetchPendingRoutes(),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: GetBuilder<TransitAdminController>(
|
||||
builder: (c) {
|
||||
if (c.isLoadingPendingRoutes) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(color: AppColor.accent));
|
||||
}
|
||||
|
||||
if (c.pendingRoutes.isEmpty) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.check_circle_outline_rounded,
|
||||
size: 64, color: AppColor.success.withOpacity(0.6)),
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
'لا توجد خطوط تنتظر الاعتماد',
|
||||
style: TextStyle(
|
||||
color: AppColor.textSecondary,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
itemCount: c.pendingRoutes.length,
|
||||
itemBuilder: (_, i) => _RouteCard(
|
||||
route: c.pendingRoutes[i],
|
||||
onApprove: (action) async {
|
||||
final routeId =
|
||||
int.tryParse(c.pendingRoutes[i]['id'].toString()) ?? 0;
|
||||
if (routeId == 0) return;
|
||||
final ok = await c.approveRoute(routeId, action);
|
||||
if (ok && mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(action == 'approve'
|
||||
? 'تم اعتماد الخط ✓'
|
||||
: 'تم رفض الخط'),
|
||||
backgroundColor: action == 'approve'
|
||||
? AppColor.success
|
||||
: AppColor.danger,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _RouteCard extends StatelessWidget {
|
||||
final Map<String, dynamic> route;
|
||||
final void Function(String action) onApprove;
|
||||
|
||||
const _RouteCard({required this.route, required this.onApprove});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final stops = (route['stops'] is List) ? route['stops'] as List : [];
|
||||
final stopsCount =
|
||||
int.tryParse(route['stops_count']?.toString() ?? '0') ?? stops.length;
|
||||
final distKm = route['distance_km']?.toString() ?? '—';
|
||||
final durMin = route['duration_min']?.toString() ?? '—';
|
||||
final direction = route['direction']?.toString() ?? '';
|
||||
final orgName = route['org_name']?.toString() ?? '';
|
||||
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.surface,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: AppColor.divider),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// ── هيدر الكارد ──────────────────────────────────
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
width: 44,
|
||||
height: 44,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.accentSoft,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Icon(Icons.route_rounded,
|
||||
color: AppColor.accent, size: 24),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
route['name_ar']?.toString() ?? '',
|
||||
style: const TextStyle(
|
||||
color: AppColor.textPrimary,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 15),
|
||||
),
|
||||
if (orgName.isNotEmpty) ...[
|
||||
const SizedBox(height: 2),
|
||||
Text(orgName,
|
||||
style: const TextStyle(
|
||||
color: AppColor.accent,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w500)),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
_TagChip(
|
||||
label: direction == 'outbound' ? 'ذهاب' : 'إياب',
|
||||
color: direction == 'outbound'
|
||||
? AppColor.info
|
||||
: AppColor.warning,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// ── إحصائيات ─────────────────────────────────────
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Row(
|
||||
children: [
|
||||
_StatChip(
|
||||
icon: Icons.location_on_rounded,
|
||||
label: '$stopsCount محطة'),
|
||||
const SizedBox(width: 8),
|
||||
if (distKm != '—') _StatChip(icon: Icons.straighten_rounded, label: '$distKm كم'),
|
||||
const SizedBox(width: 8),
|
||||
if (durMin != '—') _StatChip(icon: Icons.timer_rounded, label: '$durMin د'),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// ── قائمة المحطات ──────────────────────────────
|
||||
if (stops.isNotEmpty) ...[
|
||||
const SizedBox(height: 12),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Text('المحطات:',
|
||||
style: TextStyle(
|
||||
color: AppColor.textSecondary.withOpacity(0.8),
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600)),
|
||||
),
|
||||
SizedBox(
|
||||
height: 32,
|
||||
child: ListView.separated(
|
||||
scrollDirection: Axis.horizontal,
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||
itemCount: stops.length,
|
||||
separatorBuilder: (_, __) => const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Icon(Icons.arrow_forward_ios_rounded,
|
||||
size: 10, color: AppColor.textMuted),
|
||||
),
|
||||
itemBuilder: (_, i) => Text(
|
||||
stops[i]['name_ar']?.toString() ?? '•',
|
||||
style: const TextStyle(
|
||||
color: AppColor.textSecondary, fontSize: 12),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
// ── أزرار الإجراءات ──────────────────────────────
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: OutlinedButton(
|
||||
onPressed: () => onApprove('reject'),
|
||||
style: OutlinedButton.styleFrom(
|
||||
side: const BorderSide(color: AppColor.danger),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10)),
|
||||
),
|
||||
child: const Text('رفض',
|
||||
style: TextStyle(color: AppColor.danger)),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: ElevatedButton(
|
||||
onPressed: () => onApprove('approve'),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColor.success,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10)),
|
||||
),
|
||||
child: const Text('اعتماد الخط',
|
||||
style: TextStyle(
|
||||
color: Colors.white, fontWeight: FontWeight.bold)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _TagChip extends StatelessWidget {
|
||||
final String label;
|
||||
final Color color;
|
||||
const _TagChip({required this.label, required this.color});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.12),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(color: color.withOpacity(0.3)),
|
||||
),
|
||||
child: Text(label,
|
||||
style: TextStyle(color: color, fontSize: 11, fontWeight: FontWeight.bold)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _StatChip extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String label;
|
||||
const _StatChip({required this.icon, required this.label});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.surfaceElevated,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(icon, size: 12, color: AppColor.textMuted),
|
||||
const SizedBox(width: 4),
|
||||
Text(label,
|
||||
style: const TextStyle(color: AppColor.textSecondary, fontSize: 11)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user