File size: 4,878 Bytes
5a66745
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
وحدة المساعدات العامة
توفر هذه الوحدة مجموعة من الدوال المساعدة المستخدمة في مختلف أجزاء النظام
"""

import os
import datetime
import json
import streamlit as st

def create_directory_if_not_exists(directory_path):
    """إنشاء مجلد إذا لم يكن موجوداً بالفعل"""
    if not os.path.exists(directory_path):
        os.makedirs(directory_path)
        return True
    return False

def get_data_folder():
    """الحصول على مسار مجلد البيانات"""
    data_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'data'))
    create_directory_if_not_exists(data_folder)
    return data_folder

def format_time(timestamp=None):
    """تنسيق الوقت بصيغة قابلة للقراءة"""
    if timestamp is None:
        timestamp = datetime.datetime.now()
    return timestamp.strftime("%Y-%m-%d %H:%M:%S")

def get_user_info():
    """الحصول على معلومات المستخدم الحالي"""
    # في الوقت الحالي، نستخدم معلومات مستخدم افتراضية
    # يمكن تعديل هذه الدالة لاحقاً للتكامل مع نظام المصادقة
    return {
        "id": 1,
        "username": "admin",
        "name": "مدير النظام",
        "role": "admin"
    }

def load_css():
    """تحميل أنماط CSS المخصصة"""
    st.markdown("""
    <style>
    .module-title {
        color: #1E88E5;
        text-align: center;
        margin-bottom: 20px;
        font-weight: bold;
    }
    
    .section-title {
        color: #1565C0;
        margin-top: 20px;
        margin-bottom: 10px;
        font-weight: bold;
    }
    
    .info-box {
        background-color: #E3F2FD;
        padding: 15px;
        border-radius: 5px;
        margin-bottom: 15px;
    }
    
    .warning-box {
        background-color: #FFF8E1;
        padding: 15px;
        border-radius: 5px;
        margin-bottom: 15px;
    }
    
    .error-box {
        background-color: #FFEBEE;
        padding: 15px;
        border-radius: 5px;
        margin-bottom: 15px;
    }
    
    .success-box {
        background-color: #E8F5E9;
        padding: 15px;
        border-radius: 5px;
        margin-bottom: 15px;
    }
    
    .centered {
        text-align: center;
    }
    
    .footer {
        text-align: center;
        margin-top: 30px;
        color: #78909C;
        font-size: 0.8em;
    }
    
    /* تحسين تصميم الجداول */
    table {
        width: 100%;
    }
    
    thead th {
        background-color: #1976D2 !important;
        color: white !important;
    }
    
    tbody tr:nth-child(even) {
        background-color: #f2f2f2;
    }
    
    tbody tr:hover {
        background-color: #E3F2FD;
    }
    
    /* تحسين ظهور الفورم */
    input, select, textarea {
        border-radius: 5px !important;
        border: 1px solid #ddd !important;
        padding: 10px !important;
    }
    
    .stButton>button {
        border-radius: 5px !important;
    }
    
    /* زيادة حجم الخط للتوافق مع اللغة العربية */
    html, body, [class*="css"] {
        font-family: 'Tajawal', sans-serif;
    }
    </style>
    
    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Tajawal:wght@400;700&display=swap">
    """, unsafe_allow_html=True)

def render_credits():
    """عرض المعلومات عن حقوق الملكية وإصدار النظام"""
    st.markdown("""
    <div class="footer">
        <p>هذا النظام يعمل لصالح شركة شبه الجزيرة للمقاولات، جميع الحقوق محفوظة 2025</p>
        <p>نظام WAHBi AI - الإصدار 2.0</p>
    </div>
    """, unsafe_allow_html=True)

def load_icons():
    """تحميل الأيقونات المستخدمة في النظام"""
    icons = {
        "project": "🏗️",
        "document": "📄",
        "analysis": "🔍",
        "warning": "⚠️",
        "success": "✅",
        "error": "❌",
        "info": "ℹ️",
        "settings": "⚙️",
        "user": "👤",
        "money": "💰",
        "time": "⏱️",
        "location": "📍",
        "notification": "🔔",
        "edit": "✏️",
        "delete": "🗑️",
        "upload": "📤",
        "download": "📥",
        "save": "💾",
        "cancel": "❌",
        "add": "➕",
        "calendar": "📅",
        "chat": "💬",
        "search": "🔎",
        "star": "⭐",
        "trophy": "🏆",
        "medal": "🥇",
        "chart": "📊",
        "map": "🗺️",
        "building": "🏢",
        "road": "🛣️",
        "bridge": "🌉",
    }
    return icons