File size: 5,441 Bytes
fb20480
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a4f8def
 
fb20480
a4f8def
 
 
 
 
 
 
fb20480
a4f8def
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fb20480
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
"""
مكون الشريط الجانبي المحسن
"""

import streamlit as st
from datetime import datetime
import config
from streamlit_option_menu import option_menu


def render_sidebar():
    """
    عرض وإدارة الشريط الجانبي المحسن
    
    الإرجاع:
        اسم الوحدة المحددة
    """
    with st.sidebar:
        # عرض الشعار بحجم أكبر
        st.image("static/images/logo.png", width=200)
        
        # إنشاء قائمة الخيارات باستخدام مكتبة streamlit_option_menu
        selected_module = option_menu(
            "نظام العقود والمناقصات",
            [
                "الرئيسية",
                "إدارة المشاريع",
                "التسعير المتكاملة",
                "الموارد والتكاليف",
                "تحليل المستندات",
                "تحليل المخاطر",
                "التقارير والتحليلات",
                "المساعد الذكي"
            ],
            icons=[
                'house-fill',
                'folder-fill',
                'calculator-fill',
                'tools',
                'file-earmark-text-fill',
                'exclamation-triangle-fill',
                'bar-chart-fill',
                'robot'
            ],
            menu_icon="cast",
            default_index=0,
            styles={
                "container": {"padding": "5px", "background-color": "#f0f2f6", "direction": "rtl", "border-radius": "8px"},
                "icon": {"color": "#2C5282", "font-size": "18px"},
                "nav-link": {"font-size": "14px", "text-align": "right", "margin": "0px", "padding": "10px", "border-radius": "4px"},
                "nav-link-selected": {"background-color": "#2C5282", "font-weight": "bold"},
            },
            key="main_menu"  # إضافة معرف فريد لتجنب مشكلة تكرار المعرفات
        )
        
        # إضافة فاصل
        st.markdown("---")
        
        # إضافة معلومات المشروع الحالي
        if 'current_project' in st.session_state and st.session_state.current_project:
            # التحقق من نوع البيانات للمشروع الحالي
            project_id = st.session_state.current_project
            
            # البحث عن معلومات المشروع باستخدام المعرف
            project = None
            if 'projects' in st.session_state:
                for p in st.session_state.projects:
                    if isinstance(p, dict) and 'id' in p and p['id'] == project_id:
                        project = p
                        break
            
            # عرض معلومات المشروع إذا تم العثور عليه
            if project and isinstance(project, dict):
                st.markdown("""
                <div style="background-color: #f8f9fa; padding: 15px; border-radius: 8px; border-right: 4px solid #2C5282; margin-bottom: 15px;">
                    <h3 style="color: #2C5282; margin-top: 0; font-size: 18px;">المشروع الحالي</h3>
                    <p style="font-weight: bold; margin-bottom: 5px;">{name}</p>
                    <p style="margin: 0; font-size: 14px;">العميل: {client}</p>
                </div>
                """.format(
                    name=project.get('name', 'غير معروف'),
                    client=project.get('client', 'غير معروف')
                ), unsafe_allow_html=True)
                
                # إضافة زر للتبديل بين المشاريع
                if st.button("تبديل المشروع", key="switch_project_btn"):
                    # لتنفيذ في مرحلة لاحقة
                    pass
        
        # إضافة معلومات المستخدم
        if 'user_info' in st.session_state and st.session_state.user_info:
            user = st.session_state.user_info
            
            st.markdown("---")
            st.markdown("""
            <div style="background-color: #f8f9fa; padding: 15px; border-radius: 8px; margin-bottom: 15px;">
                <h3 style="color: #2C5282; margin-top: 0; font-size: 18px;">معلومات المستخدم</h3>
                <p style="font-weight: bold; margin-bottom: 5px;">{name}</p>
                <p style="margin: 0; font-size: 14px;">الدور: {role}</p>
            </div>
            """.format(
                name=user['full_name'],
                role=user['role']
            ), unsafe_allow_html=True)
            
            # إضافة زر لتسجيل الخروج
            if st.button("تسجيل الخروج", key="logout_btn"):
                st.session_state.is_authenticated = False
                st.session_state.user_info = None
                st.rerun()
        
        # إضافة معلومات النسخة
        st.markdown("---")
        st.markdown("""
        <div style="text-align: center; color: #6c757d; font-size: 13px;">
            <p style="margin: 0;">الإصدار: 2.0.0</p>
            <p style="margin: 0;">تاريخ الإصدار: 2025-04-01</p>
            <p style="margin: 0;">© 2025 شركة شبه الجزيرة للمقاولات</p>
        </div>
        """, unsafe_allow_html=True)
        
        return selected_module