diff --git a/.DS_Store b/.DS_Store index 0909ec4..8a81c23 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/api.php b/api.php index 275713a..027a5a0 100644 --- a/api.php +++ b/api.php @@ -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'); diff --git a/api/v2/get/dealers.php b/api/v2/get/dealers.php index 74c71a4..05d462f 100644 --- a/api/v2/get/dealers.php +++ b/api/v2/get/dealers.php @@ -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); @@ -69,7 +75,12 @@ if (!empty($criterias)){ if ($key == 'search'){ $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); } @@ -82,7 +93,13 @@ 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); diff --git a/api/v2/get/dealers_media.php b/api/v2/get/dealers_media.php new file mode 100644 index 0000000..2f8a3bf --- /dev/null +++ b/api/v2/get/dealers_media.php @@ -0,0 +1,125 @@ +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; + } +} +?> \ No newline at end of file diff --git a/api/v2/post/dealers.php b/api/v2/post/dealers.php index d06fbd0..2fb9406 100644 --- a/api/v2/post/dealers.php +++ b/api/v2/post/dealers.php @@ -10,78 +10,394 @@ $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 -list($whereclause,$condition) = getWhereclause('',$permission,$partner,''); +//CHECK IF REQUEST IS FROM DEALERFINDER +if(isset($post_content['bounds'])){ + //++++++++++++++++++++++ + //Process DEALERFINDER PROCES + //++++++++++++++++++++++ + //------------------------------------------ + //NEW ARRAY + //------------------------------------------ + $whereclause = ''; + $criterias = []; + $clause = ''; -//BUILD UP PARTNERHIERARCHY FROM USER -$partner_product = json_encode(array("salesid"=>$partner->salesid,"soldto"=>$partner->soldto), JSON_UNESCAPED_UNICODE); + //------------------------------------------ + //GET THE POST CONTENT + //------------------------------------------ + if(isset($post_content) && $post_content !=''){ -$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 + //------------------------------------------ + //RUN THROUGH POST CONTENT + //------------------------------------------ + foreach($post_content as $criteria => $value){ -//CREATE EMPTY STRINGS -$clause = ''; -$clause_insert =''; -$input_insert = ''; + //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; + } + + } -if ($command == 'update'){ - $post_content['updatedby'] = $username ; -} -if ($command == 'insert'){ - $post_content['createdby'] = $username; - $post_content['accounthierarchy'] = $partner_product; -} - -//CREAT 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 + //UPDATE THE WHERECLAUSE DEPENDING ON ORIGINAL WHERECLAUSE + if ($whereclause == '' && $clause !=''){ + $whereclause = 'WHERE '.substr($clause, 4); + } else { + $whereclause .= $clause; } - else { - $criterias[$key] = $var; - $clause .= ' , '.$key.' = ?'; - $clause_insert .= ' , '.$key.''; - $input_insert .= ', ?'; // ? for each insert item - $execute_input[]= $var; // Build array for input + + } + + //------------------------------------------ + // 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 = '-%';} + + //default whereclause + 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'] ? 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 + + //CREATE EMPTY STRINGS + $clause = ''; + $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; + } + + //CREAT 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',$profile,$permission,'U') === 1){ + $sql = 'UPDATE dealers SET '.$clause.' WHERE rowID = ? '.$whereclause.''; + $execute_input[] = $id; + $stmt = $pdo->prepare($sql); + + 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; + $stmt = $pdo->prepare($sql); + $stmt->execute([$id]); + + //Add deletion to changelog + changelog($dbname,'dealers',$id,'Delete','Delete',$username); + } else + { + //do nothing + } } -//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',$profile,$permission,'U') === 1){ - $sql = 'UPDATE dealers SET '.$clause.' WHERE rowID = ? '.$whereclause.''; - $execute_input[] = $id; - $stmt = $pdo->prepare($sql); - $stmt->execute($execute_input); -} -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); -} -elseif ($command == 'delete' && isAllowed('dealers',$profile,$permission,'D') === 1){ - $sql = 'DELETE FROM dealers WHERE rowID = ? '.$whereclause; - $stmt = $pdo->prepare($sql); - $stmt->execute([$id]); - - //Add deletion to changelog - changelog($dbname,'dealers',$id,'Delete','Delete',$username); -} else -{ - //do nothing -} - - ?> \ No newline at end of file diff --git a/api/v2/post/dealers_media.php b/api/v2/post/dealers_media.php new file mode 100644 index 0000000..a8cebbc --- /dev/null +++ b/api/v2/post/dealers_media.php @@ -0,0 +1,96 @@ +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 + } + } +} +?> \ No newline at end of file diff --git a/assets/admin.js b/assets/admin.js index 4801832..25bdad0 100644 --- a/assets/admin.js +++ b/assets/admin.js @@ -1163,4 +1163,44 @@ function decodeVIN(){ console.log(error) }) - } \ No newline at end of file + } + + 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); + } + } +} \ No newline at end of file diff --git a/assets/functions.php b/assets/functions.php index 65bb611..be0d044 100644 --- a/assets/functions.php +++ b/assets/functions.php @@ -437,20 +437,14 @@ function template_footer($js_script = '') { $user_mail = $_SESSION['email'] ?? ''; $veliti_cim = ''; if (veliti_cim){ - $veliti_cim = ''; - } - -// DO NOT INDENT THE BELOW CODE -echo << - -
$veliti_cim + $veliti_cim = ' + +
+
- - {$js_script} + '; + } + +// DO NOT INDENT THE BELOW CODE +echo << + $veliti_cim + + {$js_script} + 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/"; @@ -2106,8 +2134,7 @@ function uploadrequest($key){ $_POST['questions'][$key] = $location; } else { } - } - + } } //------------------------------------------ // displayImages @@ -3980,4 +4007,394 @@ function getDomainName($hostname) { else { return $hostname; } -} \ No newline at end of file +} + +//======================================= +// 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; +} diff --git a/assets/images/main/background_section.jpg b/assets/images/main/background_section.jpg new file mode 100644 index 0000000..30e07df Binary files /dev/null and b/assets/images/main/background_section.jpg differ diff --git a/assets/images/marker-shadow.svg b/assets/images/marker-shadow.svg new file mode 100644 index 0000000..6ecce11 --- /dev/null +++ b/assets/images/marker-shadow.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/assets/images/marker.svg b/assets/images/marker.svg new file mode 100644 index 0000000..916c9d3 --- /dev/null +++ b/assets/images/marker.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + diff --git a/dealer.php b/dealer.php new file mode 100644 index 0000000..bf35941 --- /dev/null +++ b/dealer.php @@ -0,0 +1,290 @@ + +

'.($view_dealer_h2 ?? 'Dealer').' - '.encodeUuid($responses['rowID']).'

+ '.$button_cancel.' +'; + +//------------------------------------ +// EDIT BUTTON +//------------------------------------ +if ($update_allowed === 1){ + $view .= 'Edit'; +} + +$view .= '
'; + +if (isset($success_msg)){ + $view .= '
+ +

'.$success_msg.'

+ +
'; +} + +$view .= '
'; + +$view .= '
+
+ '.($view_dealers_information ?? 'Dealer information').' +
+
+

'.($dealers_status ?? 'status').'

+

'.(${$dealer_status} ?? $dealer_status).'

+
+
+

'.($dealers_name ?? 'name').'

+

'.$responses['name'].'

+
+
+

'.($dealers_slug ?? 'slug').'

+

'.$responses['dealer_slug'].'

+
+
+

'.($dealers_rating_overall ?? 'rating_overall').'

+

'.$responses['rating_overall'].'

+
+
+

'.($dealers_rating_website ?? 'rating_website').'

+

'.$responses['rating_website'].'

+
+
+'; + +$view .='
+
+ +
'; + if (!empty($responses['full_path'])){ + $view .=' +
+ +
+ '; + } +$view .=' +
+'; + +$view .= '
'; +$view .= '
+ +
+ '.(${$responses['short_description']} ?? $responses['short_description']).' +
+
+ '.(${$responses['long_description']} ?? $responses['long_description']).' +
+
+ '.(${$responses['usp1']} ?? $responses['usp1']).' +
+
+ '.(${$responses['usp2']} ?? $responses['usp2']).' +
+
+ '.(${$responses['usp3']} ?? $responses['usp3']).' +
+
+ '; + + +$view .= '
+
+ '.($view_dealer_details_3 ?? 'Location').' +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
'.($dealers_address ?? 'address').''.$responses['address'].'
'.($dealers_postalcode ?? 'postalcode').''.$responses['postalcode'].'
'.($dealers_city ?? 'city').''.$responses['city'].'
'.($dealers_state ?? 'state').''.$responses['state'].'
'.($dealers_country ?? 'country').''.$responses['country'].'
'.($dealers_email ?? 'email').''.$responses['email'].'
'.($dealers_phone ?? 'phone').''.$responses['phone'].'
'.($dealers_url ?? 'url').''.$responses['url'].'
+
+
+'; +//SHOW LOCATION BASED ON GEOLOCATION +if ((!empty($responses['lat']) || $responses['lat'] != '') && (!empty($responses['lng']) || $responses['lng'] != '')){ + + $view .= '
+
+
+ +
+ '; + +} + +//OPENING HOURS +if (!empty($responses['opening_hours']) || $responses['opening_hours'] !='' ){ + + $opening_hours = is_string($responses['opening_hours']) ? json_decode($responses['opening_hours'],true) : ''; + + $view .= '
+
+ '.($dealers_openinghours ?? 'opening_hours').' +
+
+ '; + foreach ($opening_hours as $day => $value){ + $view .= ' + + + '; + } + $view .= ' +
'.(${'general_day_'.$day} ?? 'Not specified').''.(isset($value['start']) ? $value['start'].' - '.$value['end'] : ($general_closed ?? 'Closed')).'
+
+
+ '; +} + +$view .= '
+
+ '.($view_dealer_details_2 ?? 'Settings').' +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
'.($dealers_garden_center ?? 'Garden_center').''.($responses['garden_center'] == 0 ? $general_no : $general_yes).'
'.($dealers_brand_type ?? 'Brand_type').''.${'brand_type_'.$responses['brand_type']}.'
'.($dealers_showroom_size ?? 'Showroom_size').''.${'showroom_size_'.$responses['showroom_size']}.'
'.($dealers_focus_offering ?? 'focus_offering').''.${'focus_offering_'.$responses['focus_offering']}.'
'.($dealers_type ?? 'dealer_type').''.${'dealer_type_'.$responses['dealer_type']}.'
'.($dealers_locations ?? 'dealer_locations').''.($responses['locations'] == 0 ? $general_no : $general_yes).'
+
+
+'; + +//OUTPUT +echo $view; + +template_footer() + +?> \ No newline at end of file diff --git a/dealer_manage.php b/dealer_manage.php new file mode 100644 index 0000000..7fec88a --- /dev/null +++ b/dealer_manage.php @@ -0,0 +1,411 @@ + '', + '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 =' +
+
+

