|
|
|
|
|
|
|
""" |
|
نظام واهبي للذكاء الاصطناعي لتحليل العقود والمناقصات |
|
تطبيق Streamlit الرئيسي الذي يجمع جميع الوحدات والمكونات |
|
""" |
|
|
|
import os |
|
import sys |
|
import streamlit as st |
|
import pandas as pd |
|
import numpy as np |
|
|
|
|
|
if 'page' not in st.session_state: |
|
st.session_state.page = 'home' |
|
if 'analysis_type' not in st.session_state: |
|
st.session_state.analysis_type = None |
|
if 'show_document_upload' not in st.session_state: |
|
st.session_state.show_document_upload = False |
|
if 'report_type' not in st.session_state: |
|
st.session_state.report_type = None |
|
if 'show_report_form' not in st.session_state: |
|
st.session_state.show_report_form = False |
|
if 'analysis_result' not in st.session_state: |
|
st.session_state.analysis_result = None |
|
if 'current_document' not in st.session_state: |
|
st.session_state.current_document = None |
|
if 'current_document_text' not in st.session_state: |
|
st.session_state.current_document_text = None |
|
if 'loaded_files' not in st.session_state: |
|
st.session_state.loaded_files = [] |
|
if 'notifications' not in st.session_state: |
|
st.session_state.notifications = [] |
|
|
|
|
|
def initialize_nltk_resources(): |
|
"""تنزيل وتهيئة موارد NLTK المطلوبة""" |
|
try: |
|
|
|
import nltk |
|
|
|
|
|
nltk_data_path = os.path.join(os.path.expanduser("~"), "nltk_data") |
|
os.makedirs(nltk_data_path, exist_ok=True) |
|
nltk.data.path.append(nltk_data_path) |
|
|
|
|
|
required_packages = ['punkt', 'stopwords', 'wordnet', 'omw-1.4'] |
|
for package in required_packages: |
|
try: |
|
if package == 'punkt': |
|
nltk.data.find('tokenizers/punkt') |
|
elif package == 'stopwords': |
|
nltk.data.find('corpora/stopwords') |
|
elif package == 'wordnet': |
|
nltk.data.find('corpora/wordnet') |
|
else: |
|
nltk.data.find(f'corpora/{package}') |
|
except LookupError: |
|
print(f"تنزيل حزمة NLTK: {package}") |
|
nltk.download(package, download_dir=nltk_data_path, quiet=False) |
|
|
|
print("تم تهيئة موارد NLTK بنجاح.") |
|
except Exception as e: |
|
print(f"خطأ في تهيئة NLTK: {e}") |
|
st.error(f"حدث خطأ أثناء تهيئة موارد NLTK: {e}") |
|
|
|
|
|
initialize_nltk_resources() |
|
|
|
|
|
def get_static_path(file_path): |
|
"""مسار ملف ثابت يعمل سواء كان التشغيل من المجلد الرئيسي أو من المجلد الفرعي""" |
|
|
|
possible_paths = [ |
|
|
|
file_path, |
|
|
|
os.path.join(os.path.dirname(__file__), file_path), |
|
|
|
os.path.join(os.path.dirname(os.path.dirname(__file__)), "tender-analysis-system", file_path), |
|
] |
|
|
|
|
|
for path in possible_paths: |
|
if os.path.exists(path): |
|
return path |
|
|
|
|
|
return file_path |
|
|
|
|
|
try: |
|
st.set_page_config( |
|
page_title="نظام WAHBi للذكاء الاصطناعي | التعاقدات والمناقصات", |
|
page_icon="📊", |
|
layout="wide", |
|
initial_sidebar_state="expanded" |
|
) |
|
except Exception as e: |
|
print(f"خطأ في إعداد الصفحة: {e}") |
|
|
|
|
|
|
|
try: |
|
|
|
main_css_path = get_static_path("utils/css/main.css") |
|
rtl_css_path = get_static_path("utils/css/rtl.css") |
|
enhanced_css_path = get_static_path("utils/css/enhanced.css") |
|
|
|
|
|
if os.path.exists(main_css_path): |
|
with open(main_css_path, "r", encoding='utf-8') as f: |
|
main_css = f.read() |
|
st.markdown(f"<style>{main_css}</style>", unsafe_allow_html=True) |
|
print(f"تم تحميل ملف CSS الرئيسي بنجاح من: {main_css_path}") |
|
else: |
|
print(f"تعذر العثور على ملف CSS الرئيسي: {main_css_path}") |
|
|
|
|
|
if os.path.exists(rtl_css_path): |
|
with open(rtl_css_path, "r", encoding='utf-8') as f: |
|
rtl_css = f.read() |
|
st.markdown(f"<style>{rtl_css}</style>", unsafe_allow_html=True) |
|
print(f"تم تحميل ملف CSS للتوجيه RTL بنجاح من: {rtl_css_path}") |
|
else: |
|
print(f"تعذر العثور على ملف CSS للتوجيه RTL: {rtl_css_path}") |
|
|
|
|
|
if os.path.exists(enhanced_css_path): |
|
with open(enhanced_css_path, "r", encoding='utf-8') as f: |
|
enhanced_css = f.read() |
|
st.markdown(f"<style>{enhanced_css}</style>", unsafe_allow_html=True) |
|
print(f"تم تحميل ملف CSS المحسن بنجاح من: {enhanced_css_path}") |
|
else: |
|
print(f"تعذر العثور على ملف CSS المحسن: {enhanced_css_path}") |
|
|
|
except Exception as e: |
|
st.warning(f"حدث خطأ أثناء تحميل ملفات CSS: {str(e)}") |
|
print(f"خطأ في تحميل ملفات CSS: {str(e)}") |
|
|
|
|
|
st.markdown(""" |
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> |
|
""", unsafe_allow_html=True) |
|
|
|
|
|
st.markdown(""" |
|
<style> |
|
/* تعديل الاتجاه للدعم العربي */ |
|
.css-18e3th9, .css-1d391kg, .stMarkdown, .stTextArea, .stButton, .stTextInput, .stSelectbox, .stRadio { |
|
direction: rtl; |
|
text-align: right; |
|
} |
|
|
|
/* تحسين مظهر العناوين */ |
|
h1, h2, h3, h4 { |
|
color: #1E88E5; |
|
} |
|
|
|
/* تخصيص عنوان التطبيق */ |
|
.app-title { |
|
font-size: 2.2rem; |
|
font-weight: bold; |
|
text-align: center; |
|
color: #1E88E5; |
|
margin-bottom: 1rem; |
|
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1); |
|
background: linear-gradient(90deg, #1976D2, #64B5F6); |
|
-webkit-background-clip: text; |
|
-webkit-text-fill-color: transparent; |
|
} |
|
|
|
/* تخصيص الشريط الجانبي */ |
|
.sidebar .sidebar-content { |
|
background-color: #f8f9fa; |
|
} |
|
|
|
/* تخصيص الأقسام */ |
|
.section-card { |
|
background-color: #f9f9f9; |
|
border-radius: 10px; |
|
padding: 20px; |
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); |
|
margin-bottom: 20px; |
|
} |
|
|
|
/* تخصيص الأزرار */ |
|
.stButton>button { |
|
border-radius: 5px; |
|
background-color: #1E88E5; |
|
color: white; |
|
font-weight: bold; |
|
border: none; |
|
padding: 0.5rem 1rem; |
|
transition: all 0.3s ease; |
|
} |
|
|
|
.stButton>button:hover { |
|
background-color: #1565C0; |
|
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); |
|
} |
|
|
|
/* تخصيص المؤشرات */ |
|
.indicator { |
|
padding: 1rem; |
|
border-radius: 10px; |
|
background-color: #f5f5f5; |
|
text-align: center; |
|
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); |
|
} |
|
|
|
.indicator-value { |
|
font-size: 2rem; |
|
font-weight: bold; |
|
margin-bottom: 0.5rem; |
|
} |
|
|
|
.indicator-label { |
|
font-size: 1rem; |
|
color: #666; |
|
} |
|
|
|
/* تخصيص البطاقات */ |
|
.card { |
|
background-color: white; |
|
border-radius: 10px; |
|
padding: 15px; |
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); |
|
margin-bottom: 15px; |
|
border-right: 4px solid #1E88E5; |
|
} |
|
|
|
.card-title { |
|
font-weight: bold; |
|
color: #1E88E5; |
|
margin-bottom: 10px; |
|
} |
|
|
|
.card-metrics { |
|
display: flex; |
|
justify-content: space-between; |
|
} |
|
|
|
.card-metric { |
|
text-align: center; |
|
} |
|
|
|
.card-metric-value { |
|
font-weight: bold; |
|
font-size: 1.5rem; |
|
} |
|
|
|
.card-metric-label { |
|
font-size: 0.8rem; |
|
color: #666; |
|
} |
|
</style> |
|
""", unsafe_allow_html=True) |
|
|
|
|
|
from utils.components.sidebar import render_sidebar |
|
from utils.helpers import create_directory_if_not_exists, get_data_folder |
|
|
|
|
|
from modules.pricing.pricing_app import PricingApp |
|
from modules.projects.projects_app import ProjectsApp |
|
from modules.resources.resources_app import ResourcesApp |
|
from modules.risk_assessment.risk_assessment_app import RiskAssessmentApp |
|
from modules.project_tracker.tracker_app import TrackerApp |
|
from modules.maps.maps_app import MapsApp |
|
from modules.notifications.notifications_app import NotificationsApp |
|
from modules.voice_narration.voice_narration_app import VoiceNarrationApp |
|
from modules.achievements.achievements_app import AchievementsApp |
|
from modules.ai_finetuning.finetuning_app import FinetuningApp |
|
from modules.document_comparison.comparison_app import DocumentComparisonApp |
|
|
|
|
|
create_directory_if_not_exists(get_data_folder()) |
|
create_directory_if_not_exists(os.path.join(get_data_folder(), "projects")) |
|
create_directory_if_not_exists(os.path.join(get_data_folder(), "documents")) |
|
create_directory_if_not_exists(os.path.join(get_data_folder(), "analysis")) |
|
|
|
def main(): |
|
"""الدالة الرئيسية للتطبيق""" |
|
|
|
|
|
selected_module = render_sidebar() |
|
|
|
|
|
if "is_authenticated" in st.session_state and not st.session_state.is_authenticated: |
|
render_login_screen() |
|
return |
|
|
|
|
|
if selected_module == "الرئيسية": |
|
render_homepage() |
|
|
|
elif selected_module == "إدارة المشاريع": |
|
projects_app = ProjectsApp() |
|
projects_app.render() |
|
|
|
elif selected_module == "التسعير المتكاملة": |
|
pricing_app = PricingApp() |
|
pricing_app.render() |
|
|
|
elif selected_module == "الموارد والتكاليف": |
|
resources_app = ResourcesApp() |
|
resources_app.render() |
|
|
|
elif selected_module == "تحليل المستندات": |
|
|
|
render_document_analysis() |
|
|
|
elif selected_module == "مقارنة المستندات": |
|
|
|
comparison_app = DocumentComparisonApp() |
|
comparison_app.render() |
|
|
|
elif selected_module == "تقييم مخاطر العقود": |
|
risk_app = RiskAssessmentApp() |
|
risk_app.render() |
|
|
|
elif selected_module == "التقارير والتحليلات": |
|
|
|
render_reports_and_analytics() |
|
|
|
elif selected_module == "متتبع حالة المشروع": |
|
tracker_app = TrackerApp() |
|
tracker_app.render() |
|
|
|
elif selected_module == "خريطة المشاريع": |
|
maps_app = MapsApp() |
|
maps_app.render() |
|
|
|
elif selected_module == "نظام الإشعارات": |
|
notifications_app = NotificationsApp() |
|
notifications_app.render() |
|
|
|
elif selected_module == "الترجمة الصوتية": |
|
voice_app = VoiceNarrationApp() |
|
voice_app.render() |
|
|
|
elif selected_module == "نظام الإنجازات": |
|
achievements_app = AchievementsApp() |
|
achievements_app.render() |
|
|
|
elif selected_module == "المساعد الذكي": |
|
|
|
render_ai_assistant() |
|
|
|
elif selected_module == "ضبط نماذج الذكاء الاصطناعي": |
|
finetuning_app = FinetuningApp() |
|
finetuning_app.render() |
|
|
|
else: |
|
st.error("الوحدة المطلوبة غير موجودة") |
|
|
|
|
|
def render_login_screen(): |
|
"""عرض شاشة تسجيل الدخول""" |
|
st.markdown("<h1 class='app-title'>نظام WAHBi للذكاء الاصطناعي</h1>", unsafe_allow_html=True) |
|
|
|
st.markdown(""" |
|
<div class="section-card"> |
|
<h2>تسجيل الدخول</h2> |
|
<p>يرجى إدخال بيانات الاعتماد الخاصة بك للوصول إلى النظام.</p> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
col1, col2, col3 = st.columns([1, 2, 1]) |
|
|
|
with col2: |
|
username = st.text_input("اسم المستخدم") |
|
password = st.text_input("كلمة المرور", type="password") |
|
|
|
if st.button("تسجيل الدخول"): |
|
|
|
if username == "admin" and password == "admin": |
|
st.session_state.is_authenticated = True |
|
st.session_state.user_info = { |
|
"id": 1, |
|
"username": "admin", |
|
"full_name": "مدير النظام", |
|
"email": "[email protected]", |
|
"role": "مدير", |
|
"department": "الإدارة", |
|
"last_login": "2023-01-01 09:00:00" |
|
} |
|
st.rerun() |
|
else: |
|
st.error("اسم المستخدم أو كلمة المرور غير صحيحة") |
|
|
|
st.markdown(""" |
|
<div style="text-align: center; margin-top: 50px; color: #666;"> |
|
<p>نظام WAHBi للذكاء الاصطناعي © 2025 شركة شبه الجزيرة للمقاولات</p> |
|
<p>جميع الحقوق محفوظة</p> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
|
|
def render_homepage(): |
|
"""عرض الصفحة الرئيسية للتطبيق""" |
|
st.markdown("<h1 class='app-title'>نظام WAHBi للذكاء الاصطناعي</h1>", unsafe_allow_html=True) |
|
st.markdown("<div style='text-align: center; margin-bottom: 20px;'>نظام متكامل لتحليل العقود والمناقصات باستخدام تقنيات الذكاء الاصطناعي المتقدمة</div>", unsafe_allow_html=True) |
|
|
|
|
|
col1, col2, col3, col4 = st.columns(4) |
|
|
|
with col1: |
|
st.markdown(""" |
|
<div class="indicator"> |
|
<div class="indicator-value" style="color: #1E88E5;">24</div> |
|
<div class="indicator-label">المناقصات النشطة</div> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
with col2: |
|
st.markdown(""" |
|
<div class="indicator"> |
|
<div class="indicator-value" style="color: #43A047;">8</div> |
|
<div class="indicator-label">مشاريع قيد التنفيذ</div> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
with col3: |
|
st.markdown(""" |
|
<div class="indicator"> |
|
<div class="indicator-value" style="color: #FB8C00;">12</div> |
|
<div class="indicator-label">مستندات قيد التحليل</div> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
with col4: |
|
st.markdown(""" |
|
<div class="indicator"> |
|
<div class="indicator-value" style="color: #E53935;">5</div> |
|
<div class="indicator-label">تنبيهات تتطلب الاهتمام</div> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
|
|
col1, col2 = st.columns([2, 1]) |
|
|
|
with col1: |
|
st.markdown("### المناقصات الأخيرة") |
|
|
|
st.markdown(""" |
|
<div class="card"> |
|
<div class="card-title">إنشاء طريق سريع بمنطقة الرياض</div> |
|
<div>رقم المناقصة: TR-2025-134</div> |
|
<div>الجهة المالكة: وزارة النقل</div> |
|
<div>تاريخ الإغلاق: 15 أبريل 2025</div> |
|
<div class="card-metrics" style="margin-top: 10px;"> |
|
<div class="card-metric"> |
|
<div class="card-metric-value" style="color: #4CAF50;">85%</div> |
|
<div class="card-metric-label">نسبة الإنجاز</div> |
|
</div> |
|
<div class="card-metric"> |
|
<div class="card-metric-value" style="color: #FFC107;">متوسطة</div> |
|
<div class="card-metric-label">المخاطر</div> |
|
</div> |
|
<div class="card-metric"> |
|
<div class="card-metric-value" style="color: #2196F3;">مرتفعة</div> |
|
<div class="card-metric-label">الأولوية</div> |
|
</div> |
|
</div> |
|
</div> |
|
|
|
<div class="card"> |
|
<div class="card-title">تطوير شبكة الصرف الصحي بالمنطقة الشرقية</div> |
|
<div>رقم المناقصة: WS-2025-089</div> |
|
<div>الجهة المالكة: وزارة المياه</div> |
|
<div>تاريخ الإغلاق: 22 أبريل 2025</div> |
|
<div class="card-metrics" style="margin-top: 10px;"> |
|
<div class="card-metric"> |
|
<div class="card-metric-value" style="color: #4CAF50;">62%</div> |
|
<div class="card-metric-label">نسبة الإنجاز</div> |
|
</div> |
|
<div class="card-metric"> |
|
<div class="card-metric-value" style="color: #F44336;">مرتفعة</div> |
|
<div class="card-metric-label">المخاطر</div> |
|
</div> |
|
<div class="card-metric"> |
|
<div class="card-metric-value" style="color: #2196F3;">مرتفعة</div> |
|
<div class="card-metric-label">الأولوية</div> |
|
</div> |
|
</div> |
|
</div> |
|
|
|
<div class="card"> |
|
<div class="card-title">بناء 3 مدارس بمنطقة مكة المكرمة</div> |
|
<div>رقم المناقصة: ED-2025-112</div> |
|
<div>الجهة المالكة: وزارة التعليم</div> |
|
<div>تاريخ الإغلاق: 5 مايو 2025</div> |
|
<div class="card-metrics" style="margin-top: 10px;"> |
|
<div class="card-metric"> |
|
<div class="card-metric-value" style="color: #4CAF50;">38%</div> |
|
<div class="card-metric-label">نسبة الإنجاز</div> |
|
</div> |
|
<div class="card-metric"> |
|
<div class="card-metric-value" style="color: #4CAF50;">منخفضة</div> |
|
<div class="card-metric-label">المخاطر</div> |
|
</div> |
|
<div class="card-metric"> |
|
<div class="card-metric-value" style="color: #FFC107;">متوسطة</div> |
|
<div class="card-metric-label">الأولوية</div> |
|
</div> |
|
</div> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
with col2: |
|
st.markdown("### الوصول السريع") |
|
|
|
st.markdown(""" |
|
<div style="display: grid; gap: 10px;"> |
|
<button style="background-color: #1E88E5; color: white; border: none; border-radius: 5px; padding: 10px; text-align: right; cursor: pointer; font-weight: bold;"> |
|
<i class="fas fa-file-alt" style="margin-left: 10px;"></i> تحليل مستند جديد |
|
</button> |
|
|
|
<button style="background-color: #43A047; color: white; border: none; border-radius: 5px; padding: 10px; text-align: right; cursor: pointer; font-weight: bold;"> |
|
<i class="fas fa-calculator" style="margin-left: 10px;"></i> حساب تكاليف مشروع |
|
</button> |
|
|
|
<button style="background-color: #FB8C00; color: white; border: none; border-radius: 5px; padding: 10px; text-align: right; cursor: pointer; font-weight: bold;"> |
|
<i class="fas fa-exclamation-triangle" style="margin-left: 10px;"></i> تقييم مخاطر العقد |
|
</button> |
|
|
|
<button style="background-color: #8E24AA; color: white; border: none; border-radius: 5px; padding: 10px; text-align: right; cursor: pointer; font-weight: bold;"> |
|
<i class="fas fa-map-marker-alt" style="margin-left: 10px;"></i> استعراض خريطة المشاريع |
|
</button> |
|
|
|
<button style="background-color: #546E7A; color: white; border: none; border-radius: 5px; padding: 10px; text-align: right; cursor: pointer; font-weight: bold;"> |
|
<i class="fas fa-chart-bar" style="margin-left: 10px;"></i> إنشاء تقارير تحليلية |
|
</button> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
st.markdown("### آخر التنبيهات") |
|
|
|
st.markdown(""" |
|
<div style="background-color: #FFEBEE; border-right: 3px solid #E53935; padding: 10px; margin-bottom: 10px; border-radius: 5px;"> |
|
<div style="font-weight: bold; color: #B71C1C;">انتهاء موعد تقديم المناقصة</div> |
|
<div style="font-size: 0.9rem;">مشروع إنشاء الطريق السريع - متبقي 3 أيام</div> |
|
</div> |
|
|
|
<div style="background-color: #FFF8E1; border-right: 3px solid #FFA000; padding: 10px; margin-bottom: 10px; border-radius: 5px;"> |
|
<div style="font-weight: bold; color: #FF6F00;">تغيير في شروط المناقصة</div> |
|
<div style="font-size: 0.9rem;">تم تحديث مستندات مشروع شبكة الصرف الصحي</div> |
|
</div> |
|
|
|
<div style="background-color: #E8F5E9; border-right: 3px solid #43A047; padding: 10px; margin-bottom: 10px; border-radius: 5px;"> |
|
<div style="font-weight: bold; color: #2E7D32;">إكمال تحليل المستند</div> |
|
<div style="font-size: 0.9rem;">اكتمل تحليل عقد بناء المدارس بنجاح</div> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
|
|
st.markdown("---") |
|
|
|
st.markdown(""" |
|
<div class="section-card"> |
|
<h3>حول النظام</h3> |
|
<p>نظام WAHBi للذكاء الاصطناعي هو نظام متكامل لتحليل العقود والمناقصات وإدارة المشاريع، مصمم خصيصاً لشركات المقاولات والبناء. يستخدم النظام تقنيات الذكاء الاصطناعي المتقدمة لتحليل المستندات واستخراج المعلومات المهمة وتقييم المخاطر ودعم اتخاذ القرار.</p> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
|
|
st.markdown(""" |
|
<div style="text-align: center; margin-top: 30px; color: #666;"> |
|
<p>هذا النظام يعمل لشركة شبه الجزيرة للمقاولات</p> |
|
<p>جميع الحقوق محفوظة 2025</p> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
|
|
def render_document_analysis(): |
|
"""عرض واجهة تحليل المستندات""" |
|
st.markdown("<h1 class='app-title'>تحليل المستندات</h1>", unsafe_allow_html=True) |
|
|
|
st.markdown(""" |
|
<div class="section-card"> |
|
<p>استخدم هذه الوحدة لتحليل مستندات العقود والمناقصات باستخدام تقنيات الذكاء الاصطناعي المتقدمة. |
|
يمكنك تحميل المستندات بتنسيقات PDF أو Word وسيقوم النظام بتحليلها واستخراج المعلومات المهمة مثل الشروط والتكاليف والمخاطر والتزاماتك كمقاول.</p> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
|
|
st.markdown("### أدوات التحليل:", unsafe_allow_html=True) |
|
|
|
col1, col2, col3 = st.columns(3) |
|
|
|
with col1: |
|
st.markdown(""" |
|
<div class="card"> |
|
<div class="card-title">تحليل العقد الشامل</div> |
|
<p>تحليل شامل للعقد باستخدام Claude AI لاستخراج جميع البنود والشروط والالتزامات والمواعيد النهائية.</p> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
if st.button("تحليل جديد", key="btn_complete_analysis"): |
|
|
|
st.session_state.analysis_type = "complete" |
|
st.session_state.show_document_upload = True |
|
st.rerun() |
|
|
|
with col2: |
|
st.markdown(""" |
|
<div class="card"> |
|
<div class="card-title">تحليل جداول الكميات</div> |
|
<p>تحليل متخصص لجداول الكميات (BOQ) لاستخراج قوائم المواد والكميات والأسعار والتكاليف الإجمالية.</p> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
if st.button("تحليل جديد", key="btn_boq_analysis"): |
|
|
|
st.session_state.analysis_type = "boq" |
|
st.session_state.show_document_upload = True |
|
st.rerun() |
|
|
|
with col3: |
|
st.markdown(""" |
|
<div class="card"> |
|
<div class="card-title">تحليل الشروط والأحكام</div> |
|
<p>تحليل متخصص للشروط والأحكام في العقد لتحديد الشروط الغير عادية أو المقيدة والمخاطر القانونية.</p> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
if st.button("تحليل جديد", key="btn_terms_analysis"): |
|
|
|
st.session_state.analysis_type = "terms" |
|
st.session_state.show_document_upload = True |
|
st.rerun() |
|
|
|
|
|
st.markdown("### التحليلات الأخيرة") |
|
|
|
st.markdown(""" |
|
<table style="width: 100%; border-collapse: collapse; margin-top: 20px;"> |
|
<thead> |
|
<tr style="background-color: #f5f5f5;"> |
|
<th style="padding: 12px; text-align: right; border-bottom: 2px solid #ddd;">اسم المستند</th> |
|
<th style="padding: 12px; text-align: right; border-bottom: 2px solid #ddd;">نوع التحليل</th> |
|
<th style="padding: 12px; text-align: right; border-bottom: 2px solid #ddd;">تاريخ التحليل</th> |
|
<th style="padding: 12px; text-align: right; border-bottom: 2px solid #ddd;">الحالة</th> |
|
<th style="padding: 12px; text-align: right; border-bottom: 2px solid #ddd;">الإجراءات</th> |
|
</tr> |
|
</thead> |
|
<tbody> |
|
<tr> |
|
<td style="padding: 12px; text-align: right; border-bottom: 1px solid #ddd;">عقد إنشاء طريق سريع.pdf</td> |
|
<td style="padding: 12px; text-align: right; border-bottom: 1px solid #ddd;">تحليل شامل</td> |
|
<td style="padding: 12px; text-align: right; border-bottom: 1px solid #ddd;">2023-03-25</td> |
|
<td style="padding: 12px; text-align: right; border-bottom: 1px solid #ddd;"><span style="color: #4CAF50; font-weight: bold;">مكتمل</span></td> |
|
<td style="padding: 12px; text-align: right; border-bottom: 1px solid #ddd;"> |
|
<button style="background-color: #1E88E5; color: white; border: none; border-radius: 3px; padding: 5px 10px; margin-left: 5px; cursor: pointer;">عرض</button> |
|
<button style="background-color: #78909C; color: white; border: none; border-radius: 3px; padding: 5px 10px; cursor: pointer;">تنزيل التقرير</button> |
|
</td> |
|
</tr> |
|
<tr style="background-color: #f9f9f9;"> |
|
<td style="padding: 12px; text-align: right; border-bottom: 1px solid #ddd;">جداول كميات مشروع صرف صحي.xlsx</td> |
|
<td style="padding: 12px; text-align: right; border-bottom: 1px solid #ddd;">تحليل جداول الكميات</td> |
|
<td style="padding: 12px; text-align: right; border-bottom: 1px solid #ddd;">2023-03-23</td> |
|
<td style="padding: 12px; text-align: right; border-bottom: 1px solid #ddd;"><span style="color: #4CAF50; font-weight: bold;">مكتمل</span></td> |
|
<td style="padding: 12px; text-align: right; border-bottom: 1px solid #ddd;"> |
|
<button style="background-color: #1E88E5; color: white; border: none; border-radius: 3px; padding: 5px 10px; margin-left: 5px; cursor: pointer;">عرض</button> |
|
<button style="background-color: #78909C; color: white; border: none; border-radius: 3px; padding: 5px 10px; cursor: pointer;">تنزيل التقرير</button> |
|
</td> |
|
</tr> |
|
<tr> |
|
<td style="padding: 12px; text-align: right; border-bottom: 1px solid #ddd;">شروط وأحكام عقد بناء مدارس.pdf</td> |
|
<td style="padding: 12px; text-align: right; border-bottom: 1px solid #ddd;">تحليل الشروط والأحكام</td> |
|
<td style="padding: 12px; text-align: right; border-bottom: 1px solid #ddd;">2023-03-20</td> |
|
<td style="padding: 12px; text-align: right; border-bottom: 1px solid #ddd;"><span style="color: #4CAF50; font-weight: bold;">مكتمل</span></td> |
|
<td style="padding: 12px; text-align: right; border-bottom: 1px solid #ddd;"> |
|
<button style="background-color: #1E88E5; color: white; border: none; border-radius: 3px; padding: 5px 10px; margin-left: 5px; cursor: pointer;">عرض</button> |
|
<button style="background-color: #78909C; color: white; border: none; border-radius: 3px; padding: 5px 10px; cursor: pointer;">تنزيل التقرير</button> |
|
</td> |
|
</tr> |
|
<tr style="background-color: #f9f9f9;"> |
|
<td style="padding: 12px; text-align: right; border-bottom: 1px solid #ddd;">ملحق عقد مشروع كباري.pdf</td> |
|
<td style="padding: 12px; text-align: right; border-bottom: 1px solid #ddd;">تحليل شامل</td> |
|
<td style="padding: 12px; text-align: right; border-bottom: 1px solid #ddd;">2023-03-18</td> |
|
<td style="padding: 12px; text-align: right; border-bottom: 1px solid #ddd;"><span style="color: #FB8C00; font-weight: bold;">قيد المعالجة</span></td> |
|
<td style="padding: 12px; text-align: right; border-bottom: 1px solid #ddd;"> |
|
<button style="background-color: #9E9E9E; color: white; border: none; border-radius: 3px; padding: 5px 10px; margin-left: 5px; cursor: pointer;" disabled>عرض</button> |
|
<button style="background-color: #9E9E9E; color: white; border: none; border-radius: 3px; padding: 5px 10px; cursor: pointer;" disabled>تنزيل التقرير</button> |
|
</td> |
|
</tr> |
|
</tbody> |
|
</table> |
|
""", unsafe_allow_html=True) |
|
|
|
|
|
st.markdown("### إحصائيات التحليل") |
|
|
|
col1, col2 = st.columns(2) |
|
|
|
with col1: |
|
st.markdown(""" |
|
<div style="padding: 20px; background-color: #f5f5f5; border-radius: 10px; height: 100%;"> |
|
<h4 style="color: #1E88E5; margin-bottom: 15px;">توزيع أنواع المستندات</h4> |
|
<div style="margin-bottom: 15px;"> |
|
<div style="display: flex; justify-content: space-between; margin-bottom: 5px;"> |
|
<span>عقود ومناقصات</span> |
|
<span>45%</span> |
|
</div> |
|
<div style="height: 10px; background-color: #e0e0e0; border-radius: 5px;"> |
|
<div style="height: 100%; width: 45%; background-color: #1E88E5; border-radius: 5px;"></div> |
|
</div> |
|
</div> |
|
|
|
<div style="margin-bottom: 15px;"> |
|
<div style="display: flex; justify-content: space-between; margin-bottom: 5px;"> |
|
<span>جداول كميات</span> |
|
<span>30%</span> |
|
</div> |
|
<div style="height: 10px; background-color: #e0e0e0; border-radius: 5px;"> |
|
<div style="height: 100%; width: 30%; background-color: #43A047; border-radius: 5px;"></div> |
|
</div> |
|
</div> |
|
|
|
<div style="margin-bottom: 15px;"> |
|
<div style="display: flex; justify-content: space-between; margin-bottom: 5px;"> |
|
<span>شروط وأحكام</span> |
|
<span>15%</span> |
|
</div> |
|
<div style="height: 10px; background-color: #e0e0e0; border-radius: 5px;"> |
|
<div style="height: 100%; width: 15%; background-color: #FB8C00; border-radius: 5px;"></div> |
|
</div> |
|
</div> |
|
|
|
<div style="margin-bottom: 15px;"> |
|
<div style="display: flex; justify-content: space-between; margin-bottom: 5px;"> |
|
<span>مستندات أخرى</span> |
|
<span>10%</span> |
|
</div> |
|
<div style="height: 10px; background-color: #e0e0e0; border-radius: 5px;"> |
|
<div style="height: 100%; width: 10%; background-color: #78909C; border-radius: 5px;"></div> |
|
</div> |
|
</div> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
with col2: |
|
st.markdown(""" |
|
<div style="padding: 20px; background-color: #f5f5f5; border-radius: 10px; height: 100%;"> |
|
<h4 style="color: #1E88E5; margin-bottom: 15px;">إحصائيات التحليل الشهرية</h4> |
|
<div style="display: flex; justify-content: space-between; text-align: center;"> |
|
<div> |
|
<div style="font-size: 2rem; font-weight: bold; color: #1E88E5;">42</div> |
|
<div style="color: #666;">مستند تم تحليله</div> |
|
</div> |
|
<div> |
|
<div style="font-size: 2rem; font-weight: bold; color: #43A047;">38</div> |
|
<div style="color: #666;">تحليل ناجح</div> |
|
</div> |
|
<div> |
|
<div style="font-size: 2rem; font-weight: bold; color: #FB8C00;">4</div> |
|
<div style="color: #666;">تحليل غير مكتمل</div> |
|
</div> |
|
</div> |
|
|
|
<h4 style="color: #1E88E5; margin-top: 20px; margin-bottom: 15px;">متوسط وقت المعالجة</h4> |
|
<div style="display: flex; align-items: center; margin-bottom: 10px;"> |
|
<div style="width: 150px;">تحليل شامل:</div> |
|
<div style="flex-grow: 1; height: 8px; background-color: #e0e0e0; border-radius: 5px;"> |
|
<div style="height: 100%; width: 80%; background-color: #1E88E5; border-radius: 5px;"></div> |
|
</div> |
|
<div style="width: 50px; text-align: left; padding-left: 10px;">2:30</div> |
|
</div> |
|
|
|
<div style="display: flex; align-items: center; margin-bottom: 10px;"> |
|
<div style="width: 150px;">جداول الكميات:</div> |
|
<div style="flex-grow: 1; height: 8px; background-color: #e0e0e0; border-radius: 5px;"> |
|
<div style="height: 100%; width: 50%; background-color: #43A047; border-radius: 5px;"></div> |
|
</div> |
|
<div style="width: 50px; text-align: left; padding-left: 10px;">1:45</div> |
|
</div> |
|
|
|
<div style="display: flex; align-items: center;"> |
|
<div style="width: 150px;">الشروط والأحكام:</div> |
|
<div style="flex-grow: 1; height: 8px; background-color: #e0e0e0; border-radius: 5px;"> |
|
<div style="height: 100%; width: 60%; background-color: #FB8C00; border-radius: 5px;"></div> |
|
</div> |
|
<div style="width: 50px; text-align: left; padding-left: 10px;">2:00</div> |
|
</div> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
|
|
def render_reports_and_analytics(): |
|
"""عرض واجهة التقارير والتحليلات""" |
|
st.markdown("<h1 class='app-title'>التقارير والتحليلات</h1>", unsafe_allow_html=True) |
|
|
|
st.markdown(""" |
|
<div class="section-card"> |
|
<p>استخدم هذه الوحدة لإنشاء تقارير تحليلية متقدمة عن المشاريع والمناقصات والأداء العام. |
|
يوفر النظام رؤى وتحليلات متعمقة تساعدك على فهم أداء مشاريعك وتحسين عمليات صنع القرار.</p> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
|
|
st.markdown("### أنواع التقارير") |
|
|
|
col1, col2, col3 = st.columns(3) |
|
|
|
with col1: |
|
st.markdown(""" |
|
<div class="card"> |
|
<div class="card-title">تقارير المشاريع</div> |
|
<p>تقارير تفصيلية عن حالة المشاريع وتقدمها ومؤشرات الأداء الرئيسية والمشكلات المحتملة.</p> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
if st.button("إنشاء تقرير", key="btn_project_report"): |
|
|
|
st.session_state.report_type = "project" |
|
st.session_state.show_report_form = True |
|
st.rerun() |
|
|
|
with col2: |
|
st.markdown(""" |
|
<div class="card"> |
|
<div class="card-title">تقارير الأداء المالي</div> |
|
<p>تحليل مالي للمشاريع يتضمن الإيرادات والتكاليف والأرباح والتدفقات النقدية والانحرافات عن الميزانية.</p> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
if st.button("إنشاء تقرير", key="btn_financial_report"): |
|
|
|
st.session_state.report_type = "financial" |
|
st.session_state.show_report_form = True |
|
st.rerun() |
|
|
|
with col3: |
|
st.markdown(""" |
|
<div class="card"> |
|
<div class="card-title">تقارير المناقصات</div> |
|
<p>تحليل شامل للمناقصات النشطة والمنتهية ونسب الفوز والمنافسين ومقارنة الأسعار.</p> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
if st.button("إنشاء تقرير", key="btn_tender_report"): |
|
|
|
st.session_state.report_type = "tender" |
|
st.session_state.show_report_form = True |
|
st.rerun() |
|
|
|
|
|
st.markdown("### لوحة البيانات التنفيذية") |
|
|
|
col1, col2 = st.columns([2, 1]) |
|
|
|
with col1: |
|
st.markdown("#### أداء المشاريع حسب القطاع") |
|
|
|
|
|
sectors = ['البنية التحتية', 'السكني', 'التعليمي', 'الصحي', 'النقل'] |
|
performance = [85, 72, 64, 90, 78] |
|
|
|
|
|
chart_data = pd.DataFrame({'القطاع': sectors, 'الأداء (%)': performance}) |
|
st.bar_chart(chart_data.set_index('القطاع'), use_container_width=True) |
|
|
|
|
|
st.caption("مقارنة أداء المشاريع عبر القطاعات المختلفة (نسبة الإنجاز)") |
|
|
|
with col2: |
|
st.markdown("#### المؤشرات الرئيسية") |
|
|
|
|
|
st.markdown("##### نسبة المشاريع المتأخرة") |
|
delayed_projects = 15 |
|
st.progress(delayed_projects / 100) |
|
st.markdown(f"<p style='text-align: center; color: #F44336; font-weight: bold; margin-top: -10px;'>{delayed_projects}%</p>", unsafe_allow_html=True) |
|
|
|
|
|
st.markdown("##### متوسط هامش الربح") |
|
profit_margin = 22 |
|
st.progress(profit_margin / 100) |
|
st.markdown(f"<p style='text-align: center; color: #4CAF50; font-weight: bold; margin-top: -10px;'>{profit_margin}%</p>", unsafe_allow_html=True) |
|
|
|
|
|
st.markdown("##### معدل نجاح المناقصات") |
|
tender_success = 35 |
|
st.progress(tender_success / 100) |
|
st.markdown(f"<p style='text-align: center; color: #2196F3; font-weight: bold; margin-top: -10px;'>{tender_success}%</p>", unsafe_allow_html=True) |
|
|
|
|
|
st.markdown("### تقارير الأداء الأخيرة") |
|
|
|
|
|
with st.container(): |
|
col1, col2 = st.columns([3, 1]) |
|
|
|
with col1: |
|
st.markdown("#### التقرير الشهري لمشاريع الربع الأول 2025") |
|
st.markdown("تقرير شامل يوضح أداء جميع المشاريع النشطة خلال الربع الأول من عام 2025، بما في ذلك تحليل التكاليف والجدول الزمني والمخاطر.") |
|
st.markdown("**تاريخ الإنشاء:** 15 مارس 2025") |
|
|
|
with col2: |
|
st.markdown("<br>", unsafe_allow_html=True) |
|
col2_1, col2_2 = st.columns(2) |
|
with col2_1: |
|
if st.button("عرض", key="view_report1"): |
|
st.session_state.view_report = "quarterly_q1_2025" |
|
st.session_state.show_report_viewer = True |
|
with col2_2: |
|
if st.button("تنزيل", key="download_report1"): |
|
st.info("جاري تحميل التقرير...") |
|
|
|
st.markdown("---") |
|
|
|
|
|
with st.container(): |
|
col1, col2 = st.columns([3, 1]) |
|
|
|
with col1: |
|
st.markdown("#### تحليل أداء المناقصات 2024-2025") |
|
st.markdown("تحليل مقارن لنتائج المناقصات بين عامي 2024 و 2025، يوضح التحسن في معدلات النجاح وتحليل أسباب الخسارة وفرص التحسين.") |
|
st.markdown("**تاريخ الإنشاء:** 28 فبراير 2025") |
|
|
|
with col2: |
|
st.markdown("<br>", unsafe_allow_html=True) |
|
col2_1, col2_2 = st.columns(2) |
|
with col2_1: |
|
if st.button("عرض", key="view_report2"): |
|
st.session_state.view_report = "tenders_analysis_2024_2025" |
|
st.session_state.show_report_viewer = True |
|
with col2_2: |
|
if st.button("تنزيل", key="download_report2"): |
|
st.info("جاري تحميل التقرير...") |
|
|
|
st.markdown("---") |
|
|
|
|
|
with st.container(): |
|
col1, col2 = st.columns([3, 1]) |
|
|
|
with col1: |
|
st.markdown("#### تقرير المخاطر المالية للمشاريع الجارية") |
|
st.markdown("تقرير تفصيلي حول المخاطر المالية للمشاريع الجارية، بما في ذلك تحليل التدفقات النقدية والمستحقات المتأخرة والمطالبات المحتملة.") |
|
st.markdown("**تاريخ الإنشاء:** 10 فبراير 2025") |
|
|
|
with col2: |
|
st.markdown("<br>", unsafe_allow_html=True) |
|
col2_1, col2_2 = st.columns(2) |
|
with col2_1: |
|
if st.button("عرض", key="view_report3"): |
|
st.session_state.view_report = "financial_risks_2025" |
|
st.session_state.show_report_viewer = True |
|
with col2_2: |
|
if st.button("تنزيل", key="download_report3"): |
|
st.info("جاري تحميل التقرير...") |
|
|
|
|
|
def render_ai_assistant(): |
|
"""عرض واجهة المساعد الذكي باستخدام المكون الجديد""" |
|
try: |
|
from modules.ai_assistant.assistant_app import AssistantApp |
|
|
|
|
|
st.markdown("<h1 class='app-title'>المساعد الذكي</h1>", unsafe_allow_html=True) |
|
|
|
st.markdown(""" |
|
<div class="section-card"> |
|
<p>المساعد الذكي هو واجهة تفاعلية مدعومة بتقنيات الذكاء الاصطناعي لمساعدتك في جميع أنشطة إدارة المشاريع والعقود. |
|
يمكنك طرح أسئلة بلغتك الطبيعية والحصول على إجابات فورية، أو طلب مساعدة في مهام محددة مثل تحليل بنود العقد أو تقدير التكاليف.</p> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
|
|
ai_assistant = AssistantApp() |
|
ai_assistant.render() |
|
|
|
except Exception as e: |
|
st.error(f"حدث خطأ في تحميل المساعد الذكي: {str(e)}") |
|
st.markdown(""" |
|
<div class="error-card"> |
|
<h3>😞 عذراً، واجهنا مشكلة في تحميل المساعد الذكي</h3> |
|
<p>يرجى المحاولة مرة أخرى لاحقاً أو التواصل مع فريق الدعم الفني إذا استمرت المشكلة.</p> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
main() |