%PDF- %GIF98; %PNG;
Server : ApacheSystem : Linux sh00666.bluehost.com 5.14.0-687.26.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jul 14 16:32:02 EDT 2026 x86_64 User : ndkhermy ( 1200) PHP Version : 8.5.12 Disable Function : NONE Directory : /home1/ndkhermy/www/website_6031bb72/admin/manage_product/ |
Upload File : |
<?php
error_reporting(0);
include("../function.php");
if ($_SESSION['admin_id'] == "") {
header('location:../login.php');
}
$login_tbl = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM admin WHERE admin_id='" . $_SESSION['admin_id'] . "'"));
if ($login_tbl['roles'] == 3) {
$agent_id = $_SESSION['admin_id'];
$coin_purchase = mysqli_query($conn, "SELECT * FROM `coin_purchase_tbl` WHERE `status`='1' AND expiry_status='0' AND `limit_properties`>'0' AND agent_id='$agent_id'");
if (mysqli_num_rows($coin_purchase) > 0) {
$mysqli_fetch_coin = mysqli_fetch_array($coin_purchase);
} else {
echo "<script>window.location='show.php?page=pro';</script>";
}
}
// Sidebar strat
include('../include/sidebar.php');
// Sidebar wrap
/*error_reporting(E_ALL);
ini_set('display_errors',1)*/
?>
<?php
if (isset($_POST['add']) && $_POST['add'] == 'Add') {
// $agent_id = $mysqli_fetch_coin['agent_id'];
// $coin_id = $mysqli_fetch_coin['coin_id'];
$cat_id = $_POST['cat_id'];
$sub_cat_id = $_POST['sub_cat_id'];
// $deal_ids = isset($_POST['Deal_Types_atb']) ? implode(",", $_POST['Deal_Types_atb']) : "";
// $property_types_ids = isset($_POST['Property_Types_atb']) ? implode(",", $_POST['Property_Types_atb']) : "";
$title = str_replace("'", "\'", $_POST['title']);
$title_ar = str_replace("'", "\'", $_POST['title_ar']);
$price = str_replace("'", "\'", $_POST['price']);
$model_code = str_replace("'", "\'", $_POST['model_code']);
$model_year = str_replace("'", "\'", $_POST['model_year']);
$old_price = str_replace("'", "\'", $_POST['old_price']);
$vat_status = str_replace("'", "\'", $_POST['vat_status']);
$shipping_status = str_replace("'", "\'", $_POST['shipping_status']);
$shipping_include = str_replace("'", "\'", $_POST['shipping_include']);
$shipping_price = str_replace("'", "\'", $_POST['shipping_price']);
$part_no = str_replace("'", "\'", $_POST['part_no']);
$part_grade = str_replace("'", "\'", $_POST['part_grade']);
$part_grade_ar = str_replace("'", "\'", $_POST['part_grade_ar']);
$quantity = str_replace("'", "\'", $_POST['quantity']);
$short_description = str_replace("'", "\'", $_POST['short_description']);
$short_description_ar = str_replace("'", "\'", $_POST['short_description_ar']);
// $heading1_ar = str_replace("'", "\'", $_POST['heading1_ar']);
$description1 = str_replace("'", "\'", $_POST['description1']);
$description1_ar = str_replace("'", "\'", $_POST['description1_ar']);
// $heading2 = str_replace("'", "\'", $_POST['heading2']);
// $heading2_ar = str_replace("'", "\'", $_POST['heading2_ar']);
// $description2 = str_replace("'", "\'", $_POST['description2']);
// $description2_ar = str_replace("'", "\'", $_POST['description2_ar']);
// $heading3 = str_replace("'", "\'", $_POST['heading3']);
// $heading3_ar = str_replace("'", "\'", $_POST['heading3_ar']);
// $description3 = str_replace("'", "\'", $_POST['description3']);
// $description3_ar = str_replace("'", "\'", $_POST['description3_ar']);
// $heading4 = str_replace("'", "\'", $_POST['heading4']);
// $heading4_ar = str_replace("'", "\'", $_POST['heading4_ar']);
// $description4 = str_replace("'", "\'", $_POST['description4']);
// $description4_ar = str_replace("'", "\'", $_POST['description4_ar']);
$opportunities_status = $_POST['opportunities_status'];
$status = $_POST['status'];
$slug = create_url($title);
$file_name = $_FILES['image1']['name'];
$file_tmp = $_FILES['image1']['tmp_name'];
$file_ext = strtolower(end(explode('.', $_FILES['image1']['name'])));
$CheckQ = mysqli_query($conn, "INSERT INTO `product_tbl` SET
-- `agent_id`='$agent_id',
-- `coin_id`='$coin_id',
`cat_id`='$cat_id',
`sub_cat_id`='$sub_cat_id',
-- `deal_id`='$deal_ids',
`quantity`='$quantity',
`title`='$title',
`title_ar`='$title_ar',
`price`='$price',
`model_code`='$model_code',
`model_year`='$model_year',
`old_price`='$old_price',
`vat_status`='$vat_status',
`shipping_status`='$shipping_status',
`shipping_include`='$shipping_include',
`shipping_price`='$shipping_price',
`part_no`='$part_no',
`part_grade`='$part_grade',
`part_grade_ar`='$part_grade_ar',
`short_description`='$short_description',
`short_description_ar`='$short_description_ar',
-- `heading1`='$heading1',
-- `heading1_ar`='$heading1_ar',
`description1`='$description1',
`description1_ar`='$description1_ar',
-- `heading2`='$heading2',
-- `heading2_ar`='$heading2_ar',
-- `description2`='$description2',
-- `description2_ar`='$description2_ar',
-- `heading3`='$heading3',
-- `heading3_ar`='$heading3_ar',
-- `description3`='$description3',
-- `description3_ar`='$description3_ar',
-- `heading4`='$heading4',
-- `heading4_ar`='$heading4_ar',
-- `description4`='$description4',
-- `description4_ar`='$description4_ar',
`opportunities_status`='$opportunities_status',
`status`='$status',
`slug`= '$slug'");
if ($CheckQ) {
$ido = mysqli_insert_id($conn);
$d = sprintf("%04d", $ido);
$product_id = "Product" . $d;
mysqli_query($conn, "UPDATE `product_tbl` SET `product_id`='$product_id' WHERE id='$ido'");
// $limit_properties_minus = $mysqli_fetch_coin['limit_properties'] - 1;
// mysqli_query($conn, "UPDATE `coin_purchase_tbl` SET `limit_properties`='$limit_properties_minus' WHERE coin_id='$coin_id' AND `agent_id`='$agent_id'");
if (!empty($file_name)) {
$random_number = rand();
$new_file_name = $random_number . '.' . $file_ext;
$file_path = "../../images/Upload/product/" . $new_file_name;
move_uploaded_file($file_tmp, $file_path);
$addQry = mysqli_query($conn, "UPDATE `product_tbl` SET `image1`='$new_file_name' WHERE id='$ido'") or die(mysqli_error($conn));
}
if (isset($_FILES['image_atb']['name'])) {
foreach ($_FILES['image_atb']['name'] as $key => $val) {
$image = rand(111111111, 999999999) . '_' . $_FILES['image_atb']['name'][$key];
$file_path = "../../images/Upload/product/" . $image;
move_uploaded_file($_FILES['image_atb']['tmp_name'][$key], $file_path);
mysqli_query($conn, "INSERT INTO `product_img_tbl` SET
`product_id`='$ido',
`image_atb`='$image'");
}
}
echo "<script>window.location='show.php?page=pro';</script>";
$_SESSION['message'] = "Product Added Successfully";
}
}
?>
<!-- <style type="text/css">
.multiselect {
/* width: 256px;*/
margin-top: 5px;
margin-left: 9px;
margin-bottom: 18px;
}
.selectBox {
position: relative;
}
.selectBox select {
width: 100%;
padding: 10px;
/*font-weight: bold;*/
}
.overSelect {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
#Deal_Types_checkboxes {
display: none;
border: 1px #dadada solid;
max-height: 150px;
overflow-y: auto;
}
#Deal_Types_checkboxes label {
display: block;
}
#Deal_Types_checkboxes label:hover {
background-color: #f2a60e78;
}
#Deal_Types_search {
width: 100%;
box-sizing: border-box;
padding: 8px;
margin-bottom: 10px;
border: 1px solid #ccc;
}
#Property_Types_checkboxes {
display: none;
border: 1px #dadada solid;
max-height: 150px;
overflow-y: auto;
}
#Property_Types_checkboxes label {
display: block;
}
#Property_Types_checkboxes label:hover {
background-color: #f2a60e78;
}
#Property_Types_search {
width: 100%;
box-sizing: border-box;
padding: 8px;
margin-bottom: 10px;
border: 1px solid #ccc;
}
</style> -->
<!-- [ Main Content ] start -->
<section class="pcoded-main-container">
<div class="pcoded-content">
<!-- [ breadcrumb ] start -->
<div class="page-header">
<div class="page-block">
<div class="row align-items-center">
<div class="col-md-12">
<div class="page-header-title">
<div class="card-header d-flex justify-content-between">
<button class="btn btn-dark text-light fw-bold btn-sm btn-round has-ripple"><i class="feather icon-edit"></i> Add Product List</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- [ breadcrumb ] end -->
<!-- [ Main Content ] start -->
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-body">
<?php if (isset($_SESSION['error'])) {
echo '<div class="alert alert-danger alert-dismissible fade show" role="alert">
<i class="feather icon-alert-triangle text-danger"></i> <strong class="text-dark">' . $_SESSION['error'] . '</strong>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
</button>
</div>';
}
unset($_SESSION['error']);
?>
<form method="POST" enctype="multipart/form-data" autocomplete="off">
<div class="container">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="cat_id">Product Brands</label>
<select class="form-select" name="cat_id" required id="cat_id">
<option value="">Please select Brand</option>
<?php
$catQry = mysqli_query($conn, "SELECT * FROM category_tbl WHERE status=1 ORDER BY id ASC");
while ($row = mysqli_fetch_array($catQry)) {
?>
<option value="<?= $row['id'] ?>"><?= $row['title'] ?></option>
<?php }; ?>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="sub_cat_id">Product Models</label>
<select class="form-select" name="sub_cat_id" required id="sub_cat_id">
<option value="">Please select Model</option>
<?php
$sub_catQry = mysqli_query($conn, "SELECT * FROM sub_category_tbl WHERE status=1 AND cat_id='" . $fetchData['cat_id'] . "' ORDER BY id ASC");
while ($row_sub_cat = mysqli_fetch_array($sub_catQry)) {
?>
<option value="<?= $row_sub_cat['id'] ?>"><?= $row_sub_cat['title'] ?></option>
<?php }; ?>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="title">Product Name</label>
<input type="text" name="title" class="form-control" required>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="title">Product Name Arabic</label>
<input type="text" name="title_ar" class="form-control" required>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="Model Code">Model Code</label>
<input type="text" name="model_code" class="form-control" required>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="Model Year">Model Year</label>
<input type="text" name="model_year" class="form-control" required>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="form-label" for="Part Number">Part Number</label>
<input type="text" name="part_no" class="form-control">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="form-label" for="Part Grade">Part Grade</label>
<input type="text" name="part_grade" class="form-control">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="form-label" for="Part Grade Arabic">Part Grade Arabic</label>
<input type="text" name="part_grade_ar" class="form-control">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="form-label" for="old_price">Old Price</label>
<input type="text" name="old_price" oninput="FillNumber(this)" class="form-control">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="form-label" for="price">Price</label>
<input type="text" name="price" oninput="FillNumber(this)" class="form-control" required>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="form-label" for="quantity">Quantity</label>
<input type="text" name="quantity" oninput="FillNumber(this)" class="form-control" required>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="short_description">Description</label>
<textarea id="editor1" name="short_description"></textarea>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="short_description">Description Arabic</label>
<textarea id="editor2" name="short_description_ar"></textarea>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="Description">Description</label>
<textarea id="editor3" name="description1"></textarea>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="Description Arabic">Description Arabic</label>
<textarea id="editor4" name="description1_ar"></textarea>
</div>
</div>
<div class="form-group">
<div class="row" id="input-container">
<div class="col-lg-10">
<label class="form-label" for="Image">Image</label>
<input type="file" name="image1" class="form-control" required>
</div>
<div class="col-lg-2">
<label for="categories" class=" form-control-label mb-2 text-dark fw-bold">Add More</label>
<a id="myButton" class="bg-success form-control text-center text-white fw-bold">Add</a>
</div>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="form-label" for="Shipping Status">Shipping Company</label>
<select class="form-select" name="shipping_status" id="shipping_status" required>
<option value="0">Select Shipping Company</option>
<?php
$catQry_shipping = mysqli_query($conn, "SELECT * FROM shipping_tbl WHERE status=1 ORDER BY id ASC");
while ($row_shipping = mysqli_fetch_array($catQry_shipping)) {
?>
<option value="<?=$row_shipping['id']?>"><?=$row_shipping['title']?></option>
<?php } ?>
</select>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="form-label" for="shipping_price">Price</label>
<input type="text" name="shipping_price" oninput="FillNumber(this)" class="form-control" required>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="form-label" for="Vat Status">Vat Status</label>
<select class="form-select" name="vat_status" id="vat_status" required>
<option value="0">Hide</option>
<option value="1">Show</option>
</select>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="form-label" for="Shipping Status">Shipping Status</label>
<select class="form-select" name="shipping_include" id="shipping_include" required>
<option value="0">Free</option>
<option value="1">Include</option>
</select>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="form-label" for="Front Status">Front Status</label>
<select class="form-select" name="opportunities_status" id="opportunities_status" required>
<option value="0">Hide</option>
<option value="1">Show</option>
</select>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="form-label" for="status">Status</label>
<select class="form-select" name="status" id="status" required>
<option value="1">Show</option>
<option value="0">Hide</option>
</select>
</div>
</div>
<div class="col-md-12 mt-2">
<div class="form-group">
<input type="submit" name="add" class="btn btn-success" value="Add">
<a class="text-white btn btn-dark " href="show.php?page=pro">Back</a>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<!-- [ form-element ] end -->
</div>
<!-- [ Main Content ] end -->
</div>
</section>
<!-- Required Js -->
<?php include('../include/footer.php'); ?>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#cat_id').on('change', function() {
var area_id = this.value;
$.ajax({
url: "city-ajax.php",
type: "POST",
data: {
area_id: area_id
},
cache: false,
success: function(result) {
$("#sub_cat_id").html(result);
}
});
});
});
</script>
<!-- ///////// Image ///////////// -->
<script>
$(document).ready(function() {
$("#myButton").click(function() {
$.ajax({
url: "generate_input.php",
success: function(html) {
$("#input-container").append(html);
}
});
});
});
$(document).on("click", ".remove-input", function() {
$(this).closest(".input-element").remove();
});
</script>
<script>
$(document).ready(function() {
$(".delete-btn").click(function() {
var id = $(this).data("id");
var deleteButton = $(this);
$.ajax({
url: "delete.php",
type: "POST",
data: {
id: id
},
success: function(response) {
deleteButton.closest('.data-item').remove();
}
});
});
});
</script>
<!-- //////////// Deal Types /////////// -->
<!-- <script>
function updateDeal_TypesSelectBox() {
var checkboxes = document.querySelectorAll('input[name="Deal_Types_atb[]"]:checked');
var selectBox = document.getElementById("Deal_Types_select");
if (checkboxes.length > 0) {
selectBox.options[0].text = checkboxes.length + " selected";
} else {
selectBox.options[0].text = "Select Deal_Types";
}
}
// Initial call to update the select box text based on the pre-checked checkboxes
document.addEventListener("DOMContentLoaded", function() {
updateDeal_TypesSelectBox();
});
var Deal_Types_expanded = false;
function showDeal_TypesCheckboxes() {
var checkboxes = document.getElementById("Deal_Types_checkboxes");
var checkboxItems = checkboxes.getElementsByTagName("input");
if (!Deal_Types_expanded) {
if (checkboxItems.length > 0) {
checkboxes.style.display = "block";
Deal_Types_expanded = true;
}
} else {
checkboxes.style.display = "none";
Deal_Types_expanded = false;
}
}
function filterDeal_Types() {
var input = document.getElementById("Deal_Types_search");
var filter = input.value.toLowerCase();
var checkboxes = document.getElementById("Deal_Types_checkboxes");
var labels = checkboxes.getElementsByTagName("label");
for (var i = 0; i < labels.length; i++) {
var label = labels[i];
var text = label.textContent || label.innerText;
if (text.toLowerCase().indexOf(filter) > -1) {
label.style.display = "";
} else {
label.style.display = "none";
}
}
}
</script> -->
<!-- //////////// Property Types /////////// -->
<!-- <script>
function updateProperty_TypesSelectBox() {
var checkboxes = document.querySelectorAll('input[name="Property_Types_atb[]"]:checked');
var selectBox = document.getElementById("Property_Types_select");
if (checkboxes.length > 0) {
selectBox.options[0].text = checkboxes.length + " selected";
} else {
selectBox.options[0].text = "Select Property Types";
}
}
// Initial call to update the select box text based on the pre-checked checkboxes
document.addEventListener("DOMContentLoaded", function() {
updateProperty_TypesSelectBox();
});
var Property_Types_expanded = false;
function showProperty_TypesCheckboxes() {
var checkboxes = document.getElementById("Property_Types_checkboxes");
var checkboxItems = checkboxes.getElementsByTagName("input");
if (!Property_Types_expanded) {
if (checkboxItems.length > 0) {
checkboxes.style.display = "block";
Property_Types_expanded = true;
}
} else {
checkboxes.style.display = "none";
Property_Types_expanded = false;
}
}
function filterProperty_Types() {
var input = document.getElementById("Property_Types_search");
var filter = input.value.toLowerCase();
var checkboxes = document.getElementById("Property_Types_checkboxes");
var labels = checkboxes.getElementsByTagName("label");
for (var i = 0; i < labels.length; i++) {
var label = labels[i];
var text = label.textContent || label.innerText;
if (text.toLowerCase().indexOf(filter) > -1) {
label.style.display = "";
} else {
label.style.display = "none";
}
}
}
</script> -->