'.($dealers_h2 ?? 'Dealer').' '.$responses['name'].'

+ '.$button_cancel.' +'; + +if ($delete_allowed === 1){ + $view .= ''; +} +if ($update_allowed === 1){ + $view .= ''; +} + +$view .= '
'; + +$view .= ' + '; + +$view .= '
+
+ + +
+
+ + +
+
+ + +
+
+ + + +
+
'; + + if (isset($_GET['rowID'])){ + $view .= ''; + } + +$view .= '
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
'; + +$view .= '
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + +
+
'; + +$view .= '
+
+ '; + + $opening_hours = is_string($responses['opening_hours']) ? json_decode($responses['opening_hours'],true) : $responses['opening_hours']; + foreach ($opening_hours as $day => $value){ + $view .= ' + + + + + '; + } +$view .=' +
'.(${'general_day_'.$day} ?? 'Not specified').' + '.($general_from ?? 'From').' + '.($general_from ?? 'To').' + + '.($general_closed ?? 'Closed').' + '.(isset($value['end']) ? '' : '').' +
+
+
'; + +$view .= ' +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
'; + +$view .= '
+
+ + + + + + + + '; + + if (isset($responses['url']) && $responses['url'] !=''){ + + $view .= ''.($button_media_scanner ?? 'media_scanner').''; + } +$view .= ' +
+
'; +$view .= '
'; + +$view .= ' + +

Select an Image

+
'; + + if (isset($media_responses) && is_array($media_responses)){ + foreach ($media_responses as $media_response){ + $view .= ' + '.$media_response['title'].' + '; + } + } +$view .= '
+ +
+'; + + +$view .= ''; + +//Output +echo $view; +template_footer()?> \ No newline at end of file diff --git a/dealers.php b/dealers.php index 0a3a4a7..b8bd1ef 100644 --- a/dealers.php +++ b/dealers.php @@ -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 .= '
$view .= '
@@ -97,21 +98,22 @@ $view .= ' '; } 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 .= ' - '.$dealer['id'].' - '.(${$dealer_status} ?? $dealer['status']).' + '.$dealer['rowID'].' + '.(${$dealer_status} ?? $dealer_status).' '.$dealer['name'].' '.getRelativeTime($dealer['created']).' - '.$general_view.' + '.$general_view.' '; } } + $view .= ' diff --git a/maintenance.php b/maintenance.php index c92d808..6ffea24 100644 --- a/maintenance.php +++ b/maintenance.php @@ -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 .= '
+
+ + +
'; } diff --git a/media.php b/media.php index bec7b3d..cca6bad 100644 --- a/media.php +++ b/media.php @@ -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 .= '
} $view .= '
'; +if ($create_allowed ===1 && isAllowed('media_scanner' ,$_SESSION['profile'],$_SESSION['permission'],'C') === 1){ + $view .= ''.($button_media_scanner ?? 'media_scanner').''; +} + if ($create_allowed ===1){ - $view .= ' - + $view .= '
'; diff --git a/media_scanner.php b/media_scanner.php new file mode 100644 index 0000000..d2f3d3d --- /dev/null +++ b/media_scanner.php @@ -0,0 +1,528 @@ + '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 =' + + + +
+

Media scanner

+ '.$button_cancel.' +
+ +
+
+ + +
+ +
+
+

Loading images...

+
+ +
+ + + +
+ +
+
+ + +'; + +//Output +echo $view; + +template_footer(); +?> \ No newline at end of file diff --git a/settings/settingsprofiles.php b/settings/settingsprofiles.php index 2999088..33a6519 100644 --- a/settings/settingsprofiles.php +++ b/settings/settingsprofiles.php @@ -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*/ diff --git a/settings/settingsviews.php b/settings/settingsviews.php index 16b891b..ddbd37a 100644 --- a/settings/settingsviews.php +++ b/settings/settingsviews.php @@ -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", diff --git a/settings/translations/translations_DE.php b/settings/translations/translations_DE.php index c266421..f06f480 100644 --- a/settings/translations/translations_DE.php +++ b/settings/translations/translations_DE.php @@ -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'; ?> \ No newline at end of file diff --git a/settings/translations/translations_ES.php b/settings/translations/translations_ES.php index 04c90c2..2dca143 100644 --- a/settings/translations/translations_ES.php +++ b/settings/translations/translations_ES.php @@ -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'; ?> \ No newline at end of file diff --git a/settings/translations/translations_NL.php b/settings/translations/translations_NL.php index 686a767..8c9eef8 100644 --- a/settings/translations/translations_NL.php +++ b/settings/translations/translations_NL.php @@ -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'; ?> \ No newline at end of file diff --git a/settings/translations/translations_PT.php b/settings/translations/translations_PT.php index a126d38..197d2ea 100644 --- a/settings/translations/translations_PT.php +++ b/settings/translations/translations_PT.php @@ -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'; ?> \ No newline at end of file diff --git a/settings/translations/translations_US.php b/settings/translations/translations_US.php index 2c7e9d9..ae0c0c8 100644 --- a/settings/translations/translations_US.php +++ b/settings/translations/translations_US.php @@ -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'; ?> \ No newline at end of file diff --git a/uploader.php b/uploader.php index 7d1916e..4e88c41 100644 --- a/uploader.php +++ b/uploader.php @@ -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,7 +290,9 @@ $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(); form.append(\'table\', JSON.stringify(tableName));