File: D:/HostingSpaces/SBogers10/molennooitgedagtbudel.nl/wwwroot/kms/emailBestellingVerzonden.php
<?php
$q_orderEmail = "SELECT kms_orders.order_id, kms_orders.ordernummer, kms_orders.bedrijfsnaam, kms_orders.voornaam, kms_orders.tussenvoegsel, kms_orders.achternaam, kms_orders.geslacht,
kms_orders.emailadres, kms_orders.telefoonnummer, kms_orders.straatnaam, kms_orders.huisnummer, kms_orders.toevoeging, kms_orders.postcode, kms_orders.woonplaats, kms_orders.land,
kms_orders.bezorgadresWijktAf, kms_orders.bedrijfsnaamBezorg, kms_orders.voornaamBezorg, kms_orders.tussenvoegselBezorg, kms_orders.achternaamBezorg, kms_orders.geslachtBezorg,
kms_orders.straatnaamBezorg, kms_orders.huisnummerBezorg, kms_orders.toevoegingBezorg, kms_orders.postcodeBezorg, kms_orders.woonplaatsBezorg, kms_orders.landBezorg, kms_orders.subtotaalprijs, kms_orders.verzendkosten,
kms_orders.totaalprijs, kms_orders.verzendwijze, kms_orders.betaald, kms_orders.status, kms_orders.afleverdatum, kms_orders.datum, kms_orders.tijd FROM kms_orders WHERE kms_orders.order_id = '".mysql_real_escape_string($order_id)."'";
$r_orderEmail = mysql_query($q_orderEmail);
$rec_orderEmail = mysql_fetch_assoc($r_orderEmail);
$ordernummer = html_entity_decode($rec_orderEmail['ordernummer']);
$bedrijfsnaam = html_entity_decode($rec_orderEmail['bedrijfsnaam']);
$voornaam = html_entity_decode($rec_orderEmail['voornaam']);
$tussenvoegsel = html_entity_decode($rec_orderEmail['tussenvoegsel']);
$achternaam = html_entity_decode($rec_orderEmail['achternaam']);
$geslacht = $rec_orderEmail['geslacht'];
$emailadres = $rec_orderEmail['emailadres'];
$bevestigingEmail = $emailadres;
$telefoonnummer = $rec_orderEmail['telefoonnummer'];
$straatnaam = html_entity_decode($rec_orderEmail['straatnaam']);
$huisnummer = html_entity_decode($rec_orderEmail['huisnummer']);
$toevoeging = html_entity_decode($rec_orderEmail['toevoeging']);
$postcode = html_entity_decode($rec_orderEmail['postcode']);
$woonplaats = html_entity_decode($rec_orderEmail['woonplaats']);
$land = "Nederland";
$bezorgadresWijktAf = $rec_orderEmail['bezorgadresWijktAf'];
$bedrijfsnaamBezorg = html_entity_decode($rec_orderEmail['bedrijfsnaamBezorg']);
$voornaamBezorg = html_entity_decode($rec_orderEmail['voornaamBezorg']);
$tussenvoegselBezorg = html_entity_decode($rec_orderEmail['tussenvoegselBezorg']);
$achternaamBezorg = html_entity_decode($rec_orderEmail['achternaamBezorg']);
$geslachtBezorg = $rec_orderEmail['geslachtBezorg'];
$straatnaamBezorg = html_entity_decode($rec_orderEmail['straatnaamBezorg']);
$huisnummerBezorg = html_entity_decode($rec_orderEmail['huisnummerBezorg']);
$toevoegingBezorg = html_entity_decode($rec_orderEmail['toevoegingBezorg']);
$postcodeBezorg = html_entity_decode($rec_orderEmail['postcodeBezorg']);
$woonplaatsBezorg = html_entity_decode($rec_orderEmail['woonplaatsBezorg']);
$landBezorg = "Nederland";
$bestelDatum = date_dutch($rec_orderEmail['datum']);
if($geslacht == "man"){
$aanhef = "heer";
}else{
$aanhef = "mevrouw";
}
if(empty($tussenvoegsel)){
$achternaam_volledig = $achternaam;
}else{
$achternaam_volledig = ucfirst($tussenvoegsel)." ".$achternaam;
}
$bericht_html = "";
$header_html = "<html><head><title>Bestelling oudespulletjes.nl</title></head><body><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#FFFFFF\">
<tr><td align=\"center\"><table width=\"600\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"font-family:Arial, Helvetica, sans-serif; font-size: 11px; line-height: 14px;\">
<tr><td align=\"left\"><table width=\"600\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"font-family:Arial, Helvetica, sans-serif;font-size: 11px; line-height: 14px;\">
<tr><td colspan=\"6\" align=\"center\"><img src=\"http://oudespulletjes.komma-mediadesign.nl/img/logo.jpg\" alt=\"oudespulletjes.nl\" width=\"171\" height=\"170\"></td></tr><tr><td colspan=\"6\">";
$bericht_html .= $header_html;
$header_html = "";
$bericht_html .= "<span style=\"font-family:Arial, Helvetica, sans-serif; font-size: 13px; color:#000000; line-height:16px;\"><br><br>Geachte ".$aanhef." ".$achternaam_volledig.",</span>
<p style=\"font-family:Arial, Helvetica, sans-serif; font-size: 13px; color:#000000; line-height:16px;\">Onderstaand(e) artikel(en) uit uw bestelling met bestelnummer ".$ordernummer." van ".$bestelDatum." hebben wij overgedragen aan de bezorgdienst.
U ontvangt de bestelling zo spoedig mogelijk. <br><br><strong>Bestelnummer</strong>: ".$ordernummer."<br><br></p>";
$article_table = "</td></tr><tr><td colspan=\"6\" valign=\"top\"><hr style=\"border:0; width: 600px; color:#5AAF5A; background-color:#5AAF5A; height:2px;\">
<span style=\"font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-weight: bold; color: #5AAF5A; margin-top:10px; #5AAF5A; margin-bottom:10px; display:block;\">Besteld bij oudespulletjes.nl:</span>
</td></tr><tr><td colspan=\"1\" width=\"375\" valign=\"top\" style=\"padding-right:20px; padding-bottom:4px; padding-top:4px;\"><strong>Titel</strong></td>
<td colspan=\"1\" valign=\"top\" style=\"padding-right:20px; padding-bottom:4px; padding-top:4px;\"><strong>Aantal</strong></td>
<td colspan=\"2\" valign=\"top\" style=\"padding-right:20px; padding-bottom:4px; padding-top:4px;\"><strong>Prijs </strong></td>
<td colspan=\"2\" valign=\"top\" style=\"padding-right:20px; padding-bottom:4px; padding-top:4px;\"><STRONG>Totaal</STRONG></td>
</tr>";
$subtotaalprijs = 0;
$verzendkosten = 0;
$q_atikel = sprintf("SELECT kms_orders_articles.article_id, kms_orders_articles.order_aantal, kms_orders_articles.naam, kms_orders_articles.artikelnummer, kms_orders_articles.prijs, kms_orders_articles.verzendkosten, kms_orders_articles.voorraad FROM kms_orders_articles WHERE kms_orders_articles.order_id='%s'", $rec_orderEmail['order_id']);
$r_atikel = mysql_query($q_atikel);
while($rec_artikel = mysql_fetch_assoc($r_atikel)){
$artikelPrijs = $rec_artikel['prijs'] * $rec_artikel['order_aantal'];
$artikelVerzendkosten = $rec_artikel['verzendkosten'] * $rec_artikel['order_aantal'];
$subtotaalprijs = $subtotaalprijs + $artikelPrijs;
$verzendkosten = $verzendkosten + $artikelVerzendkosten;
$artikelPrijs = formatPrice($artikelPrijs);
$artikelVerzendkosten = formatPrice($artikelVerzendkosten);
$article_table .= "<tr>
<td valign=\"top\" style=\"padding-right:20px; padding-bottom:4px; padding-top:4px;\">".html_entity_decode($rec_artikel['naam'])." (".html_entity_decode($rec_artikel['artikelnummer']).")</td>
<td valign=\"top\" style=\"padding-right:20px; padding-bottom:4px; padding-top:4px;\">".$rec_artikel['order_aantal']."</td>
<td valign=\"top\" style=\"padding-bottom:4px; padding-top:4px; padding-right:8px; text-align:right\">€</td>
<td valign=\"top\" style=\"padding-right:20px; padding-bottom:4px; padding-top:4px; text-align:right\">".str_replace('.',',',$rec_artikel['prijs'])."</td>
<td valign=\"top\" style=\"padding-right:8px; padding-bottom:4px; padding-top:4px; text-align:right\">€</td>
<td valign=\"top\" style=\"padding-right:20px; padding-bottom:4px; padding-top:4px; text-align:right;\">".str_replace('.',',',$artikelPrijs)."</td>
</tr>";
}
if($rec_orderEmail['verzendwijze'] == "ophalen"){
$verzendkosten = 0;
}
$totaalprijs = $subtotaalprijs + $verzendkosten;
$subtotaalprijs = formatPrice($subtotaalprijs);
$verzendkosten = formatPrice($verzendkosten);
$totaalprijs = formatPrice($totaalprijs);
$article_table .= "<tr><td colspan=\"6\"> </td></tr><tr><td colspan=\"6\" valign=\"top\"><hr style=\"border:0; width: 600px; color:#5AAF5A; background-color:#5AAF5A; height:2px;\"></td>
</tr><tr>
<td colspan=\"4\" valign=\"top\" style=\"padding-right:20px; padding-bottom:4px; padding-top:4px;\">Bestelbedrag</td>
<td valign=\"top\" style=\"padding-right:8px; padding-bottom:4px; padding-top:4px; text-align:right;\">€</td>
<td valign=\"top\" style=\"padding-right:20px; padding-bottom:4px; padding-top:4px; text-align:right;\">".str_replace('.',',',$subtotaalprijs)."</td>
</tr><tr>
<td colspan=\"4\" valign=\"top\" style=\"padding-right:20px; padding-bottom:6px; padding-top:4px;\">Verzendkosten</td>
<td valign=\"top\" style=\"padding-right:8px; padding-bottom:6px; padding-top:4px; text-align:right\">€</td>
<td valign=\"top\" style=\"padding-right:20px; padding-bottom:6px; padding-top:4px; text-align:right;\">".str_replace('.',',',$verzendkosten)."</td>
</tr><tr>
<td colspan=\"4\" valign=\"top\" style=\"padding-right:20px; padding-bottom:4px; padding-top:4px; border-top:solid #5AAF5A 1px;\"><strong>Totaalbedrag</strong></td>
<td valign=\"top\" style=\"padding-right:8px; padding-bottom:4px; padding-top:4px; text-align:right; border-top:solid #5AAF5A 1px;\"><strong>€</strong></td>
<td valign=\"top\" style=\"padding-right:20px; padding-bottom:4px; padding-top:4px; text-align:right; border-top:solid #5AAF5A 1px;\"><strong>".str_replace('.',',',$totaalprijs)."</strong></td>
</tr></table><br><span style=\"font-family:Arial, Helvetica, sans-serif; font-size: 11px; color:#000000; line-height:14px;\">";
$bericht_html .= $article_table;
$article_table = "";
if($rec_orderEmail['betaald'] == "yes"){
$bericht_html .= "<strong>Betaalmethode:</strong> iDEAL <br>U heeft de bestelling al betaald via iDEAL.</span><br><br>";
}else{
$bericht_html .= "<strong>Betaalmethode:</strong> Acceptgiro <br>U heeft deze bestelling nog niet betaald.</span><br><br>";
}
$adresgegevens .= "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#FFFFFF\">
<tr><td align=\"left\"><table width=\"400\" border=\"0\" cellspacing=\"0\" style=\"font-family: Arial, Helvetica, sans-serif;font-size: 11px; line-height: 14px;\">
<tr>
<td width=\"200\" valign=\"top\"><strong>Factuuradres</strong></td>
<td width=\"200\" valign=\"top\"><strong>Bezorgadres</strong></td>
</tr>
<tr>
<td valign=\"top\" style=\"padding-right:20px;\">";
$factuuradres = "";
if(!empty($bedrijfsnaam)){ $factuuradres .= $bedrijfsnaam."<br>"; }
if($geslacht == "man"){ $aanheftTekst = "Dhr."; }else{ $aanheftTekst = "Mevr."; }
$factuuradres .= $aanheftTekst." ".$voornaam." ".$achternaam_smallCap."<br>".$straatnaam." ".$huisnummer."".$toevoeging."<br>".$postcode." ".$woonplaats."<br>".$land."</td>";
$adresgegevens .= $factuuradres;
$adresgegevens .= "<td valign=\"top\">";
if($bezorgadresWijktAf == "no"){
$adresgegevens .= $factuuradres;
}else{
if(!empty($bedrijfsnaam)){ $adresgegevens .= $bedrijfsnaamBezorg."<br>"; }
if($geslachtBezorg == "man"){ $aanheftTekstBezorg = "Dhr."; }else{ $aanheftTekstBezorg = "Mevr."; }
$adresgegevens .= $aanheftTekstBezorg." ".$voornaamBezorg." ".$achternaam_smallCapBezorg."<br>".$straatnaamBezorg." ".$huisnummerBezorg."".$toevoegingBezorg."<br>".$postcodeBezorg." ".$woonplaatsBezorg."<br>".$landBezorg."</td>";
}
$adresgegevens .= "</tr>
</table></td></tr></table>
<br><hr style=\"border:0; width: 600px; color:#5AAF5A; background-color:#5AAF5A; height:1px;\"><br>";
$bericht_html .= $adresgegevens;
$adresgegevens = "";
$footer_html .= "<p style=\"font-family:Arial, Helvetica, sans-serif; font-size: 13px; color:#000000; line-height:16px;\">Veel plezier met uw bestelling!<br><br>Met vriendelijke groet,<br>
<br>Oude Spulletjes<br><a href=\"http://www.oudespulletjes.nl\" target=\"_blank\" style=\"text-decoration:underline; color:#5AAF5A;\">www.oudespulletjes.nl</a><br><br></p>
<span style=\"font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#666666; line-height:14px;\">Overeenkomst:<br>
Conform de Algemene Verkoopvoorwaarden, Artikel 5, is Oude Spulletjes gerechtigd bestellingen te weigeren dan wel bepaalde voorwaarden aan de levering te verbinden, tenzij uitdrukkelijk anders bepaald. </span><br> <br>
</td></tr></table></td></tr></table></body></html>";
$bericht_html .= $footer_html;
$footer_html = "";
require_once '../css-js/phpmailer/class.phpmailer.php';
if($r_orderEmail && $r_atikel){
$send_message = false;
$from = "webmaster@oudespulletjes.nl";
$from_naam = "Oude Spulletjes";
$onderwerp_besteller = "Uw bestelling met bestelnummer ".$ordernummer." wordt verzonden";
$mail = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch
try {
$mail->AddReplyTo($from , $from_naam);
$mail->AddAddress($emailadres, $naam);
$mail->SetFrom($from, $from_naam);
$mail->AddReplyTo($from, $from_naam);
$mail->Subject = $onderwerp_besteller;
$mail->MsgHTML($bericht_html);
$mail->Send();
$send_message = true;
} catch (phpmailerException $e) {
$send_message = false;
$foutmeldingEmailBesteller = $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
$send_message = false;
$foutmeldingEmailBesteller = $e->getMessage(); //Boring error messages from anything else!
}
}else{
$db_error = true;
}