CMXX - Dealers

This commit is contained in:
“VeLiTi”
2025-04-13 17:16:12 +02:00
parent cb18443af9
commit c3e5873912
25 changed files with 2630 additions and 100 deletions

BIN
.DS_Store vendored

Binary file not shown.

28
api.php
View File

@@ -21,15 +21,37 @@ include './settings/config_redirector.php';
//------------------------------------------
if (header_security){
// Array of allowed domain patterns (without the protocol part)
$allowedDomainPatterns = [
'vanbeers.tv',
'soveliti.nl',
'veliti.nl',
'gewoonlekkerspaans.nl'
];
// Get the origin from the request headers
$origin = $_SERVER['HTTP_ORIGIN'] ?? '';
// Set CORS headers if origin is allowed
if (isOriginAllowed($origin, $allowedDomainPatterns)) {
header("Access-Control-Allow-Origin: $origin");
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
header("Access-Control-Allow-Headers: Authorization, Content-Type");
//header("Access-Control-Allow-Credentials: true"); // Include if needed
}
// Handle preflight requests
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
// Return early with 204 No Content for preflight requests
http_response_code(204);
exit;
}
// Strict security headers
header('Content-Type: application/json');
header('X-Content-Type-Options: nosniff');
header('X-Frame-Options: DENY');
header('X-XSS-Protection: 1; mode=block');
header('Content-Security-Policy: default-src \'none\'');
header('Access-Control-Allow-Origin: ' . $_ENV['ALLOWED_ORIGIN']);
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type, Accept, Authorization');
header('Strict-Transport-Security: max-age=31536000; includeSubDomains');
header('Referrer-Policy: strict-origin-when-cross-origin');

View File

@@ -12,7 +12,7 @@ $pdo = dbConnect($dbname);
if (empty($partner->soldto) || $partner->soldto == ''){$soldto_search = '%';} else {$soldto_search = '-%';}
//default whereclause
list($whereclause,$condition) = getWhereclauselvl2("",$permission,$partner,'get');
list($whereclause,$condition) = getWhereclauselvl2("dealers",$permission,$partner,'get');
//NEW ARRAY
$criterias = [];
@@ -33,7 +33,10 @@ if(isset($get_content) && $get_content!=''){
}
elseif ($v[0] == 'search') {
//build up search
$clause .= ' AND name like :'.$v[0];
$clause .= ' AND d.name like :'.$v[0];
}
elseif ($v[0] == 'id') {//create clause
$clause .= ' AND d.rowID = :'.$v[0];
}
else {//create clause
$clause .= ' AND d.'.$v[0].' = :'.$v[0];
@@ -51,9 +54,12 @@ if(isset($criterias['totals']) && $criterias['totals'] ==''){
//Request for total rows
$sql = 'SELECT count(*) as count FROM dealers '.$whereclause.'';
}
elseif (isset($criterias['list']) && $criterias['list'] ==''){
$sql = 'SELECT d.* FROM dealers d '.$whereclause;
}
else {
//SQL for Paging
$sql = 'SELECT * FROM dealers '.$whereclause.' LIMIT :page,:num_products';
$sql = 'SELECT d.*, m.full_path FROM dealers d LEFT JOIN media m ON d.dealer_media = m.rowID '.$whereclause.' LIMIT :page,:num_products';
}
$stmt = $pdo->prepare($sql);
@@ -70,6 +76,11 @@ if (!empty($criterias)){
$search_value = '%'.$value.'%';
$stmt->bindValue($key, $search_value, PDO::PARAM_STR);
}
elseif($key == 'rowid' || $key == 'id' ){
//decode UUID to ID
$decoded_value = decodeUuid($value);
$stmt->bindValue($key, $decoded_value, PDO::PARAM_STR);
}
else {
$stmt->bindValue($key, $value, PDO::PARAM_STR);
}
@@ -83,6 +94,12 @@ if(isset($criterias['totals']) && $criterias['totals']==''){
$messages = $stmt->fetch();
$messages = $messages[0];
}
elseif (isset($criterias['list']) && $criterias['list']==''){
//Excute Query
$stmt->execute();
//Get results
$messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
else {
$current_page = isset($criterias['p']) && is_numeric($criterias['p']) ? (int)$criterias['p'] : 1;
$stmt->bindValue('page', ($current_page - 1) * $page_rows_dealers, PDO::PARAM_INT);

View File

@@ -0,0 +1,125 @@
<?php
defined($security_key) or exit;
//------------------------------------------
// dealers
//------------------------------------------
//Connect to DB
$pdo = dbConnect($dbname);
//SoldTo is empty
if (empty($partner->soldto) || $partner->soldto == ''){$soldto_search = '%';} else {$soldto_search = '-%';}
//default whereclause
$whereclause = '';
//NEW ARRAY
$criterias = [];
$clause = '';
//Check for $_GET variables and build up clause
if(isset($get_content) && $get_content!=''){
//GET VARIABLES FROM URL
$requests = explode("&", $get_content);
//Check for keys and values
foreach ($requests as $y){
$v = explode("=", $y);
//INCLUDE VARIABLES IN ARRAY
$criterias[$v[0]] = $v[1];
if ($v[0] == 'page' || $v[0] =='p' || $v[0] =='totals' || $v[0] =='list' || $v[0] =='history'|| $v[0] =='success_msg'){
//do nothing
}
else {//create clause
$clause .= ' AND '.$v[0].' = :'.$v[0];
}
}
if ($whereclause == '' && $clause !=''){
$whereclause = 'WHERE '.substr($clause, 4);
} else {
$whereclause .= $clause;
}
}
//ENSURE PRODUCTROWID IS SEND
if (isset($criterias['dealer_id']) && $criterias['dealer_id'] != ''){
//CHECK IF ALLOWED TO CRUD VERSIONS
$sql = "SELECT * FROM dealers WHERE rowID = ? '.$whereclause.'";
$stmt = $pdo->prepare($sql);
$stmt->execute([decodeUuid($criterias['dealer_id'])]);
$dealer_data = $stmt->fetch();
$dealer_owner = ($dealer_data['rowID'])? 1 : 0;
//IF PRODUCT IS OWNED THEN CRUD is ALLOWED
if ($dealer_owner === 1 ){
//Define Query
if(isset($criterias['totals']) && $criterias['totals'] ==''){
//Request for total rows
$sql = 'SELECT count(*) as count FROM dealers_media '.$whereclause.'';
}
elseif (isset($criterias['list']) && $criterias['list'] =='') {
//SQL for Paging
$sql = 'SELECT * FROM dealers_media '.$whereclause.'';
}
else {
//SQL for Paging
$sql = 'SELECT p_m.*, m.full_path FROM dealers_media p_m LEFT JOIN media m ON p_m.media_id = m.rowID '.$whereclause.'';
}
$stmt = $pdo->prepare($sql);
//Bind to query
if (str_contains($whereclause, ':condition')){
$stmt->bindValue('condition', $condition, PDO::PARAM_STR);
}
if (!empty($criterias)){
foreach ($criterias as $key => $value){
$key_condition = ':'.$key;
if (str_contains($whereclause, $key_condition)){
if ($key == 'search'){
$search_value = '%'.$value.'%';
$stmt->bindValue($key, $search_value, PDO::PARAM_STR);
}
else {
$stmt->bindValue($key, $value, PDO::PARAM_STR);
}
}
}
}
//Add paging details
if(isset($criterias['totals']) && $criterias['totals']==''){
$stmt->execute();
$messages = $stmt->fetch();
$messages = $messages[0];
}
elseif(isset($criterias['list']) && $criterias['list']==''){
//Excute Query
$stmt->execute();
//Get results
$messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
else {
//$current_page = isset($criterias['p']) && is_numeric($criterias['p']) ? (int)$criterias['p'] : 1;
//$stmt->bindValue('page', ($current_page - 1) * $page_rows_dealers, PDO::PARAM_INT);
//$stmt->bindValue('num_dealers', $page_rows_dealers, PDO::PARAM_INT);
//Excute Query
$stmt->execute();
//Get results
$messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
//------------------------------------------
//JSON_ENCODE
//------------------------------------------
$messages = json_encode($messages, JSON_UNESCAPED_UNICODE);
//Send results
echo $messages;
}
}
?>

View File

@@ -10,6 +10,288 @@ $pdo = dbConnect($dbname);
//CONTENT FROM API (POST)
$post_content = json_decode($input,true);
//CHECK IF REQUEST IS FROM DEALERFINDER
if(isset($post_content['bounds'])){
//++++++++++++++++++++++
//Process DEALERFINDER PROCES
//++++++++++++++++++++++
//------------------------------------------
//NEW ARRAY
//------------------------------------------
$whereclause = '';
$criterias = [];
$clause = '';
//------------------------------------------
//GET THE POST CONTENT
//------------------------------------------
if(isset($post_content) && $post_content !=''){
//------------------------------------------
//RUN THROUGH POST CONTENT
//------------------------------------------
foreach($post_content as $criteria => $value){
//HANDLE MAP BOUNDS
if ($criteria == 'bounds'){
//GET THE INPUT
$northEastLat = (float)$value['_northEast']['lat'];
$northEastLng = (float)$value['_northEast']['lng'];
$southWestLat = (float)$value['_southWest']['lat'];
$southWestLng = (float)$value['_southWest']['lng'];
// Handle the case where the map crosses the 180/-180 longitude line
if ($southWestLng > $northEastLng) {
$clause .= " AND (d.lng >= :lng_sw OR d.lng <= :lng_ne)";
$criterias['lng_sw'] = $southWestLng;
$criterias['lng_ne'] = $northEastLng;
} else {
$clause .= " AND d.lng >= :lng_sw AND d.lng <= :lng_ne";
$criterias['lng_sw'] = $southWestLng;
$criterias['lng_ne'] = $northEastLng;
}
// Latitude is simpler as it doesn't wrap around
$clause .= " AND d.lat >= :lat_sw AND d.lat <= :lat_ne";
$criterias['lat_sw'] = $southWestLat;
$criterias['lat_ne'] = $northEastLat;
}
}
//UPDATE THE WHERECLAUSE DEPENDING ON ORIGINAL WHERECLAUSE
if ($whereclause == '' && $clause !=''){
$whereclause = 'WHERE '.substr($clause, 4);
} else {
$whereclause .= $clause;
}
}
//------------------------------------------
// SQL
//------------------------------------------
$sql = 'SELECT d.*, m.full_path FROM dealers d LEFT JOIN media m ON d.dealer_media = m.rowID '.$whereclause;
//PREPARE QUERY
$stmt = $pdo->prepare($sql);
//------------------------------------------
// BIND CRITERIAS TO SQL
//------------------------------------------
if (!empty($criterias)){
foreach ($criterias as $key => $value){
$key_condition = ':'.$key;
if (str_contains($whereclause, $key_condition)){
if ($key == 'search'){
$search_value = '%'.$value.'%';
$stmt->bindValue($key, $search_value, PDO::PARAM_STR);
}
elseif ($key == 'p'){
//Do nothing (bug)
}
else {
$stmt->bindValue($key, $value, PDO::PARAM_STR);
}
}
}
}
//------------------------------------------
// EXECUTE QUERY
//------------------------------------------
$stmt->execute();
//Get results
$messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
//------------------------------------------
//CHANGE ROWID INTO UUID
//------------------------------------------
function updateRowID($row) {
$row['rowID'] = encodeUuid($row['rowID']);
return $row;
}
$updatedData = array_map('updateRowID', $messages);
//------------------------------------------
//JSON_ENCODE
//------------------------------------------
$messages = [
"results" => $updatedData,
"total" => count($updatedData)
];
$messages = json_encode($messages, JSON_UNESCAPED_UNICODE);
//------------------------------------------
//Send results
//------------------------------------------
echo $messages;
}
elseif(isset($post_content['dealerfinder'])){
//++++++++++++++++++++++
//DEALER FINDER
//++++++++++++++++++++++
//remove dealerfinder from post_content
unset($post_content['dealerfinder']);
//GET GEOLOCATION
if ($post_content['range'] && $post_content['lat']!='0' && $post_content['lng']!='0'){
//INPUT GEOLOCATION USER
$lat = $post_content['lat'];
$lng = $post_content['lng'];
//BUILD GEO-QUERY
$geo_search_1 = 'ROUND((6371 * acos(cos(radians('.$lat.')) * cos(radians(d.lat)) * cos(radians(d.lng) - radians('.$lng.')) + sin(radians('.$lat.')) * sin(radians(d.lat)))), (2)) AS distance';
$geo_search_2 = 'HAVING distance < '.$post_content['range'];
//Build SQL FOR GEO SEARCH
$sql = 'select d.*, m.full_path, '.$geo_search_1.' FROM dealers d LEFT JOIN media m ON d.dealer_media = m.rowID '.$geo_search_2.' ORDER BY d.rating_overall ';
}
else {
//Use standard
$sql = 'select d.*, m.full_path FROM dealers d LEFT JOIN media m ON d.dealer_media = m.rowID ORDER BY d.rating_overall ';
}
//CHECK ALL THE POSTED ITEMS
foreach ($post_content as $key => $value){
//GET FILTER CRITERIA
if ($key !='submit' && $key !='city' && $key !='range' && $key !='lat' && $key !='lng' && $value !='C'){
//TRANSLATE RESPONSE TO DATABASE VALUES
switch ($key) {
case $field_question_1: //rating overall
//check value returned and include SQL
switch ($value) {
case '1':
$sql .= 'case when d.'.$key.' = 8 then 1 else 0 end +';
break;
case '0':
$sql .= 'case when (d.'.$key.' > 6.5 && d.d.'.$key.' < 8 ) then 1 else 0 end +';
break;
}
//------------------------------------
break;
case $field_question_2: //locations
//check value returned and include SQL
switch ($value) {
case '1':
$sql .= 'case when d.'.$key.' = 1 then 1 else 0 end +';
break;
case '0':
$sql .= 'case when d.'.$key.' = 0 then 1 else 0 end +';
break;
}
//------------------------------------
break;
case $field_question_3: //brand_type
//check value returned and include SQL
switch ($value) {
case '1':
$sql .= 'case when d.'.$key.' = 1 then 1 else 0 end +';
break;
case '0':
$sql .= 'case when d.'.$key.' = 0 then 1 else 0 end +';
break;
}
//------------------------------------
break;
case $field_question_4: //showroom size
//check value returned and include SQL
switch ($value) {
case '1':
$sql .= 'case when d.'.$key.' = 1 then 1 else 0 end +';
break;
case '0':
$sql .= 'case when d.'.$key.' = 0 then 1 else 0 end +';
break;
case 'C':
$sql .= 'case when d.'.$key.' = 2 then 1 else 0 end +';
break;
}
//------------------------------------
break;
case $field_question_5: //garden_center
//check value returned and include SQL
switch ($value) {
case '1':
$sql .= 'case when d.'.$key.' = 1 then 1 else 0 end +';
break;
case '0':
$sql .= 'case when d.'.$key.' = 0 then 1 else 0 end +';
break;
}
//------------------------------------
break;
case $field_question_6: // focus offering
//check value returned and include SQL
switch ($value) {
case '1':
$sql .= 'case when d.'.$key.' = 1 then 1 else 0 end +';
break;
case '0':
$sql .= 'case when d.'.$key.' = 0 then 1 else 0 end +';
break;
}
//------------------------------------
break;
}
}
}
//REPLACE LAST + with DESC
$sql = substr($sql, 0, -1).' desc limit 0,4';
//Prepare statement
$stmt = $pdo->prepare($sql);
//Excute Query
$stmt->execute();
//Get results
$messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
//------------------------------------------
//CHANGE ROWID INTO UUID
//------------------------------------------
function updateRowID($row) {
$row['rowID'] = encodeUuid($row['rowID']);
return $row;
}
$updatedData = array_map('updateRowID', $messages);
$messages = json_encode($messages, JSON_UNESCAPED_UNICODE);
//------------------------------------------
//Send results
//------------------------------------------
echo $messages;
}
else
{
//++++++++++++++++++++++
//STANDAARD PROCESS
//++++++++++++++++++++++
//SoldTo is empty
if (empty($partner->soldto) || $partner->soldto == ''){$soldto_search = '%';} else {$soldto_search = '-%';}
@@ -20,7 +302,7 @@ list($whereclause,$condition) = getWhereclause('',$permission,$partner,'');
//BUILD UP PARTNERHIERARCHY FROM USER
$partner_product = json_encode(array("salesid"=>$partner->salesid,"soldto"=>$partner->soldto), JSON_UNESCAPED_UNICODE);
$id = $post_content['rowID'] ?? ''; //check for rowID
$id = $post_content['rowID'] ? decodeUuid($post_content['rowID']):''; //check for rowID
$command = ($id == '')? 'insert' : 'update'; //IF rowID = empty then INSERT
if (isset($post_content['delete'])){$command = 'delete';} //change command to delete
@@ -30,10 +312,39 @@ $clause_insert ='';
$input_insert = '';
if (isset($post_content['opening_hours'])){
$post_content['opening_hours'] = json_encode($post_content['opening_hours'], JSON_UNESCAPED_UNICODE);
}
if ($command == 'update'){
$post_content['updatedby'] = $username ;
}
if ($command == 'insert'){
//Generate content for missing data
$keysToCheck = ['short_description', 'long_description', 'usp1', 'usp2', 'usp3'];
foreach ($keysToCheck as $key) {
$gc = ($post_content['garden_center'] == 0 ? false : true);
$ml = ($post_content['locations'] == 0 ? false : true);
//GENERATE DATA
$generated_content = generateSpaCompanyContent(
$post_content['name'], // Company name
$post_content['city'], // City
$gc, // Garden center (yes/no)
${'brand_type_'.$post_content['brand_type']}, // Brand type
${'showroom_size_'.$post_content['showroom_size']}, // Showroom size
${'focus_offering_'.$post_content['focus_offering']}, // Offering
${'dealer_type_'.$post_content['dealer_type']}, // Dealer type
$ml // Multiple locations
);
if (isset($post_content[$key]) && (empty($post_content[$key]) || $post_content[$key] == '')) {
$post_content[$key] = $generated_content[$key];
}
}
$post_content['createdby'] = $username;
$post_content['accounthierarchy'] = $partner_product;
}
@@ -64,12 +375,17 @@ if ($command == 'update' && isAllowed('dealers',$profile,$permission,'U') === 1)
$sql = 'UPDATE dealers SET '.$clause.' WHERE rowID = ? '.$whereclause.'';
$execute_input[] = $id;
$stmt = $pdo->prepare($sql);
$stmt->execute($execute_input);
if ($stmt->execute($execute_input)) {
echo json_encode(array('rowID'=> $id, 'status' => 'updated'));
}
}
elseif ($command == 'insert' && isAllowed('dealers',$profile,$permission,'C') === 1){
$sql = 'INSERT INTO dealers ('.$clause_insert.') VALUES ('.$input_insert.')';
$stmt = $pdo->prepare($sql);
$stmt->execute($execute_input);
// Return ID
echo json_encode(array('rowID'=> $pdo->lastInsertId(), 'status' => 'created'));
}
elseif ($command == 'delete' && isAllowed('dealers',$profile,$permission,'D') === 1){
$sql = 'DELETE FROM dealers WHERE rowID = ? '.$whereclause;
@@ -82,6 +398,6 @@ elseif ($command == 'delete' && isAllowed('dealers',$profile,$permission,'D') ==
{
//do nothing
}
}
?>

View File

@@ -0,0 +1,96 @@
<?php
defined($security_key) or exit;
//------------------------------------------
// dealers
//------------------------------------------
//Connect to DB
$pdo = dbConnect($dbname);
//CONTENT FROM API (POST)
$post_content = json_decode($input,true);
//SoldTo is empty
if (empty($partner->soldto) || $partner->soldto == ''){$soldto_search = '%';} else {$soldto_search = '-%';}
//default whereclause
$whereclause = '';
//ENSURE PRODUCTROWID IS SEND
if (isset($post_content['dealer_id'])){
//change UUID to ROWID
$post_content['dealer_id'] = decodeUuid($post_content['dealer_id']);
//CHECK IF ALLOWED TO CRUD VERSIONS
$sql = "SELECT * FROM dealers WHERE rowID = ? '.$whereclause.'";
$stmt = $pdo->prepare($sql);
$stmt->execute([$post_content['dealer_id']]);
$dealer_data = $stmt->fetch();
$dealer_owner = ($dealer_data['rowID'])? 1 : 0;
//IF PRODUCT IS OWNED THEN CRUD is ALLOWED
if ($dealer_owner === 1 ){
//SET PARAMETERS FOR QUERY
$id = $post_content['rowID'] ?? ''; //check for rowID
$command = ($id == '')? 'insert' : 'update'; //IF rowID = empty then INSERT
if (isset($post_content['delete'])){$command = 'delete';} //change command to delete
//CREATE EMPTY STRINGS
$clause = '';
$clause_insert ='';
$input_insert = '';
if ($command == 'insert'){
$post_content['createdby'] = $username;
}
if ($command == 'update'){
$post_content['updatedby'] = $username;
}
//CREATE NEW ARRAY AND MAP TO CLAUSE
if(isset($post_content) && $post_content!=''){
foreach ($post_content as $key => $var){
if ($key == 'submit' || $key == 'rowID'){
//do nothing
}
else {
$criterias[$key] = $var;
$clause .= ' , '.$key.' = ?';
$clause_insert .= ' , '.$key.'';
$input_insert .= ', ?'; // ? for each insert item
$execute_input[]= $var; // Build array for input
}
}
}
//CLEAN UP INPUT
$clause = substr($clause, 2); //Clean clause - remove first comma
$clause_insert = substr($clause_insert, 2); //Clean clause - remove first comma
$input_insert = substr($input_insert, 1); //Clean clause - remove first comma
//QUERY AND VERIFY ALLOWED
if ($command == 'update' && isAllowed('dealers_media',$profile,$permission,'U') === 1){
$sql = 'UPDATE dealers_media SET '.$clause.' WHERE rowID = ? ';
$execute_input[] = $id;
$stmt = $pdo->prepare($sql);
$stmt->execute($execute_input);
}
elseif ($command == 'insert' && isAllowed('dealers_media',$profile,$permission,'C') === 1){
$sql = 'INSERT INTO dealers_media ('.$clause_insert.') VALUES ('.$input_insert.')';
$stmt = $pdo->prepare($sql);
$stmt->execute($execute_input);
}
elseif ($command == 'delete' && isAllowed('dealers_media',$profile,$permission,'D') === 1){
$stmt = $pdo->prepare('DELETE FROM dealers_media WHERE rowID = ? ');
$stmt->execute([ $id ]);
//Add deletion to changelog
changelog($dbname,'dealers_media',$id,'Delete','Delete',$username);
} else
{
//do nothing
}
}
}
?>

View File

@@ -1164,3 +1164,43 @@ function decodeVIN(){
})
}
function toggleClosed(day, skipToggle = false) {
const checkbox = document.getElementById(`closed_${day}`);
const startInput = document.getElementById(`start_${day}`);
const endInput = document.getElementById(`end_${day}`);
if (checkbox.checked) {
// If closed, disable time inputs and set hidden field for null value
startInput.disabled = true;
endInput.disabled = true;
// Remove the time inputs from form submission
startInput.name = "";
endInput.name = "";
// Add a hidden field to explicitly set the day to null
if (!document.getElementById(`null_${day}`)) {
const hiddenField = document.createElement('input');
hiddenField.type = 'hidden';
hiddenField.id = `null_${day}`;
hiddenField.name = `opening_hours[${day}]`;
hiddenField.value = 'null';
checkbox.parentNode.appendChild(hiddenField);
}
} else {
// If open, enable time inputs
startInput.disabled = false;
endInput.disabled = false;
// Restore the time input names for form submission
startInput.name = `opening_hours[${day}][start]`;
endInput.name = `opening_hours[${day}][end]`;
// Remove the hidden null field if it exists
const hiddenField = document.getElementById(`null_${day}`);
if (hiddenField) {
hiddenField.parentNode.removeChild(hiddenField);
}
}
}

View File

@@ -437,20 +437,14 @@ function template_footer($js_script = '') {
$user_mail = $_SESSION['email'] ?? '';
$veliti_cim = '';
if (veliti_cim){
$veliti_cim = '<iframe src="https://change.veliti.nl/request_popup.php?language='.$lancode.'&email='.$user_mail.'" style="border: solid 1px;border-radius: 5px;min-width:400px;min-height:400px;"></iframe>';
}
// DO NOT INDENT THE BELOW CODE
echo <<<EOT
</main>
$veliti_cim = '
<button id="support_btn" class="btn" style="opacity: 0.8;position: fixed;bottom: 23px;right: 28px;background:#4a79b400;font-size:36px;z-index:999;" onclick="openForm()"><img src="./assets/images/tss-persoon.svg" alt="tss-persoon" height="115"></button>
<div class="form-popup" id="request">$veliti_cim
<div class="form-popup" id="request">
<iframe src="https://change.veliti.nl/request_popup.php?language='.$lancode.'&email='.$user_mail.'" style="border: solid 1px;border-radius: 5px;min-width:400px;min-height:400px;"></iframe>
<div class="close">
<button type="button" style="border: solid 1px;" onclick="closeForm()">X</button>
</div>
</div>
<script src="./assets/admin.js"></script>
{$js_script}
<script>
function openForm() {
document.getElementById("request").style.display = "block";
@@ -460,6 +454,16 @@ echo <<<EOT
document.getElementById("request").style.display = "none";
}
</script>
';
}
// DO NOT INDENT THE BELOW CODE
echo <<<EOT
</main>
$veliti_cim
<script src="./assets/admin.js"></script>
{$js_script}
</body>
</html>
EOT;
@@ -860,6 +864,7 @@ function getWhereclauselvl2($table_name,$permission,$partner,$method){
"config" => "pc.accounthierarchy",
"software" => "p.accounthierarchy",
"transactions" => "tx.accounthierarchy",
"dealers" => "d.accounthierarchy",
"categories" => "c.accounthierarchy"
];
@@ -2090,7 +2095,30 @@ if(($imageFileType == "jpg" || $imageFileType == "png" || $imageFileType == "jpe
}
//------------------------------------------
// UPLOAD PICTURE for PRODUCTS
// UPLOAD PICTURE for DEALERS
//------------------------------------------
function uploadDealers($name){
$target_dir = dirname(__FILE__)."/images/dealers/";
$input_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$imageFileType = strtolower(pathinfo($input_file,PATHINFO_EXTENSION));
$target_file = $target_dir . $name.'.jpg';
$file_input_check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
//Do when JPG or PNG or JPEG or GIF and smaller than 5MB
if(($imageFileType == "jpg" || $imageFileType == "png" || $imageFileType == "jpeg" || $imageFileType == "gif" || $imageFileType == "png") && $_FILES["fileToUpload"]["size"] < 5000000 && $file_input_check !== false) {
//Upload picture
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "Done";
} else {
echo "Error";
}
//}
}
}
//------------------------------------------
// UPLOAD PICTURE for CARTEST
//------------------------------------------
function uploadrequest($key){
$target_dir = dirname(__FILE__)."/images/cartests/";
@@ -2107,7 +2135,6 @@ function uploadrequest($key){
} else {
}
}
}
//------------------------------------------
// displayImages
@@ -3981,3 +4008,393 @@ function getDomainName($hostname) {
return $hostname;
}
}
//=======================================
// encode ID to UUID
//=======================================
function encodeUuid($number) {
$alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
$base = strlen($alphabet);
$encoded = '';
while ($number) {
$encoded = $alphabet[$number % $base] . $encoded;
$number = floor($number / $base);
}
$encoded = $encoded ?: '0';
// Pad with leading zeros from the alphabet (which is '0') if shorter than 5 characters
while (strlen($encoded) < 5) {
$encoded = '0' . $encoded;
}
return $encoded;
}
//=======================================
// decode UUID to ID
//=======================================
function decodeUuid($encoded) {
$alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
$base = strlen($alphabet);
$number = 0;
$length = strlen($encoded);
for ($i = 0; $i < $length; $i++) {
$char = $encoded[$i];
$position = strpos($alphabet, $char);
if ($position === false) {
// Character not found in alphabet
return false;
}
$number = $number * $base + $position;
}
return $number;
}
/**
* Generate marketing content for a spa/hot tub company based on business criteria
*
* @param string $companyName The name of the company
* @param string $city The city location
* @param bool $gardenCenter Whether the company is a garden center
* @param string $brandType Single brand or Multi brand
* @param string $showroomSize Normal, Large, or Extra Large
* @param string $offering Economy-Premium or Premium-Highend
* @param string $dealerType Local, Professional, or Corporate
* @param bool $multipleLocations Whether the company has multiple locations
* @return array An array containing short description, long description, and unique selling points
*/
function generateSpaCompanyContent($companyName, $city, $gardenCenter, $brandType, $showroomSize, $offering, $dealerType, $multipleLocations) {
// Determine content template to use based on criteria combination
$templateIndex = determineTemplateIndex($gardenCenter, $brandType, $offering, $dealerType, $multipleLocations);
// Get content templates
$shortDescTemplates = getShortDescriptionTemplates();
$longDescTemplates = getLongDescriptionTemplates();
$uspTemplates = getUniqueSellingPointsTemplates();
// Replace placeholders in templates
$shortDescription = str_replace(
['{CompanyName}', '{City}', '{BrandType}', '{ShowroomSize}'],
[$companyName, $city, $brandType, $showroomSize],
$shortDescTemplates[$templateIndex]
);
$longDescription = str_replace(
['{CompanyName}', '{City}', '{BrandType}', '{ShowroomSize}'],
[$companyName, $city, $brandType, $showroomSize],
$longDescTemplates[$templateIndex]
);
$usps = [];
foreach ($uspTemplates[$templateIndex] as $usp) {
$usps[] = str_replace(
['{CompanyName}', '{City}', '{BrandType}', '{ShowroomSize}'],
[$companyName, $city, $brandType, $showroomSize],
$usp
);
}
return [
'short_description' => $shortDescription,
'long_description' => $longDescription,
'usp1' => $usps[0],
'usp2' => $usps[1],
'usp3' => $usps[2]
];
}
/**
* Determine which template to use based on company criteria
*/
function determineTemplateIndex($gardenCenter, $brandType, $offering, $dealerType, $multipleLocations) {
// This is a simplified method to select a template
// In a real implementation, you might want more sophisticated logic
if ($gardenCenter) {
if (strpos($offering, 'Premium') !== false) {
return 3; // Garden Center Premium
} else {
return 7; // Garden Center High-End
}
}
if ($dealerType == 'Local') {
if ($brandType == 'Single brand') {
return strpos($offering, 'Economy') !== false ? 0 : 4; // Local Economy Single Brand or Local High-End Single Brand
}
}
if ($dealerType == 'Professional') {
if ($brandType == 'Single brand') {
return 9; // Professional Single Brand Specialist
} else {
return strpos($offering, 'Economy') !== false ? 5 : 1; // Professional Economy Multi-Brand or Professional Premium Multi-Brand
}
}
if ($dealerType == 'Corporate') {
if ($multipleLocations) {
return 2; // Corporate High-End Multi-Location
} else {
return 8; // Corporate Premium Multi-Brand
}
}
if ($multipleLocations && strpos($offering, 'Economy') !== false) {
return 6; // Multi-Location Economy Single Brand
}
// Default to template 0 if no conditions match
return 0;
}
/**
* Get all short description templates
*/
function getShortDescriptionTemplates() {
return [
// 0. Local Economy Single Brand
"{CompanyName} is {City}'s trusted provider of quality hot tubs and spas at affordable prices, featuring the complete {BrandType} collection in our {ShowroomSize} showroom.",
// 1. Professional Premium Multi-Brand
"{CompanyName} brings premium spa experiences to {City} with our curated selection of luxury brands in our {ShowroomSize} professional showroom.",
// 2. Corporate High-End Multi-Location
"With locations across the region including {City}, {CompanyName} delivers exceptional high-end spa solutions backed by corporate reliability and service excellence.",
// 3. Garden Center Premium
"{CompanyName} combines garden expertise with premium spa offerings in {City}, creating the perfect outdoor relaxation destinations within our {ShowroomSize} garden center.",
// 4. Local High-End Single Brand
"{CompanyName} is {City}'s exclusive dealer for {BrandType} luxury spas, offering personalized service in an intimate {ShowroomSize} showroom experience.",
// 5. Professional Economy Multi-Brand
"As {City}'s professional spa specialists, {CompanyName} presents affordable solutions from leading brands in our {ShowroomSize} showroom designed for every budget.",
// 6. Multi-Location Economy Single Brand
"{CompanyName} makes quality relaxation accessible across multiple locations including {City}, specializing exclusively in the reliable {BrandType} collection.",
// 7. Garden Center High-End
"Elevate your garden oasis with {CompanyName}'s selection of high-end spas and hot tubs, showcased within our {ShowroomSize} {City} garden center.",
// 8. Corporate Premium Multi-Brand
"{CompanyName} combines corporate expertise with personalized service in {City}, offering premium spa solutions from the industry's most respected brands.",
// 9. Professional Single Brand Specialist
"{City}'s dedicated {BrandType} specialists at {CompanyName} provide expert guidance and professional support in our {ShowroomSize} showroom."
];
}
/**
* Get all long description templates
*/
function getLongDescriptionTemplates() {
return [
// 0. Local Economy Single Brand
"Welcome to {CompanyName}, {City}'s dedicated hot tub and spa center where affordability meets quality. Our {ShowroomSize} showroom exclusively features the complete {BrandType} line, offering reliable relaxation solutions for every home and budget. As a locally owned business, we take pride in providing personalized service to our neighbors while maintaining competitive pricing. Our knowledgeable staff guides you through the entire process from selection to installation, ensuring your perfect spa experience.",
// 1. Professional Premium Multi-Brand
"{CompanyName} has established itself as {City}'s premier destination for premium spa experiences. Our professional team showcases a carefully selected range of luxury brands in our {ShowroomSize} showroom, each chosen for superior craftsmanship and innovative features. We combine technical expertise with a consultative approach, helping clients discover the perfect spa solution for their lifestyle and wellness goals. From initial design consultation through professional installation and ongoing maintenance, our comprehensive service ensures a seamless ownership experience.",
// 2. Corporate High-End Multi-Location
"With our flagship location in {City} and showrooms across the region, {CompanyName} delivers unparalleled access to high-end spa solutions. Our corporate structure ensures consistent quality, competitive pricing, and exceptional service at every location. The {ShowroomSize} {City} showroom features our complete collection of luxury spa brands, each representing the pinnacle of design, technology, and comfort. Our team of spa professionals provides expert guidance backed by our company-wide commitment to customer satisfaction and long-term support.",
// 3. Garden Center Premium
"At {CompanyName}, we've expanded our {City} garden expertise to include premium spa and hot tub solutions that complement your outdoor living space. Our {ShowroomSize} garden center now showcases a thoughtfully curated selection of quality spas designed to transform your backyard into a year-round wellness retreat. Our unique perspective combines landscaping knowledge with spa technology expertise, allowing us to help you create integrated outdoor environments where garden beauty meets relaxation therapy. Visit our {City} location to explore how our premium spa offerings can enhance your garden sanctuary.",
// 4. Local High-End Single Brand
"{CompanyName} brings exclusive {BrandType} luxury spas to discerning clients throughout {City}. Our intimate {ShowroomSize} showroom creates a personalized shopping experience where you can explore every detail of these exceptional wellness products. As {City}'s dedicated {BrandType} specialists, we offer unmatched product knowledge and customization options not available elsewhere. Our commitment to white-glove service extends from your first consultation through years of ownership, with dedicated support from our team who knows your installation personally.",
// 5. Professional Economy Multi-Brand
"{CompanyName} was founded on the belief that quality relaxation should be accessible to everyone in {City}. Our {ShowroomSize} showroom features carefully selected spa brands that deliver reliable performance without premium price tags. Our professional team applies the same expertise and attention to detail regardless of your budget, helping you navigate options to find the perfect balance of features and affordability. We handle everything from site preparation to installation and maintenance education, ensuring a stress-free experience that matches our stress-relieving products.",
// 6. Multi-Location Economy Single Brand
"With {CompanyName}'s expanding presence across the region, including our {City} location, we've streamlined operations to bring you exceptional value through our exclusive partnership with {BrandType}. Our {ShowroomSize} showrooms showcase the complete range of these reliable spas, with consistent pricing and service standards at every location. By focusing on a single trusted manufacturer, we've developed specialized expertise that benefits our customers through knowledgeable guidance, efficient service, and optimized inventory that ensures prompt delivery and installation.",
// 7. Garden Center High-End
"{CompanyName} has evolved our {City} garden center concept to include a curated collection of high-end spas and hot tubs that represent the perfect fusion of nature and luxury. Our {ShowroomSize} showroom displays these premium wellness products in contextual settings that help you envision the transformation of your own outdoor space. Our unique approach combines horticultural expertise with spa technology knowledge, allowing us to create integrated relaxation environments that function beautifully through every season. Experience the difference at our {City} location, where garden artistry meets wellness innovation.",
// 8. Corporate Premium Multi-Brand
"As {City}'s corporate-backed premium spa provider, {CompanyName} combines the reliability of organizational strength with the personal touch of dedicated local experts. Our {ShowroomSize} showroom presents a comprehensive selection of premium brands, each meeting our rigorous standards for quality, innovation, and value. Our structured approach ensures consistency through every phase of ownership, from transparent pricing and professional needs assessment through expert installation and scheduled maintenance programs. Experience the confidence that comes from working with {City}'s most established spa provider.",
// 9. Professional Single Brand Specialist
"{CompanyName} has dedicated our {City} business to becoming the region's foremost experts in {BrandType} spas and hot tubs. Our {ShowroomSize} showroom is designed to showcase every model and feature in this exceptional line, with working displays that demonstrate the unique benefits of these wellness systems. Our professional staff undergoes specialized factory training, making them uniquely qualified to help you select, customize, and maintain your {BrandType} spa. Choose {City}'s only dedicated {BrandType} specialists for an ownership experience as refined as the products we represent."
];
}
/**
* Get all unique selling points templates
*/
function getUniqueSellingPointsTemplates() {
return [
// 0. Local Economy Single Brand
[
"Exclusive {BrandType} dealer offering the full product line at competitive prices",
"Locally owned with personalized service from neighbors who care about your experience",
"Complete solutions from selection through installation with no hidden costs"
],
// 1. Professional Premium Multi-Brand
[
"Curated selection of premium brands chosen for superior quality and innovation",
"Professional consultation process that matches your lifestyle with the perfect spa",
"Comprehensive service from design consultation through lifetime maintenance"
],
// 2. Corporate High-End Multi-Location
[
"Regional presence with consistent high-end offerings across all locations",
"Corporate buying power delivering competitive pricing on luxury products",
"Standardized excellence in customer care backed by substantial resources"
],
// 3. Garden Center Premium
[
"Integrated approach to outdoor living combining garden expertise with spa technology",
"Contextual showroom displays demonstrating how spas enhance garden environments",
"Year-round wellness solutions that complement your existing garden investments"
],
// 4. Local High-End Single Brand
[
"Exclusive {City} source for the complete {BrandType} luxury collection",
"Intimate showroom experience with personalized attention to your specific needs",
"Specialized knowledge of customization options not available at general retailers"
],
// 5. Professional Economy Multi-Brand
[
"Carefully vetted affordable brands that maximize features while minimizing cost",
"Professional guidance typically reserved for luxury customers, at every price point",
"Transparent pricing with no compromise on installation quality or service"
],
// 6. Multi-Location Economy Single Brand
[
"Specialized {BrandType} expertise developed through exclusive brand focus",
"Consistent pricing and service standards across all regional locations",
"Optimized inventory management ensuring faster delivery and installation"
],
// 7. Garden Center High-End
[
"Unique perspective integrating luxury spas into complete garden environments",
"Seasonal expertise ensuring your spa enhances your outdoor space year-round",
"One-stop resource for creating cohesive outdoor relaxation destinations"
],
// 8. Corporate Premium Multi-Brand
[
"Organizational strength providing stability and reliability throughout ownership",
"Structured approach from consultation through installation and maintenance",
"Corporate accountability backing every product sold and service performed"
],
// 9. Professional Single Brand Specialist
[
"Deep {BrandType} expertise through specialized factory training and certification",
"Complete demonstration capability showing every model in working condition",
"Unmatched product knowledge of the complete {BrandType} feature set and options"
]
];
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Generate dealer information ++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
function generateDealerInformation($token){
//INCLUDE US LANGUAGE
include dirname(__FILE__,2).'/settings/translations/translations_US.php';
//GET ALL DEALERS
$api_url = '/v2/dealers/list=';
$responses = ioAPIv2($api_url,'',$token);
$log_results =[];
if(!empty($responses)){
//decode the API response
$responses = json_decode($responses,true);
//loop through translation records and create variables
foreach ($responses as $response){
$new_content = [];
//Generate content for missing data
$keysToCheck = ['short_description', 'long_description', 'usp1', 'usp2', 'usp3'];
foreach ($keysToCheck as $key) {
$gc = ($response['garden_center'] == 0 ? false : true);
$ml = ($response['locations'] == 0 ? false : true);
//GENERATE DATA
$generated_content = generateSpaCompanyContent(
$response['name'], // Company name
$response['city'], // City
$gc, // Garden center (yes/no)
${'brand_type_'.$response['brand_type']}, // Brand type
${'showroom_size_'.$response['showroom_size']}, // Showroom size
${'focus_offering_'.$response['focus_offering']}, // Offering
${'dealer_type_'.$response['dealer_type']}, // Dealer type
$ml // Multiple locations
);
if (isset($response[$key]) && (empty($response[$key]) || $response[$key] == '')) {
$new_content['rowID'] = encodeUuid($response['rowID']);
$new_content[$key] = $generated_content[$key];
}
}
//GET ALL POST DATA
$payload = json_encode($new_content, JSON_UNESCAPED_UNICODE);
//API call
$api_call = ioAPIv2('/v2/dealers', $payload,$token);
$api_response = json_decode($api_call ,true);
//Provide feedback
$log_results[$response['rowID']] = $api_response['rowID'].' '.$api_response['status'];
}
}
return $log_results;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Function to check if origin matches allowed patterns
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
function isOriginAllowed($origin, $allowedPatterns) {
if (empty($origin)) {
return false;
}
// Parse the origin to get the host part
$parsedOrigin = parse_url($origin);
$host = $parsedOrigin['host'] ?? '';
if (empty($host)) {
return false;
}
// Check if the host matches any of our patterns (exact match or subdomain)
foreach ($allowedPatterns as $pattern) {
// Check for exact match
if ($host === $pattern) {
return true;
}
// Check for subdomain match (domain.example.com)
$patternWithDot = '.' . $pattern;
if (substr($host, -strlen($patternWithDot)) === $patternWithDot) {
return true;
}
}
return false;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 587 KiB

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
viewBox="0 0 817.2 820" style="enable-background:new 0 0 817.2 820;" xml:space="preserve">
<style type="text/css">
.shadow{fill-rule:evenodd;clip-rule:evenodd;fill:url(#gradient); fill-opacity:0.7; filter: blur(15px);}
</style>
<radialGradient id="gradient" cx="526.5995" cy="486.8359" r="478.1535" fx="275.8764" fy="893.9829" gradientUnits="userSpaceOnUse">
<stop offset="0" style="stop-color:#5C5C5C;stop-opacity:0.9477"/>
<stop offset="0.1123" style="stop-color:#474747;stop-opacity:0.7805"/>
<stop offset="0.3403" style="stop-color:#202020;stop-opacity:0.4413"/>
<stop offset="0.5232" style="stop-color:#090909;stop-opacity:0.1692"/>
<stop offset="0.6369" style="stop-color:#000000;stop-opacity:0"/>
</radialGradient>
<path class="shadow" d="M778.8,483.2c-34.3,52.8-101.9,94.1-150.3,124.6L255.7,820L169,522l170.8-299.6l0-0.1l9.8-17.3
C421.3,94.6,585,56.3,702.5,132.5S850.3,372.8,778.8,483.2z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

20
assets/images/marker.svg Normal file
View File

@@ -0,0 +1,20 @@
<svg viewBox="0 0 500 820" version="1.1" xmlns="http://www.w3.org/2000/svg" xml:space="preserve"
style="fill-rule: evenodd; clip-rule: evenodd; stroke-linecap: round;">
<defs>
<linearGradient x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(2.30025e-15,-37.566,37.566,2.30025e-15,416.455,540.999)" id="map-marker-38-f">
<stop offset="0" stop-color="rgb(18,111,198)"/>
<stop offset="1" stop-color="rgb(76,156,209)"/>
</linearGradient>
<linearGradient x1="0" y1="0" x2="1" y2="0"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.16666e-15,-19.053,19.053,1.16666e-15,414.482,522.486)"
id="map-marker-38-s">
<stop offset="0" stop-color="rgb(46,108,151)"/>
<stop offset="1" stop-color="rgb(56,131,183)"/>
</linearGradient>
</defs>
<g transform="matrix(19.5417,0,0,19.5417,-7889.1,-9807.44)">
<path fill="#FFFFFF" d="M421.2,515.5c0,2.6-2.1,4.7-4.7,4.7c-2.6,0-4.7-2.1-4.7-4.7c0-2.6,2.1-4.7,4.7-4.7 C419.1,510.8,421.2,512.9,421.2,515.5z"/>
<path d="M416.544,503.612C409.971,503.612 404.5,509.303 404.5,515.478C404.5,518.256 406.064,521.786 407.194,524.224L416.5,542.096L425.762,524.224C426.892,521.786 428.5,518.433 428.5,515.478C428.5,509.303 423.117,503.612 416.544,503.612ZM416.544,510.767C419.128,510.784 421.223,512.889 421.223,515.477C421.223,518.065 419.128,520.14 416.544,520.156C413.96,520.139 411.865,518.066 411.865,515.477C411.865,512.889 413.96,510.784 416.544,510.767Z" stroke-width="1.1px" fill="url(#map-marker-38-f)" stroke="url(#map-marker-38-s)"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

290
dealer.php Normal file
View File

@@ -0,0 +1,290 @@
<?php
defined(page_security_key) or exit;
if (debug && debug_id == $_SESSION['id']){
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
}
include_once './assets/functions.php';
include_once './settings/settings_redirector.php';
//SET ORIGIN FOR NAVIGATION
$_SESSION['prev_origin_dealer'] = $_SERVER['REQUEST_URI'];
$page = 'dealer';
//Check if allowed
if (isAllowed($page,$_SESSION['profile'],$_SESSION['permission'],'R') === 0){
header('location: index.php');
exit;
}
//PAGE Security
$page_manage = 'dealer_manage';
$update_allowed = isAllowed($page_manage ,$_SESSION['profile'],$_SESSION['permission'],'U');
$delete_allowed = isAllowed($page_manage ,$_SESSION['profile'],$_SESSION['permission'],'D');
$create_allowed = isAllowed($page_manage ,$_SESSION['profile'],$_SESSION['permission'],'C');
//GET Details from URL
$GET_VALUES = urlGETdetails($_GET) ?? '';
//CALL TO API FOR General information
$api_url = '/v2/dealers/'.$GET_VALUES;
$responses = ioServer($api_url,'');
//Decode Payload
if (!empty($responses)){$responses = json_decode($responses,true);}else{$responses = null;}
$responses = $responses[0];
//Translate status INT to STR
$dealer_status = 'general_status_'.$responses['status'];
// Handle success messages
if (isset($_GET['success_msg'])) {
if ($_GET['success_msg'] == 1) {
$success_msg = $message_eq_1;
}
if ($_GET['success_msg'] == 2) {
$success_msg = $message_eq_2;
}
if ($_GET['success_msg'] == 3) {
$success_msg = $message_eq_3;
}
}
template_header('Dealer', 'dealer', 'view');
$view = '
<div class="content-title responsive-flex-wrap responsive-pad-bot-3">
<h2 class="responsive-width-100">'.($view_dealer_h2 ?? 'Dealer').' - '.encodeUuid($responses['rowID']).'</h2>
<a href="index.php?page='.$_SESSION['origin'].'&p='.$_SESSION['p'].$_SESSION['search'].$_SESSION['partnerid'].'" class="btn alt mar-right-2">'.$button_cancel.'</a>
';
//------------------------------------
// EDIT BUTTON
//------------------------------------
if ($update_allowed === 1){
$view .= '<a href="index.php?page=dealer_manage&rowID='.encodeUuid($responses['rowID']).'" class="btn">Edit</a>';
}
$view .= '</div>';
if (isset($success_msg)){
$view .= ' <div class="msg success">
<i class="fas fa-check-circle"></i>
<p>'.$success_msg.'</p>
<i class="fas fa-times"></i>
</div>';
}
$view .= '<div class="content-block-wrapper">';
$view .= ' <div class="content-block order-details">
<div class="block-header">
<i class="fa-solid fa-circle-info"></i></i>'.($view_dealers_information ?? 'Dealer information').'
</div>
<div class="order-detail">
<h3>'.($dealers_status ?? 'status').'</h3>
<p><span class="status id'.$responses['status'].'">'.(${$dealer_status} ?? $dealer_status).'</span></p>
</div>
<div class="order-detail">
<h3>'.($dealers_name ?? 'name').'</h3>
<p>'.$responses['name'].'</p>
</div>
<div class="order-detail">
<h3>'.($dealers_slug ?? 'slug').'</h3>
<p>'.$responses['dealer_slug'].'</p>
</div>
<div class="order-detail">
<h3>'.($dealers_rating_overall ?? 'rating_overall').'</h3>
<p>'.$responses['rating_overall'].'</p>
</div>
<div class="order-detail">
<h3>'.($dealers_rating_website ?? 'rating_website').'</h3>
<p>'.$responses['rating_website'].'</p>
</div>
</div>
';
$view .='<div class="content-block order-details">
<div class="block-header">
<i class="fa-solid fa-user fa-sm"></i>
</div>';
if (!empty($responses['full_path'])){
$view .='
<div class="order-detail">
<img style="border-radius: 4px;height: 200px;margin: auto;" src="'.$responses['full_path'].'" alt="">
</div>
';
}
$view .='
</div>
';
$view .= '</div>';
$view .= '<div class="content-block">
<div class="block-header">
<i class="fa-solid fa-bars fa-sm"></i>'.($view_dealer_details_1 ?? 'Descriptions').'
<div class="tabs">
<a href="#" class="active">'.($dealers_short_description ?? 'Short').'</a>
<a href="#">'.($dealers_long_description ?? 'Long').'</a>
<a href="#">'.($dealers_usp1 ?? 'USP1').'</a>
<a href="#">'.($dealers_usp2 ?? 'USP2').'</a>
<a href="#">'.($dealers_usp3 ?? 'USP3').'</a>
</div>
</div>
<div class="table order-table tab-content active">
'.(${$responses['short_description']} ?? $responses['short_description']).'
</div>
<div class="table order-table tab-content">
'.(${$responses['long_description']} ?? $responses['long_description']).'
</div>
<div class="table order-table tab-content">
'.(${$responses['usp1']} ?? $responses['usp1']).'
</div>
<div class="table order-table tab-content">
'.(${$responses['usp2']} ?? $responses['usp2']).'
</div>
<div class="table order-table tab-content">
'.(${$responses['usp3']} ?? $responses['usp3']).'
</div>
</div>
';
$view .= '<div class="content-block">
<div class="block-header">
<i class="fa-solid fa-bars fa-sm"></i>'.($view_dealer_details_3 ?? 'Location').'
</div>
<div class="table order-table">
<table>
<tr>
<td style="width:25%;">'.($dealers_address ?? 'address').'</td>
<td>'.$responses['address'].'</td>
</tr>
<tr>
<td style="width:25%;">'.($dealers_postalcode ?? 'postalcode').'</td>
<td>'.$responses['postalcode'].'</td>
</tr>
<tr>
<td style="width:25%;">'.($dealers_city ?? 'city').'</td>
<td>'.$responses['city'].'</td>
</tr>
<tr>
<td style="width:25%;">'.($dealers_state ?? 'state').'</td>
<td>'.$responses['state'].'</td>
</tr>
<tr>
<td style="width:25%;">'.($dealers_country ?? 'country').'</td>
<td>'.$responses['country'].'</td>
</tr>
<tr>
<td style="width:25%;">'.($dealers_email ?? 'email').'</td>
<td>'.$responses['email'].'</td>
</tr>
<tr>
<td style="width:25%;">'.($dealers_phone ?? 'phone').'</td>
<td>'.$responses['phone'].'</td>
</tr>
<tr>
<td style="width:25%;">'.($dealers_url ?? 'url').'</td>
<td>'.$responses['url'].'</td>
</tr>
</table>
</div>
</div>
';
//SHOW LOCATION BASED ON GEOLOCATION
if ((!empty($responses['lat']) || $responses['lat'] != '') && (!empty($responses['lng']) || $responses['lng'] != '')){
$view .= '<div class="content-block">
<div id="map" style="height:300px;z-index: 0;">
</div>
<script>
// initialize Leaflet
var map = L.map(\'map\').setView({lon: '.$responses['lng'].', lat: '.$responses['lat'].'}, 10);
//Add TSS Avatar to MAP
var TSSemp = L.icon({
iconUrl: \'./assets/images/marker.svg\',
iconSize: [50, 50], // size of the icon
});
L.marker(['.$responses['lat'].','.$responses['lng'].'], {icon: TSSemp}).addTo(map);
// add the OpenStreetMap tiles
L.tileLayer(\'https://tile.openstreetmap.org/{z}/{x}/{y}.png\', {
maxZoom: 19,
attribution: \'&copy; <a href="https://openstreetmap.org/copyright">OpenStreetMap contributors</a>\'
}).addTo(map);
// show the scale bar on the lower left corner
L.control.scale({imperial: true, metric: true}).addTo(map);
</script>
</div>
';
}
//OPENING HOURS
if (!empty($responses['opening_hours']) || $responses['opening_hours'] !='' ){
$opening_hours = is_string($responses['opening_hours']) ? json_decode($responses['opening_hours'],true) : '';
$view .= '<div class="content-block">
<div class="block-header">
<i class="fa-solid fa-bars fa-sm"></i>'.($dealers_openinghours ?? 'opening_hours').'
</div>
<div class="table order-table">
<table>';
foreach ($opening_hours as $day => $value){
$view .= '<tr>
<td style="width:25%;">'.(${'general_day_'.$day} ?? 'Not specified').'</td>
<td>'.(isset($value['start']) ? $value['start'].' - '.$value['end'] : ($general_closed ?? 'Closed')).'</td>
</tr>';
}
$view .= '
</table>
</div>
</div>
';
}
$view .= '<div class="content-block">
<div class="block-header">
<i class="fa-solid fa-bars fa-sm"></i>'.($view_dealer_details_2 ?? 'Settings').'
</div>
<div class="table order-table">
<table>
<tr>
<td style="width:25%;">'.($dealers_garden_center ?? 'Garden_center').'</td>
<td>'.($responses['garden_center'] == 0 ? $general_no : $general_yes).'</td>
</tr>
<tr>
<td style="width:25%;">'.($dealers_brand_type ?? 'Brand_type').'</td>
<td>'.${'brand_type_'.$responses['brand_type']}.'</td>
</tr>
<tr>
<td style="width:25%;">'.($dealers_showroom_size ?? 'Showroom_size').'</td>
<td>'.${'showroom_size_'.$responses['showroom_size']}.'</td>
</tr>
<tr>
<td style="width:25%;">'.($dealers_focus_offering ?? 'focus_offering').'</td>
<td>'.${'focus_offering_'.$responses['focus_offering']}.'</td>
</tr>
<tr>
<td style="width:25%;">'.($dealers_type ?? 'dealer_type').'</td>
<td>'.${'dealer_type_'.$responses['dealer_type']}.'</td>
</tr>
<tr>
<td style="width:25%;">'.($dealers_locations ?? 'dealer_locations').'</td>
<td>'.($responses['locations'] == 0 ? $general_no : $general_yes).'</td>
</tr>
</table>
</div>
</div>
';
//OUTPUT
echo $view;
template_footer()
?>

411
dealer_manage.php Normal file
View File

@@ -0,0 +1,411 @@
<?php
defined(page_security_key) or exit;
$page = 'dealer_manage';
//Check if allowed
if (isAllowed($page,$_SESSION['profile'],$_SESSION['permission'],'R') === 0){
header('location: index.php');
exit;
}
//PAGE Security
$update_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],'U');
$delete_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],'D');
$create_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],'C');
if (isset($_GET['rowID']) && $_GET['rowID'] !=''){
$url = 'index.php?page=dealer&rowID='.$_GET['rowID'];
} else {
$url = 'index.php?page=dealers';
}
// Default input dealer values
$responses = [
'rowID' => '',
'name' => '',
'status' => '',
'usp1' => '',
'usp2' => '',
'usp3' => '',
'short_description' => '',
'long_description' => '',
'address' => '',
'postalcode' => '',
'city' => '',
'state' => '',
'country' => '',
'email' => '',
'phone' => '',
'opening_hours' => [
1 => ['start' => '09:00', 'end' => '17:00'], // Monday
2 => ['start' => '09:00', 'end' => '17:00'], // Tuesday
3 => ['start' => '09:00', 'end' => '17:00'], // Wednesday
4 => ['start' => '09:00', 'end' => '17:00'], // Thursday
5 => ['start' => '09:00', 'end' => '17:00'], // Friday
6 => ['start' => '09:00', 'end' => '20:00'], // Saturday
7 => null // Sunday - Closed
],
'lat' => '',
'lng' => '',
'url' => '',
'rating_overall' => '',
'rating_website' => '',
'garden_center' => '',
'brand_type' => '',
'showroom_size' => '',
'locations' => '',
'focus_offering' => '',
'dealer_type' => '',
'dealer_slug' => '',
'dealer_media' => '',
'full_path' =>'',
'created' => '',
'createdby' => $_SESSION['username'],
'updated' => '',
'updatedby' => ''
];
if (isset($_GET['rowID'])) {
// ID param exists, edit an existing dealer
//CALL TO API
$api_url = '/v2/dealers/rowID='.$_GET['rowID'];
$responses = ioServer($api_url,'');
//Decode Payload
if (!empty($responses)){$responses = json_decode($responses,true);}else{$responses = null;}
$responses = $responses[0];
//CALL TO MEDIA API
$api_url = '/v2/media/list=dealer_image';
$media_responses = ioServer($api_url,'');
//Decode Payload
if (!empty($media_responses)){$media_responses = json_decode($media_responses,true);}else{$media_responses = null;}
if ($update_allowed === 1){
if (isset($_POST['submit'])) {
//GET ALL POST DATA
$payload = json_encode($_POST, JSON_UNESCAPED_UNICODE);
//API call
$responses = ioServer('/v2/dealers', $payload);
if ($responses === 'NOK'){
} else {
header('Location: index.php?page=dealer&rowID='.$_GET['rowID'].'&success_msg=2');
exit;
}
}
}
if ($delete_allowed === 1){
if (isset($_POST['delete'])) {
//GET ALL POST DATA
$payload = json_encode($_POST, JSON_UNESCAPED_UNICODE);
//API call
$responses = ioServer('/v2/dealers', $payload);
if ($responses === 'NOK'){
} else {
// Redirect and delete dealer
header('Location: index.php?page=dealers&success_msg=3');
exit;
}
}
}
} else {
// Create a new dealer
if (isset($_POST['submit']) && $create_allowed === 1) {
//GET ALL POST DATA
$payload = json_encode($_POST , JSON_UNESCAPED_UNICODE);
//API call
$responses = ioServer('/v2/dealers', $payload);
if ($responses === 'NOK'){
}
else {
header('Location: index.php?page=dealers&success_msg=1');
exit;
}
}
}
template_header('Dealer', 'dealer', 'manage');
$view ='
<form action="" method="post">
<div class="content-title responsive-flex-wrap responsive-pad-bot-3">
<h2 class="responsive-width-100">'.($dealers_h2 ?? 'Dealer').' '.$responses['name'].'</h2>
<a href="'.$url.'" class="btn alt mar-right-2">'.$button_cancel.'</a>
';
if ($delete_allowed === 1){
$view .= '<input type="submit" name="delete" value="Delete" class="btn red mar-right-2" onclick="return confirm(\'Are you sure you want to delete this dealer?\')">';
}
if ($update_allowed === 1){
$view .= '<input type="submit" name="submit" value="Save" class="btn">';
}
$view .= '</div>';
$view .= '<div class="tabs">
<a href="#" class="active">'.($view_dealers_information ?? 'Dealer information').'</a>
<a href="#">'.($view_dealer_details_1 ?? 'Descriptions').'</a>
<a href="#">'.($view_dealer_details_3 ?? 'Location').'</a>
<a href="#">'.($dealers_openinghours ?? 'opening_hours').'</a>
<a href="#">'.($view_dealer_details_2 ?? 'Settings').'</a>
<a href="#">'.$tab3.'</a>
</div>
';
$view .= '<div class="content-block tab-content active">
<div class="form responsive-width-100">
<label for="status">'.$dealers_status.'</label>
<select id="status" name="status">
<option value="1" '.($responses['status']==1?' selected':'').'>'.$general_status_1 .'</option>
<option value="0" '.($responses['status']==0?' selected':'').'>'.$general_status_0 .'</option>
</select>
</div>
<div class="form responsive-width-100">
<label for="dealername"><i class="required">*</i>'.$dealers_name.'</label>
<input id="name" type="text" name="name" placeholder="'.$dealers_name.'" value="'.$responses['name'].'" required>
</div>
<div class="form responsive-width-100">
<label for=""><i class="required">*</i>'.($dealers_slug ?? 'dealer_slug').'</label>
<input id="name" type="text" name="dealer_slug" placeholder="'.($dealers_slug ?? 'dealer_slug').'" value="'.$responses['dealer_slug'].'">
</div>
<div class="form responsive-width-100">
<input id="source_'.$responses['rowID'].'" type="hidden" name="dealer_media" value="'.$responses['dealer_media'].'">
<img id="image_'.$responses['rowID'].'" src="'.$responses['full_path'].'" alt="" style="display: block; max-width: 75px;">
<button type="button" class="btn" id="openSelectorBtn" onclick="setSourceID(\''.$responses['rowID'].'\'), openDialog(\'image_'.$responses['rowID'].'\')">'.($button_assign_image ?? 'Assign Image').'</button>
</div>
</div>';
if (isset($_GET['rowID'])){
$view .= '<input type="hidden" name="rowID" value="'.(encodeUuid($responses['rowID']) ?? '').'">';
}
$view .= '<div class="content-block tab-content">
<div class="form responsive-width-100">
<label for="dealerdescription">'.($dealers_short_description ?? 'short').'</label>
<textarea id="description" name="short_description" placeholder="'.($dealers_short_description ?? 'short').'">'.$responses['short_description'].'</textarea>
</div>
<div class="form responsive-width-100">
<label for="dealerdescription">'.($dealers_long_description ?? 'long').'</label>
<textarea id="description" name="long_description" placeholder="'.($dealers_long_description ?? 'long').'">'.$responses['long_description'].'</textarea>
</div>
<div class="form responsive-width-100">
<label for="dealerdescription">'.($dealers_usp1 ?? 'usp').'</label>
<textarea id="description" name="usp1" placeholder="'.($dealers_usp1 ?? 'usp').'">'.$responses['usp1'].'</textarea>
</div>
<div class="form responsive-width-100">
<label for="dealerdescription">'.($dealers_usp2 ?? 'usp').'</label>
<textarea id="description" name="usp2" placeholder="'.($dealers_usp2 ?? 'usp').'">'.$responses['usp2'].'</textarea>
</div>
<div class="form responsive-width-100">
<label for="dealerdescription">'.($dealers_usp3 ?? 'usp').'</label>
<textarea id="description" name="usp3" placeholder="'.($dealers_usp3 ?? 'usp').'">'.$responses['usp3'].'</textarea>
</div>
</div>';
$view .= '<div class="content-block tab-content">
<div class="form responsive-width-100">
<label for="">'.($dealers_address ?? 'address').'</label>
<input name="address" type="text" value="'.$responses['address'].'">
</div>
<div class="form responsive-width-100">
<label for="">'.($dealers_postalcode ?? 'postalcode').'</label>
<input name="postalcode" type="text" value="'.$responses['postalcode'].'">
</div>
<div class="form responsive-width-100">
<label for="">'.($dealers_city ?? 'city').'</label>
<input name="city" type="text" value="'.$responses['city'].'" required>
</div>
<div class="form responsive-width-100">
<label for="">'.($dealers_state ?? 'state').'</label>
<input name="state" type="text" value="'.$responses['state'].'">
</div>
<div class="form responsive-width-100">
<label for="">'.($dealers_country ?? 'country').'</label>
<input name="country" type="text" value="'.$responses['country'].'">
</div>
<div class="form responsive-width-100">
<label for="">'.($dealers_email ?? 'email').'</label>
<input name="email" type="text" value="'.$responses['email'].'">
</div>
<div class="form responsive-width-100">
<label for="">'.($dealers_phone ?? 'phone').'</label>
<input name="phone" type="text" value="'.$responses['phone'].'">
</div>
<div class="form responsive-width-100">
<label for="">'.($dealers_url ?? 'url').'</label>
<input name="url" type="text" value="'.$responses['url'].'">
</div>
<div class="form responsive-width-100">
<label for="">'.($dealers_lat.' - '.$dealers_lng ?? 'geolocation').'</label>
<input name="lat" type="text" value="'.$responses['lat'].'">
<input name="lng" type="text" value="'.$responses['lng'].'">
</div>
</div>';
$view .= '<div class="content-block tab-content">
<div class="form responsive-width-100">
<table>';
$opening_hours = is_string($responses['opening_hours']) ? json_decode($responses['opening_hours'],true) : $responses['opening_hours'];
foreach ($opening_hours as $day => $value){
$view .= '<tr>
<td style="width:25%;">'.(${'general_day_'.$day} ?? 'Not specified').'</td>
<td>
'.($general_from ?? 'From').' <input type="time" id="start_'.$day.'" name="'.(isset($value['start']) ? 'opening_hours['.$day.'][start]' : '').'" value="'.(isset($value['start']) ? $value['start'] : '09:00').'" '.(isset($value['start']) ? '' : 'disabled').'>
'.($general_from ?? 'To').' <input type="time" id="end_'.$day.'" name="'.(isset($value['end']) ? 'opening_hours['.$day.'][end]' : '').'" value="'.(isset($value['end']) ? $value['end'] : '18:00').'" '.(isset($value['end']) ? '' : 'disabled').'>
</td>
<td>
'.($general_closed ?? 'Closed').'<input type="checkbox" id="closed_'.$day.'" onchange="toggleClosed('.$day.')" '.(isset($value['end']) ? '' : 'checked').'>
'.(isset($value['end']) ? '' : '<input type="hidden" id="null_'.$day.'" name="opening_hours['.$day.']" value="null">').'
</td>
</tr>';
}
$view .='
</table>
</div>
</div>';
$view .= '
<div class="content-block tab-content">
<div class="form responsive-width-100">
<label for="status">'.($dealers_garden_center ?? 'Garden_center').'</label>
<select id="status" name="garden_center">
<option value="1" '.($responses['garden_center']==1?' selected':'').'>'.$general_yes .'</option>
<option value="0" '.($responses['garden_center']==0?' selected':'').'>'.$general_no .'</option>
</select>
</div>
<div class="form responsive-width-100">
<label for="status">'.($dealers_brand_type ?? 'Brand_type').'</label>
<select id="status" name="brand_type">
<option value="0" '.($responses['brand_type']==0?' selected':'').'>'.$brand_type_0.'</option>
<option value="1" '.($responses['brand_type']==1?' selected':'').'>'.$brand_type_1.'</option>
</select>
</div>
<div class="form responsive-width-100">
<label for="status">'.($dealers_showroom_size ?? 'Showroom_size').'</label>
<select id="status" name="showroom_size">
<option value="0" '.($responses['showroom_size']==0?' selected':'').'>'.$showroom_size_0.'</option>
<option value="1" '.($responses['showroom_size']==1?' selected':'').'>'.$showroom_size_1.'</option>
<option value="2" '.($responses['showroom_size']==2?' selected':'').'>'.$showroom_size_2.'</option>
</select>
</div>
<div class="form responsive-width-100">
<label for="status">'.($dealers_focus_offering ?? 'focus_offering').'</label>
<select id="status" name="focus_offering">
<option value="0" '.($responses['focus_offering']==0?' selected':'').'>'.$focus_offering_0.'</option>
<option value="1" '.($responses['focus_offering']==1?' selected':'').'>'.$focus_offering_1.'</option>
</select>
</div>
<div class="form responsive-width-100">
<label for="status">'.($dealers_type ?? 'dealer_type').'</label>
<select id="status" name="dealer_type">
<option value="0" '.($responses['dealer_type']==0?' selected':'').'>'.$dealer_type_0.'</option>
<option value="1" '.($responses['dealer_type']==1?' selected':'').'>'.$dealer_type_1.'</option>
<option value="2" '.($responses['dealer_type']==2?' selected':'').'>'.$dealer_type_2.'</option>
</select>
</div>
<div class="form responsive-width-100">
<label for="status">'.($dealers_locations ?? 'dealer_locations').'</label>
<select id="status" name="locations">
<option value="1" '.($responses['locations']==1?' selected':'').'>'.$general_yes .'</option>
<option value="0" '.($responses['locations']==0?' selected':'').'>'.$general_no .'</option>
</select>
</div>
</div>';
$view .= '<div class="content-block tab-content">
<div class="form responsive-width-100">
<label for="dealercode">'.$general_created.'</label>
<input id="name" type="text" name="" placeholder="'.$general_created.'" value="'.$responses['created'].'" readonly>
<label for="dealercode">'.$general_createdby.'</label>
<input id="name" type="text" name="" placeholder="'.$general_createdby.'" value="'.$responses['createdby'].'" readonly>
<label for="dealercode">'.$general_updated.'</label>
<input id="name" type="text" name="" placeholder="'.$general_updated.'" value="'.$responses['updated'].'" readonly>
<label for="dealercode">'.$general_updatedby.'</label>
<input id="name" type="text" name="" placeholder="'.$general_updatedby.'" value="'.$responses['updatedby'].'" readonly>';
if (isset($responses['url']) && $responses['url'] !=''){
$view .= '<a href="index.php?page=media_scanner&domain='.$responses['url'].'&rowID='.encodeUuid($responses['rowID']).'" class="btn">'.($button_media_scanner ?? 'media_scanner').'</a>';
}
$view .= '
</div>
</div>';
$view .= '</form>';
$view .= '<!-- Image Selector Dialog -->
<dialog id="imageSelector" style="padding: 20px; max-width: 800px;">
<h3>Select an Image</h3>
<div style="display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 20px 0;">';
if (isset($media_responses) && is_array($media_responses)){
foreach ($media_responses as $media_response){
$view .= '
<img src="'.$media_response['full_path'].'" id="'.$media_response['rowID'].'" title="'.$media_response['title'].'" alt="'.$media_response['title'].'" style="width: 100%; cursor: pointer; border: 2px solid transparent;" onmouseover="this.style.border=\'2px solid #4CAF50\'" onmouseout="this.style.border=\'2px solid transparent\'" onclick="selectImage(this.id,this.src)">
';
}
}
$view .= '</div>
<button onclick="closeImageSelector()">Close</button>
</dialog>
';
$view .= '<script>
//POPUP FOR IMAGE SELECTION
const dialog = document.getElementById(\'imageSelector\');
image_source_id = 0;
//const openButton = document.getElementById(\'openSelectorBtn\');
function setSourceID(sourceid){
image_source_id = "source_"+sourceid;
image_source_src = "image_"+sourceid;
}
function openDialog(){
dialog.showModal();
}
function selectImage(id,src) {
if (image_source_id != 0){
const selectedImageInput = document.getElementById(image_source_id);
const previewImage = document.getElementById(image_source_src);
selectedImageInput.value = id;
previewImage.src = src;
}
else {
const selectedImageInput = document.getElementById(\'selectedImage\');
const previewImage = document.getElementById(\'previewImage\');
selectedImageInput.value = id;
previewImage.src = src;
previewImage.style.display = \'block\';
}
dialog.close();
}
function closeImageSelector() {
dialog.close();
}
</script>';
//Output
echo $view;
template_footer()?>

View File

@@ -21,8 +21,9 @@ if (isAllowed($page,$_SESSION['profile'],$_SESSION['permission'],'R') === 0){
}
//GET PARAMETERS
$pagination_page = isset($_GET['p']) ? $_GET['p'] : 1;
$search = isset($_GET['search']) ? '&search='.$_GET['search'] : '';
$pagination_page = $_SESSION['p'] = isset($_GET['p']) ? $_GET['p'] : 1;
$search = $_SESSION['search'] = isset($_GET['search']) ? '&search='.$_GET['search'] : '';
$partnerid = $_SESSION['partnerid'] = isset($_GET['partnerid']) ? '&partnerid='.$_GET['partnerid'] : '';
// Determine the URL
$url = 'index.php?page=dealers'.$search;
@@ -76,7 +77,7 @@ $view .= ' <div class="msg success">
$view .= '
<div class="content-header responsive-flex-column pad-top-5">
<a href="index.php?page=dealers_manage" class="btn">'.($button_create_dealers ?? 'Create dealer').'</a>
<a href="index.php?page=dealer_manage" class="btn">'.($button_create_dealers ?? 'Create dealer').'</a>
</div>
<div class="content-block">
<div class="table">
@@ -97,22 +98,23 @@ $view .= '
</tr>';
}
else {
foreach ($dealers as $order){
foreach ($dealers as $dealer){
//Translate status INT to STR
$payment_status = 'general_status_'.$dealer['status'];
$dealer_status = 'general_status_'.$dealer['status'];
$view .= '
<tr>
<td>'.$dealer['id'].'</td>
<td>'.(${$dealer_status} ?? $dealer['status']).'</td>
<td>'.$dealer['rowID'].'</td>
<td>'.(${$dealer_status} ?? $dealer_status).'</td>
<td>'.$dealer['name'].'</td>
<td class="responsive-hidden">'.getRelativeTime($dealer['created']).'</td>
<td><a href="index.php?page=dealer&id='.$dealer['id'].'" class="btn_link">'.$general_view.'</a></td>
<td><a href="index.php?page=dealer&id='.encodeUuid($dealer['rowID']).'" class="btn_link">'.$general_view.'</a></td>
</tr>';
}
}
$view .= '
</tbody>
</table>

View File

@@ -37,6 +37,9 @@ if ($update_allowed === 1){
if (isset($_POST['generatefile'])){
generateLanguageFile($_POST['language'],$_SESSION['userkey']);
}
if (isset($_POST['generateDealerInformation'])){
generateDealerInformation($_SESSION['userkey']);
}
}
// Handle success messages
@@ -86,6 +89,10 @@ $view .= '<div class="content-block tab-content active">
<label for="service">GeoUpdate</label>
<input type="submit" name="geoupdate" style="width: 15%;" value="GeoUpdate" class="btn">
</div>
<div class="form responsive-width-100">
<label for="service">GenerateDealerInfo</label>
<input type="submit" name="generateDealerInformation" style="width: 15%;" value="DealerInfo" class="btn">
</div>
</div>
</div>';
}

View File

@@ -25,6 +25,10 @@ $create_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],
$pagination_page = isset($_GET['p']) ? $_GET['p'] : 1;
$search = isset($_GET['search']) ? '&search='.$_GET['search'] : '';
//SET PAGE ORIGIN FOR NAVIGATION AND SECURITY
$prev_page = $_SESSION['prev_origin'] ?? '';
$page = $_SESSION['origin'] = 'media';
// Determine the URL
$url = 'index.php?page='.$page.$search;
//GET Details from URL
@@ -103,9 +107,12 @@ $view .= ' <div class="msg success">
}
$view .= '
<div class="content-header responsive-flex-column pad-top-5">';
if ($create_allowed ===1 && isAllowed('media_scanner' ,$_SESSION['profile'],$_SESSION['permission'],'C') === 1){
$view .= '<a href="index.php?page=media_scanner" class="btn">'.($button_media_scanner ?? 'media_scanner').'</a>';
}
if ($create_allowed ===1){
$view .= '
<form action="" method="post" enctype="multipart/form-data">
<input type="file" onchange="this.form.submit()" name="fileToUpload[]" id="fileToUpload" accept=".png, .PNG, .jpg,.JPG,.jpeg,.JPEG" style="width: 30%;padding: 50px 0 0 0;height: 10px;" multiple>
</form>';

528
media_scanner.php Normal file
View File

@@ -0,0 +1,528 @@
<?php
defined(page_security_key) or exit;
$page = 'media_scanner';
//Check if allowed
if (isAllowed($page,$_SESSION['profile'],$_SESSION['permission'],'R') === 0){
header('location: index.php');
exit;
}
//PAGE Security
$update_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],'U');
$delete_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],'D');
$create_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],'C');
// Check if domain is passed in URL
$autoFetchDomain = isset($_GET['domain']) ? $_GET['domain'] : '';
// check if rowID is passed in url
$autoFetchRowID = isset($_GET['rowID']) ? $_GET['rowID'] : '';
if ($autoFetchRowID != ''){
$_SESSION['autoFetchRowID'] = $_GET['rowID'];
}
// This variable will be used in the JavaScript to trigger auto-fetch
$autoFetch = !empty($autoFetchDomain);
if ($create_allowed === 1){
// Check if this is an AJAX request for fetching images
if (isset($_POST['action']) && $_POST['action'] === 'fetch_images') {
header('Content-Type: application/json');
$domain = isset($_POST['domain']) ? $_POST['domain'] : '';
// Validate domain
if (empty($domain)) {
echo json_encode(['error' => 'Please provide a valid domain']);
exit;
}
// Add http:// if not present
if (!preg_match('~^(?:f|ht)tps?://~i', $domain)) {
$domain = 'http://' . $domain;
}
// Try to get the content from the domain
try {
$context = stream_context_create([
'http' => [
'timeout' => 30,
'user_agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
]
]);
$content = @file_get_contents($domain, false, $context);
if ($content === false) {
echo json_encode(['error' => 'Could not access the domain']);
exit;
}
// Create a DOM object
$dom = new DOMDocument();
// Suppress warnings from invalid HTML
@$dom->loadHTML($content);
// Extract all image elements
$images = $dom->getElementsByTagName('img');
$imageUrls = [];
foreach ($images as $image) {
$src = $image->getAttribute('src');
// Skip empty sources
if (empty($src)) {
continue;
}
// Handle relative URLs
if (strpos($src, 'http') !== 0) {
// If src starts with //, add http:
if (strpos($src, '//') === 0) {
$src = 'http:' . $src;
}
// If src starts with /, add domain
elseif (strpos($src, '/') === 0) {
$parsedUrl = parse_url($domain);
$baseUrl = $parsedUrl['scheme'] . '://' . $parsedUrl['host'];
$src = $baseUrl . $src;
}
// Otherwise, assume it's a relative path
else {
$parsedUrl = parse_url($domain);
$baseUrl = $parsedUrl['scheme'] . '://' . $parsedUrl['host'];
$path = isset($parsedUrl['path']) ? $parsedUrl['path'] : '';
// Remove filename from path if it exists
$path = preg_replace('/\/[^\/]*$/', '/', $path);
$src = $baseUrl . $path . $src;
}
}
// Add to our list of URLs if it's not already there
if (!in_array($src, $imageUrls)) {
$imageUrls[] = $src;
}
}
// Return the list of images
echo json_encode(['images' => $imageUrls]);
} catch (Exception $e) {
echo json_encode(['error' => 'Error: ' . $e->getMessage()]);
exit;
}
// Important: exit after sending JSON to avoid sending HTML too
exit;
}
// Check if this is an AJAX request for uploading images
if (isset($_SERVER['CONTENT_TYPE']) && strpos($_SERVER['CONTENT_TYPE'], 'application/json') !== false) {
header('Content-Type: application/json');
// Get the raw POST data and decode the JSON
$jsonData = file_get_contents('php://input');
$data = json_decode($jsonData, true);
// Check if we have images to process
if (!isset($data['images']) || empty($data['images'])) {
echo json_encode(['error' => 'No images provided']);
exit;
}
// Directory to save images
$uploadDir = 'assets/images/media/';
$successCount = 0;
$errorMessages = [];
// Process each image URL
foreach ($data['images'] as $imageUrl) {
// Generate a unique filename
$fileTitle = uniqid() . '_' . basename(parse_url($imageUrl, PHP_URL_PATH));
$fileName = $uploadDir . $fileTitle;
// Clean the filename to avoid security issues
//$fileName = preg_replace('/[^a-zA-Z0-9_.-]/', '_', $fileName);
try {
// Create a context with a timeout for file_get_contents
$context = stream_context_create([
'http' => [
'timeout' => 30,
'user_agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
]
]);
// Fetch the image
$imageContent = @file_get_contents($imageUrl, false, $context);
if ($imageContent === false) {
$errorMessages[] = "Failed to download: $imageUrl";
continue;
}
// Save the image
if (file_put_contents($fileName, $imageContent)) {
//STORE MEDIA DATA
$payload = [
'title' => $fileTitle,
'full_path' => $fileName
];
$payload = json_encode($payload, JSON_UNESCAPED_UNICODE);
//API call
$responses = ioServer('/v2/media', $payload);
$inserted_media = json_decode($responses,true);
//STORE MEDIA RELATED TO DEALER WHEN ROWID IS SEND
if (isset($_SESSION['autoFetchRowID']) && $inserted_media['rowID'] !=''){
$dealer_id = $_SESSION['autoFetchRowID'];
$payload_2 = json_encode(array("rowID" => $dealer_id, "dealer_media" => $inserted_media['rowID']), JSON_UNESCAPED_UNICODE);
//API call
ioServer('/v2/dealers', $payload_2);
}
$successCount++;
} else {
$errorMessages[] = "Failed to save: $imageUrl";
}
} catch (Exception $e) {
$errorMessages[] = "Error processing $imageUrl: " . $e->getMessage();
}
}
// Return the results
$result = [
'success' => $successCount,
'total' => count($data['images'])
];
if (!empty($errorMessages)) {
$result['errors'] = $errorMessages;
}
//RESET S_SESSION VARIABLE
if (isset($_SESSION['autoFetchRowID'])){
unset($_SESSION['autoFetchRowID']);
}
echo json_encode($result);
exit;
}
}
template_header('Media_scanner', 'media_scanner', 'manage');
$view ='
<style>
.container {
max-width: 1200px;
margin: 0 auto;
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
.domain-input {
flex-grow: 1;
margin-right: 10px;
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 16px;
}
.gallery {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 15px;
margin-top: 20px;
}
.thumbnail {
position: relative;
height: 150px;
border: 1px solid #ddd;
overflow: hidden;
cursor: pointer;
border-radius: 4px;
transition: transform 0.2s;
}
.thumbnail:hover {
transform: scale(1.03);
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.thumbnail img {
width: 100%;
height: 100%;
object-fit: cover;
}
.thumbnail.selected {
border: 3px solid #4CAF50;
}
.thumbnail-overlay {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: rgba(0,0,0,0.5);
color: white;
padding: 5px;
font-size: 12px;
text-align: center;
opacity: 0;
transition: opacity 0.3s;
}
.thumbnail:hover .thumbnail-overlay {
opacity: 1;
}
.selected-count {
background-color: #333;
color: white;
padding: 5px 10px;
border-radius: 15px;
margin-left: 10px;
}
.status {
margin-top: 10px;
padding: 10px;
border-radius: 4px;
}
.status.success {
background-color: #dff0d8;
color: #3c763d;
}
.status.error {
background-color: #f2dede;
color: #a94442;
}
.loading {
display: none;
text-align: center;
margin: 20px 0;
}
.spinner {
border: 5px solid #f3f3f3;
border-top: 5px solid #4CAF50;
border-radius: 50%;
width: 40px;
height: 40px;
animation: spin 1s linear infinite;
margin: 0 auto;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
</head>
<body>
<div class="content-title responsive-flex-wrap responsive-pad-bot-3">
<h2 class="responsive-width-100">Media scanner</h2>
<a href="index.php?page='.$_SESSION['origin'].'" class="btn alt mar-right-2">'.$button_cancel.'</a>
</div>
<div class="container">
<div class="header" '.(($autoFetch) ? 'style="display:none;"' : '').'>
<input type="text" class="domain-input" id="domainInput" placeholder="Enter domain (e.g., example.com)" '.(($autoFetch) ? 'value="'.htmlspecialchars($autoFetchDomain).'"' : '').'/>
<button id="fetchBtn" class="btn">Fetch Images</button>
</div>
<div class="loading" id="loadingIndicator">
<div class="spinner"></div>
<p>Loading images...</p>
</div>
<div id="statusMessage"></div>
<div class="gallery" id="imageGallery"></div>
<div class="header" style="margin-top: 20px;">
<button id="uploadBtn" class="btn" disabled>Upload Selected Images <span id="selectedCount" class="selected-count">0</span></button>
</div>
</div>
<script>
document.addEventListener(\'DOMContentLoaded\', function() {
const domainInput = document.getElementById(\'domainInput\');
const fetchBtn = document.getElementById(\'fetchBtn\');
const uploadBtn = document.getElementById(\'uploadBtn\');
const imageGallery = document.getElementById(\'imageGallery\');
const statusMessage = document.getElementById(\'statusMessage\');
const selectedCount = document.getElementById(\'selectedCount\');
const loadingIndicator = document.getElementById(\'loadingIndicator\');
let selectedImages = [];
';
if ($autoFetch){
// Automatically trigger fetch when page loads with domain parameter
// Small delay to ensure DOM is fully loaded
$view .= 'setTimeout(function() {fetchBtn.click();}, 500)';
}
$view .= '
// Fetch images from domain
fetchBtn.addEventListener(\'click\', function() {
const domain = domainInput.value.trim();
if (!domain) {
showStatus(\'Please enter a valid domain\', \'error\');
return;
}
// Reset state
imageGallery.innerHTML = \'\';
selectedImages = [];
updateSelectedCount();
uploadBtn.disabled = true;
// Show loading indicator
loadingIndicator.style.display = \'block\';
showStatus(\'\', \'\');
// Key change: send to the current page but with a special parameter
fetch(window.location.href, {
method: \'POST\',
headers: {
\'Content-Type\': \'application/x-www-form-urlencoded\',
},
body: \'action=fetch_images&domain=\' + encodeURIComponent(domain)
})
.then(response => response.json())
.then(data => {
loadingIndicator.style.display = \'none\';
if (data.error) {
showStatus(data.error, \'error\');
return;
}
if (!data.images || data.images.length === 0) {
showStatus(\'No images found on this domain\', \'error\');
return;
}
showStatus(`Found ${data.images.length} images`, \'success\');
// Create thumbnails
data.images.forEach((imageUrl, index) => {
const thumbnail = document.createElement(\'div\');
thumbnail.className = \'thumbnail\';
thumbnail.dataset.url = imageUrl;
const img = document.createElement(\'img\');
img.src = imageUrl;
img.alt = `Image ${index + 1}`;
img.onerror = function() {
// Replace with placeholder if image fails to load
this.src = \'https://via.placeholder.com/200x150?text=Image+Error\';
};
const overlay = document.createElement(\'div\');
overlay.className = \'thumbnail-overlay\';
overlay.textContent = \'Click to select\';
thumbnail.appendChild(img);
thumbnail.appendChild(overlay);
imageGallery.appendChild(thumbnail);
// Add click event to select/deselect
thumbnail.addEventListener(\'click\', function() {
this.classList.toggle(\'selected\');
const imageUrl = this.dataset.url;
const index = selectedImages.indexOf(imageUrl);
if (index === -1) {
selectedImages.push(imageUrl);
this.querySelector(\'.thumbnail-overlay\').textContent = \'Selected\';
} else {
selectedImages.splice(index, 1);
this.querySelector(\'.thumbnail-overlay\').textContent = \'Click to select\';
}
updateSelectedCount();
});
});
uploadBtn.disabled = false;
})
.catch(error => {
loadingIndicator.style.display = \'none\';
showStatus(\'Error fetching images: \' + error.message, \'error\');
});
});
// Upload selected images
uploadBtn.addEventListener(\'click\', function() {
if (selectedImages.length === 0) {
showStatus(\'Please select at least one image\', \'error\');
return;
}
showStatus(\'Uploading images...\', \'success\');
loadingIndicator.style.display = \'block\';
fetch(window.location.href, {
method: \'POST\',
headers: {
\'Content-Type\': \'application/json\',
},
body: JSON.stringify({ images: selectedImages })
})
.then(response => response.json())
.then(data => {
loadingIndicator.style.display = \'none\';
if (data.error) {
showStatus(data.error, \'error\');
return;
}
showStatus(`Successfully uploaded ${data.success} images`, \'success\');
// Clear selections after successful upload
document.querySelectorAll(\'.thumbnail.selected\').forEach(thumbnail => {
thumbnail.classList.remove(\'selected\');
thumbnail.querySelector(\'.thumbnail-overlay\').textContent = \'Click to select\';
});
selectedImages = [];
updateSelectedCount();
})
.catch(error => {
loadingIndicator.style.display = \'none\';
showStatus(\'Error uploading images: \' + error.message, \'error\');
});
});
// Helper functions
function updateSelectedCount() {
selectedCount.textContent = selectedImages.length;
uploadBtn.disabled = selectedImages.length === 0;
}
function showStatus(message, type) {
if (!message) {
statusMessage.innerHTML = \'\';
return;
}
statusMessage.innerHTML = message;
statusMessage.className = \'status \' + type;
}
});
</script>
';
//Output
echo $view;
template_footer();
?>

View File

@@ -6,7 +6,7 @@ define('superuser_profile','dashboard,profile,assets,equipments,equipment,equipm
/*Admin*/
define('admin_profile','dashboard,profile,buildtool,sales,accounts,account,contracts,contract,contract_manage,cartests,cartest,cartest_manage,assets,equipments,equipment,equipment_healthindex,equipment_data,equipment_manage,equipment_manage_edit,equipments_mass_update,histories,history,history_manage,firmwaretool,rmas,rma,rma_manage,rma_history,rma_history_manage,buildtool,products,products_versions,products_software,product,product_manage,servicereports,servicereport,admin,partners,partner,users,user,user_manage,communications,communication,communication_send,marketing,reporting,report_build,report_contracts_billing,report_healthindex,changelog,application');
/*AdminPlus*/
define('adminplus_profile','dashboard,profile,buildtool,sales,accounts,account,contracts,contract,contract_manage,billing,cartests,cartest,cartest_manage,assets,equipments,equipment,equipment_healthindex,equipment_data,equipment_manage,equipment_manage_edit,equipments_mass_update,histories,history,history_manage,firmwaretool,rmas,rma,rma_manage,rma_history,rma_history_manage,buildtool,products,products_versions,products_software,products_attributes,products_attributes_items,products_attributes_manage,products_configurations,products_categories,products_media,product,product_manage,pricelists,pricelists_items,pricelists_manage,catalog,categories,category,discounts,discount,shipping,shipping_manage,servicereports,servicereport,admin,partners,partner,users,user,user_manage,communications,communication,communication_send,marketing,reporting,report_build,report_contracts_billing,report_healthindex,report_usage,config,settings,logfile,changelog,language,translations,translations_details,translation_manage,media,media_manage,application,maintenance,uploader,profiles,vin,shopping_cart,checkout,placeorder,taxes,transactions,transactions_items,invoice,order,orders,identity');
define('adminplus_profile','dashboard,profile,buildtool,sales,accounts,account,contracts,contract,contract_manage,billing,cartests,cartest,cartest_manage,dealers,dealers_media,dealer,dealer_manage,assets,equipments,equipment,equipment_healthindex,equipment_data,equipment_manage,equipment_manage_edit,equipments_mass_update,histories,history,history_manage,firmwaretool,rmas,rma,rma_manage,rma_history,rma_history_manage,buildtool,products,products_versions,products_software,products_attributes,products_attributes_items,products_attributes_manage,products_configurations,products_categories,products_media,product,product_manage,pricelists,pricelists_items,pricelists_manage,catalog,categories,category,discounts,discount,shipping,shipping_manage,servicereports,servicereport,admin,partners,partner,users,user,user_manage,communications,communication,communication_send,marketing,reporting,report_build,report_contracts_billing,report_healthindex,report_usage,config,settings,logfile,changelog,language,translations,translations_details,translation_manage,media,media_manage,media_scanner,application,maintenance,uploader,profiles,vin,shopping_cart,checkout,placeorder,taxes,transactions,transactions_items,invoice,order,orders,identity');
/*Build*/
define('build','dashboard,profile,buildtool,firmwaretool,buildtool,products_software,application');
/*Commerce*/

View File

@@ -18,6 +18,7 @@ $all_views = [
"cartest",
"cartest_manage",
"dealers",
"dealers_media",
"dealer",
"dealer_manage",
"assets",
@@ -86,6 +87,7 @@ $all_views = [
"translation_manage",
"media",
"media_manage",
"media_scanner",
"application",
"maintenance",
"uploader",

View File

@@ -766,4 +766,45 @@ $button_reset = 'Zurücksetzen anfordern';
$password_new = 'Neues Passwort';
$password_check = 'Wiederhole das Passwort';
$button_password_update = 'Passwort aktualisieren';
$menu_dealers = 'Händler';
$dealers_id = '#';
$dealers_status = 'Status';
$dealers_name = 'Name';
$message_no_dealers = 'Es gibt keine Händler';
$message_dealers_1 = 'Erschaffen';
$message_dealers_2 = 'Aktualisiert';
$message_dealers_3 = 'Gelöscht';
$dealers_usp1 = 'Alleinstellungsmerkmal';
$dealers_usp2 = 'Alleinstellungsmerkmal';
$dealers_usp3 = 'Alleinstellungsmerkmal';
$dealers_short_description = 'Kurze Beschreibung';
$dealers_long_description = 'Beschreibung';
$dealers_address = 'Adresse';
$dealers_postalcode = 'Postleitzahl';
$dealers_city = 'Stadt';
$dealers_state = 'Bundesland';
$dealers_country = 'Land';
$dealers_lat = 'Breitengrad';
$dealers_lng = 'Längengrad';
$dealers_url = 'Webseite';
$dealers_rating_overall = 'Gesamtbewertung';
$dealers_rating_website = 'Website-Bewertung';
$dealers_garden_center = 'Gartenzentrum';
$dealers_brand_type = 'Markenart';
$dealers_showroom_size = 'Ausstellungsraumgröße';
$dealers_locations = 'Standorte';
$dealers_focus_offering = 'Angebot';
$dealers_type = 'Händlerart';
$dealers_slug = 'Slug';
$dealers_media = 'Medien';
$brand_type_0 = 'Einzelmarke';
$brand_type_1 = 'Multi-Marke';
$showroom_size_0 = 'Normal';
$showroom_size_1 = 'Groß';
$showroom_size_2 = 'Extra groß';
$focus_offering_0 = 'Economy - Premium';
$focus_offering_1 = 'Premium - Highend';
$dealer_type_0 = 'Lokal';
$dealer_type_1 = 'Professionell';
$dealer_type_2 = 'Unternehmens';
?>

View File

@@ -772,4 +772,45 @@ $button_reset = 'Solicitar restablecimiento';
$password_new = 'Nueva contraseña';
$password_check = 'Repite la contraseña';
$button_password_update = 'Actualizar contraseña';
$menu_dealers = 'Distribuidores';
$dealers_id = '#';
$dealers_status = 'Estado';
$dealers_name = 'Nombre';
$message_no_dealers = 'No hay distribuidores';
$message_dealers_1 = 'Creado';
$message_dealers_2 = 'Actualizado';
$message_dealers_3 = 'Eliminado';
$dealers_usp1 = 'Punto de venta único';
$dealers_usp2 = 'Punto de venta único';
$dealers_usp3 = 'Punto de venta único';
$dealers_short_description = 'Descripción corta';
$dealers_long_description = 'Descripción';
$dealers_address = 'Dirección';
$dealers_postalcode = 'Código postal';
$dealers_city = 'Ciudad';
$dealers_state = 'Estado';
$dealers_country = 'País';
$dealers_lat = 'Latitud';
$dealers_lng = 'Longitud';
$dealers_url = 'Sitio web';
$dealers_rating_overall = 'Calificación general';
$dealers_rating_website = 'Calificación del sitio';
$dealers_garden_center = 'Centro de jardinería';
$dealers_brand_type = 'Tipo de marca';
$dealers_showroom_size = 'Tamaño del showroom';
$dealers_locations = 'Ubicaciones';
$dealers_focus_offering = 'Oferta';
$dealers_type = 'Tipo de distribuidor';
$dealers_slug = 'Slug';
$dealers_media = 'Medios';
$brand_type_0 = 'Marca única';
$brand_type_1 = 'Marca múltiple';
$showroom_size_0 = 'Normal';
$showroom_size_1 = 'Grande';
$showroom_size_2 = 'Extra grande';
$focus_offering_0 = 'Economía - Premium';
$focus_offering_1 = 'Premium - Alta gama';
$dealer_type_0 = 'Local';
$dealer_type_1 = 'Profesional';
$dealer_type_2 = 'Corporativo';
?>

View File

@@ -275,7 +275,7 @@ $User_pw_reset = 'Password reset';
$User_pw_login_count = 'Mislukte inlog pogingen';
$User_block = 'Geblokkeerd';
$User_unblock = 'Deblokkeer';
$reset_message = 'Password reset started => See your email inbox for further instructions, you will be redirected to the login page.';
$reset_message = 'Wachtwoordherstel gestart => Raadpleeg uw e-mail voor verdere instructies. U wordt doorgestuurd naar de inlogpagina.';
$reset_message2 = 'Resettoken not valid, you will be redirected';
$reset_message3 = 'Password minimal length of 6 characters';
$enabled = 'Actief';
@@ -978,4 +978,45 @@ $button_reset = 'Aanvraag reset';
$password_new = 'Nieuw wachtwoord';
$password_check = 'Herhaal wachtwoord';
$button_password_update = 'Wachtwoord bijwerken';
$menu_dealers = 'Dealers';
$dealers_id = '#';
$dealers_status = 'Status';
$dealers_name = 'Naam';
$message_no_dealers = 'Er zijn geen dealers';
$message_dealers_1 = 'Aangemaakt';
$message_dealers_2 = 'Bijgewerkt';
$message_dealers_3 = 'Verwijderd';
$dealers_usp1 = 'Uniek verkoopargument';
$dealers_usp2 = 'Uniek verkoopargument';
$dealers_usp3 = 'Uniek verkoopargument';
$dealers_short_description = 'Korte beschrijving';
$dealers_long_description = 'Beschrijving';
$dealers_address = 'Adres';
$dealers_postalcode = 'Postcode';
$dealers_city = 'Stad';
$dealers_state = 'Staat';
$dealers_country = 'Land';
$dealers_lat = 'Breedtegraad';
$dealers_lng = 'Lengtegraad';
$dealers_url = 'Website';
$dealers_rating_overall = 'Algemeen cijfer';
$dealers_rating_website = 'Website beoordeling';
$dealers_garden_center = 'Tuincentrum';
$dealers_brand_type = 'Merktype';
$dealers_showroom_size = 'Showroomgrootte';
$dealers_locations = 'Locaties';
$dealers_focus_offering = 'Aanbod';
$dealers_type = 'Dealer type';
$dealers_slug = 'Slug';
$dealers_media = 'Media';
$brand_type_0 = 'Enkel merk';
$brand_type_1 = 'Meerdere merken';
$showroom_size_0 = 'Normaal';
$showroom_size_1 = 'Groot';
$showroom_size_2 = 'Extra groot';
$focus_offering_0 = 'Economisch - Premium';
$focus_offering_1 = 'Premium - Highend';
$dealer_type_0 = 'Lokaal';
$dealer_type_1 = 'Professioneel';
$dealer_type_2 = 'Bedrijf';
?>

View File

@@ -772,4 +772,45 @@ $button_reset = 'Solicitar redefiniçao';
$password_new = 'Nova senha';
$password_check = 'Repita a senha';
$button_password_update = 'Atualizar senha';
$menu_dealers = 'Revendedores';
$dealers_id = '#';
$dealers_status = 'Estado';
$dealers_name = 'Nome';
$message_no_dealers = 'Não há revendedores';
$message_dealers_1 = 'Criado';
$message_dealers_2 = 'Atualizado';
$message_dealers_3 = 'Excluído';
$dealers_usp1 = 'Ponto de venda único';
$dealers_usp2 = 'Ponto de venda único';
$dealers_usp3 = 'Ponto de venda único';
$dealers_short_description = 'Descrição curta';
$dealers_long_description = 'Descrição';
$dealers_address = 'Endereço';
$dealers_postalcode = 'Código postal';
$dealers_city = 'Cidade';
$dealers_state = 'Estado';
$dealers_country = 'País';
$dealers_lat = 'Latitude';
$dealers_lng = 'Longitude';
$dealers_url = 'Site web';
$dealers_rating_overall = 'Avaliação geral';
$dealers_rating_website = 'Avaliação do site';
$dealers_garden_center = 'Centro de jardinagem';
$dealers_brand_type = 'Tipo de marca';
$dealers_showroom_size = 'Tamanho do showroom';
$dealers_locations = 'Localizações';
$dealers_focus_offering = 'Oferta';
$dealers_type = 'Tipo de revendedor';
$dealers_slug = 'Slug';
$dealers_media = 'Mídia';
$brand_type_0 = 'Marca única';
$brand_type_1 = 'Marca múltipla';
$showroom_size_0 = 'Normal';
$showroom_size_1 = 'Grande';
$showroom_size_2 = 'Extra grande';
$focus_offering_0 = 'Econômico - Premium';
$focus_offering_1 = 'Premium - Alta gama';
$dealer_type_0 = 'Local';
$dealer_type_1 = 'Profissional';
$dealer_type_2 = 'Corporativo';
?>

View File

@@ -275,7 +275,7 @@ $User_pw_reset = 'Password reset';
$User_pw_login_count = 'Failed login attempts';
$User_block = 'Blocked';
$User_unblock = 'Deblock';
$reset_message = 'Password reset started => See your email inbox for further instructions, you will be redirected to the login page.';
$reset_message = 'Password reset started => See your email for further instructions, you will be redirected to the login page.';
$reset_message2 = 'Resettoken not valid, you will be redirected';
$reset_message3 = 'Password minimal length of 6 characters';
$enabled = 'Active';
@@ -983,4 +983,45 @@ $button_reset = 'Request reset';
$password_new = 'New Password';
$password_check = 'Repeat password';
$button_password_update = 'Update password';
$menu_dealers = 'Dealers';
$dealers_id = '#';
$dealers_status = 'Status';
$dealers_name = 'Name';
$message_no_dealers = 'There are no dealers';
$message_dealers_1 = 'Created';
$message_dealers_2 = 'Updated';
$message_dealers_3 = 'Deleted';
$dealers_usp1 = 'Unique selling point';
$dealers_usp2 = 'Unique selling point';
$dealers_usp3 = 'Unique selling point';
$dealers_short_description = 'Short description';
$dealers_long_description = 'Description';
$dealers_address = 'Address';
$dealers_postalcode = 'Postalcode';
$dealers_city = 'City';
$dealers_state = 'State';
$dealers_country = 'Country';
$dealers_lat = 'Latitude';
$dealers_lng = 'Longitude';
$dealers_url = 'Website';
$dealers_rating_overall = 'Overall rating';
$dealers_rating_website = 'Website rating';
$dealers_garden_center = 'Garden Center';
$dealers_brand_type = 'Brand type';
$dealers_showroom_size = 'Showroom size';
$dealers_locations = 'Locations';
$dealers_focus_offering = 'Offering';
$dealers_type = 'Dealer type';
$dealers_slug = 'Slug';
$dealers_media = 'Media';
$brand_type_0 = 'Single brand';
$brand_type_1 = 'Multi brand';
$showroom_size_0 = 'Normal';
$showroom_size_1 = 'Large';
$showroom_size_2 = 'Extra Large';
$focus_offering_0 = 'Economy - Premium';
$focus_offering_1 = 'Premium - Highend';
$dealer_type_0 = 'Local';
$dealer_type_1 = 'Professional';
$dealer_type_2 = 'Corporate';
?>

View File

@@ -86,6 +86,14 @@ if ($create_allowed === 1 && $_POST){
case 'dealers':
//SEND CONTENT TO API
$payload = json_encode($content, JSON_UNESCAPED_UNICODE);
//API call
$api_call = ioServer('/v2/dealers',$payload);
//returns results
$api_response = json_decode($api_call ,true);
//Provide feedback
$log_results[$content['name']] = $api_response['rowID'].' '.$api_response['status'];
break;
}
@@ -217,7 +225,6 @@ $view ='
const processingResults = document.getElementById(\'processingResults\');
const resultsContent = document.getElementById(\'resultsContent\');
const downloadCsvBtn = document.getElementById(\'downloadCsvBtn\');
const tableName = document.getElementById(\'table_name\').value;
// Convert pasted Excel data to HTML table
convertBtn.addEventListener(\'click\', function() {
@@ -283,6 +290,8 @@ $view ='
tableData.push(rowData);
});
// GET TABLE NAME
const tableName = document.getElementById(\'table_name\').value;
// Use standard form submission approach instead of JSON
const form = new FormData();