File: D:/HostingSpaces/SBogers10/deensekroon.komma-mediadesign.nl/wwwroot/php/mailformats.php
<?php
function getActivationEmail(){
$siteroot = SITE_ROOT;
$output = '';
$output .= '<html><body style="line-height: 16px; font-family: Helvetica, Arial, sans-serif; font-size: 11px; color: #565656; ">';
$output .= '<div style="width: 500px;">';
$output .= '<h1 style="font-size: 18px; font-variant: small-caps; margin: 0 0 16px 0;">deense kroon</h1>';
$output .= 'Welkom bij Deense Kroon!<br /><br/>';
$output .= 'U bent slechts één stap verwijderd van uw eigen Deense Kroon account, <br />u hoeft het alleen nog maar te activeren.<br /><br />';
$output .= 'Door een simple klik op de volgende link kunt uw account activeren:<br /><br />';
$output .= '<a style="color: #0080C9" href="'.$siteroot.'/activeer-uw-account/[activationkey]/" target="_blank">'.$siteroot.'/activeer-uw-account/[activationkey]/</a><br /><br />';
$output .= '<em style="color: #9c9c9b">Mocht u niet op link kunnen klikken kunt u deze kopieëren in uw browser.</em><br /><br />';
$output .= '<em style="color: #9c9c9b">Dit is een automatisch gegenereerde email, u kunt hier niet op reageren. <br />U kunt ons bereiken via info@deensekroon.nl</em><br /><br />';
$output .= '</div>';
$output .= '</body></html>';
return $output;
}
function getWelcomeEmail($name)
{
$output = '';
$output .= '<html><body style="line-height: 16px; font-family: Helvetica, Arial, sans-serif; font-size: 11px; color: #565656; ">';
$output .= '<div style="width: 500px;">';
$output .= '<h1 style="font-size: 18px; font-variant: small-caps; margin: 0 0 16px 0;">Welkom bij Deense Kroon!</h1>';
$output .= 'Beste ' . ucfirst($name) . '<br />';
$output .= 'Welkom bij Deense Kroon!<br /><br/>';
$output .= '</div>';
$output .= '</body></html>';
return $output;
}
function getInvoiceEmail($orderId){
global $mysqli;
$output = '';
if($result = $mysqli->query('SELECT DISTINCT oi.id AS orderId, oi.orderCode, oi.customerId, oi.orderDate, oi.amount,oi.shippingCosts, oi.paymentMethod, oi.paymentStatus, oi.shippingMethod, oi.orderStatus, oi.lastUpdate,
oc.customerCode, oc.shipping_title, oc.shipping_firstName, oc.shipping_lastName, oc.shipping_postal, oc.shipping_adres, oc.shipping_city, oc.shipping_country,
oc.invoice_firstName, oc.invoice_lastName, oc.invoice_postal, oc.invoice_adres, oc.invoice_city, oc.invoice_country, oc.email, oc.phone
FROM shop_order_info AS oi, shop_order_customer AS oc
WHERE oi.id = oc.orderId
AND oi.id = '.$orderId.'
LIMIT 1')){
if($result->num_rows == 1){
$record = $result->fetch_assoc();
$orderId = $record['orderId'];
$lastUpdate = $record['lastUpdate'];
$orderDate = date('d / m / Y',$record['orderDate']);
$paymentMethod = $record['paymentMethod'];
$shippingMethod = $record['shippingMethod'];
$paymentStatus = $record['paymentStatus'];
$orderCode = $record['orderCode'];
// klant details
$customerCode = $record['customerCode'];
$shipping_title = $record['shipping_title'];
$shipping_firstname = $record['shipping_firstName'];
$shipping_lastname = $record['shipping_lastName'];
$invoice_firstname = $record['invoice_firstname'];
$invoice_lastname = $record['invoice_lastname'];
$email = $record['email'];
$phone = $record['phone'];
$shipping_adres = $record['shipping_adres'];
$shipping_postal = $record['shipping_postal'];
$shipping_city = $record['shipping_city'];
$shipping_country = $record['shipping_country'];
$invoice_postal = $record['invoice_postal'];
$invoice_adres = $record['invoice_adres'];
$invoice_city = $record['invoice_city'];
$invoice_country = $record['invoice_country'];
$status = '';
switch ($paymentStatus) {
case "completed": // payment complete
$status = 'Je hebt je betaling<br />voldaan via '.$paymentMethod;
break;
case "initialized": // waiting
break;
case "uncleared": // waiting (credit cards or direct debit)
break;
}
//get info instances
$totalProductPrice = 0;
$instanceResult = $mysqli->query('SELECT DISTINCT title, price_original, price_current, instanceId, productId, size, color, numProducts
FROM shop_order_products
WHERE orderId = '.$orderId);
$productlist = '';
$pricelist = '';
$allProductsAvailable = true;
while($instanceRecord = $instanceResult->fetch_assoc()){
$title = $instanceRecord['title'];
$numProducts = $instanceRecord['numProducts'];
$productId = $instanceRecord['productId'];
$size = $instanceRecord['size'];
if ( ! empty($size))
{
$available = 1; // je kunt geen kleding bestellen als het niet op voorraad is.
}
else
{
$available = checkAvailableInStock($productId);
}
$available > 0 ? $instock = true : $instock = false;
if(!$instock) $allProductsAvailable = false;
$totalProductPrice += $instanceRecord['price_current']*$numProducts;
$productlist .= $numProducts.'x '.$title;
//if(!$instock) $productlist .= ' (niet op vooraad)';
$productlist .= '<br />';
$pricelist .= displayPriceForMail($instanceRecord['price_current']*$numProducts).'<br />';
}
$output .= '<hr />';
//calculate prices
/*if(isset($_SESSION['cart'])){
$shippingcost = getDeliveryCosts($_SESSION['cart']['delivery']['country'] );
}
else{
$shippingcost = 1.95;
}
$totalPrice = $record['amount'];
$displayTotalPrice = displayPriceForMail($totalPrice);
$subtotalPrice = $totalPrice - $shippingcost;
$displayShippingCost = displayPriceForMail($shippingcost);
$displaySubtotalPrice = displayPriceForMail($subtotalPrice);*/
$totalPrice = $record['amount'];
// check if giftcards where used
$gcAmount = 0;
if($gcresult = $mysqli->query('SELECT amount FROM gc_used WHERE orderId = '.$orderId))
{
while($gcrecord = $gcresult->fetch_assoc())
{
$gcAmount += $gcrecord['amount'];
}
}
// Use invoice service
include_once $_SERVER['DOCUMENT_ROOT'] . '/App/Invoice/InvoiceService.php';
$invoiceService = new \App\Invoice\InvoiceService();
$shippingCosts = $record['shippingCosts'];
// Fix the old way:
if($shippingCosts === null)
$shippingCosts = $invoiceService->estimateShippingCosts($totalPrice,$totalProductPrice,$gcAmount,$shipping_country);
// Prepare values
$subtotalPrice = (float) $totalProductPrice;
$shippingCosts = (float) $shippingCosts;
$totalPrice = (float) $totalPrice;
// Do we have order-discount?
// Check if the total price matches the subtotal + shipping
// If not the order has a discount
$orderDiscount = $invoiceService->calculateOrderDiscount($totalPrice,$subtotalPrice,$shippingCosts,$gcAmount);
//$temp .= 'sc('.$shippingcost.') = tp('.$totalPrice.') - tpp('.$totalProductPrice.') - gc('.$gcAmount.')<br />';
$subtotalPrice = $totalProductPrice;
//$temp .= 'stp('.$subtotalPrice.') = tp('.$totalPrice.') - sc('.$shippingcost.') - gc('.$gcAmount.')<br />';
$displayTotalPrice = displayPriceForMail($totalPrice);
$displayShippingCost = displayPriceForMail($shippingCosts);
$displaySubtotalPrice = displayPriceForMail($subtotalPrice);
$displayOrderDiscount = displayPriceForMail($orderDiscount);
//VAT
if($vatresult = $mysqli->query('SELECT VAT FROM countries WHERE isocode = "'.$invoice_country.'" LIMIT 1')){
$vatrecord = $vatresult->fetch_assoc();
$vat = $vatrecord['VAT'];
$factor = 1 + ($vat / 100);
$exbtw = $totalPrice / $factor;
$btw = $totalPrice - $exbtw;
$displayExBtw = displayPriceForMail($exbtw);
$displayBtw = displayPriceForMail($btw);
}
else{
echo $mysqli->error;
}
/*
if($delresult = $mysqli->query('SELECT deliveryInStock, deliverySoldOut FROM countries WHERE isocode = "'.$shipping_country.'" LIMIT 1')){
// some products not in stock ?
$delRecord = $delresult->fetch_assoc();
if(!$allProductsAvailable){
$deliveryMessage = 'Uw bestelling is helaas niet bij ons op voorraad. Je ontvangen een e-mail wanneer je bestelling verzonden wordt.<br />Verwachte levertijd: '.$delRecord['deliverySoldOut'].'<br />';
}
else{
$deliveryMessage = 'Verwachte levertijd: '.$delRecord['deliveryInStock'].'<br />';
}
}*/
$deliveryMessage = 'Verwachte levertijd: 3-5 werkdagen';
}
$output = '';
$output .= '<html><body style="line-height: 18px; font-family: Helvetica, Arial, sans-serif; font-size: 12px; color: #565656; ">';
$output .= '<table width="400" cellpadding="8" cellspacing="0">';
$output .= '<tr>';
$output .= '<td colspan="2"><h1>Factuur</h1></td>';
$output .= '</tr>';
$output .= '<tr>';
$output .= '<td colspan="2" style="border-bottom: 1px solid #eaeaea;">';
$output .= 'Hartelijk bedankt voor je bestelling bij Deense Kroon.';
$output .= '</td>';
$output .= '</tr>';
$output .= '<tr>';
$output .= '<td style="border-bottom: 1px solid #eaeaea;">';
$output .= '<strong>Deense Kroon</strong><br />
Willemstraat 17<br />
5611 HB Eindhoven<br />
Nederland<br /><br />';
$output .= 'Datum: '.$orderDate.'<br />';
$output .= 'Ordernr: '. $orderCode.'<br />';
$output .= '</td>';
$output .= '<td style="border-bottom: 1px solid #eaeaea;">';
$output .= 'ING: NL74 INGB 0006 0825 28<br />';
$output .= 'tnv Deense Kroon<br />';
if(!empty($status)) $output .= '<em>('.$status.')</em><br /><br />';
$output .= 'Kvk: 54829992<br />';
$output .= 'Btw: NL851456467B01<br />';
$output .= '</td>';
$output .= '</tr>';
$output .= '<tr>';
$output .= '<td colspan="2" style="border-bottom: 1px solid #eaeaea;">';
$output .= '<strong>Aan</strong><br />';
$output .= $invoice_firstname.' '.$invoice_lastname.'<br />';
$output .= $invoice_adres.'<br />
'.$invoice_postal.' '.$invoice_city.'<br />
'.$invoice_country;
$output .= '</td>';
$output .= '</tr>';
if($shippingMethod == 'pickUpFromShopEindhoven')
{
$output .= '<tr>';
$output .= '<td colspan="2" style="border-bottom: 1px solid #eaeaea;">';
$output .= '<strong>Afhalen in Eindhoven</strong><br />';
$output .= 'Willemstraat 17, 5611 HB Eindhoven';
$output .= '</td>';
$output .= '</tr>';
}
else
{
$output .= '<tr>';
$output .= '<td colspan="2" style="border-bottom: 1px solid #eaeaea;">';
$output .= '<strong>Afleveradres</strong><br />
'.$shipping_firstname.' '.$shipping_lastname.'<br />
'.$shipping_adres.'<br />
'.$shipping_postal.' '.$shipping_city.'<br />
'.$shipping_country;
$output .= '</td>';
$output .= '</tr>';
}
$output .= '<tr>';
$output .= '<td style="border-bottom: 1px solid #eaeaea;">';
$output .= '<strong>Uw bestelling</strong><br />';
$output .= $productlist;
$output .= '</td>';
$output .= '<td style="border-bottom: 1px solid #eaeaea;">';
$output .= '<br />';
$output .= $pricelist;
$output .= '</td>';
$output .= '</tr>';
$output .= '<tr>';
$output .= '<td>';
$output .= 'subtotaal:<br />';
if($orderDiscount < 0) $output .= 'korting:<br />';
$output .= 'verzendkosten:<br />';
if($gcAmount > 0) $output .= 'giftcards:<br/>';
$output .= 'totaal:<br />';
$output .= '</td>';
$output .= '<td>';
$output .= $displaySubtotalPrice.'<br />';
if($orderDiscount < 0) $output .= '-' . $displayOrderDiscount . '<br />';
$output .= $displayShippingCost.'<br />';
if($gcAmount > 0) $output .= '- '.displayPrice($gcAmount).'<br />';
$output .= $displayTotalPrice.'';
$output .= '</td>';
$output .= '</tr>';
//comment row
/*$output .= '<tr>';
$output .= '<td colspan="2">';
$output .= $temp;
$output .= '</td>';
$output .= '</tr>';
*/
$output .= '<tr>';
$output .= '<td>';
$output .= 'excl. btw:<br />';
$output .= $vat.'% btw:<br />';
$output .= '</td>';
$output .= '<td>';
$output .= $displayExBtw.'<br />';
$output .= $displayBtw.'<br />';
$output .= '</td>';
$output .= '</tr>';
$output .= '<tr>';
$output .= '<td colspan="2" style="border-bottom: 1px solid #eaeaea; color: #9c9c9b;" >';
$output .= $deliveryMessage;
$output .= '</td>';
$output .= '</tr>';
$output .= '<tr>';
$output .= '<td colspan="2" style="border-bottom: 1px solid #eaeaea; color: #9c9c9b;" >';
$output .= 'Heb je vragen of opmerkingen over deze factuur of je bestelling,<br />neem dan contact met ons op. <br /><br />info@deensekroon.nl.<br /><br />
Met vriendelijke groet,<br />
Deense Kroon<br />
www.deensekroon.nl<br />
';
$output .= '</td>';
$output .= '</tr>';
$output .= '</table>';
$output .= '</body></html>';
}
else{
}
return $output;
}
function getChangeStatusMail($orderId){
global $mysqli;
$output = '';
if($result = $mysqli->query('SELECT DISTINCT oi.id AS orderId, oi.orderCode, oi.customerId, oi.orderDate, oi.amount, oi.paymentMethod, oi.paymentStatus, oi.shippingMethod, oi.shippingDate, oi.orderStatus, oi.lastUpdate,
oc.customerCode, oc.shipping_title, oc.shipping_firstName, oc.shipping_lastName, oc.shipping_postal, oc.shipping_adres, oc.shipping_city, oc.shipping_country,
oc.invoice_firstName, oc.invoice_lastName, oc.invoice_postal, oc.invoice_adres, oc.invoice_city, oc.invoice_country, oc.email, oc.phone
FROM shop_order_info AS oi, shop_order_customer AS oc
WHERE oi.id = oc.orderId
AND oi.id = '.$orderId.'
LIMIT 1')){
if($result->num_rows == 1){
$record = $result->fetch_assoc();
$orderId = $record['orderId'];
$orderDate = date('d / m / Y',$record['orderDate']);
$paymentMethod = $record['paymentMethod'];
$paymentStatus = $record['paymentStatus'];
$orderCode = $record['orderCode'];
$shippingDate = date('d / m / Y',$record['shippingDate']);
$shippingMethod = $record['shippingMethod'];
$orderStatus = $record['orderStatus'];
$orderStatusResult = $mysqli->query('SELECT orderStatus
FROM shop_status
WHERE statusNr = '.$orderStatus.' LIMIT 1');
$orderStatusRecord = $orderStatusResult->fetch_assoc();
$displayOrderStatus = $orderStatusRecord['orderStatus'];
if($orderStatus == 1) $displayOrderStatus = 'Verzonden op '.$shippingDate;
$status = '';
switch ($paymentStatus) {
case "completed": // payment complete
break;
case "initialized": // waiting
break;
case "uncleared": // waiting (credit cards or direct debit)
break;
}
// klant details
$customerCode = $record['customerCode'];
$shipping_title = $record['shipping_title'];
$shipping_firstname = $record['shipping_firstName'];
$shipping_lastname = $record['shipping_lastName'];
//$invoice_firstname = $record['invoice_firstname'];
//$invoice_lastname = $record['invoice_lastname'];
$email = $record['email'];
$phone = $record['phone'];
$shipping_adres = $record['shipping_adres'];
$shipping_postal = $record['shipping_postal'];
$shipping_city = $record['shipping_city'];
$shipping_country = $record['shipping_country'];
$invoice_postal = $record['invoice_postal'];
$invoice_adres = $record['invoice_adres'];
$invoice_city = $record['invoice_city'];
$invoice_country = $record['invoice_country'];
}
$output = '';
$output .= '<html><body style="line-height: 18px; font-family: Helvetica, Arial, sans-serif; font-size: 12px; color: #565656; ">';
$output .= '<table width="400" cellpadding="8" cellspacing="0">';
$output .= '<tr>';
$output .= '<td colspan="2"><h1>Wijziging bestelstatus</h1></td>';
$output .= '</tr>';
$output .= '<tr>';
$output .= '<td colspan="2" style="border-bottom: 1px solid #eaeaea;">';
$output .= 'Hartelijk bedankt voor je bestelling bij Deense Kroon.';
$output .= '</td>';
$output .= '</tr>';
$output .= '<tr>';
$output .= '<td style="border-bottom: 1px solid #eaeaea;">';
$output .= '<strong>Deense Kroon</strong><br />
Willemstraat 17<br />
5611 HB Eindhoven<br />
Nederland<br /><br />';
$output .= 'Datum van bestelling: '.$orderDate.'<br />';
$output .= 'Ordernr: <a href="'. SITE_ROOT .'mijn-account/bestellingen/#201222010000007001" target="_blank">'.$orderCode.'</a><br />';
$output .= '</td>';
$output .= '<td style="border-bottom: 1px solid #eaeaea;">';
$output .= 'ING: 608 25 28<br />';
$output .= 'tnv Deense Kroon<br />';
if(!empty($status)) $output .= '<em>('.$status.')</em><br /><br />';
$output .= 'Kvk: 54829992<br />';
$output .= 'Btw: NL851456467B01<br />';
$output .= '</td>';
$output .= '</tr>';
if($shippingMethod == 'pickUpFromShopEindhoven')
{
$output .= '<tr>';
$output .= '<td colspan="2" style="border-bottom: 1px solid #eaeaea;">';
$output .= '<strong>Afhalen in Eindhoven</strong><br />';
$output .= 'Willemstraat 17, 5611 HB Eindhoven';
$output .= '</td>';
$output .= '</tr>';
}
else
{
$output .= '<tr>';
$output .= '<td colspan="2" style="border-bottom: 1px solid #eaeaea;">';
$output .= '<strong>Aan</strong><br />';
$output .= $shipping_firstname.' '.$shipping_lastname.'<br />';
$output .= $shipping_adres.'<br />
'.$shipping_postal.' '.$shipping_city.'<br />
'.$shipping_country;
$output .= '</td>';
$output .= '</tr>';
}
$output .= '<tr>';
$output .= '<td colspan="2" style="border-bottom: 1px solid #eaeaea;">';
$output .= '<strong>Wijziging bestelstatus</strong><br />';
$output .= 'De status van je bestelling is gewijzigd, de status luidt nu als volgt:<br /><br /><strong>'.$displayOrderStatus.'</strong><br /><br />';
$output .= '</td>';
$output .= '</tr>';
$output .= '<tr>';
$output .= '<td colspan="2" style="border-bottom: 1px solid #eaeaea; color: #9c9c9b;" >';
$output .= 'Heb je vragen of opmerkingen over of je bestelling,<br />neem dan contact met ons op. <br /><br />info@deensekroon.nl.<br /><br />
Met vriendelijke groet,<br />
Deense Kroon<br />
www.deensekroon.nl<br />
';
$output .= '</td>';
$output .= '</tr>';
$output .= '</table>';
$output .= '</body></html>';
}
return $output;
}
function getMailPickUpFromShop($orderId)
{
global $mysqli;
// Check for order nummer
$orderDetail = '';
$query = 'SELECT DISTINCT shop_order_info.id AS orderId, shop_order_info.orderCode
FROM shop_order_info
WHERE shop_order_info.id = '.$orderId.'
LIMIT 1';
if($result = $mysqli->query($query))
{
$record = $result->fetch_assoc();
if(! empty($record['orderCode']) )
{
$orderDetail = ' order: ' . fromDatabase($record['orderCode']);
}
}
// Message
$output = '';
$output .= '<html><body style="line-height: 18px; font-family: Helvetica, Arial, sans-serif; font-size: 12px; color: #565656; ">';
$output .= '<table width="600" cellpadding="8" cellspacing="0">';
$output .= '<tr>';
$output .= '<td colspan="2"><h1 style="font-size: 18px">Wijziging bestelstatus' . $orderDetail . '</h1></td>';
$output .= '</tr>';
$output .= '<tr>';
$output .= '<td colspan="2" style="border-bottom: 1px solid #eaeaea;">';
$output .= 'Hartelijk dank voor je bestelling bij Deense Kroon.<br />
Je bestelling staat voor je klaar in de winkel aan de Willemstraat 17.<br />
<br />
<strong>De openingstijden van de winkel zijn:</strong><br />
ma gesloten<br />
di-do 10-17.30<br />
vrij 10-20.30<br />
zat 10-17.30<br />
zo 12.30-17.30<br />
<br />
We hopen je snel te mogen begroeten.<br />
<br />
Team Deense Kroon.';
$output .= '</td>';
$output .= '</tr>';
$output .= '</table>';
$output .= '</body></html>';
return $output;
}
function getNewOrderMail($orderId){
global $mysqli;
$output = '';
if($result = $mysqli->query('SELECT DISTINCT oi.id AS orderId, oi.orderCode, oi.customerId, oi.orderDate, oi.amount, oi.paymentMethod, oi.paymentStatus, oi.shippingMethod, oi.shippingDate, oi.orderStatus, oi.lastUpdate,
oc.customerCode, oc.shipping_title, oc.shipping_firstName, oc.shipping_lastName, oc.shipping_postal, oc.shipping_adres, oc.shipping_city, oc.shipping_country,
oc.invoice_firstName, oc.invoice_lastName, oc.invoice_postal, oc.invoice_adres, oc.invoice_city, oc.invoice_country, oc.email, oc.phone
FROM shop_order_info AS oi, shop_order_customer AS oc
WHERE oi.id = oc.orderId
AND oi.id = '.$orderId.'
LIMIT 1')){
if($result->num_rows == 1){
$record = $result->fetch_assoc();
$orderId = $record['orderId'];
$orderDate = date('d / m / Y',$record['orderDate']);
$paymentMethod = $record['paymentMethod'];
$paymentStatus = $record['paymentStatus'];
$orderCode = $record['orderCode'];
// klant details
$customerCode = $record['customerCode'];
$shipping_title = $record['shipping_title'];
$shipping_firstname = $record['shipping_firstName'];
$shipping_lastname = $record['shipping_lastName'];
$invoice_postal = $record['invoice_postal'];
$invoice_adres = $record['invoice_adres'];
$invoice_city = $record['invoice_city'];
$invoice_country = $record['invoice_country'];
$output .= '<html><body style="line-height: 18px; font-family: Helvetica, Arial, sans-serif; font-size: 12px; color: #565656; ">';
$output .= '<table width="400" cellpadding="8" cellspacing="0">';
$output .= '<tr>';
$output .= '<td colspan="2"><h1>Nieuwe Order</h1></td>';
$output .= '</tr>';
$output .= '<tr>';
$output .= '<td colspan="2" style="border-bottom: 1px solid #eaeaea;">';
$output .= '<strong>Order '.$orderCode.'</strong><br />';
$output .= 'Er is een nieuwe order binnengekomen. ';
$output .= '</td>';
$output .= '</tr>';
$output .= '<tr>';
$output .= '<td colspan="2" style="border-bottom: 1px solid #eaeaea;">';
$output .= '<strong>Order geplaatst door:</strong><br />';
$output .= $shipping_firstname.' '.$shipping_lastname.'<br />';
$output .= $invoice_adres.'<br />
'.$invoice_postal.' '.$invoice_city.'<br />
'.$invoice_country;
$output .= '</td>';
$output .= '</tr>';
$output .= '<tr>';
$output .= '<td colspan="2" style="border-bottom: 1px solid #eaeaea; color: #9c9c9b;" >';
$output .= 'Bekijk de volledige order op <a href="'. BASE_ROOT .'admin/orders/" target="_blank">het beheerpaneel</a>';
$output .= '</td>';
$output .= '</tr>';
$output .= '</table>';
$output .= '</body></html>';
}
}
return $output;
}