




costume 40OMR
0.00 omr
<?php
include_once "settings.php"; // Ensure this file sets up $connessione (database connection)
//include 'ar.php';
if(isset($_GET["accessCat"])) $_SESSION["ad"]=$_GET["accessCat"]; //for the cntrol to dsply ads && (HIDE) not to display the cars brands logos
$bId = htmlspecialchars($_GET['bId'] ?? $_GET['bId']);
// Check if the 'accessCat' GET parameter is set
$accessCat = isset($_GET['accessCat']) ? $_GET['accessCat'] : '';
// Define available categories and their fields
$categories = $_SESSION['translations']['category'];
// Process form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$category = $connessione->real_escape_string($_POST['accessCat'] ?? $_GET['accessCat']);
$title = $connessione->real_escape_string($_POST['title'] ?? '');
$berid = $connessione->real_escape_string($_POST['berid'] ?? '');
$hetef = $connessione->real_escape_string($_POST['hetef'] ?? '');
$country = $connessione->real_escape_string($_POST['country'] ?? '');
$location_city = $connessione->real_escape_string($_POST['location_city'] ?? '');
$price = $connessione->real_escape_string($_POST['price'] ?? '');
$el3omla = $connessione->real_escape_string($_POST['el3omla'] ?? '');
$description = $connessione->htmlspecialchars(real_escape_string($_POST['description'] ?? ''));
$quantity = $connessione->real_escape_string($_POST['quantity'] ?? '');
$yearModel = $connessione->real_escape_string($_POST['yearModel'] ?? $_GET['year']);
$views = intval($_POST['views'] ?? 0);
//$attributes = $connessione->real_escape_string($_POST['attributes'] ?? '');
// Collect prod attributes data with default values
$attributes__ = [
'brand' => $_GET['brand'] ?? '',
'year' => $yearModel ?? '',
'regional_specifications' => $_POST['property3'] ?? '',
'odometer' => $_POST['property4'] ?? '',
'cylinders' => $_POST['property5'] ?? '',
'transmission' => $_POST['property6'] ?? '',
'keys' => $_POST['property7'] ?? '',
'full_options' => $_POST['property8'] ?? '',
'fuel' => $_POST['property9'] ?? '',
'wheel_drive' => $_POST['property10'] ?? '',
'exterior_color' => $_POST['property11'] ?? '',
'interior_color' => $_POST['property12'] ?? '',
'maintenance_report' => $_POST['property13'] ?? '',
'car_status' => $_POST['property17'] ?? ''
];
// Initialize an array to hold form data
$formData = [];
$formHtml = isset($_POST['form_html']) ? $_POST['form_html'] : '';
// Collect and sanitize form data, excluding specific keys
foreach ($_POST as $key => $value) {
// Exclude specific fields from being added to formData
if ($key !== 'form_html' && !in_array($key, ['berid', 'hetef', 'country', 'location_city', 'price', 'el3omla', 'description', 'quantity', 'yearModel', 'delivery_available', 'negotiable_price', 'status', 'collector'])) {
$formData[$key] = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
}
}
// Build the JSON object for the attributes field
$attributes = [
'form_html' => $formHtml,
'data' => $formData
];
// Convert the attributes array to a JSON string
$attributesJson = json_encode($attributes);
// Sanitize the JSON string for safe insertion
$attributes = $connessione->real_escape_string($attributesJson);
//$attributes = $connessione->real_escape_string(json_encode($attributes));
$delivery_available = isset($_POST['delivery_available']) ? 1 : 0;
$negotiable_price = isset($_POST['negotiable_price']) ? 1 : 0;
$status = $connessione->real_escape_string($_POST['status'] ?? '');
$collector = $connessione->real_escape_string($_POST['collector'] ?? '');
// Handle file uploads
$images = [];
if (isset($_FILES['images']) && !empty($_FILES['images']['name'][0])) {
$uploadDir = 'uploads/';
if (!is_dir($uploadDir)) {
mkdir($uploadDir, 0755, true);
}
foreach ($_FILES['images']['tmp_name'] as $key => $tmp_name) {
$fileName = basename($_FILES['images']['name'][$key]);
$uploadFile = $uploadDir . $fileName;
if (move_uploaded_file($tmp_name, $uploadFile)) {
$images[] = $uploadFile;
}
}
}
$imagesList = implode(',', $images);
try {
$sql = mysqli_query($connessione, "INSERT INTO `bathae3i` (
`idBathae3i`,
`images`,
`category`,
`title`,
`berid`,
`hetef`,
`country`,
`location_city`,
`price`,
`el3omla`,
`description`,
`quantity`,
`chronoBathae3`,
`views`,
`attributes`,
`delivery_available`,
`negotiable_price`,
`status`,
`collector`
) VALUES (
NULL, '$imagesList', '$category', '$title', '$berid', '$hetef', '$country',
'$location_city', '$price', '$el3omla', '$description', '$quantity',
'".time()."', $views, '$attributes', $delivery_available, $negotiable_price,
'$status', '$collector'
)");
if (!$sql) {
die('Error: ' . htmlspecialchars($connessione->error));
}
} catch(Exception $e) {
echo "Exception: " . $e->getMessage();
}
}
// Retrieve records from the database
$sql = "SELECT * FROM `bathae3i` WHERE idBathae3i = '" . $bId . "'";
$result = $connessione->query($sql);
?>
<!DOCTYPE html>
<html <?php if(!isset($_SESSION['lang']) || $_SESSION['lang']=="ar") echo"lang=ar dir=rtl"; else echo"lang=en dir=ltr"; ?>>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bathae3i Management</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css__">
<style>
body {
<?php if(!isset($_SESSION['lang']) || $_SESSION['lang']=="ar") echo"lang=ar dir=rtl"; else echo"lang=en dir=ltr"; ?>
background-color: #f8f9fa;
font-family: Arial, sans-serif;
}
.container {
max-width: 1200px;
margin: 20px auto;
padding: 20px;
background-color: #ffffff;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
border-radius: 8px;
}
.form-control {
display: block;
width: 100%;
height: calc(1.5em + .75rem + 2px);
padding: .375rem .75rem;
margin-top: 3px;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #495057;
background-color: #fff;
background-clip: padding-box;
border: 1px solid #ced4da;
border-radius: .25rem;
transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}
.btn {
display: inline-block;
font-weight: 400;
color: #212529;
text-align: center;
vertical-align: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-color: transparent;
border: 1px solid transparent;
padding: .375rem .75rem;
font-size: 1rem;
line-height: 1.5;
border-radius: .25rem;
transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}
.btn-primary {
color: #fff;
background-color: #007bff;
border-color: #007bff;
}
h1 {
margin-bottom: 20px;
}
form {
margin-bottom: 30px;
}
.form-group {
margin-bottom: 15px;
}
.form-control, .form-check-input {
border-radius: 4px;
}
.custom-file-input {
display: none;
}
.custom-file-upload {
border: 2px solid #007bff;
border-radius: 8px;
display: inline-block;
padding: 12px 24px;
cursor: pointer;
background: linear-gradient(135deg, #007bff 0%, #00d2ff 100%);
color: #ffffff;
text-align: center;
font-weight: bold;
font-size: 16px;
transition: all 0.3s ease;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
position: relative;
}
.custom-file-upload:hover {
background: linear-gradient(135deg, #00d2ff 0%, #007bff 100%);
color: #f0f0f0;
transform: scale(1.05);
}
.custom-file-upload:before {
content: '???? ';
position: absolute;
<?php if(!isset($_SESSION['lang']) || $_SESSION['lang']=="ar") echo"right: 0px;"; else echo"left: 0px;"; ?>
top: 40%;
transform: translateY(-50%);
font-size: 18px;
}
.custom-file-input {
display: none;
}
.image-preview {
display: flex;
flex-wrap: wrap;
margin-top: 10px;
}
.image-preview img {
max-width: 100px;
margin-right: 5px;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
.image-preview {
display: flex;
flex-wrap: wrap;
margin-top: 10px;
border: 2px dashed #007bff;
border-radius: 8px;
padding: 10px;
background-color: #f8f9fa;
min-height: 120px;
position: relative;
overflow: auto;
}
.image-preview .placeholder {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: #007bff;
font-size: 18px;
font-weight: bold;
text-align: center;
pointer-events: none;
}
.image-preview img {
max-width: 100px;
margin: 5px;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
table {
width: 100%;
border-collapse: collapse;
}
table th, table td {
border: 1px solid #dee2e6;
padding: 12px;
text-align: left;
}
table th {
background-color: #007bff;
color: #ffffff;
}
table td {
background-color: #ffffff;
}
.attributes-list {
white-space: pre-wrap; /* Preserve whitespace for line breaks */
}
.details-list {
list-style-type: none;
padding: 0;
margin: 0;
}
.details-list li:nth-child(even) {
background-color: #f9f9f9;
}
.details-list li {
padding: 10px;
border-bottom: 1px solid #eee;
}
.details-container {
background-color: #fff;
border: 1px solid #ddd;
padding: 20px;
margin-bottom: 20px;
font-family: Arial, sans-serif;
width: 100%;
margin: 0 auto;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
._vkey{
<?php if(!isset($_SESSION['lang']) || $_SESSION['lang']=="ar") echo"margin-left: 40px;"; else echo"margin-right: 40px;"; ?>
}
</style>
</head>
<body>
<div class="container">
<h1>Insert New Record</h1>
<form method="post" action="?accessCat=<?php echo $_GET['accessCat']; ?>&brand=<?php echo $_GET['brand']; ?>&year=<?php echo $_GET['year']; ?>" enctype="multipart/form-data">
<!--div class="form-group">
<label for="category">Category:</label>
<input type="text" id="category" name="accessCat" class="form-control" required>
</div -->
<div class="form-group">
<label for="images" class="custom-file-upload">
<span><?php echo $_SESSION["imageUpload"]; ?></span>
</label>
<input type="file" id="images" name="images[]" class="custom-file-input" accept="image/*" multiple>
<div class="image-preview" id="image-preview">
<div class="placeholder"><?php echo $_SESSION["imagesselected"]; ?></div>
</div>
</div>
<div class="form-group">
<label for="title">Title:</label>
<input type="text" id="title" name="title" class="form-control" required>
</div>
<?php if($_GET["accessCat"]=="cars")include_once"_carsSpecificities.php"; ?>
<?php //include_once"_vpcategoriesForms.php";
// Function to generate form fields
function generateFormFields($fields) {
$formHtml = '';
foreach ($fields as $field => $label) {
if (is_array($label)) { // Check if the field has subvalues
$formHtml .= '<label for="' . htmlspecialchars($field) . '">' . htmlspecialchars($label['type']) . ':</label>';
$formHtml .= '<select id="' . htmlspecialchars($field) . '" name="' . htmlspecialchars($field) . '" class="form-control">';
foreach ($label as $subValue => $subLabel) {
if ($subValue !== 'type') { // Skip the 'type' key
$formHtml .= '<option value="' . htmlspecialchars($subValue) . '">' . htmlspecialchars($subLabel) . '</option>';
}
}
$formHtml .= '</select><br><br>';
} else {
$formHtml .= '<label for="' . htmlspecialchars($field) . '">' . htmlspecialchars($label) . ':</label>';
$formHtml .= '<input type="text" id="' . htmlspecialchars($field) . '" class="form-control" name="' . htmlspecialchars($field) . '" placeholder="' . htmlspecialchars($label) . '"><br><br>';
}
}
return $formHtml;
}
?>
<?php if ($accessCat): ?>
<?php
// Split the selected category into category and subcategory
list($category, $subcategory) = explode('/', $accessCat);
// Check if the selected category and subcategory exist
if (isset($categories[$category][$subcategory])) {
$fields = $categories[$category][$subcategory];
?>
<h2><?= htmlspecialchars($subcategory) ?></h2>
<div method="post" class="_carContainer image-preview">
<?= generateFormFields($fields) ?>
<!-- input type="submit" value="إرسال" -->
</div>
<?php
} else {
echo '<p class="error-message">الفئة أو التصنيف المحدد غير موجود.</p>';
}
?>
<?php endif; ?>
<div class="form-group">
<label for="berid">Berid:</label>
<input type="text" id="berid" name="berid" class="form-control" required>
</div>
<div class="form-group">
<label for="hetef">Hetef:</label>
<input type="text" id="hetef" name="hetef" class="form-control" required>
</div>
<div class="form-group">
<label for="country">Country:</label>
<input type="text" id="country" name="country" class="form-control" required>
</div>
<div class="form-group">
<label for="location_city">City:</label>
<input type="text" id="location_city" name="location_city" class="form-control" required>
</div>
<div class="form-group">
<label for="price">Price:</label>
<input type="text" id="price" name="price" class="form-control" required>
</div>
<div class="form-group">
<label for="el3omla">Currency:</label>
<input type="text" id="el3omla" name="el3omla" class="form-control" required>
</div>
<div class="form-group">
<label for="description">Description:</label>
<textarea id="description" name="description" class="form-control" rows="4" required></textarea>
</div>
<div class="form-group">
<label for="quantity">Quantity:</label>
<input type="text" id="quantity" name="quantity" class="form-control" required>
</div>
<div class="form-group">
<label for="yearModel">Year:</label>
<input type="text" id="yearModel" name="yearModel" class="form-control" required>
</div>
<!-- div class="form-group">
<label for="views">Views:</label>
<input type="text" id="views" name="views" class="form-control" required>
</div -->
<!-- div class="form-group">
<label for="attributes">Attributes (JSON):</label>
<textarea id="attributes" name="attributes" class="form-control" rows="4" required></textarea>
</div -->
<div class="form-group form-check">
<input type="checkbox" id="delivery_available" name="delivery_available" class="form-check-input" value="1">
<label for="delivery_available" class="form-check-label"><?php echo $_SESSION['property19']; ?>Delivery Available</label>
</div>
<div class="form-group form-check">
<input type="checkbox" id="negotiable_price" name="negotiable_price" class="form-check-input" value="1">
<label for="negotiable_price" class="form-check-label"><?php echo $_SESSION['property16']; ?>Negotiable Price</label>
</div>
<div class="form-group">
<label for="status">Status:</label>
<input type="text" id="status" name="status" class="form-control" required>
</div>
<div class="form-group">
<label for="collector">Collector:</label>
<input type="text" id="collector" name="collector" class="form-control" required>
</div>
<input type="hidden" name="form_html" value="<?php echo htmlspecialchars($formHtml); ?>">
<button type="submit" class="btn btn-primary"><?php echo $_SESSION['goNUploadNsell']; ?></button>
</form>
<h2>Existing Records</h2>
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>Images</th>
<th>Category</th>
<th>Attributes / Delivery Available / Negotiable Price</th>
<th>Status</th>
<th>Collector</th>
</tr>
</thead>
<tbody>
<?php while ($row = $result->fetch_assoc()): ?>
<tr>
<td><?php echo htmlspecialchars($row['idBathae3i']); ?></td>
<td style="max-width:300px;">
<?php
$images = explode(',', $row['images']);
foreach ($images as $image): ?>
<img src="<?php echo htmlspecialchars($image); ?>" alt="Image" style="max-width: 100px; margin-right: 5px;">
<?php endforeach; ?>
</td>
<td><?php echo htmlspecialchars($row['category']); ?></td>
<td><?php /*echo htmlspecialchars($row['attributes']);*/ ?>
<?php
// Start session if not already started
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
// Decode the JSON-encoded attributes field
$attributes = json_decode($row['attributes'], true);
?>
<div>
<?php
$formHtml = $attributes['form_html'];
$formData = $attributes['data'];
?>
<div class="details-container">
<div class="data-display details-list">
<?php foreach ($formData as $key => $value): ?>
<?php
// Find the translation for the current key
$translation = '';
//foreach ($_SESSION['translations']['category']['vehicles']['cars'] as $category) {
foreach ($_SESSION['translations'] as $category) {
if (isset($category[$key])) {
$translation = $category[$key];
break;
}else if (isset($category['vehicles'][$key])) {
$translation = $category[$key];
break;
}
}
?>
<li><strong><font color=brown class=_vkey><?php echo htmlspecialchars($translation ?: $key, ENT_QUOTES, 'UTF-8'); ?>:</font></strong> <?php echo htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); ?></li>
<?php endforeach; ?>
</div>
</div>
</div>
<br /><?php echo $_SESSION['property19']; ?>: <?php echo $row['delivery_available'] ? $_SESSION['yes'] : $_SESSION['no'] ; ?><br /><?php echo $_SESSION['property16']; ?>: <?php echo $row['negotiable_price'] ? $_SESSION['yes'] : $_SESSION['no']; ?></td>
<td><?php echo htmlspecialchars($row['status']); ?></td>
<td><?php echo htmlspecialchars($row['collector']); ?></td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</div>
<script>
document.querySelector('#images').addEventListener('change', function() {
const preview = document.querySelector('#image-preview');
preview.innerHTML = '';
for (const file of this.files) {
const reader = new FileReader();
reader.onload = function(e) {
const img = document.createElement('img');
img.src = e.target.result;
img.alt = 'Image Preview';
preview.appendChild(img);
};
reader.readAsDataURL(file);
}
});
</script>
</body>
</html>
include_once "settings.php"; // Ensure this file sets up $connessione (database connection)
//include 'ar.php';
if(isset($_GET["accessCat"])) $_SESSION["ad"]=$_GET["accessCat"]; //for the cntrol to dsply ads && (HIDE) not to display the cars brands logos
$bId = htmlspecialchars($_GET['bId'] ?? $_GET['bId']);
// Check if the 'accessCat' GET parameter is set
$accessCat = isset($_GET['accessCat']) ? $_GET['accessCat'] : '';
// Define available categories and their fields
$categories = $_SESSION['translations']['category'];
// Process form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$category = $connessione->real_escape_string($_POST['accessCat'] ?? $_GET['accessCat']);
$title = $connessione->real_escape_string($_POST['title'] ?? '');
$berid = $connessione->real_escape_string($_POST['berid'] ?? '');
$hetef = $connessione->real_escape_string($_POST['hetef'] ?? '');
$country = $connessione->real_escape_string($_POST['country'] ?? '');
$location_city = $connessione->real_escape_string($_POST['location_city'] ?? '');
$price = $connessione->real_escape_string($_POST['price'] ?? '');
$el3omla = $connessione->real_escape_string($_POST['el3omla'] ?? '');
$description = $connessione->htmlspecialchars(real_escape_string($_POST['description'] ?? ''));
$quantity = $connessione->real_escape_string($_POST['quantity'] ?? '');
$yearModel = $connessione->real_escape_string($_POST['yearModel'] ?? $_GET['year']);
$views = intval($_POST['views'] ?? 0);
//$attributes = $connessione->real_escape_string($_POST['attributes'] ?? '');
// Collect prod attributes data with default values
$attributes__ = [
'brand' => $_GET['brand'] ?? '',
'year' => $yearModel ?? '',
'regional_specifications' => $_POST['property3'] ?? '',
'odometer' => $_POST['property4'] ?? '',
'cylinders' => $_POST['property5'] ?? '',
'transmission' => $_POST['property6'] ?? '',
'keys' => $_POST['property7'] ?? '',
'full_options' => $_POST['property8'] ?? '',
'fuel' => $_POST['property9'] ?? '',
'wheel_drive' => $_POST['property10'] ?? '',
'exterior_color' => $_POST['property11'] ?? '',
'interior_color' => $_POST['property12'] ?? '',
'maintenance_report' => $_POST['property13'] ?? '',
'car_status' => $_POST['property17'] ?? ''
];
// Initialize an array to hold form data
$formData = [];
$formHtml = isset($_POST['form_html']) ? $_POST['form_html'] : '';
// Collect and sanitize form data, excluding specific keys
foreach ($_POST as $key => $value) {
// Exclude specific fields from being added to formData
if ($key !== 'form_html' && !in_array($key, ['berid', 'hetef', 'country', 'location_city', 'price', 'el3omla', 'description', 'quantity', 'yearModel', 'delivery_available', 'negotiable_price', 'status', 'collector'])) {
$formData[$key] = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
}
}
// Build the JSON object for the attributes field
$attributes = [
'form_html' => $formHtml,
'data' => $formData
];
// Convert the attributes array to a JSON string
$attributesJson = json_encode($attributes);
// Sanitize the JSON string for safe insertion
$attributes = $connessione->real_escape_string($attributesJson);
//$attributes = $connessione->real_escape_string(json_encode($attributes));
$delivery_available = isset($_POST['delivery_available']) ? 1 : 0;
$negotiable_price = isset($_POST['negotiable_price']) ? 1 : 0;
$status = $connessione->real_escape_string($_POST['status'] ?? '');
$collector = $connessione->real_escape_string($_POST['collector'] ?? '');
// Handle file uploads
$images = [];
if (isset($_FILES['images']) && !empty($_FILES['images']['name'][0])) {
$uploadDir = 'uploads/';
if (!is_dir($uploadDir)) {
mkdir($uploadDir, 0755, true);
}
foreach ($_FILES['images']['tmp_name'] as $key => $tmp_name) {
$fileName = basename($_FILES['images']['name'][$key]);
$uploadFile = $uploadDir . $fileName;
if (move_uploaded_file($tmp_name, $uploadFile)) {
$images[] = $uploadFile;
}
}
}
$imagesList = implode(',', $images);
try {
$sql = mysqli_query($connessione, "INSERT INTO `bathae3i` (
`idBathae3i`,
`images`,
`category`,
`title`,
`berid`,
`hetef`,
`country`,
`location_city`,
`price`,
`el3omla`,
`description`,
`quantity`,
`chronoBathae3`,
`views`,
`attributes`,
`delivery_available`,
`negotiable_price`,
`status`,
`collector`
) VALUES (
NULL, '$imagesList', '$category', '$title', '$berid', '$hetef', '$country',
'$location_city', '$price', '$el3omla', '$description', '$quantity',
'".time()."', $views, '$attributes', $delivery_available, $negotiable_price,
'$status', '$collector'
)");
if (!$sql) {
die('Error: ' . htmlspecialchars($connessione->error));
}
} catch(Exception $e) {
echo "Exception: " . $e->getMessage();
}
}
// Retrieve records from the database
$sql = "SELECT * FROM `bathae3i` WHERE idBathae3i = '" . $bId . "'";
$result = $connessione->query($sql);
?>
<!DOCTYPE html>
<html <?php if(!isset($_SESSION['lang']) || $_SESSION['lang']=="ar") echo"lang=ar dir=rtl"; else echo"lang=en dir=ltr"; ?>>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bathae3i Management</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css__">
<style>
body {
<?php if(!isset($_SESSION['lang']) || $_SESSION['lang']=="ar") echo"lang=ar dir=rtl"; else echo"lang=en dir=ltr"; ?>
background-color: #f8f9fa;
font-family: Arial, sans-serif;
}
.container {
max-width: 1200px;
margin: 20px auto;
padding: 20px;
background-color: #ffffff;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
border-radius: 8px;
}
.form-control {
display: block;
width: 100%;
height: calc(1.5em + .75rem + 2px);
padding: .375rem .75rem;
margin-top: 3px;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #495057;
background-color: #fff;
background-clip: padding-box;
border: 1px solid #ced4da;
border-radius: .25rem;
transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}
.btn {
display: inline-block;
font-weight: 400;
color: #212529;
text-align: center;
vertical-align: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-color: transparent;
border: 1px solid transparent;
padding: .375rem .75rem;
font-size: 1rem;
line-height: 1.5;
border-radius: .25rem;
transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}
.btn-primary {
color: #fff;
background-color: #007bff;
border-color: #007bff;
}
h1 {
margin-bottom: 20px;
}
form {
margin-bottom: 30px;
}
.form-group {
margin-bottom: 15px;
}
.form-control, .form-check-input {
border-radius: 4px;
}
.custom-file-input {
display: none;
}
.custom-file-upload {
border: 2px solid #007bff;
border-radius: 8px;
display: inline-block;
padding: 12px 24px;
cursor: pointer;
background: linear-gradient(135deg, #007bff 0%, #00d2ff 100%);
color: #ffffff;
text-align: center;
font-weight: bold;
font-size: 16px;
transition: all 0.3s ease;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
position: relative;
}
.custom-file-upload:hover {
background: linear-gradient(135deg, #00d2ff 0%, #007bff 100%);
color: #f0f0f0;
transform: scale(1.05);
}
.custom-file-upload:before {
content: '???? ';
position: absolute;
<?php if(!isset($_SESSION['lang']) || $_SESSION['lang']=="ar") echo"right: 0px;"; else echo"left: 0px;"; ?>
top: 40%;
transform: translateY(-50%);
font-size: 18px;
}
.custom-file-input {
display: none;
}
.image-preview {
display: flex;
flex-wrap: wrap;
margin-top: 10px;
}
.image-preview img {
max-width: 100px;
margin-right: 5px;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
.image-preview {
display: flex;
flex-wrap: wrap;
margin-top: 10px;
border: 2px dashed #007bff;
border-radius: 8px;
padding: 10px;
background-color: #f8f9fa;
min-height: 120px;
position: relative;
overflow: auto;
}
.image-preview .placeholder {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: #007bff;
font-size: 18px;
font-weight: bold;
text-align: center;
pointer-events: none;
}
.image-preview img {
max-width: 100px;
margin: 5px;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
table {
width: 100%;
border-collapse: collapse;
}
table th, table td {
border: 1px solid #dee2e6;
padding: 12px;
text-align: left;
}
table th {
background-color: #007bff;
color: #ffffff;
}
table td {
background-color: #ffffff;
}
.attributes-list {
white-space: pre-wrap; /* Preserve whitespace for line breaks */
}
.details-list {
list-style-type: none;
padding: 0;
margin: 0;
}
.details-list li:nth-child(even) {
background-color: #f9f9f9;
}
.details-list li {
padding: 10px;
border-bottom: 1px solid #eee;
}
.details-container {
background-color: #fff;
border: 1px solid #ddd;
padding: 20px;
margin-bottom: 20px;
font-family: Arial, sans-serif;
width: 100%;
margin: 0 auto;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
._vkey{
<?php if(!isset($_SESSION['lang']) || $_SESSION['lang']=="ar") echo"margin-left: 40px;"; else echo"margin-right: 40px;"; ?>
}
</style>
</head>
<body>
<div class="container">
<h1>Insert New Record</h1>
<form method="post" action="?accessCat=<?php echo $_GET['accessCat']; ?>&brand=<?php echo $_GET['brand']; ?>&year=<?php echo $_GET['year']; ?>" enctype="multipart/form-data">
<!--div class="form-group">
<label for="category">Category:</label>
<input type="text" id="category" name="accessCat" class="form-control" required>
</div -->
<div class="form-group">
<label for="images" class="custom-file-upload">
<span><?php echo $_SESSION["imageUpload"]; ?></span>
</label>
<input type="file" id="images" name="images[]" class="custom-file-input" accept="image/*" multiple>
<div class="image-preview" id="image-preview">
<div class="placeholder"><?php echo $_SESSION["imagesselected"]; ?></div>
</div>
</div>
<div class="form-group">
<label for="title">Title:</label>
<input type="text" id="title" name="title" class="form-control" required>
</div>
<?php if($_GET["accessCat"]=="cars")include_once"_carsSpecificities.php"; ?>
<?php //include_once"_vpcategoriesForms.php";
// Function to generate form fields
function generateFormFields($fields) {
$formHtml = '';
foreach ($fields as $field => $label) {
if (is_array($label)) { // Check if the field has subvalues
$formHtml .= '<label for="' . htmlspecialchars($field) . '">' . htmlspecialchars($label['type']) . ':</label>';
$formHtml .= '<select id="' . htmlspecialchars($field) . '" name="' . htmlspecialchars($field) . '" class="form-control">';
foreach ($label as $subValue => $subLabel) {
if ($subValue !== 'type') { // Skip the 'type' key
$formHtml .= '<option value="' . htmlspecialchars($subValue) . '">' . htmlspecialchars($subLabel) . '</option>';
}
}
$formHtml .= '</select><br><br>';
} else {
$formHtml .= '<label for="' . htmlspecialchars($field) . '">' . htmlspecialchars($label) . ':</label>';
$formHtml .= '<input type="text" id="' . htmlspecialchars($field) . '" class="form-control" name="' . htmlspecialchars($field) . '" placeholder="' . htmlspecialchars($label) . '"><br><br>';
}
}
return $formHtml;
}
?>
<?php if ($accessCat): ?>
<?php
// Split the selected category into category and subcategory
list($category, $subcategory) = explode('/', $accessCat);
// Check if the selected category and subcategory exist
if (isset($categories[$category][$subcategory])) {
$fields = $categories[$category][$subcategory];
?>
<h2><?= htmlspecialchars($subcategory) ?></h2>
<div method="post" class="_carContainer image-preview">
<?= generateFormFields($fields) ?>
<!-- input type="submit" value="إرسال" -->
</div>
<?php
} else {
echo '<p class="error-message">الفئة أو التصنيف المحدد غير موجود.</p>';
}
?>
<?php endif; ?>
<div class="form-group">
<label for="berid">Berid:</label>
<input type="text" id="berid" name="berid" class="form-control" required>
</div>
<div class="form-group">
<label for="hetef">Hetef:</label>
<input type="text" id="hetef" name="hetef" class="form-control" required>
</div>
<div class="form-group">
<label for="country">Country:</label>
<input type="text" id="country" name="country" class="form-control" required>
</div>
<div class="form-group">
<label for="location_city">City:</label>
<input type="text" id="location_city" name="location_city" class="form-control" required>
</div>
<div class="form-group">
<label for="price">Price:</label>
<input type="text" id="price" name="price" class="form-control" required>
</div>
<div class="form-group">
<label for="el3omla">Currency:</label>
<input type="text" id="el3omla" name="el3omla" class="form-control" required>
</div>
<div class="form-group">
<label for="description">Description:</label>
<textarea id="description" name="description" class="form-control" rows="4" required></textarea>
</div>
<div class="form-group">
<label for="quantity">Quantity:</label>
<input type="text" id="quantity" name="quantity" class="form-control" required>
</div>
<div class="form-group">
<label for="yearModel">Year:</label>
<input type="text" id="yearModel" name="yearModel" class="form-control" required>
</div>
<!-- div class="form-group">
<label for="views">Views:</label>
<input type="text" id="views" name="views" class="form-control" required>
</div -->
<!-- div class="form-group">
<label for="attributes">Attributes (JSON):</label>
<textarea id="attributes" name="attributes" class="form-control" rows="4" required></textarea>
</div -->
<div class="form-group form-check">
<input type="checkbox" id="delivery_available" name="delivery_available" class="form-check-input" value="1">
<label for="delivery_available" class="form-check-label"><?php echo $_SESSION['property19']; ?>Delivery Available</label>
</div>
<div class="form-group form-check">
<input type="checkbox" id="negotiable_price" name="negotiable_price" class="form-check-input" value="1">
<label for="negotiable_price" class="form-check-label"><?php echo $_SESSION['property16']; ?>Negotiable Price</label>
</div>
<div class="form-group">
<label for="status">Status:</label>
<input type="text" id="status" name="status" class="form-control" required>
</div>
<div class="form-group">
<label for="collector">Collector:</label>
<input type="text" id="collector" name="collector" class="form-control" required>
</div>
<input type="hidden" name="form_html" value="<?php echo htmlspecialchars($formHtml); ?>">
<button type="submit" class="btn btn-primary"><?php echo $_SESSION['goNUploadNsell']; ?></button>
</form>
<h2>Existing Records</h2>
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>Images</th>
<th>Category</th>
<th>Attributes / Delivery Available / Negotiable Price</th>
<th>Status</th>
<th>Collector</th>
</tr>
</thead>
<tbody>
<?php while ($row = $result->fetch_assoc()): ?>
<tr>
<td><?php echo htmlspecialchars($row['idBathae3i']); ?></td>
<td style="max-width:300px;">
<?php
$images = explode(',', $row['images']);
foreach ($images as $image): ?>
<img src="<?php echo htmlspecialchars($image); ?>" alt="Image" style="max-width: 100px; margin-right: 5px;">
<?php endforeach; ?>
</td>
<td><?php echo htmlspecialchars($row['category']); ?></td>
<td><?php /*echo htmlspecialchars($row['attributes']);*/ ?>
<?php
// Start session if not already started
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
// Decode the JSON-encoded attributes field
$attributes = json_decode($row['attributes'], true);
?>
<div>
<?php
$formHtml = $attributes['form_html'];
$formData = $attributes['data'];
?>
<div class="details-container">
<div class="data-display details-list">
<?php foreach ($formData as $key => $value): ?>
<?php
// Find the translation for the current key
$translation = '';
//foreach ($_SESSION['translations']['category']['vehicles']['cars'] as $category) {
foreach ($_SESSION['translations'] as $category) {
if (isset($category[$key])) {
$translation = $category[$key];
break;
}else if (isset($category['vehicles'][$key])) {
$translation = $category[$key];
break;
}
}
?>
<li><strong><font color=brown class=_vkey><?php echo htmlspecialchars($translation ?: $key, ENT_QUOTES, 'UTF-8'); ?>:</font></strong> <?php echo htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); ?></li>
<?php endforeach; ?>
</div>
</div>
</div>
<br /><?php echo $_SESSION['property19']; ?>: <?php echo $row['delivery_available'] ? $_SESSION['yes'] : $_SESSION['no'] ; ?><br /><?php echo $_SESSION['property16']; ?>: <?php echo $row['negotiable_price'] ? $_SESSION['yes'] : $_SESSION['no']; ?></td>
<td><?php echo htmlspecialchars($row['status']); ?></td>
<td><?php echo htmlspecialchars($row['collector']); ?></td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</div>
<script>
document.querySelector('#images').addEventListener('change', function() {
const preview = document.querySelector('#image-preview');
preview.innerHTML = '';
for (const file of this.files) {
const reader = new FileReader();
reader.onload = function(e) {
const img = document.createElement('img');
img.src = e.target.result;
img.alt = 'Image Preview';
preview.appendChild(img);
};
reader.readAsDataURL(file);
}
});
</script>
</body>
</html>
Form_html:
Warning: Array to string conversion in /home/u423793718/domains/dadabay.com/public_html/item.php on line 288
Data: Array