/
var
/
www
/
vhosts
/
m-auto.co
/
httpdocs
/
admin
/
/var/www/vhosts/m-auto.co/httpdocs/admin
mkdir
upload
Name
Size
Mode
Actions
assets/
-
0755
rm
includes/
-
0755
rm
7-6-2026.zip
10206
0644
edit
dl
rm
about_edit.php
3899
0644
edit
dl
rm
about_process.php
1367
0644
edit
dl
rm
auth.php
684
0644
edit
dl
rm
bookings.php
5367
0644
edit
dl
rm
booking_delete.php
924
0644
edit
dl
rm
branches.php
2470
0644
edit
dl
rm
branch_delete.php
1290
0644
edit
dl
rm
branch_form.php
4694
0644
edit
dl
rm
branch_process.php
1233
0644
edit
dl
rm
brands.php
2578
0644
edit
dl
rm
brand_delete.php
1327
0644
edit
dl
rm
brand_form.php
2369
0644
edit
dl
rm
brand_process.php
1660
0644
edit
dl
rm
cars.php
6946
0644
edit
dl
rm
car_delete.php
2886
0644
edit
dl
rm
car_form.php
40348
0644
edit
dl
rm
car_image_actions.php
5142
0644
edit
dl
rm
car_process.php
10426
0644
edit
dl
rm
categories.php
2167
0644
edit
dl
rm
category_delete.php
746
0644
edit
dl
rm
category_form.php
1607
0644
edit
dl
rm
category_process.php
943
0644
edit
dl
rm
dashboard.php
4965
0644
edit
dl
rm
index.php
2713
0644
edit
dl
rm
login_process.php
1532
0644
edit
dl
rm
logout.php
100
0644
edit
dl
rm
news.php
3448
0644
edit
dl
rm
news_delete.php
771
0644
edit
dl
rm
news_form.php
6769
0644
edit
dl
rm
news_process.php
2527
0644
edit
dl
rm
offers.php
2810
0644
edit
dl
rm
offer_delete.php
1327
0644
edit
dl
rm
offer_form.php
4573
0644
edit
dl
rm
offer_process.php
2115
0644
edit
dl
rm
settings.php
5217
0644
edit
dl
rm
settings_process.php
692
0644
edit
dl
rm
slider.php
3529
0644
edit
dl
rm
slider_delete.php
1345
0644
edit
dl
rm
slider_form.php
4529
0644
edit
dl
rm
slider_process.php
1983
0644
edit
dl
rm
themes.php
4703
0644
edit
dl
rm
theme_delete.php
1332
0644
edit
dl
rm
theme_form.php
1522
0644
edit
dl
rm
theme_process.php
1785
0644
edit
dl
rm
users.php
4480
0644
edit
dl
rm
user_delete.php
1055
0644
edit
dl
rm
user_form.php
5463
0644
edit
dl
rm
user_process.php
3193
0644
edit
dl
rm
videos.php
4942
0644
edit
dl
rm
video_delete.php
1717
0644
edit
dl
rm
video_form.php
7181
0644
edit
dl
rm
video_process.php
3336
0644
edit
dl
rm
Edit:
/var/www/vhosts/m-auto.co/httpdocs/admin/car_form.php
(40348B)
<?php include 'includes/header.php'; if (isset($_GET['id'])) { require_permission('cars_edit'); } else { require_permission('cars_add'); } include '../includes/db.php'; // Initialize variables $car = [ 'id' => '', 'name' => '', 'brand' => '', 'model' => '', 'year' => '', 'category' => '', 'description' => '', 'image' => '', 'video_url' => '' ]; $car_images = []; $car_trims = []; $page_title = "إضافة سيارة جديدة"; // Fetch brands and categories for dropdowns $brands_result = $conn->query("SELECT name, logo FROM brands ORDER BY name"); $categories_result = $conn->query("SELECT name FROM categories ORDER BY name"); // Check if this is an edit request if (isset($_GET['id'])) { $car_id = $_GET['id']; $stmt = $conn->prepare("SELECT * FROM cars WHERE id = ?"); $stmt->bind_param("i", $car_id); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows === 1) { $car = $result->fetch_assoc(); $page_title = "تعديل بيانات السيارة"; // Fetch existing images for this car $images_stmt = $conn->prepare("SELECT * FROM car_images WHERE car_id = ? ORDER BY is_primary DESC, sort_order ASC"); $images_stmt->bind_param("i", $car_id); $images_stmt->execute(); $images_result = $images_stmt->get_result(); while ($img = $images_result->fetch_assoc()) { $car_images[] = $img; } $images_stmt->close(); // Fetch existing trims for this car $trims_stmt = $conn->prepare("SELECT * FROM car_trims WHERE car_id = ? ORDER BY price ASC"); $trims_stmt->bind_param("i", $car_id); $trims_stmt->execute(); $trims_result = $trims_stmt->get_result(); while ($trim = $trims_result->fetch_assoc()) { $car_trims[] = $trim; } $trims_stmt->close(); } else { header("Location: cars.php?error=Car not found"); exit(); } $stmt->close(); } // Populate with at least one default trim if empty if (empty($car_trims)) { $car_trims[] = [ 'id' => '', 'name' => 'الفئة القياسية', 'price' => '', 'fuel_type' => '', 'car_condition' => '', 'engine_capacity' => '', 'transmission_type' => '', 'horsepower' => '', 'torque' => '', 'acceleration' => '', 'top_speed' => '', 'fuel_consumption' => '', 'drivetrain' => '', 'seating_capacity' => '', 'body_type' => '', 'exterior_color' => '', 'interior_color' => '', 'tech_specs_pdf' => '' ]; } ?> <h3 class="fs-4 mb-3"><?= $page_title ?></h3> <div class="row"> <div class="col"> <div class="glass-card p-4"> <form action="car_process.php" method="POST" enctype="multipart/form-data"> <input type="hidden" name="id" value="<?= htmlspecialchars($car['id']) ?>"> <div class="row"> <div class="col-md-6 mb-3"> <label for="name" class="form-label">اسم السيارة</label> <input type="text" class="form-control" id="name" name="name" value="<?= htmlspecialchars($car['name']) ?>" required> </div> <div class="col-md-6 mb-3"> <label for="brand" class="form-label">الماركة (Brand)</label> <select class="form-select" id="brand" name="brand" required> <option value="">-- اختر الماركة --</option> <?php while($brand_row = $brands_result->fetch_assoc()): ?> <option value="<?= htmlspecialchars($brand_row['name']) ?>" data-logo="<?= htmlspecialchars($brand_row['logo']) ?>" <?= ($car['brand'] == $brand_row['name']) ? 'selected' : '' ?>> <?= htmlspecialchars($brand_row['name']) ?> </option> <?php endwhile; ?> </select> <div id="brand-logo-preview" class="mt-2" style="display: none;"> <div class="d-flex align-items-center"> <img id="brand-logo-img" src="" alt="Brand Logo" style="width: 50px; height: 50px; object-fit: contain; border-radius: 5px; background: white; padding: 3px; margin-left: 10px;"> <small class="text-muted" id="brand-name-display"></small> </div> </div> </div> </div> <div class="row"> <div class="col-md-6 mb-3"> <label for="model" class="form-label">الموديل</label> <input type="text" class="form-control" id="model" name="model" value="<?= htmlspecialchars($car['model']) ?>"> </div> <div class="col-md-6 mb-3"> <label for="year" class="form-label">سنة الصنع</label> <input type="number" class="form-control" id="year" name="year" value="<?= htmlspecialchars($car['year']) ?>"> </div> </div> <div class="row"> <div class="col-md-6 mb-3"> <label for="category" class="form-label">نوع هيكل السيارة (الفئة)</label> <select class="form-select" id="category" name="category" required> <option value="">-- اختر الفئة --</option> <?php while($category_row = $categories_result->fetch_assoc()): ?> <option value="<?= htmlspecialchars($category_row['name']) ?>" <?= ($car['category'] == $category_row['name']) ? 'selected' : '' ?>><?= htmlspecialchars($category_row['name']) ?></option> <?php endwhile; ?> </select> </div> </div> <div class="mb-3"> <label for="description" class="form-label">الوصف</label> <textarea class="form-control" id="description" name="description" rows="4"><?= htmlspecialchars($car['description']) ?></textarea> </div> <!-- Dynamic Car Trims Section --> <div class="mb-4"> <div class="d-flex justify-content-between align-items-center mb-3"> <h5 class="text-primary mb-0"><i class="fas fa-tags"></i> فئات السيارة ومواصفاتها</h5> <button type="button" class="btn btn-primary btn-sm" id="add-trim-btn"><i class="fas fa-plus"></i> إضافة فئة جديدة</button> </div> <div class="accordion" id="trimsAccordion"> <?php foreach ($car_trims as $index => $trim): ?> <div class="accordion-item bg-dark border-secondary trim-item" data-index="<?= $index ?>"> <input type="hidden" name="trims[<?= $index ?>][id]" value="<?= htmlspecialchars($trim['id']) ?>"> <h2 class="accordion-header" id="headingTrim<?= $index ?>"> <button class="accordion-button bg-dark text-white collapsed border-bottom border-secondary d-flex justify-content-between align-items-center" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTrim<?= $index ?>" aria-expanded="false" aria-controls="collapseTrim<?= $index ?>"> <span class="trim-title-display"><?= !empty($trim['name']) ? htmlspecialchars($trim['name']) : 'فئة جديدة' ?></span> <span class="text-muted ms-auto me-3 trim-price-display"><?= !empty($trim['price']) ? number_format($trim['price']) . ' EGP' : '' ?></span> </button> </h2> <div id="collapseTrim<?= $index ?>" class="accordion-collapse collapse" aria-labelledby="headingTrim<?= $index ?>" data-bs-parent="#trimsAccordion"> <div class="accordion-body text-white"> <div class="row"> <div class="col-md-4 mb-3"> <label class="form-label">اسم الفئة</label> <input type="text" class="form-control trim-name-input" name="trims[<?= $index ?>][name]" value="<?= htmlspecialchars($trim['name']) ?>" required placeholder="مثال: الفئة الأولى Active"> </div> <div class="col-md-4 mb-3"> <label class="form-label">السعر (بالجنيه المصري)</label> <input type="number" step="0.01" class="form-control trim-price-input" name="trims[<?= $index ?>][price]" value="<?= htmlspecialchars($trim['price']) ?>" required placeholder="مثال: 1200000"> </div> <div class="col-md-4 mb-3 d-flex align-items-end justify-content-end"> <button type="button" class="btn btn-danger remove-trim-btn w-100"><i class="fas fa-trash-alt"></i> حذف هذه الفئة</button> </div> </div> <div class="row"> <div class="col-md-6 mb-3"> <label class="form-label">نوع الوقود</label> <select class="form-select" name="trims[<?= $index ?>][fuel_type]" required> <option value="بنزين" <?= ($trim['fuel_type'] == 'بنزين') ? 'selected' : '' ?>>بنزين</option> <option value="ديزل" <?= ($trim['fuel_type'] == 'ديزل') ? 'selected' : '' ?>>ديزل</option> <option value="هجين" <?= ($trim['fuel_type'] == 'هجين') ? 'selected' : '' ?>>هجين (Hybrid)</option> <option value="كهربائي" <?= ($trim['fuel_type'] == 'كهربائي') ? 'selected' : '' ?>>كهربائي</option> <option value="غاز طبيعي" <?= ($trim['fuel_type'] == 'غاز طبيعي') ? 'selected' : '' ?>>غاز طبيعي (CNG)</option> <option value="بنزين + غاز" <?= ($trim['fuel_type'] == 'بنزين + غاز') ? 'selected' : '' ?>>بنزين + غاز</option> </select> </div> <div class="col-md-6 mb-3"> <label class="form-label">حالة السيارة</label> <select class="form-select" name="trims[<?= $index ?>][car_condition]" required> <option value="جديدة" <?= ($trim['car_condition'] == 'جديدة') ? 'selected' : '' ?>>جديدة</option> <option value="مستعملة" <?= ($trim['car_condition'] == 'مستعملة') ? 'selected' : '' ?>>مستعملة</option> </select> </div> </div> <h6 class="text-secondary mt-3 mb-2"><i class="fas fa-cogs"></i> المواصفات الفنية للفئة</h6> <div class="row"> <div class="col-md-4 mb-3"> <label class="form-label">سعة المحرك</label> <input type="text" class="form-control" name="trims[<?= $index ?>][engine_capacity]" value="<?= htmlspecialchars($trim['engine_capacity']) ?>" placeholder="مثال: 1.6 لتر"> </div> <div class="col-md-4 mb-3"> <label class="form-label">ناقل الحركة</label> <select class="form-select" name="trims[<?= $index ?>][transmission_type]"> <option value="">-- اختر --</option> <option value="يدوي" <?= ($trim['transmission_type'] == 'يدوي') ? 'selected' : '' ?>>يدوي</option> <option value="أوتوماتيك" <?= ($trim['transmission_type'] == 'أوتوماتيك') ? 'selected' : '' ?>>أوتوماتيك</option> <option value="CVT" <?= ($trim['transmission_type'] == 'CVT') ? 'selected' : '' ?>>CVT</option> <option value="ديوال كلاتش dual clutch" <?= ($trim['transmission_type'] == 'ديوال كلاتش dual clutch') ? 'selected' : '' ?>>ديوال كلاتش</option> </select> </div> <div class="col-md-4 mb-3"> <label class="form-label">القوة الحصانية</label> <input type="number" class="form-control" name="trims[<?= $index ?>][horsepower]" value="<?= htmlspecialchars($trim['horsepower']) ?>" placeholder="مثال: 120"> </div> </div> <div class="row"> <div class="col-md-4 mb-3"> <label class="form-label">عزم الدوران</label> <input type="text" class="form-control" name="trims[<?= $index ?>][torque]" value="<?= htmlspecialchars($trim['torque']) ?>" placeholder="مثال: 155 نيوتن متر"> </div> <div class="col-md-4 mb-3"> <label class="form-label">التسارع 0-100 كم/س</label> <input type="text" class="form-control" name="trims[<?= $index ?>][acceleration]" value="<?= htmlspecialchars($trim['acceleration']) ?>" placeholder="مثال: 10.2 ثانية"> </div> <div class="col-md-4 mb-3"> <label class="form-label">السرعة القصوى</label> <input type="text" class="form-control" name="trims[<?= $index ?>][top_speed]" value="<?= htmlspecialchars($trim['top_speed']) ?>" placeholder="مثال: 190 كم/س"> </div> </div> <div class="row"> <div class="col-md-6 mb-3"> <label class="form-label">استهلاك الوقود</label> <input type="text" class="form-control" name="trims[<?= $index ?>][fuel_consumption]" value="<?= htmlspecialchars($trim['fuel_consumption']) ?>" placeholder="مثال: 6 لتر/100كم"> </div> <div class="col-md-6 mb-3"> <label class="form-label">نظام الدفع</label> <select class="form-select" name="trims[<?= $index ?>][drivetrain]"> <option value="">-- اختر --</option> <option value="دفع أمامي" <?= ($trim['drivetrain'] == 'دفع أمامي') ? 'selected' : '' ?>>دفع أمامي</option> <option value="دفع خلفي" <?= ($trim['drivetrain'] == 'دفع خلفي') ? 'selected' : '' ?>>دفع خلفي</option> <option value="دفع رباعي" <?= ($trim['drivetrain'] == 'دفع رباعي') ? 'selected' : '' ?>>دفع رباعي</option> </select> </div> </div> <div class="row"> <div class="col-md-6 mb-3"> <label class="form-label">عدد المقاعد</label> <input type="number" class="form-control" name="trims[<?= $index ?>][seating_capacity]" value="<?= htmlspecialchars($trim['seating_capacity']) ?>" placeholder="مثال: 5"> </div> <div class="col-md-6 mb-3"> <label class="form-label">نوع الهيكل</label> <input type="text" class="form-control" name="trims[<?= $index ?>][body_type]" value="<?= htmlspecialchars($trim['body_type']) ?>" placeholder="مثال: سيدان"> </div> </div> <div class="row"> <div class="col-md-6 mb-3"> <label class="form-label">اللون الخارجي</label> <input type="text" class="form-control" name="trims[<?= $index ?>][exterior_color]" value="<?= htmlspecialchars($trim['exterior_color']) ?>" placeholder="مثال: فضي"> </div> <div class="col-md-6 mb-3"> <label class="form-label">اللون الداخلي</label> <input type="text" class="form-control" name="trims[<?= $index ?>][interior_color]" value="<?= htmlspecialchars($trim['interior_color']) ?>" placeholder="مثال: أسود جلد"> </div> </div> <div class="mb-3"> <label class="form-label">ملف المواصفات الفنية (PDF)</label> <input type="file" class="form-control" name="tech_specs_pdf_<?= $index ?>" accept=".pdf"> <?php if (!empty($trim['tech_specs_pdf'])): ?> <div class="mt-2 d-flex align-items-center"> <a href="../uploads/pdfs/<?= htmlspecialchars($trim['tech_specs_pdf']) ?>" target="_blank" class="btn btn-sm btn-outline-primary"><i class="fas fa-file-pdf"></i> عرض ملف الـ PDF الحالي</a> <div class="form-check ms-3"> <input class="form-check-input" type="checkbox" name="trims[<?= $index ?>][remove_pdf]" id="remove_pdf_<?= $index ?>" value="1"> <label class="form-check-label text-danger" for="remove_pdf_<?= $index ?>">حذف ملف الـ PDF</label> </div> <input type="hidden" name="trims[<?= $index ?>][tech_specs_pdf_existing]" value="<?= htmlspecialchars($trim['tech_specs_pdf']) ?>"> </div> <?php endif; ?> </div> </div> </div> </div> <?php endforeach; ?> </div> </div> <!-- Car Images Gallery --> <div class="mb-4"> <label class="form-label">ألبوم صور السيارة</label> <div class="border rounded p-3"> <div class="mb-3"> <label for="car_images" class="form-label">إضافة صور جديدة (يمكن اختيار عدة صور)</label> <input class="form-control" type="file" id="car_images" name="car_images[]" accept="image/*" multiple> <small class="text-muted">يمكنك اختيار عدة صور في نفس الوقت. الصورة الأولى ستكون الصورة الرئيسية.</small> </div> <?php if (!empty($car_images)): ?> <div class="existing-images"> <h6>الصور الحالية:</h6> <div class="row"> <?php foreach ($car_images as $img): ?> <div class="col-md-3 mb-3"> <div class="card"> <img src="../uploads/cars/<?= htmlspecialchars($img['image_name']) ?>" class="card-img-top" style="height: 150px; object-fit: cover;"> <div class="card-body p-2"> <?php if ($img['is_primary']): ?> <span class="badge bg-primary">صورة رئيسية</span> <?php endif; ?> <div class="mt-2"> <button type="button" class="btn btn-sm btn-danger delete-image" data-image-id="<?= $img['id'] ?>"> <i class="fas fa-trash"></i> حذف </button> <?php if (!$img['is_primary']): ?> <button type="button" class="btn btn-sm btn-outline-primary set-primary" data-image-id="<?= $img['id'] ?>"> جعلها رئيسية </button> <?php endif; ?> </div> </div> </div> </div> <?php endforeach; ?> </div> </div> <?php endif; ?> </div> </div> <!-- Car Video --> <div class="mb-3"> <label for="video_url" class="form-label">رابط فيديو السيارة (اختياري)</label> <input type="url" class="form-control" id="video_url" name="video_url" value="<?= htmlspecialchars($car['video_url']) ?>" placeholder="https://www.youtube.com/watch?v=..."> <small class="text-muted">يمكنك إضافة رابط فيديو من YouTube أو أي منصة أخرى</small> <?php if (!empty($car['video_url'])): ?> <div class="mt-2"> <small>الفيديو الحالي:</small> <a href="<?= htmlspecialchars($car['video_url']) ?>" target="_blank" class="btn btn-sm btn-outline-primary ms-2"> <i class="fas fa-play"></i> مشاهدة الفيديو </a> </div> <?php endif; ?> </div> <button type="submit" class="btn btn-success mt-3">حفظ البيانات</button> <a href="cars.php" class="btn btn-secondary mt-3">إلغاء</a> </form> </div> </div> </div> <script> document.addEventListener('DOMContentLoaded', function() { // Brand logo preview functionality const brandSelect = document.getElementById('brand'); const logoPreview = document.getElementById('brand-logo-preview'); const logoImg = document.getElementById('brand-logo-img'); const brandNameDisplay = document.getElementById('brand-name-display'); if (brandSelect.value) { const selectedOption = brandSelect.options[brandSelect.selectedIndex]; const logoPath = selectedOption.getAttribute('data-logo'); if (logoPath) { logoImg.src = '../uploads/brands/' + logoPath; brandNameDisplay.textContent = brandSelect.value; logoPreview.style.display = 'block'; } } brandSelect.addEventListener('change', function() { const selectedOption = this.options[this.selectedIndex]; const logoPath = selectedOption.getAttribute('data-logo'); if (logoPath && this.value) { logoImg.src = '../uploads/brands/' + logoPath; brandNameDisplay.textContent = this.value; logoPreview.style.display = 'block'; } else { logoPreview.style.display = 'none'; } }); // Delete image functionality document.querySelectorAll('.delete-image').forEach(button => { button.addEventListener('click', function() { const imageId = this.getAttribute('data-image-id'); if (confirm('هل أنت متأكد من حذف هذه الصورة؟')) { fetch('car_image_actions.php', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, body: `action=delete&image_id=${imageId}` }) .then(response => response.json()) .then(data => { if (data.success) { location.reload(); } else { alert('حدث خطأ أثناء حذف الصورة'); } }) .catch(error => { console.error('Error:', error); alert('حدث خطأ أثناء حذف الصورة'); }); } }); }); // Set primary image functionality document.querySelectorAll('.set-primary').forEach(button => { button.addEventListener('click', function() { const imageId = this.getAttribute('data-image-id'); fetch('car_image_actions.php', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, body: `action=set_primary&image_id=${imageId}` }) .then(response => response.json()) .then(data => { if (data.success) { location.reload(); } else { alert('حدث خطأ أثناء تعيين الصورة الرئيسية'); } }) .catch(error => { console.error('Error:', error); alert('حدث خطأ أثناء تعيين الصورة الرئيسية'); }); }); }); // Dynamic Trims handling let trimIndexCount = document.querySelectorAll('.trim-item').length; const trimsAccordion = document.getElementById('trimsAccordion'); const addTrimBtn = document.getElementById('add-trim-btn'); // Live update trim headers on name/price typing function registerTrimLiveUpdates(trimEl) { const nameInput = trimEl.querySelector('.trim-name-input'); const priceInput = trimEl.querySelector('.trim-price-input'); const titleDisplay = trimEl.querySelector('.trim-title-display'); const priceDisplay = trimEl.querySelector('.trim-price-display'); nameInput.addEventListener('input', function() { titleDisplay.textContent = this.value || 'فئة جديدة'; }); priceInput.addEventListener('input', function() { if (this.value) { const formattedPrice = Number(this.value).toLocaleString('en-US') + ' EGP'; priceDisplay.textContent = formattedPrice; } else { priceDisplay.textContent = ''; } }); const removeBtn = trimEl.querySelector('.remove-trim-btn'); removeBtn.addEventListener('click', function() { if (document.querySelectorAll('.trim-item').length <= 1) { alert('يجب أن تحتوي السيارة على فئة واحدة على الأقل!'); return; } if (confirm('هل أنت متأكد من حذف هذه الفئة؟')) { trimEl.remove(); } }); } // Register events on initial elements document.querySelectorAll('.trim-item').forEach(registerTrimLiveUpdates); // Add new trim card addTrimBtn.addEventListener('click', function() { const nextIndex = trimIndexCount++; const template = ` <div class="accordion-item bg-dark border-secondary trim-item" data-index="${nextIndex}"> <input type="hidden" name="trims[${nextIndex}][id]" value=""> <h2 class="accordion-header" id="headingTrim${nextIndex}"> <button class="accordion-button bg-dark text-white collapsed border-bottom border-secondary d-flex justify-content-between align-items-center" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTrim${nextIndex}" aria-expanded="true" aria-controls="collapseTrim${nextIndex}"> <span class="trim-title-display">فئة جديدة</span> <span class="text-muted ms-auto me-3 trim-price-display"></span> </button> </h2> <div id="collapseTrim${nextIndex}" class="accordion-collapse collapse show" aria-labelledby="headingTrim${nextIndex}" data-bs-parent="#trimsAccordion"> <div class="accordion-body text-white"> <div class="row"> <div class="col-md-4 mb-3"> <label class="form-label">اسم الفئة</label> <input type="text" class="form-control trim-name-input" name="trims[${nextIndex}][name]" value="" required placeholder="مثال: الفئة الأولى Active"> </div> <div class="col-md-4 mb-3"> <label class="form-label">السعر (بالجنيه المصري)</label> <input type="number" step="0.01" class="form-control trim-price-input" name="trims[${nextIndex}][price]" value="" required placeholder="مثال: 1200000"> </div> <div class="col-md-4 mb-3 d-flex align-items-end justify-content-end"> <button type="button" class="btn btn-danger remove-trim-btn w-100"><i class="fas fa-trash-alt"></i> حذف هذه الفئة</button> </div> </div> <div class="row"> <div class="col-md-6 mb-3"> <label class="form-label">نوع الوقود</label> <select class="form-select" name="trims[${nextIndex}][fuel_type]" required> <option value="بنزين" selected>بنزين</option> <option value="ديزل">ديزل</option> <option value="هجين">هجين (Hybrid)</option> <option value="كهربائي">كهربائي</option> <option value="غاز طبيعي">غاز طبيعي (CNG)</option> <option value="بنزين + غاز">بنزين + غاز</option> </select> </div> <div class="col-md-6 mb-3"> <label class="form-label">حالة السيارة</label> <select class="form-select" name="trims[${nextIndex}][car_condition]" required> <option value="جديدة" selected>جديدة</option> <option value="مستعملة">مستعملة</option> </select> </div> </div> <h6 class="text-secondary mt-3 mb-2"><i class="fas fa-cogs"></i> المواصفات الفنية للفئة</h6> <div class="row"> <div class="col-md-4 mb-3"> <label class="form-label">سعة المحرك</label> <input type="text" class="form-control" name="trims[${nextIndex}][engine_capacity]" value="" placeholder="مثال: 1.6 لتر"> </div> <div class="col-md-4 mb-3"> <label class="form-label">ناقل الحركة</label> <select class="form-select" name="trims[${nextIndex}][transmission_type]"> <option value="" selected>-- اختر --</option> <option value="يدوي">يدوي</option> <option value="أوتوماتيك">أوتوماتيك</option> <option value="CVT">CVT</option> <option value="ديوال كلاتش dual clutch">ديوال كلاتش</option> </select> </div> <div class="col-md-4 mb-3"> <label class="form-label">القوة الحصانية</label> <input type="number" class="form-control" name="trims[${nextIndex}][horsepower]" value="" placeholder="مثال: 120"> </div> </div> <div class="row"> <div class="col-md-4 mb-3"> <label class="form-label">عزم الدوران</label> <input type="text" class="form-control" name="trims[${nextIndex}][torque]" value="" placeholder="مثال: 155 نيوتن متر"> </div> <div class="col-md-4 mb-3"> <label class="form-label">التسارع 0-100 كم/س</label> <input type="text" class="form-control" name="trims[${nextIndex}][acceleration]" value="" placeholder="مثال: 10.2 ثانية"> </div> <div class="col-md-4 mb-3"> <label class="form-label">السرعة القصوى</label> <input type="text" class="form-control" name="trims[${nextIndex}][top_speed]" value="" placeholder="مثال: 190 كم/س"> </div> </div> <div class="row"> <div class="col-md-6 mb-3"> <label class="form-label">استهلاك الوقود</label> <input type="text" class="form-control" name="trims[${nextIndex}][fuel_consumption]" value="" placeholder="مثال: 6 لتر/100كم"> </div> <div class="col-md-6 mb-3"> <label class="form-label">نظام الدفع</label> <select class="form-select" name="trims[${nextIndex}][drivetrain]"> <option value="" selected>-- اختر --</option> <option value="دفع أمامي">دفع أمامي</option> <option value="دفع خلفي">دفع خلفي</option> <option value="دفع رباعي">دفع رباعي</option> </select> </div> </div> <div class="row"> <div class="col-md-6 mb-3"> <label class="form-label">عدد المقاعد</label> <input type="number" class="form-control" name="trims[${nextIndex}][seating_capacity]" value="" placeholder="مثال: 5"> </div> <div class="col-md-6 mb-3"> <label class="form-label">نوع الهيكل</label> <input type="text" class="form-control" name="trims[${nextIndex}][body_type]" value="" placeholder="مثال: سيدان"> </div> </div> <div class="row"> <div class="col-md-6 mb-3"> <label class="form-label">اللون الخارجي</label> <input type="text" class="form-control" name="trims[${nextIndex}][exterior_color]" value="" placeholder="مثال: فضي"> </div> <div class="col-md-6 mb-3"> <label class="form-label">اللون الداخلي</label> <input type="text" class="form-control" name="trims[${nextIndex}][interior_color]" value="" placeholder="مثال: أسود جلد"> </div> </div> <div class="mb-3"> <label class="form-label">ملف المواصفات الفنية (PDF)</label> <input type="file" class="form-control" name="tech_specs_pdf_${nextIndex}" accept=".pdf"> </div> </div> </div> </div> `; // Collapse all other accordion items document.querySelectorAll('#trimsAccordion .accordion-collapse').forEach(collapse => { collapse.classList.remove('show'); collapse.classList.add('collapse'); }); document.querySelectorAll('#trimsAccordion .accordion-button').forEach(btn => { btn.classList.add('collapsed'); btn.setAttribute('aria-expanded', 'false'); }); // Insert new item const tempDiv = document.createElement('div'); tempDiv.innerHTML = template.trim(); const newTrimEl = tempDiv.firstChild; trimsAccordion.appendChild(newTrimEl); // Register events registerTrimLiveUpdates(newTrimEl); }); }); </script> <?php include 'includes/footer.php'; ?>
Save
cmd:
run