File: D:/HostingSpaces/SBogers10/spire.komma-mediadesign.nl/wwwroot/mvc/views/v_wtb_pop_up_resellers.php
<?php
session_start();
ini_set('display_errors', 1);
ini_set('log_errors', 1);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
error_reporting(E_ALL);
function environment()
{
if( strpos( $_SERVER['SERVER_NAME'] ,'local') !== false) return 'local';
if( strpos( $_SERVER['SERVER_NAME'] ,'komma') !== false) return 'development';
return 'production';
}
require '../../config/config_db.php';
$resellers = array();
if(isset($_GET['id']))
{
$itemId = $_GET['id'];
$catId = $_GET['catId'];
if(isset($_GET['countries']))
{
$country = $_SESSION['current_country'] = $_GET['countries'];
}
else if(isset($_SESSION['current_country']))
{
$country = $_SESSION['current_country'];
}
/*
GET RESELLERS
*/
/*
* Get resellers from the database
*/
$query = 'SELECT DISTINCT p.id, p.title, p.city, p.country, p.link
FROM page_wheretobuy_items AS p, page_wheretobuy_products AS pr, kms_active AS a
WHERE pr.categoryId = :catId
AND pr.itemId = p.id
AND pr.productId = :itemId
AND a.active = 1
AND a.itemId = p.id
AND a.pageId = 15';
if(isset($country)) $query .= ' AND p.country = :country';
$query .= ' ORDER BY title ASC';
// prepare statement
if($st = $pdo->prepare($query))
{
$param = array();
$param[':catId'] = $catId;
$param[':itemId'] = $itemId;
if(isset($country)) $param[':country'] = $country;
if($st->execute($param)){
if($st->rowCount() > 0)
{
while($result = $st->fetch(PDO::FETCH_ASSOC))
{
$resellers[] = $result;
}
}
}
}
// Add logos to the resellers
$query = 'SELECT DISTINCT i.filename_thumb
FROM page_wheretobuy_images AS i
WHERE i.itemId = :itemId
LIMIT 1';
// prepare statement
if($st = $pdo->prepare($query))
{
foreach($resellers as $key => $reseller)
{
// Get Id
$id = $reseller['id'];
$param = array();
$param[':itemId'] = $id;
if($st->execute($param)){
if($st->rowCount() > 0)
{
while($result = $st->fetch(PDO::FETCH_ASSOC))
{
$resellers[$key]['thumb'] = $result['filename_thumb'];
}
}
}
}
}
}
// style="background: url(\'/kms/images/uploads/\') center center no-repeat;"
/*echo '<li>
<span class="logo">
</span>
<span class="text">
<span class="title">Coolgods</span>
<span class="location">The Netherlands</span>
<a class="ctaButton" href="http://www.coolgods.com" target="_blank"><span class="text">Visit website</span><span class="left"><span class="up"></span><span class="hover"></span></span><span class="right"><span class="up"></span><span class="hover"></span></span></a>
</span>
<span class="clear_both"></span>
</li>';*/
if ( ! empty($resellers))
{
foreach($resellers as $reseller)
{
$location = '';
if( ! empty ($reseller['city'])) $location .= $reseller['city'] . ', ';
$location .= str_replace('_',' ',$reseller['country']);
if(substr($reseller['link'],0,4) != 'http') $reseller['link'] = 'http://' . $reseller['link'];
?>
<li>
<span class="logo"
<?php
if(isset($reseller['thumb']))
{
echo ' style="background: url(\'/kms/images/uploads/' . $reseller['thumb'] . '\') center center no-repeat;"';
}
?>
>
</span>
<span class="text">
<span class="title"><?php echo $reseller['title']; ?></span>
<span class="location"><?php echo $location; ?></span>
<a class="ctaButton" href="<?php echo $reseller['link']; ?>" target="_blank"><span class="text">Visit website</span><span class="left"><span class="up"></span><span class="hover"></span></span><span class="right"><span class="up"></span><span class="hover"></span></span></a>
</span>
<span class="clear_both"></span>
</li>
<?php
}
}
else{
echo '<li><h2>No resellers listed at this moment, please contact us directly to find a solution.</h2></li>';
}
?>