*/
$prijzen = get_option(‘product-prijzen’);

add_shortcode(‘offerte-side-bar’, ‘getOfferteSideBar’);
if (!function_exists(‘getOfferteSideBar’)) {
function getOfferteSideBar() {
return
‘<div class=”offerte-sidebar”>
<p id=”lege-offerte”>Uw offerte is leeg</p>
<img src=”data:image/gif;base64,R0lGODlhfQBuAKUAAP////v7+/f39/Pz8+/v7+vr6+fn5+Pj49/f39vb29fX19LS0s7OzsrKysbGxsLCwr6+vrq6ura2trKysq6urqqqqqampqKiop6enpqampaWlpKSko6OjoqKioaGhoKCgn19fXl5eXV1dXFxcW1tbWlpaWVlZWFhYV1dXVlZWVVVVVFRUU1NTUlJSUVFRUFBQT09PTk5OTU1NTExMS0tLSgoKBwcHP///////////////////////////////////yH/C05FVFNDQVBFMi4wAwEAAAAh+QQFCgA/ACwAAAAAfQBuAAAG/kCAcEgsGo/IpHLJbDqf0Kh0Sq1ar9isdsvter/gsHhMLpvP6LR6zW673/C4fE6v2+/4vH7P7/v/gIGCg4SFhoeIiYqLjI2Oj5CRkpOUlZaXmJmam5ydfQYJAgABGygHQgcKAZ5RARYjCKMdpgACGyEDrEwFCwRCFysPsimnBiUkuQECq7pGDSUTQgwmGgEBHiqnDSkYqwEDuc1FBSAnCgAEIyME1ysGABgtwt8DouIEodIqHssYHQUBIlwYEAADiFMCCNirtZDTghEYRJFa0QBAAQQNAxw44G2ZkIThOhHIoCIiAAQWFjRR9pGAQl0C4mkIx8zJAAMFGmbCFy5m/ohzrQbkHCJAJ6UFJEAwEKLRl5SiTAkIrVmJwAQSJzTEuqKMgAGPmgpYKGHBaNChnhAkoDpFQD1NByhIwPglodRKC0AkDUGhwJYABgwgQOB0UoACCiiAyJBgi4CN9dhS+maWijLJ4jIrsYAhAwYMDTBTuTl4cCW9JkyUoCB6Cr4FDGJXLUAb7V9rYDXrTjJAAQQIp7Icpl35kYEKHEBADI7lsAIGCQhXQrBhAwQFhbWQVvBu8lumBLlmbB1pwYUHxZ0QGJw+ksYJITwsvTIAAYM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6OnqWqZEJywsLSwW6gQOEvgR6/vkEPrpCnb9sDDiRIsP6hRIoLAA0wcP/AYpcBBR0gZp2xo4K3LBRAhS0xxEgODkgwkK6gpEaNDkQTpMQlBlIaGM2AJ6hUpokOOKDlsDDCCf5PHAs0GiOhT+/WCQQYEWipU0DHHAhMgCqAsoDUlgS0uEDlYwaI1Q80HNHxUw8gqhFq0QCkd/bIhkoK0rpQg4YJJwlsIEdRBEeBknZAJOdM4itBIiEEoQADs=”>
</div>
<div class=”offerte-sidebar-totaal-prijs”>
<p id=”totaal_prijs”><span class=”pull-left”>Totaal prijs:</span><span class=”pull-right” >&euro; <span id=”totaal_prijs_value”>0.00</span></span></p>
</div>’
;
}
}

add_shortcode(‘vurenprijs’, ‘getVurenPrijs’);
if (!function_exists(‘getVurenPrijs’)) {
function getVurenPrijs() {
$prijzen = get_option(‘product-prijzen’);
return $prijzen[‘Noord Europees Vuren, meerprijs per meter’];
}
}
add_shortcode(‘grenenprijs’, ‘getGrenenPrijs’);
if (!function_exists(‘getGrenenPrijs’)) {
function getGrenenPrijs() {
$prijzen = get_option(‘product-prijzen’);
return $prijzen[‘Midden Europees Grenen (standaard)’];
}
}
add_shortcode(‘douglasprijs’, ‘getDouglasPrijs’);
if (!function_exists(‘getDouglasPrijs’)) {
function getDouglasPrijs() {
$prijzen = get_option(‘product-prijzen’);
return $prijzen[‘Douglas, meerprijs per meter’];
}
}
add_shortcode(‘bangkiraiprijs’, ‘getBangkiraiPrijs’);
if (!function_exists(‘getBangkiraiPrijs’)) {
function getBangkiraiPrijs() {
$prijzen = get_option(‘product-prijzen’);
return $prijzen[‘Bangkirai hardhout, meerprijs per meter’];
}
}
add_shortcode(‘reiskostenperkm’, ‘getReisKostenPerKm’);
if (!function_exists(‘getReisKostenPerKm’)) {
function getReisKostenPerKm() {
$prijzen = get_option(‘product-prijzen’);
return $prijzen[‘Prijs per km’];
}
}

require_once( getcwd() . ‘/wp-blog-header.php’);
require_once( getcwd() . ‘/wp-content/themes/enfold/prijs.php’);

$pricelist = getItems();

$json_pricelist = [];
foreach ($pricelist AS $key => $value) {
foreach ($value AS $k => $v) {
$k = str_replace(‘ ‘, ”, $k);
if ($k != ‘name’) {
if (isset($v[‘price’])) {
$json_pricelist[$k] = $v[‘price’];
} elseif (is_array($v)) {
foreach ($v AS $s => $w) {
if (isset($w[‘price’])) {
$s = str_replace(‘ ‘, ”, $s);
$json_pricelist[$k . $s] = $w[‘price’];
}
}
}
}
}
}
$json_pricelist = json_encode($json_pricelist);

$response = “”;
function my_contact_form_generate_response($type, $message) {
global $response;

if($type == “success”) $response = “<div class=’alert alert-success’>{$message}</div>”;
else $response = “<div class=’alert alert-danger’>{$message}</div>”;
}

/* Error meldingen schrijven */
$conditionserror = “Voordat u de offerte kunt aanvragen moet u eerst akkoord gaan met onze voorwaarden.”;
$missing_content = “Vul alstublieft alle informatie in.”;
$email_invalid = “E-mailadres klopt niet.”;
$message_unsent = “Het bericht is niet verzonden. Probeer het later opnieuw.”;
$message_sent = “Bedankt! Je bericht is verzonden.”;
$db_failure = “Er is iets foutgegaan bij het registreren van de nieuwsbrief. Probeer het opnieuw zonder de nieuwsbrief.”;

/* Defining variables */
$content = ‘<table cellpadding=”2″ cellspacing=”2″width=”100%”>’;
$content .= ‘<tr><td width=”30%”><b>Informatie</b></td><td width=”70%”></td></tr>’;
$content .= ‘<tr><td width=”30%”>Datum</td><td width=”70%”>’ . date(‘Y-m-d H:i:s’) . ‘</td></tr>’;
$totalprice = 0;
$totaladditions = 0;
$materials = [];

/* Unset waardes die niet in de email moeten */
$conditions = $_POST[‘Voorwaarden’];
$email = $_POST[‘Email’];
$file = $_POST[‘Bestand’];
unset($_POST[‘Voorwaarden’]);
unset($_POST[‘Bestand’]);

foreach ($_POST AS $key => $value) {

$price = null;

if ($pos = strpos($value, ‘- ‘) !== false ) {
$value = str_replace(‘- ‘, ”, $value);
}

/* Check voor toevoegingen, toevoegingen worden niet geteld per meter
maar aan het einde bij het totaal opgeteld. Toevoegingen hoeven ook niet
gecheckt te worden op modifier aangezien toevoegingen altijd + zijn. */
if ($key == ‘Kleurvanhetbeton’) {
if (isset($pricelist[$key][$value][‘price’])) {
$totaladditions = $totaladditions + $pricelist[$key][$value][‘price’];
}
} elseif ($key == ‘Wiltubetonpalenwaareenlichtleidingingestortzit’) {
if (isset($pricelist[$key][$value][‘price’])) {
$totaladditions = $totaladditions + $pricelist[$key][$value][‘price’];
}
} elseif ($key == ‘Aantalhoekpalen’) {
if (isset($pricelist[$key][$value][‘price’])) {
$totaladditions = $totaladditions + $pricelist[$key][$value][‘price’];
}
} elseif ($key == ‘Wiltuookspecialetuinschermenzoalstrellisofvscherm’) {
if (isset($pricelist[$key][$value][‘price’])) {
$totaladditions = $totaladditions + $pricelist[$key][$value][‘price’];
}
} elseif ($key == ‘Inclusieftuindeur’) {
/* Er moet minimaal 1 tuindeur zijn wil je de prijs van tuindeuren kunnen berekenen */
if (isset($pricelist[$key][$value][‘price’]) && $_POST[‘Aantaltuindeuren’] > 0) {
$totaladditions = $totaladditions + ($pricelist[$key][$value][‘price’] * $_POST[‘Aantaltuindeuren’]);
}
}

/* If the value is empty, unset */
if ($value == ”) {
unset($_POST[$key]);
} else {
if (isset($pricelist[$key])) {
/* Check if price is set, if not, this is an array containing multiple options */
if (isset($pricelist[$key][$value][‘price’])) {
$price = $pricelist[$key][$value];
} else {
/* Check if value contains one of these words, if it does, get the price */
if (strpos($value, ‘enkelzijdig’) !== false) {
if (isset($pricelist[$key][$value][‘enkelzijdig’][‘price’])) {
$price = $pricelist[$key][$value][‘enkelzijdig’];
}
} elseif (strpos($value, ‘dubbelzijdig’) !== false) {
if (isset($pricelist[$key][$value][‘dubbelzijdig’][‘price’])) {
$price = $pricelist[$key][$value][‘dubbelzijdig’];
}
} elseif (strpos($value, ‘Grenen’) !== false) {
if (isset($pricelist[$key][$value][‘grenen’][‘price’])) {
$price = $pricelist[$key][$value][‘grenen’];
}
} elseif (strpos($value, ‘Vuren’) !== false) {
if (isset($pricelist[$key][$value][‘vuren’][‘price’])) {
$price = $pricelist[$key][$value][‘vuren’];
}
} elseif (strpos($value, ‘Douglas’) !== false) {
if (isset($pricelist[$key][$value][‘douglas’][‘price’])) {
$price = $pricelist[$key][$value][‘douglas’];
}
} elseif (strpos($value, ‘Bangkirai’) !== false) {
if (isset($pricelist[$key][$value][‘bangkirai’][‘price’])) {
$price = $pricelist[$key][$value][‘bangkirai’];
}
}
}
}
}

/* Writing content for the email,
If name is set, print name instead of seo_name */
if ($key === ‘Totalelengtevandeschutting’) {
if (isset($pricelist[$key][‘name’])) {
$content .= ‘<tr><td width=”30%”>’ . $pricelist[$key][‘name’] . ‘</td><td width=”70%”>’ . $value . ‘ Meter</td><tr>’;
}
} else {
if (isset($pricelist[$key][‘name’])) {
$content .= ‘<tr><td width=”30%”>’ . $pricelist[$key][‘name’] . ‘</td><td width=”70%”>’ . $value . ‘</td><tr>’;
} else {
$content .= ‘<tr><td width=”30%”>’ . $key . ‘</td><td width=”70%”>’ . $value . ‘</td><tr>’;
}
}

/* Check if price is being added or distracted from total */
if (!is_null($price) && isset($price[‘modifier’]) && isset($price[‘price’])) {
if ($price[‘modifier’] == ‘+’) {
$totalprice = $totalprice + $price[‘price’];
} elseif ($price[‘modifier’] == ‘-‘) {
$totalprice = $totalprice – $price[‘price’];
}
}

if (substr($value, 0, 2) === ‘- ‘) {
$value = substr($value, 2);
}

/* Materialen opslaan */
if (isset($pricelist[$key][$value][‘materials’])) {
$materials[$key] = $pricelist[$key][$value][‘materials’];
} elseif (isset($pricelist[$key][‘- ‘ . $value][‘materials’])) {
$materials[$key] = $pricelist[$key][‘- ‘ . $value][‘materials’];
}
if (strpos($value, ‘enkelzijdig’) !== false) {
$_val = explode(‘ ‘, $value);
foreach ($_val AS $k => $v) {
if ($v === ‘enkelzijdig’) {
$materials[$key] = $pricelist[$key][‘- ‘ . $_val[0]. ‘ ‘ . $_val[1]][‘enkelzijdig’][‘materials’];
}
}
}
if (strpos($value, ‘dubbelzijdig’) !== false) {
$_val = explode(‘ ‘, $value);
foreach ($_val AS $k => $v) {
if ($v === ‘dubbelzijdig’) {
$materials[$key] = $pricelist[$key][‘- ‘ . $_val[0]. ‘ ‘ . $_val[1]][‘dubbelzijdig’][‘materials’];
}
}
}
$meters = $_POST[‘Totalelengtevandeschutting’];
$palen_schermen = floatval(($meters / 1.9));
$materials[‘palen’] = ceil($palen_schermen);
$materials[‘schermen’] = round($palen_schermen, 1 , PHP_ROUND_HALF_UP);
}
/* Check if the form has been submitted */
if (isset($_POST[‘Postcode’]) && isset($_POST[‘Totalelengtevandeschutting’])) {
/* Reiskosten berekenen met Google maps distance matrix */
$apikey = ‘AIzaSyA3OEgPEabuKy10asaB6vX1ZUgIFHEvDcI’;
$units = ‘metric’;
$googleurl = ‘https://maps.googleapis.com/maps/api/distancematrix/’;
$outputformat = ‘json’;
$origins = urlencode(‘5706td’);
$destination = urlencode($_POST[‘Postcode’]);
/* Bouw de api link */
$link = $googleurl . $outputformat . ‘?units=’ . $units . ‘&origins=’ . $origins . ‘&destinations=’ . $destination . ‘&key=’ . $apikey;
$result = json_decode(file_get_contents($link));
$afstand = $result->rows[0]->elements[0]->distance->value; // Afstand in meters
$tijd = $result->rows[0]->elements[0]->duration->value; // Tijd in seconden
$reiskosten = round(($afstand / 1000) * $prijzen[‘Prijs per km’] , 2); // Formule: Prijs per kilometer * aantal km

$content .= ‘<tr><td width=”30%”>Reistijd</td><td width=”70%”>’ . round(($tijd / 60)) . ‘ minuten</td><tr>’;
$content .= ‘<tr><td width=”30%”>Afstand</td><td width=”70%”>’ . round(($afstand / 1000),1) . ‘ kilometer</td><tr>’;

/* Prijslijst maken */
$content .= ‘</table><table cellpadding=”2″ cellspacing=”2″ width=”100%”><tr><td width=”30%”><b>Prijzen</b></td><td width=”70%”></td></tr>’;

$totalprice = $totalprice + $reiskosten;

/* Totaalprijs keer het aantal meters */
$totalprice = $totalprice * intval($_POST[‘Totalelengtevandeschutting’]);

/* Tel de toevoegingen op bij de totaalprijs */
$totalprice = $totalprice + $totaladditions;

/* Reiskosten toevoegen aan de mail */
$content .= ‘<tr><td width=”30%”>Voorrijkosten</td><td width=”70%”>&euro;’ . $reiskosten . ‘</td><tr>’;

/* Writing content for the email */
$content .= ‘<tr><td>Prijs totaal</td><td width=”70%”>&euro;’ . $totalprice . ‘</td><tr>’;

/* Totaalprijs + BTW */
$totalprice = round($totalprice * 1.21, 2);

/* Writing content for the email */
$content .= ‘<tr><td>Prijs inclusief BTW</td><td width=”70%”>&euro;’ . $totalprice . ‘</td><tr>’;

$content .= ‘</table><table cellpadding=”2″ cellspacing=”2″ width=”100%”><tr><td><b>Materialen</b></td><td></td><tr>’;
foreach ($materials AS $m_key => $mats) {
$m_key === ‘Ikbengeinteresseerdin’ ? $length = true : $length = false;
if (is_array($mats)) {
foreach ($mats AS $k => $m) {
if ((isset($k) && $k != ”) || (isset($m) && $m != ”)) {
$content .= ‘<tr><td width=”30%”>’;
if (is_int($m)) {
$content .= $k . ‘</td><td width=”70%”>’ . $m;
} else {
if ($length) {
$content .= $m . ‘</td><td width=”70%”>’ . intval($_POST[‘Totalelengtevandeschutting’]) . ‘ Meter’;
$length = false;
} else {
$content .= $m . ‘</td><td width=”70%”>&nbsp;’;
}
}
$content .= ‘</td></tr>’;
}
}
} elseif ($m_key == ‘palen’ || $m_key == ‘schermen’) {
$content .= ‘<tr><td width=”30%”>’ . ucfirst($m_key) . ‘</td><td width=”70%”>’ . $mats . ‘</td></tr>’;
}
}
echo ‘</table>’;

/* Setting options for the email */
$to = get_option(‘admin_email’);
$subject = “Iemand heeft een offerte aangevraagd”;
$headers = [
‘From: ‘. $email . “\r\n”,
‘Reply-To: ‘ . $email . “\r\n”,
‘Content-Type: text/html; charset=UTF-8’
];

if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
my_contact_form_generate_response(“error”, $email_invalid);
} else {
/* Check of de voorwaarden zijn geaccepteerd */
if (!isset($conditions) || strtolower($conditions) !== ‘ja’) {
my_contact_form_generate_response(“error”, $conditionserror);
} else {
$sent = wp_mail($to, $subject, $content, $headers, $attachment);
if ($sent) {
my_contact_form_generate_response(“success”, $message_sent); //Verzonden
} else {

my_contact_form_generate_response(“error”, $message_unsent); //Niet verzonden
}
}
}
}

get_header();

if(have_posts()) :
while (have_posts()) : the_post();
?>

<div data-scroll-offset=”88″ id=”main”>
<div class=”stretch_full container_wrap alternate_color light_bg_color title_container”>
<div class=”container”>
<h1 class=”main-title entry-title”><a href=”https://www.deschuttingbouwer.nl/offerte-aanvragen/” itemprop=”headline” rel=”bookmark” title=”Permanente Link: Offerte aanvragen”>Offerte aanvragen</a></h1>
<div class=”breadcrumb breadcrumbs avia-breadcrumbs”>
<div class=”breadcrumb-trail”>
<span class=”trail-before”><span class=”breadcrumb-title”>U bevindt zich hier:</span></span> <a class=”trail-begin” href=”https://www.deschuttingbouwer.nl” rel=”home” title=”De Schuttingbouwer”>Home</a> <span class=”sep”>/</span> <span class=”trail-end”>Offerte aanvragen</span>
</div>
</div>
</div>
</div>
<?php echo do_shortcode(“