blob: 5d888aff28f6f6ff3d9a537d0a0f9c01659b2319 [file] [log] [blame]
<?php
include_once 'User.php';
use \User as User;
require 'vendor/autoload.php';
use Konekt\PdfInvoice\InvoicePrinter;
#include_once '../src/InvoicePrinter.php';
include 'config.php';
$FULL_VAT=0.19;
function create_invoice(User $user)
{
global $FULL_VAT, $SERVICE_ACRONYM, $SERVICE_NAME, $SERVICE_LOGO, $REGULAR_CONFERENCE_FEE, $EARLYBIRD_CONFERENCE_FEE, $STUDENT_DISCOUNT, $CONFERENCE_DINNER, $LUNCH, $EXCURSION;
$vat_sum = 0;
$invoice = new InvoicePrinter("A4", "€", "en");
$invoice->lang['product'] = "Item";
$invoice->lang['discount'] = "VAT " . $FULL_VAT * 100 . "%";
/* Header Settings */
$invoice->setLogo(str_replace(".svg", ".png", $SERVICE_LOGO));
$invoice->setColor('#4bb044');
$invoice->setType('Invoice');
$invoice->setReference('ICLC-10-' . $user->id);
$invoice->setDate(date('Y-m-d', time()));
$invoice->flipflop();
$invoice->lang['to'] = "to";
$invoice->lang['from'] = "from";
$invoice->setFrom(['ICLC-conference / Administration', 'Leibniz Institute for the German Language', 'R5 6-13', '68181 Mannheim', 'Germany']);
$invoice->setTo([($user->title? $user->title . ' ' : ''). $user->first_name . ' ' . $user->last_name, $user->organization, $user->street, $user->zip . ' ' . $user->city, $user->country]);
$invoice->setDue(date('Y-m-d', strtotime('+2 weeks')));
// $invoice->hide_tofrom();
/* Adding Items in table */
if ($user->earlybird_registration) {
$invoice->addItem( $SERVICE_ACRONYM . ' Early Bird Registration', $SERVICE_NAME, 1, false, $EARLYBIRD_CONFERENCE_FEE, false, $EARLYBIRD_CONFERENCE_FEE);
} else
$invoice->addItem( $SERVICE_ACRONYM . ' Registration', $SERVICE_NAME, 1, false, $REGULAR_CONFERENCE_FEE, false, $REGULAR_CONFERENCE_FEE);
if($user->student) $invoice->addItem('Student Discount', 'Student discount', 1, false, - $STUDENT_DISCOUNT, false, -$STUDENT_DISCOUNT);
if($user->conference_dinner) {
$net = $CONFERENCE_DINNER / (1 + $FULL_VAT);
$vat = $CONFERENCE_DINNER - $net;
$invoice->addItem('Conference Dinner' . ($user->vegetarian_dinner ? " (vegetarian option)" : ""), 'The conference dinner takes place on 20 July.', 1, false, $net, $vat, $CONFERENCE_DINNER);
$vat_sum += $vat;
}
$lunch_count = 0;
$lunch_details = "";
$i = 0;
if ($user->lunch_day_1 && $user->lunch_day_1 != "--") {
if ($i > 0)
$lunch_details .= ", ";
$lunch_count++;
$lunch_details .= "Day 1: " . $user->lunch_day_1;
$i++;
}
if ($user->lunch_day_2 && $user->lunch_day_2 != "--") {
if ($i > 0)
$lunch_details .= ", ";
$lunch_count++;
$lunch_details .= "Day 2: " . $user->lunch_day_2;
$i++;
}
if ($user->lunch_day_3 && $user->lunch_day_3 != "--") {
if ($i > 0)
$lunch_details .= ", ";
$lunch_count++;
$lunch_details .= "Day 3: " . $user->lunch_day_3;
$i++;
}
if ($lunch_count > 0) {
$net = $lunch_count * $LUNCH / (1 + $FULL_VAT);
$vat = $lunch_count * $LUNCH - $net;
$vat_sum += $vat;
$invoice->addItem('Lunch', $lunch_details, $lunch_count, false, $net, $vat, $lunch_count * $LUNCH);
}
if ($user->excursion) {
$net = $EXCURSION / (1 + $FULL_VAT);
$vat = $EXCURSION - $net;
$vat_sum += $vat;
$invoice->addItem('Guided City Walk', 'The Guided City Walk takes place in the late afternoon of 21 July.', 1, false, $net, $vat, $EXCURSION);
}
/* Add totals */
$invoice->addTotal('Gross', $user->total_due);
if ($vat_sum > 0) {
$invoice->addTotal('incl. VAT', $vat_sum, false);
}
$invoice->addTotal('Total due', $user->total_due, true);
$invoice->addTitle("Payment Details");
$invoice->addParagraph("Please transfer the total amount due to our account: ");
$invoice->addParagraph("Leibniz-Institute for the German Language
IBAN: DE70 6708 0050 0694 9411 00
BIC: DRESDEFF670
Commerzbank Mannheim
Reference: ICLC-10-" . $user->id . "
If you have any questions about this invoice, please contact us via buchhaltung@ids-mannheim.de.
");
$invoice->setFooterNote("Leibniz Institute for the German Language, Civil Law Foundation, VAT ID: DE 143 845 359");
/* Render */
$ret = $invoice->render('example4.pdf', 'S'); /* I => Display on browser, D => Force Download, F => local path save, S => return document path */
return $ret;
}
/*
$user = new User();
$user->id = 107;
$user->first_name = "John";
$user->last_name = "Урсула";
$user->organization = "Урсула ACME Inc.";
$user->street = "123 Main St.";
$user->zip = "12345";
$user->city = "Mannheim";
$user->country = "Germany";
$user->total_due = 285.0;
$user->student = true;
$user->lunch_day_1 = "vegan";
$user->lunch_day_2 = "non-vegetarian";
$user->conference_dinner = true;
create_invoice($user);
*/
?>