- version : 1.3
- description : adding two optional fields (notes and registration date) and make the change accessable in the frontend .
هذا الالتزام موجود في:
108
app.py
108
app.py
@@ -3,6 +3,7 @@ import csv
|
|||||||
import io
|
import io
|
||||||
import re
|
import re
|
||||||
from flask import Flask, render_template, request, redirect, url_for, flash, send_from_directory
|
from flask import Flask, render_template, request, redirect, url_for, flash, send_from_directory
|
||||||
|
import datetime # Import datetime for current date
|
||||||
|
|
||||||
# --- App Setup ---
|
# --- App Setup ---
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
@@ -30,12 +31,14 @@ def init_db():
|
|||||||
grade TEXT NOT NULL,
|
grade TEXT NOT NULL,
|
||||||
school_name TEXT NOT NULL,
|
school_name TEXT NOT NULL,
|
||||||
address TEXT NOT NULL,
|
address TEXT NOT NULL,
|
||||||
memorizing TEXT NOT NULL
|
memorizing TEXT NOT NULL,
|
||||||
|
notes TEXT, -- New: Optional notes field
|
||||||
|
registration_date TEXT NOT NULL -- New: Registration date
|
||||||
)
|
)
|
||||||
''')
|
''')
|
||||||
# Add indexes for faster search
|
# Add indexes for faster search
|
||||||
conn.execute('CREATE INDEX idx_student_name ON students(student_name)')
|
conn.execute('CREATE INDEX idx_student_name ON students(student_name)')
|
||||||
conn.execute('CREATE INDEX idx_parent_name ON students(parent_name)')
|
conn.execute('CREATE INDEX idx_parent_name ON students(parent_name)') # Changed from idx_parent_phone
|
||||||
print("Database initialized with schema constraints and indexes")
|
print("Database initialized with schema constraints and indexes")
|
||||||
|
|
||||||
@app.cli.command('init-db')
|
@app.cli.command('init-db')
|
||||||
@@ -77,6 +80,15 @@ def validate_student_data(form_data, is_csv=False):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
errors.append("العمر يجب أن يكون رقماً صحيحاً")
|
errors.append("العمر يجب أن يكون رقماً صحيحاً")
|
||||||
|
|
||||||
|
# Validate registration_date format if provided
|
||||||
|
reg_date_str = form_data.get('registration_date')
|
||||||
|
if reg_date_str:
|
||||||
|
try:
|
||||||
|
# Attempt to parse the date. Format 'YYYY-MM-DD' is common for HTML date input
|
||||||
|
datetime.datetime.strptime(reg_date_str, '%Y-%m-%d')
|
||||||
|
except ValueError:
|
||||||
|
errors.append("تاريخ التسجيل غير صالح. يجب أن يكون بالصيغة YYYY-MM-DD")
|
||||||
|
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
# --- App Routes ---
|
# --- App Routes ---
|
||||||
@@ -103,6 +115,11 @@ def add_student():
|
|||||||
flash(error, 'danger')
|
flash(error, 'danger')
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
|
# Get current date if registration_date is not provided
|
||||||
|
registration_date = form_data.get('registration_date')
|
||||||
|
if not registration_date:
|
||||||
|
registration_date = datetime.date.today().isoformat() # YYYY-MM-DD format
|
||||||
|
|
||||||
try:
|
try:
|
||||||
student_data = (
|
student_data = (
|
||||||
form_data['student_name'],
|
form_data['student_name'],
|
||||||
@@ -114,7 +131,9 @@ def add_student():
|
|||||||
form_data['grade'],
|
form_data['grade'],
|
||||||
form_data['school_name'],
|
form_data['school_name'],
|
||||||
form_data['address'],
|
form_data['address'],
|
||||||
form_data['memorizing']
|
form_data['memorizing'],
|
||||||
|
form_data.get('notes') or None, # New: notes
|
||||||
|
registration_date # New: registration_date
|
||||||
)
|
)
|
||||||
|
|
||||||
with get_db_connection() as conn:
|
with get_db_connection() as conn:
|
||||||
@@ -123,8 +142,8 @@ def add_student():
|
|||||||
student_name, age, parent_name,
|
student_name, age, parent_name,
|
||||||
parent_phone_1, parent_phone_2,
|
parent_phone_1, parent_phone_2,
|
||||||
student_phone, grade, school_name,
|
student_phone, grade, school_name,
|
||||||
address, memorizing
|
address, memorizing, notes, registration_date
|
||||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
''', student_data)
|
''', student_data)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
||||||
@@ -172,6 +191,12 @@ def modify_student(student_id):
|
|||||||
flash(f'خطأ في قاعدة البيانات: {str(e)}', 'danger')
|
flash(f'خطأ في قاعدة البيانات: {str(e)}', 'danger')
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
|
# Get current date if registration_date is not provided during modification
|
||||||
|
registration_date = form_data.get('registration_date')
|
||||||
|
if not registration_date:
|
||||||
|
registration_date = datetime.date.today().isoformat() # YYYY-MM-DD format
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
student_data = (
|
student_data = (
|
||||||
form_data['student_name'],
|
form_data['student_name'],
|
||||||
@@ -184,6 +209,8 @@ def modify_student(student_id):
|
|||||||
form_data['school_name'],
|
form_data['school_name'],
|
||||||
form_data['address'],
|
form_data['address'],
|
||||||
form_data['memorizing'],
|
form_data['memorizing'],
|
||||||
|
form_data.get('notes') or None, # New: notes
|
||||||
|
registration_date, # New: registration_date
|
||||||
student_id # The ID is the last parameter for the WHERE clause
|
student_id # The ID is the last parameter for the WHERE clause
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -199,7 +226,9 @@ def modify_student(student_id):
|
|||||||
grade = ?,
|
grade = ?,
|
||||||
school_name = ?,
|
school_name = ?,
|
||||||
address = ?,
|
address = ?,
|
||||||
memorizing = ?
|
memorizing = ?,
|
||||||
|
notes = ?, -- New
|
||||||
|
registration_date = ? -- New
|
||||||
WHERE id = ?
|
WHERE id = ?
|
||||||
''', student_data)
|
''', student_data)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
@@ -214,25 +243,6 @@ def modify_student(student_id):
|
|||||||
|
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
@app.route('/delete_student/<int:student_id>', methods=['POST'])
|
|
||||||
def delete_student(student_id):
|
|
||||||
try:
|
|
||||||
with get_db_connection() as conn:
|
|
||||||
# First, check if the student exists
|
|
||||||
student = conn.execute('SELECT id FROM students WHERE id = ?', (student_id,)).fetchone()
|
|
||||||
if student is None:
|
|
||||||
flash('الطالب غير موجود.', 'danger')
|
|
||||||
return redirect(url_for('index'))
|
|
||||||
|
|
||||||
conn.execute('DELETE FROM students WHERE id = ?', (student_id,))
|
|
||||||
conn.commit()
|
|
||||||
flash('تم حذف الطالب بنجاح!', 'success')
|
|
||||||
except sqlite3.Error as e:
|
|
||||||
flash(f'خطأ في قاعدة البيانات أثناء الحذف: {str(e)}', 'danger')
|
|
||||||
except Exception as e:
|
|
||||||
flash(f'خطأ غير متوقع أثناء الحذف: {str(e)}', 'danger')
|
|
||||||
|
|
||||||
return redirect(url_for('index'))
|
|
||||||
|
|
||||||
@app.route('/import_csv', methods=['POST'])
|
@app.route('/import_csv', methods=['POST'])
|
||||||
def import_csv():
|
def import_csv():
|
||||||
@@ -255,9 +265,12 @@ def import_csv():
|
|||||||
valid_rows = []
|
valid_rows = []
|
||||||
row_errors = []
|
row_errors = []
|
||||||
|
|
||||||
|
# Assuming CSV now has 12 columns: existing 10 + notes + registration_date
|
||||||
|
expected_columns = 12
|
||||||
|
|
||||||
for i, row in enumerate(csv_reader, 1):
|
for i, row in enumerate(csv_reader, 1):
|
||||||
if len(row) != 10:
|
if len(row) != expected_columns:
|
||||||
row_errors.append(f'السطر {i}: عدد الأعمدة غير صحيح (10 مطلوبة)')
|
row_errors.append(f'السطر {i}: عدد الأعمدة غير صحيح ({expected_columns} مطلوبة)')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Map CSV columns to form fields
|
# Map CSV columns to form fields
|
||||||
@@ -271,9 +284,15 @@ def import_csv():
|
|||||||
'grade': row[6].strip(),
|
'grade': row[6].strip(),
|
||||||
'school_name': row[7].strip(),
|
'school_name': row[7].strip(),
|
||||||
'address': row[8].strip(),
|
'address': row[8].strip(),
|
||||||
'memorizing': row[9].strip()
|
'memorizing': row[9].strip(),
|
||||||
|
'notes': row[10].strip(), # New: notes
|
||||||
|
'registration_date': row[11].strip() # New: registration_date
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# If registration_date is empty in CSV, set to current date
|
||||||
|
if not student_data['registration_date']:
|
||||||
|
student_data['registration_date'] = datetime.date.today().isoformat()
|
||||||
|
|
||||||
# Validate row
|
# Validate row
|
||||||
errors = validate_student_data(student_data, is_csv=True)
|
errors = validate_student_data(student_data, is_csv=True)
|
||||||
if errors:
|
if errors:
|
||||||
@@ -287,12 +306,13 @@ def import_csv():
|
|||||||
student_data['parent_name'],
|
student_data['parent_name'],
|
||||||
student_data['parent_phone_1'],
|
student_data['parent_phone_1'],
|
||||||
student_data['parent_phone_2'] or None,
|
student_data['parent_phone_2'] or None,
|
||||||
student_data['student_phone']
|
student_data['student_phone'] or None,
|
||||||
or None,
|
|
||||||
student_data['grade'],
|
student_data['grade'],
|
||||||
student_data['school_name'],
|
student_data['school_name'],
|
||||||
student_data['address'],
|
student_data['address'],
|
||||||
student_data['memorizing']
|
student_data['memorizing'],
|
||||||
|
student_data['notes'] or None, # New: notes
|
||||||
|
student_data['registration_date'] # New: registration_date
|
||||||
))
|
))
|
||||||
|
|
||||||
# Process validation results
|
# Process validation results
|
||||||
@@ -310,8 +330,8 @@ def import_csv():
|
|||||||
student_name, age, parent_name,
|
student_name, age, parent_name,
|
||||||
parent_phone_1, parent_phone_2,
|
parent_phone_1, parent_phone_2,
|
||||||
student_phone, grade, school_name,
|
student_phone, grade, school_name,
|
||||||
address, memorizing
|
address, memorizing, notes, registration_date
|
||||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
''', valid_rows)
|
''', valid_rows)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
flash(f'تم استيراد {len(valid_rows)} طالب بنجاح', 'success')
|
flash(f'تم استيراد {len(valid_rows)} طالب بنجاح', 'success')
|
||||||
@@ -342,6 +362,26 @@ def record():
|
|||||||
def points():
|
def points():
|
||||||
return render_template('points.html')
|
return render_template('points.html')
|
||||||
|
|
||||||
|
@app.route('/delete_student/<int:student_id>', methods=['POST'])
|
||||||
|
def delete_student(student_id):
|
||||||
|
try:
|
||||||
|
with get_db_connection() as conn:
|
||||||
|
# First, check if the student exists
|
||||||
|
student = conn.execute('SELECT id FROM students WHERE id = ?', (student_id,)).fetchone()
|
||||||
|
if student is None:
|
||||||
|
flash('الطالب غير موجود.', 'danger')
|
||||||
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
|
conn.execute('DELETE FROM students WHERE id = ?', (student_id,))
|
||||||
|
conn.commit()
|
||||||
|
flash('تم حذف الطالب بنجاح!', 'success')
|
||||||
|
except sqlite3.Error as e:
|
||||||
|
flash(f'خطأ في قاعدة البيانات أثناء الحذف: {str(e)}', 'danger')
|
||||||
|
except Exception as e:
|
||||||
|
flash(f'خطأ غير متوقع أثناء الحذف: {str(e)}', 'danger')
|
||||||
|
|
||||||
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(debug=True)
|
app.run(debug=True)
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,14 @@
|
|||||||
<label for="memorizing" class="block text-sm font-medium text-gray-700 mb-1">المحفوظات</label>
|
<label for="memorizing" class="block text-sm font-medium text-gray-700 mb-1">المحفوظات</label>
|
||||||
<input type="text" name="memorizing" id="memorizing" placeholder="مثال: القرآن، جزء عم" required class="w-full px-4 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
|
<input type="text" name="memorizing" id="memorizing" placeholder="مثال: القرآن، جزء عم" required class="w-full px-4 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="md:col-span-2">
|
||||||
|
<label for="notes" class="block text-sm font-medium text-gray-700 mb-1">ملاحظات (اختياري)</label>
|
||||||
|
<textarea name="notes" id="notes" rows="3" placeholder="أضف أي ملاحظات إضافية هنا..." class="w-full px-4 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500"></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="md:col-span-2">
|
||||||
|
<label for="registration_date" class="block text-sm font-medium text-gray-700 mb-1">تاريخ التسجيل (اختياري، الافتراضي هو اليوم)</label>
|
||||||
|
<input type="date" name="registration_date" id="registration_date" class="w-full px-4 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-8 text-left">
|
<div class="mt-8 text-left">
|
||||||
<button type="submit" id="submit-add-button" class="px-8 py-3 bg-blue-600 text-white font-semibold rounded-lg shadow-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-all">
|
<button type="submit" id="submit-add-button" class="px-8 py-3 bg-blue-600 text-white font-semibold rounded-lg shadow-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-all">
|
||||||
@@ -85,9 +93,9 @@
|
|||||||
<p>يجب أن يكون الملف بصيغة CSV ومرمّزاً بترميز UTF-8.</p>
|
<p>يجب أن يكون الملف بصيغة CSV ومرمّزاً بترميز UTF-8.</p>
|
||||||
<p>يجب **ألا يحتوي** الملف على صف للعناوين، ويجب أن تكون الأعمدة بالترتيب الدقيق التالي:</p>
|
<p>يجب **ألا يحتوي** الملف على صف للعناوين، ويجب أن تكون الأعمدة بالترتيب الدقيق التالي:</p>
|
||||||
<p class="mt-2" style="direction: ltr; text-align: right;">
|
<p class="mt-2" style="direction: ltr; text-align: right;">
|
||||||
<code class="text-xs font-mono">اسم الطالب, العمر, اسم ولي الأمر, هاتف ولي الأمر 1, هاتف ولي الأمر 2, هاتف الطالب, الصف, اسم المدرسة, العنوان, المحفوظات</code>
|
<code class="text-xs font-mono">اسم الطالب, العمر, اسم ولي الأمر, هاتف ولي الأمر 1, هاتف ولي الأمر 2, هاتف الطالب, الصف, اسم المدرسة, العنوان, المحفوظات, الملاحظات, تاريخ التسجيل</code>
|
||||||
</p>
|
</p>
|
||||||
<p>إذا كانت الحقول الاختيارية (هاتف ولي الأمر 2، هاتف الطالب) فارغة، اتركها كذلك.</p>
|
<p>إذا كانت الحقول الاختيارية (هاتف ولي الأمر 2، هاتف الطالب، الملاحظات، تاريخ التسجيل) فارغة، اتركها كذلك. تاريخ التسجيل سيُعيّن تلقائياً لليوم الحالي إذا تُرِك فارغاً.</p>
|
||||||
{# Added link to download CSV template #}
|
{# Added link to download CSV template #}
|
||||||
<p class="mt-3">
|
<p class="mt-3">
|
||||||
<a href="{{ url_for('download_csv_template') }}" class="text-blue-600 hover:underline font-semibold" download>
|
<a href="{{ url_for('download_csv_template') }}" class="text-blue-600 hover:underline font-semibold" download>
|
||||||
@@ -131,7 +139,7 @@
|
|||||||
<thead class="bg-gray-50">
|
<thead class="bg-gray-50">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider">#</th>
|
<th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider">#</th>
|
||||||
<th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider">الإجراءات</th> {# Moved this header here #}
|
<th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider">الإجراءات</th>
|
||||||
<th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider">اسم الطالب</th>
|
<th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider">اسم الطالب</th>
|
||||||
<th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider">العمر</th>
|
<th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider">العمر</th>
|
||||||
<th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider">ولي الأمر</th>
|
<th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider">ولي الأمر</th>
|
||||||
@@ -140,26 +148,22 @@
|
|||||||
<th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider">المدرسة</th>
|
<th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider">المدرسة</th>
|
||||||
<th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider">العنوان</th>
|
<th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider">العنوان</th>
|
||||||
<th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider">المحفوظات</th>
|
<th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider">المحفوظات</th>
|
||||||
|
<th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider">تاريخ التسجيل</th> {# New Header #}
|
||||||
|
<th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider">ملاحظات</th> {# New Header #}
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="bg-white divide-y divide-gray-200" id="students-table-body">
|
<tbody class="bg-white divide-y divide-gray-200" id="students-table-body">
|
||||||
{% for student in students %}
|
{% for student in students %}
|
||||||
<tr class="hover:bg-gray-50 transition-colors duration-200">
|
<tr class="hover:bg-gray-50 transition-colors duration-200">
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm font-bold text-gray-700">{{ loop.index }}</td>
|
<td class="px-6 py-4 whitespace-nowrap text-sm font-bold text-gray-700">{{ loop.index }}</td>
|
||||||
{# Moved the actions column here #}
|
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
|
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
|
||||||
<a href="{{ url_for('modify_student', student_id=student['id']) }}" class="text-indigo-600 hover:text-indigo-900 mx-1">
|
<a href="{{ url_for('modify_student', student_id=student['id']) }}" class="text-indigo-600 hover:text-indigo-900 mx-1">
|
||||||
<i class="fas fa-pen" title="تعديل"></i> {# Pen icon #}
|
<i class="fas fa-pen" title="تعديل"></i>
|
||||||
</a>
|
</a>
|
||||||
<a href="#" onclick="confirmDelete({{ student['id'] }}, '{{ student['student_name'] }}')" class="text-red-600 hover:text-red-900 mx-1">
|
<a href="#" onclick="confirmDelete({{ student['id'] }}, '{{ student['student_name'] }}')" class="text-red-600 hover:text-red-900 mx-1">
|
||||||
<i class="fas fa-trash-alt" title="حذف"></i> {# Trash can icon #}
|
<i class="fas fa-trash-alt" title="حذف"></i>
|
||||||
</a>
|
</a>
|
||||||
{# A hidden form for deletion, used by JavaScript.
|
<form id="delete-form-{{ student['id'] }}" action="{{ url_for('delete_student', student_id=student['id']) }}" method="POST" style="display: none;"></form>
|
||||||
In a real application, consider adding a CSRF token for security. #}
|
|
||||||
<form id="delete-form-{{ student['id'] }}" action="{{ url_for('delete_student', student_id=student['id']) }}" method="POST" style="display: none;">
|
|
||||||
{# Example for CSRF token (requires Flask-WTF or similar setup): #}
|
|
||||||
{# <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"> #}
|
|
||||||
</form>
|
|
||||||
</td>
|
</td>
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">{{ student['student_name'] }}</td>
|
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">{{ student['student_name'] }}</td>
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">{{ student['age'] }}</td>
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">{{ student['age'] }}</td>
|
||||||
@@ -175,10 +179,12 @@
|
|||||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">{{ student['school_name'] }}</td>
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">{{ student['school_name'] }}</td>
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">{{ student['address'] }}</td>
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">{{ student['address'] }}</td>
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">{{ student['memorizing'] }}</td>
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">{{ student['memorizing'] }}</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">{{ student['registration_date'] }}</td> {# Display registration_date #}
|
||||||
|
<td class="px-6 py-4 text-sm text-gray-600 max-w-xs overflow-hidden text-ellipsis">{{ student['notes'] or 'لا يوجد' }}</td> {# Display notes #}
|
||||||
</tr>
|
</tr>
|
||||||
{% else %}
|
{% else %}
|
||||||
<tr id="no-students-row">
|
<tr id="no-students-row">
|
||||||
<td colspan="10" class="text-center py-6 text-gray-500">لم تتم إضافة أي طالب بعد.</td>
|
<td colspan="12" class="text-center py-6 text-gray-500">لم تتم إضافة أي طالب بعد.</td> {# Adjusted colspan #}
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -215,11 +221,11 @@
|
|||||||
}
|
}
|
||||||
allStudentData.push({
|
allStudentData.push({
|
||||||
element: row,
|
element: row,
|
||||||
student_name: row.children[2] ? row.children[2].textContent : '', // Adjusted index for student_name
|
student_name: row.children[2] ? row.children[2].textContent : '',
|
||||||
parent_name: row.children[4] ? row.children[4].textContent : '', // Adjusted index for parent_name
|
parent_name: row.children[4] ? row.children[4].textContent : '',
|
||||||
// Store original HTML of potentially highlighted cells to restore them later
|
// Store original HTML of potentially highlighted cells to restore them later
|
||||||
originalStudentNameHTML: row.children[2] ? row.children[2].innerHTML : '', // Adjusted index
|
originalStudentNameHTML: row.children[2] ? row.children[2].innerHTML : '',
|
||||||
originalParentNameHTML: row.children[4] ? row.children[4].innerHTML : '' // Adjusted index
|
originalParentNameHTML: row.children[4] ? row.children[4].innerHTML : ''
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -266,10 +272,10 @@
|
|||||||
allStudentData.forEach(data => {
|
allStudentData.forEach(data => {
|
||||||
data.element.classList.remove('hidden');
|
data.element.classList.remove('hidden');
|
||||||
// Restore original HTML for highlighted cells
|
// Restore original HTML for highlighted cells
|
||||||
if (data.element.children[2]) { // Adjusted index
|
if (data.element.children[2]) {
|
||||||
data.element.children[2].innerHTML = data.originalStudentNameHTML;
|
data.element.children[2].innerHTML = data.originalStudentNameHTML;
|
||||||
}
|
}
|
||||||
if (data.element.children[4]) { // Adjusted index
|
if (data.element.children[4]) {
|
||||||
data.element.children[4].innerHTML = data.originalParentNameHTML;
|
data.element.children[4].innerHTML = data.originalParentNameHTML;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -294,20 +300,20 @@
|
|||||||
foundResults++;
|
foundResults++;
|
||||||
|
|
||||||
// Apply highlighting to the student name cell
|
// Apply highlighting to the student name cell
|
||||||
if (data.element.children[2]) { // Adjusted index
|
if (data.element.children[2]) {
|
||||||
data.element.children[2].innerHTML = highlightText(studentName, searchTerm);
|
data.element.children[2].innerHTML = highlightText(studentName, searchTerm);
|
||||||
}
|
}
|
||||||
// Apply highlighting to the parent name cell
|
// Apply highlighting to the parent name cell
|
||||||
if (data.element.children[4]) { // Adjusted index
|
if (data.element.children[4]) {
|
||||||
data.element.children[4].innerHTML = highlightText(parentName, searchTerm);
|
data.element.children[4].innerHTML = highlightText(parentName, searchTerm);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
data.element.classList.add('hidden'); // Hide the row
|
data.element.classList.add('hidden'); // Hide the row
|
||||||
// Restore original content if the row is hidden
|
// Restore original content if the row is hidden
|
||||||
if (data.element.children[2]) { // Adjusted index
|
if (data.element.children[2]) {
|
||||||
data.element.children[2].innerHTML = data.originalStudentNameHTML;
|
data.element.children[2].innerHTML = data.originalStudentNameHTML;
|
||||||
}
|
}
|
||||||
if (data.element.children[4]) { // Adjusted index
|
if (data.element.children[4]) {
|
||||||
data.element.children[4].innerHTML = data.originalParentNameHTML;
|
data.element.children[4].innerHTML = data.originalParentNameHTML;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,14 @@
|
|||||||
<label for="memorizing" class="block text-sm font-medium text-gray-700 mb-1">المحفوظات</label>
|
<label for="memorizing" class="block text-sm font-medium text-gray-700 mb-1">المحفوظات</label>
|
||||||
<input type="text" name="memorizing" id="memorizing" value="{{ student.memorizing }}" required class="w-full px-4 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
|
<input type="text" name="memorizing" id="memorizing" value="{{ student.memorizing }}" required class="w-full px-4 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="md:col-span-2">
|
||||||
|
<label for="notes" class="block text-sm font-medium text-gray-700 mb-1">ملاحظات (اختياري)</label>
|
||||||
|
<textarea name="notes" id="notes" rows="3" placeholder="أضف أي ملاحظات إضافية هنا..." class="w-full px-4 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500">{{ student.notes or '' }}</textarea>
|
||||||
|
</div>
|
||||||
|
<div class="md:col-span-2">
|
||||||
|
<label for="registration_date" class="block text-sm font-medium text-gray-700 mb-1">تاريخ التسجيل</label>
|
||||||
|
<input type="date" name="registration_date" id="registration_date" value="{{ student.registration_date }}" required class="w-full px-4 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-8 text-left flex space-x-4 space-x-reverse">
|
<div class="mt-8 text-left flex space-x-4 space-x-reverse">
|
||||||
<button type="submit" id="submit-modify-button" class="px-8 py-3 bg-blue-600 text-white font-semibold rounded-lg shadow-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-all">
|
<button type="submit" id="submit-modify-button" class="px-8 py-3 bg-blue-600 text-white font-semibold rounded-lg shadow-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-all">
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم