Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Http\Controllers\booking;
- use App\Http\Requests;
- use App\Http\Controllers\Controller;
- use Request;
- use \CouponPDF;
- use \PDF;
- class CouponController extends Controller {
- public function index() {
- $input = Request::all();
- if (isset($input['belboon'])) {
- \Session::put('belboon', $input['belboon']);
- }
- if (preg_match('/(alcatel|android|blackberry|benq|cell|elaine|htc|iemobile|iphone|ipad|ipaq|ipod|j2me|java|midp|mini|mobi|motorola|nokia|palm|panasonic|philips|phone|sagem|sharp|smartphone|sony|symbian|t-mobile|up\.browser|up\.link|vodafone|wap|wireless|xda|zte)/i', $_SERVER['HTTP_USER_AGENT'])) {
- $price = \App\Price::find(1);
- $price->price = number_format($price->price);
- return view('booking.coupon.home_mobile')->with(['eventPrice' => $price->price]);
- } else {
- $price = \App\Price::find(1);
- $price->price = number_format($price->price);
- return view('booking.coupon.home')->with(['eventPrice' => $price->price]);
- }
- }
- public function createUniqueCouponCode() {
- $excisting = array();
- $possibleCode = "";
- while (is_array($excisting)) {
- $possibleCode = \App\Http\Controllers\backend\CouponController::getRandomString(8);
- $possibleCode = 'UC' . $possibleCode;
- $excisting = \App\CouponUnique::findCouponByCode("$possibleCode");
- $excisting = \App\Coupon::findByCode("$possibleCode");
- }
- return $possibleCode;
- }
- public function sendCouponConfirmMail($input, $email, $couponPDFName, $billPDFName, $slots, $firstName) {
- $betreff = "Socialmatch - Gutschein";
- if ($slots > 1) {
- $text = "<p>Hallo $firstName, </p><p>du hast eine tolle Wahl getroffen!</p> <p>Du hast erfolgreich einen Socialmatch-Gutschein für $slots Personen gekauft, die beschenkten Personen werden sich freuen ☺</p>";
- } else {
- $text = "<p>Hallo $firstName, </p><p>du hast eine tolle Wahl getroffen!</p> <p>Du hast erfolgreich einen Socialmatch-Gutschein für $slots Person gekauft, die beschenkte Person wird sich freuen ☺</p>";
- }
- $text .= "<p>Wir haben dir den Gutschein an die E-Mail angehängt, dort befinden sich auch die Infos zur Einlösung des Gutscheins.</p>"
- . "<p>Viel Spaß beim Verschenken!"
- . "<p>Dein Socialmatch-Team!</p>"
- . "<p><a href=\"http://www.socialmatch.de\" target=\"_blank\">socialmatch.de</a><br><img src=\"http://www.socialmatch.de/img/banner-email.png\" width=\"449\" height=\"150\" alt=\"BANNER\"/></p><p>Hast Du noch Fragen? Kontaktiere uns gerne jederzeit unter <a href=\"mailto:julie@socialmatch.de\">julie@socialmatch.de</a> oder schau auf unsere <a href=\"http://www.socialmatch.de/faq_de.php\" target=\"_blank\">FAQ-Seite</a>!</p>";
- $mail = new \PHPMailer;
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = 'smtp.socialmatch.de'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'julie@socialmatch.de'; // SMTP username
- $mail->Password = 'maTch3$1ds1!'; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = 587;
- if ($couponPDFName != "") {
- $mail->addAttachment(realpath("../../rechnungen/socialmatch/" . $couponPDFName), $couponPDFName, 'base64', 'application/pdf');
- }
- if ($billPDFName != "") {
- $mail->addAttachment(realpath("../../rechnungen/socialmatch/" . $billPDFName), $billPDFName, 'base64', 'application/pdf');
- }
- $mail->From = 'julie@socialmatch.de';
- $mail->FromName = 'Socialmatch';
- $mail->addAddress($email); // Add a recipient
- $mail->isHTML(true);
- $mail->addBCC("confirmmail@socialmatch.de", "$email");
- $mail->Subject = $betreff;
- $mail->Body = $text;
- $mail->CharSet = "UTF-8";
- if (!$mail->send()) {
- echo 'Message could not be sent.';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- } else {
- }
- }
- public function createCouponPDF($slots, $code) {
- $now = new \DateTime();
- $cleanDate = $now->format("d-m-Y");
- $dateLimit = \Carbon\Carbon::now()->addYear(1);
- $dateLimit = $dateLimit->format("d.m.Y");
- // Instanciation of inherited class
- $pdf = new \App\Http\Controllers\CouponPDF();
- $pdf->AliasNbPages();
- $pdf->AddPage();
- // obere blaue Linie zeichnen
- $pdf->SetDrawColor(1, 155, 205);
- $pdf->SetLineWidth(0.5);
- $pdf->Line(13, 50, 200, 50);
- // untere blaue Linie zeichnen
- $pdf->SetDrawColor(1, 155, 205);
- $pdf->SetLineWidth(0.5);
- $pdf->Line(13, 145, 200, 145);
- // Zeile Gutscheincode
- $pdf->SetFont('Arial', 'B', 14);
- $pdf->Ln(30);
- $pdf->Cell(55);
- $pdf->Cell(10, 10, 'GUTSCHEINCODE: ', 0, 1);
- $pdf->Ln(-10);
- $pdf->Cell(105);
- $pdf->SetTextColor(1, 155, 205);
- $pdf->Cell(10, 10, $code, 0, 1);
- // Bereich "Gutschein für n Personen"
- $pdf->Ln(20);
- $pdf->Cell(20);
- $pdf->SetTextColor(15, 15, 15);
- $pdf->SetFont('Arial', 'B', 22);
- $pdf->Cell(10, 10, 'Gutschein ', 0, 1);
- if ($slots > 1) {
- $pdf->Cell(12);
- $pdf->Cell(10, 10, $pdf->convert_chars('für ' . $slots . ' Personen'), 0, 1);
- } else {
- $pdf->Cell(15);
- $pdf->Cell(10, 10, $pdf->convert_chars('für ' . $slots . ' Person'), 0, 1);
- }
- // Bereich: Einlösung des Gutscheins
- $pdf->Ln(-35);
- $pdf->Cell(90);
- $pdf->SetFont('Arial', 'B', 12);
- $pdf->SetTextColor(206, 93, 37);
- $pdf->Cell(10, 10, $pdf->convert_chars('Einlösung des Gutscheins: '), 0, 1);
- $pdf->Cell(90);
- $pdf->SetFont('Arial', '', 12);
- $pdf->SetTextColor(15, 15, 15);
- $pdf->Cell(5, 5, $pdf->convert_chars('1. Besuche'), 0, 1);
- $pdf->Ln(-5);
- $pdf->Cell(113);
- $pdf->SetFont('Arial', 'U', 12);
- $pdf->SetTextColor(53, 33, 206);
- $pdf->Cell(5, 5, $pdf->convert_chars('www.socialmatch.de'), 0, 1);
- $pdf->Ln(3);
- $pdf->Cell(90);
- $pdf->SetFont('Arial', '', 12);
- $pdf->SetTextColor(15, 15, 15);
- $pdf->Cell(5, 5, $pdf->convert_chars('2. Wähle das Event in Deiner Stadt und'), 0, 1);
- $pdf->Cell(95);
- $pdf->Cell(5, 5, $pdf->convert_chars('Altersgruppe aus'), 0, 1);
- $pdf->Ln(3);
- $pdf->Cell(90);
- $pdf->Cell(5, 5, $pdf->convert_chars('3. Nach der Anmeldung für das Event kannst'), 0, 1);
- $pdf->Cell(95);
- $pdf->Cell(5, 5, $pdf->convert_chars('Du auf der Bezahlseite im Feld "Gutschein"'), 0, 1);
- $pdf->Cell(95);
- $pdf->Cell(5, 5, $pdf->convert_chars('Deinen Gutscheincode eingeben'), 0, 1);
- $pdf->Ln(3);
- $pdf->Cell(90);
- $pdf->Cell(5, 5, $pdf->convert_chars('4. Bei erfolgreicher Anmeldung erhälst du eine'), 0, 1);
- $pdf->Cell(95);
- $pdf->Cell(5, 5, $pdf->convert_chars('Bestätigungsmail.'), 0, 1);
- // Fußbereich URL Socialmatch.de
- $pdf->Ln(17);
- $pdf->Cell(5);
- $pdf->SetTextColor(15, 15, 15);
- $pdf->SetFont('Arial', 'B', 16);
- $pdf->Cell(10, 10, 'www.socialmatch.de ', 0, 1);
- // Bereich Gutscheingültigkeit
- $pdf->Ln(-11);
- $pdf->Cell(90);
- $pdf->SetTextColor(128,128,128);
- $pdf->SetFont('Arial', '', 9);
- $pdf->Cell(4, 4, $pdf->convert_chars('Der Gutschein ist in allen Socialmatch-Städten einlösbar.'), 0, 1);
- $pdf->Cell(90);
- $pdf->Cell(4, 4, $pdf->convert_chars('Eine Auszahlung des Gutscheins ist nicht möglich.'), 0, 1);
- $pdf->Cell(90);
- $pdf->Cell(4, 4, $pdf->convert_chars("Gutschein ist gültig bis zum $dateLimit"), 0, 1);
- // schwarze Trennlinie zeichnen + Schere
- $pdf->SetDrawColor(0, 0, 0);
- $pdf->SetDash(1,1);
- $pdf->SetLineWidth(0.25);
- $pdf->Line(5, 180, 205, 180);
- $pdf->Image('img/scissor.jpeg', 5, 182, 5);
- $pdf->Output("../../rechnungen/socialmatch/Socialmatch-Gutschein-" . $cleanDate . ".pdf", "f");
- $return = "Socialmatch-Gutschein-" . $cleanDate . ".pdf";
- return $return;
- }
- public function store() {
- $input = Request::all();
- if (preg_match('/(alcatel|android|blackberry|benq|cell|elaine|htc|iemobile|iphone|ipad|ipaq|ipod|j2me|java|midp|mini|mobi|motorola|nokia|palm|panasonic|philips|phone|sagem|sharp|smartphone|sony|symbian|t-mobile|up\.browser|up\.link|vodafone|wap|wireless|xda|zte)/i', $_SERVER['HTTP_USER_AGENT'])) {
- $price = \App\Price::find(1);
- $price->price = number_format($price->price);
- return view('booking.coupon.success')->with(['eventPrice' => $price->price]);
- } else {
- $price = \App\Price::find(1);
- $price->price = number_format($price->price);
- return view('booking.coupon.success')->with(['eventPrice' => $price->price]);
- }
- }
- public function paypalSuccess() {
- $request = Request::all();
- $key = \App\Key::find(1);
- $modus = $key->paypal_mode;
- if ($modus == 'live') {
- $ppurl = 'api.paypal.com';
- $billUrl = '../';
- } else {
- $ppurl = 'api.sandbox.paypal.com';
- $billUrl = '../..';
- }
- $paymentId = $request['paymentId'];
- $PayerID = $request['PayerID'];
- $token = $request['token'];
- \App\Http\Controllers\booking\CouponController::executePayPal($PayerID, $paymentId, $ppurl);
- /*$input = \Session::get('input');
- $date = \Carbon\Carbon::now()->addYear(1);
- $slots = $input['slots'];
- $firstName = $input['firstname'];
- $lastName = $input['lastname'];
- $mail = $input['mail'];
- $coupon = new \App\CouponUnique();
- $uniqueCode = \App\Http\Controllers\booking\CouponController::createUniqueCouponCode();
- $coupon->code = $uniqueCode;
- $coupon->slots = $slots;
- $coupon->mail = $mail;
- $coupon->type = 'gekauft';
- $coupon->used = 0;
- $coupon->taken = 1;
- $coupon->date = $date;
- $coupon->created = \Carbon\Carbon::now();
- $coupon->save();
- $couponPDFName = \App\Http\Controllers\booking\CouponController::createCouponPDF($slots, $uniqueCode);
- $billPDFName = \App\Http\Controllers\booking\CouponController::createBillPDF($firstName, $lastName, $slots);
- \App\Http\Controllers\booking\CouponController::sendCouponConfirmMail($input, $mail, $couponPDFName, $billPDFName, $slots, $firstName);
- unlink(realpath("../../rechnungen/socialmatch/" . $couponPDFName));
- if (preg_match('/(alcatel|android|blackberry|benq|cell|elaine|htc|iemobile|iphone|ipad|ipaq|ipod|j2me|java|midp|mini|mobi|motorola|nokia|palm|panasonic|philips|phone|sagem|sharp|smartphone|sony|symbian|t-mobile|up\.browser|up\.link|vodafone|wap|wireless|xda|zte)/i', $_SERVER['HTTP_USER_AGENT'])) {
- $price = \App\Price::find(1);
- $price->price = number_format($price->price);
- return view('booking.coupon.success')->with(['eventPrice' => $price->price]);
- } else {
- $price = \App\Price::find(1);
- $price->price = number_format($price->price);
- return view('booking.coupon.success')->with(['eventPrice' => $price->price]);
- }*/
- }
- public function payment() {
- $input = Request::all();
- $slots = $input['slots'];
- \Session::put('input', $input);
- $key = \App\Key::find(1);
- $pp_clientID = $key->paypal_public;
- $pp_secret = $key->paypal_private;
- $modus = $key->paypal_mode;
- if ($modus == 'live') {
- $ppurl = 'api.paypal.com';
- } else {
- $ppurl = 'api.sandbox.paypal.com';
- }
- $api_credentials = $pp_clientID . ':' . $pp_secret;
- $access_token = \App\Http\Controllers\booking\CouponController::getAccessToken($ppurl, $api_credentials);
- \Session::put('access_token', $access_token);
- $approvalArray = \App\Http\Controllers\booking\CouponController::getApprovalURL($access_token, $slots, $ppurl);
- $approval = $approvalArray['approval'];
- \Session::put('PayID', $approvalArray['PayID']);
- if (preg_match('/(alcatel|android|blackberry|benq|cell|elaine|htc|iemobile|iphone|ipad|ipaq|ipod|j2me|java|midp|mini|mobi|motorola|nokia|palm|panasonic|philips|phone|sagem|sharp|smartphone|sony|symbian|t-mobile|up\.browser|up\.link|vodafone|wap|wireless|xda|zte)/i', $_SERVER['HTTP_USER_AGENT'])) {
- $price = \App\Price::find(1);
- $price->price = number_format($price->price);
- return view('booking.coupon.payment_mobile')->with([
- 'eventPrice' => $price->price,
- 'modus' => $modus,
- 'approval' => $approval,
- 'slots' => $slots
- ]);
- } else {
- $price = \App\Price::find(1);
- $price->price = number_format($price->price);
- return view('booking.coupon.payment')->with([
- 'eventPrice' => $price->price,
- 'modus' => $modus,
- 'approval' => $approval,
- 'slots' => $slots
- ]);
- }
- }
- public function getAccessToken($ppurl, $api_credentials) {
- //Get Access Token
- $url = 'https://' . $ppurl . '/v1/oauth2/token';
- $JSONrequest = 'grant_type=client_credentials';
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- //curl_setopt($ch, CURLOPT_SSLCERT, $sslcertpath);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
- 'Accept: application/json',
- 'Accept-Language: de_DE'
- ));
- curl_setopt($ch, CURLOPT_USERPWD, $api_credentials);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $JSONrequest);
- $result = curl_exec($ch);
- // $error=curl_getinfo($ch);
- // var_dump($error);
- $result1 = json_decode($result, true);
- //var_dump($result1);
- curl_close($ch);
- $access_token = $result1['access_token'];
- return $access_token;
- }
- public function executePayPal($payer_id, $payId, $ppurl){
- $token = \Session::get('access_token');
- $url = "https://$ppurl/v1/payments/payment/$payId/execute";
- $JSONrequest = '{
- "payer_id": "'.$payer_id.'",
- }';
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- //curl_setopt($ch, CURLOPT_SSLCERT, $sslcertpath);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
- 'Content-Type: application/json',
- 'Authorization: Bearer ' . $token
- ));
- curl_setopt($ch, CURLOPT_HEADER, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $JSONrequest);
- $result = curl_exec($ch);
- // $error=curl_getinfo($ch);
- // print_r($error);
- var_dump($url);
- var_dump($JSONrequest);
- var_dump($result);
- $result1 = json_decode($result, true);
- curl_close($ch);
- }
- public function getApprovalURL($access_token, $slots, $ppurl) {
- $baseUrl = \App\Http\Controllers\booking\BookingController::getBaseUrl();
- $redirect = "$baseUrl/gutscheinerfolg";
- $redirectCancel = "$baseUrl/gutschein";
- $coupon = \App\CouponUnique::getLatest();
- $invoiceID = 'G34' . ($coupon[0]->id + 1);
- $price = \App\Price::find(1);
- $singlePrice = $price->price;
- $sumPrice = $slots * $singlePrice;
- $items = '';
- $items.= '{
- "quantity": "1",
- "name": "Dein Socialmatch Gutschein",
- "description": "Dein Socialmatch Gutschein",
- "price": "' . $sumPrice . '",
- "currency": "EUR"
- }';
- $url = 'https://' . $ppurl . '/v1/payments/payment';
- $JSONrequest = '{
- "intent": "sale",
- "payer": {
- "payment_method": "paypal"
- },
- "transactions": [
- {
- "amount": {
- "currency": "EUR",
- "total": "'.$sumPrice.'",
- "details": {
- "subtotal": "'.$sumPrice.'"
- }
- },
- "invoice_number":"' . $invoiceID . '",
- "item_list": {
- "items": [
- '. $items . '
- ]
- }
- }
- ],
- "redirect_urls": {
- "return_url": "' . $redirect . '",
- "cancel_url": "' . $redirectCancel . '"
- }
- }';
- #print($JSONrequest);
- #print('<br>');
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- //curl_setopt($ch, CURLOPT_SSLCERT, $sslcertpath);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
- 'Content-Type: application/json',
- 'Authorization: Bearer ' . $access_token
- ));
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $JSONrequest);
- $result = curl_exec($ch);
- // $error=curl_getinfo($ch);
- // print_r($error);
- $result1 = json_decode($result, true);
- curl_close($ch);
- $approvalURL = $result1['links'][1]['href'];
- //print_r($result1);
- $payID = $result1['id'];
- // var_dump($result1);
- return array("approval" => $approvalURL, "PayID" => $payID);
- }
- public function check($code) {
- $coupon = \App\Coupon::findByCode($code);
- if (is_array($coupon)) {
- \Session::put('coupon', $coupon[0]->discount);
- \Session::put('couponCode', $coupon[0]->code);
- $discount = $coupon[0]->discount;
- return json_encode($discount, JSON_NUMERIC_CHECK);
- } else {
- $couponUnique = \App\CouponUnique::findByCode($code);
- if (is_array($couponUnique)) {
- return \App\Http\Controllers\booking\CouponController::checkAvailbility($couponUnique);
- } else {
- return "wrong";
- }
- }
- }
- public function checkAvailbility($couponUnique) {
- $coupon = $couponUnique[0];
- $dateCoupon = new \DateTime($coupon->date);
- $dateNow = new \DateTime();
- if ($coupon->used == 1) {
- return "used";
- }
- if ($dateCoupon < $dateNow) {
- return "passed";
- }
- \Session::put('coupon', $coupon->slots * 19);
- \Session::put('couponCode', $coupon->code);
- \Session::put('uniqueCouponSlots', $coupon->slots);
- \Session::put('uniqueCouponType', $coupon->type);
- return json_encode($coupon);
- }
- public function checkUnique($code, $slots) {
- $coupon = \App\CouponUnique::getByCodeNotUsedDate($code, $slots);
- if (is_array($coupon)) {
- $coupon = $coupon[0];
- return json_encode($coupon);
- } else {
- return "wrong";
- }
- }
- public function renew($code) {
- $session = \Session::get('capture');
- $slots = $session['input']['slots'];
- $city = $session['input']['city'];
- $event = $session['input']['event'];
- $city = \App\City::find($city);
- $event = \App\Event::find($event);
- $price = \App\Price::find($event->price_id);
- $price = $price['price'];
- $formatPrice = number_format($price, 2, ",", ".");
- $coupon = \App\Coupon::findByCode($code);
- $coupon = $coupon[0];
- $couponMoney = $coupon->discount;
- $couponMoney = number_format($couponMoney, 2, ",", ".");
- $amountArray = explode(".", $couponMoney);
- $amount = $slots * $price - $coupon->discount;
- $amount = number_format($amount, 2, ",", ".");
- return view('booking/coupon')->with(['amount' => $amount, 'couponMoney' => $couponMoney, 'formatPrice' => $formatPrice, 'price' => $price, 'slots' => $slots]);
- }
- public function renewUnique($code, $unique) {
- \Session::put('couponSecurity', $unique);
- $session = \Session::get('capture');
- $slots = $session['input']['slots'];
- $city = $session['input']['city'];
- $event = $session['input']['event'];
- $city = \App\City::find($city);
- $event = \App\Event::find($event);
- $price = \App\Price::find($event->price_id);
- $price = $price['price'];
- $formatPrice = number_format($price, 2, ",", ".");
- $coupon = \App\CouponUnique::findByCode($code);
- $coupon = $coupon[0];
- $couponMoney = $coupon->slots * 19;
- $couponMoney = number_format($couponMoney, 2, ",", ".");
- $amountArray = explode(".", $couponMoney);
- $amount = $slots * $price - ($coupon->slots * 19);
- $amount = number_format($amount, 2, ",", ".");
- return view('booking/coupon')->with(['amount' => $amount, 'couponMoney' => $couponMoney, 'formatPrice' => $formatPrice, 'price' => $price, 'slots' => $slots]);
- }
- public static function setCouponUsed($code) {
- $security = \Session::get('couponSecurity');
- $coupon = \App\CouponUnique::findCouponByCode($code);
- if (is_array($coupon)) {
- $coupon = $coupon[0];
- $coupon = \App\CouponUnique::find($coupon->id);
- $coupon->used = 1;
- $coupon->taken = 1;
- if ($security != 'none') {
- $coupon->security_code = $security;
- }
- $booking = \App\Booking::getLatest();
- $coupon->booking_id = $booking[0]->id;
- $coupon->save();
- }
- }
- public static function createBillPDF($firstName, $lastName, $slots) {
- $datTimeObj = new \DateTime();
- $output_date = $datTimeObj->format('d.m.Y');
- $price = \App\Price::find(1);
- $price = $price->price;
- $uniqueCoupon = \App\CouponUnique::getLatest();
- $uniqueCouponId = $uniqueCoupon[0]->id;
- $greeting = "Hallo " . $firstName . ",";
- $full_name = $firstName . ' ' . $lastName;
- $pdf = new \App\Http\Controllers\PDF();
- $pdf->AliasNbPages();
- $pdf->AddPage();
- $pdf->Ln(25);
- $pdf->SetFont('Arial', 'B', 14);
- $pdf->Cell(0, 5, $pdf->convert_chars($full_name), 0, 1);
- $pdf->SetFont('Arial', 'B', 12);
- $pdf->Cell(0, 10, 'Deine Socialmatch Rechnung vom ' . $output_date . ' - Rechnungs-Nr.: G34' . $uniqueCouponId, 0, 1);
- $pdf->Ln(15);
- $pdf->SetFont('Arial', '', 12);
- $pdf->Cell(0, 5, $pdf->convert_chars($greeting), 0, 1);
- $pdf->Cell(0, 15, $pdf->convert_chars('wir haben Deine Zahlung für folgende Bestellung erhalten:'), 0, 1);
- // Table Column heading
- $header = ['Bezeichnung', 'Einzelpreis', 'Anzahl', 'Preis'];
- // Create Table Data
- $preis = $price;
- $preis_freunde = 0;
- if ($slots > 1){
- $anz_freunde = $slots - 1;
- $preis_freunde = $preis * $anz_freunde;
- $preis_freunde = $preis_freunde . " EUR";
- }
- $gesamtpreis = $preis + $preis_freunde;
- $gesamtpreis = $gesamtpreis . " EUR";
- $preis = $preis . " EUR";
- if ($slots == 1){
- $data = [
- 0 => [0 => "Dein Socialmatch-Gutschein", 1 => $preis, 2 => "1", 3 => $preis],
- 1 => [0 => "Gesamtbetrag", 1 => "", 2 => "", 3 => $gesamtpreis]
- ];
- } else{
- $data = [
- 0 => [0 => "Dein Socialmatch-Gutschein", 1 => $preis, 2 => $slots, 3 => $gesamtpreis],
- 1 => [0 => "Gesamtbetrag", 1 => "", 2 => "", 3 => $gesamtpreis]
- ];
- }
- //add improved table
- $pdf->ImprovedTable($header, $data);
- $pdf->SetFont('Arial', '', 10);
- $pdf->Cell(0, 2, ' ', 0, 1);
- $pdf->Cell(0, 5, 'Alle angegebenen Preise sind Endpreise.', 0, 1);
- $pdf->Cell(0, 5, $pdf->convert_chars('Aufgrund des Kleinunternehmerstatus gem. § 19 UStG erheben wir keine Umsatzsteuer '), 0, 1);
- $pdf->Cell(0, 5, 'und weisen diese daher auch nicht aus.', 0, 1);
- $pdf->SetFont('Arial', '', 12);
- $pdf->Ln(5);
- //TODO zahlungsmittel if usw
- $pdf->Cell(0, 5, $pdf->convert_chars('Der angegebene Gesamtbetrag wurde von Deinem ausgewählten Zahlungsmittel eingezogen.'), 0, 1);
- $pdf->Ln(15);
- $pdf->Cell(0, 5, $pdf->convert_chars('Mit freundlichen Grüßen'), 0, 1);
- $pdf->Ln(5);
- $pdf->Cell(0, 5, 'Dein Socialmatch-Team', 0, 1);
- $pdf->Ln(20);
- $pdf->SetFont('Arial', 'B', 11);
- $pdf->Cell(0, 5, 'Bei Facebook Fan werden!', 0, 1);
- $pdf->SetFont('Arial', '', 11);
- $pdf->Cell(0, 5, $pdf->convert_chars('Jetzt unter www.facebook.de/socialmatchevents Fan werden und regelmäßig Rabatte und Neuigkeiten'), 0, 1);
- $pdf->Cell(0, 5, $pdf->convert_chars('von Socialmatch sichern.'), 0, 1);
- $pdf->Output("../../rechnungen/socialmatch/" . $output_date . "-Rechnung-G34" . $uniqueCouponId . "-Socialmatch-" . $firstName . '-' . $lastName . ".pdf", "f");
- $return = "" . $output_date . "-Rechnung-G34" . $uniqueCouponId . "-Socialmatch-" . $firstName . '-' . $lastName . ".pdf";
- return $return;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement