blob: d262a97c3559064c9342fb13e5e79f46a487ea8b [file] [log] [blame]
Marc Kupietzb411f462023-03-09 08:21:11 +01001<?php
2
Marc Kupietz49f677c2023-03-10 08:29:41 +01003include_once 'User.php';
4use \User as User;
5
6require 'vendor/autoload.php';
Marc Kupietzb411f462023-03-09 08:21:11 +01007
8use Konekt\PdfInvoice\InvoicePrinter;
9
Marc Kupietz49f677c2023-03-10 08:29:41 +010010#include_once '../src/InvoicePrinter.php';
11include 'config.php';
Marc Kupietz7081be92023-03-20 19:46:55 +010012$FULL_VAT=0.19;
Marc Kupietz49f677c2023-03-10 08:29:41 +010013function create_invoice(User $user)
14{
Marc Kupietz8b80c7a2023-03-28 21:41:39 +020015 global $FULL_VAT, $SERVICE_ACRONYM, $SERVICE_NAME, $SERVICE_LOGO, $REGULAR_CONFERENCE_FEE, $EARLYBIRD_CONFERENCE_FEE, $STUDENT_DISCOUNT, $CONFERENCE_DINNER, $LUNCH, $EXCURSION;
Marc Kupietz7081be92023-03-20 19:46:55 +010016 $vat_sum = 0;
Marc Kupietz49f677c2023-03-10 08:29:41 +010017 $invoice = new InvoicePrinter("A4", "€", "en");
18 $invoice->lang['product'] = "Item";
Marc Kupietz7081be92023-03-20 19:46:55 +010019 $invoice->lang['discount'] = "VAT " . $FULL_VAT * 100 . "%";
Marc Kupietz49f677c2023-03-10 08:29:41 +010020 /* Header Settings */
21 $invoice->setLogo(str_replace(".svg", ".png", $SERVICE_LOGO));
22 $invoice->setColor('#4bb044');
23 $invoice->setType('Invoice');
24 $invoice->setReference('ICLC-10-' . $user->id);
25 $invoice->setDate(date('Y-m-d', time()));
Marc Kupietz17b2e5f2023-04-01 17:51:48 +020026 $invoice->flipflop();
27 $invoice->lang['to'] = "to";
28 $invoice->lang['from'] = "from";
29 $invoice->setFrom(['ICLC-conference / Administration', 'Leibniz Institute for the German Language', 'R5 6-13', '68181 Mannheim', 'Germany']);
30 $invoice->setTo([($user->title? $user->title . ' ' : ''). $user->first_name . ' ' . $user->last_name, $user->organization, $user->street, $user->zip . ' ' . $user->city, $user->country]);
Marc Kupietz49f677c2023-03-10 08:29:41 +010031 $invoice->setDue(date('Y-m-d', strtotime('+2 weeks')));
32 // $invoice->hide_tofrom();
33 /* Adding Items in table */
34 if ($user->earlybird_registration) {
35 $invoice->addItem( $SERVICE_ACRONYM . ' Early Bird Registration', $SERVICE_NAME, 1, false, $EARLYBIRD_CONFERENCE_FEE, false, $EARLYBIRD_CONFERENCE_FEE);
36 } else
37 $invoice->addItem( $SERVICE_ACRONYM . ' Registration', $SERVICE_NAME, 1, false, $REGULAR_CONFERENCE_FEE, false, $REGULAR_CONFERENCE_FEE);
Marc Kupietz7081be92023-03-20 19:46:55 +010038 if($user->student) $invoice->addItem('Student Discount', 'Student discount', 1, false, - $STUDENT_DISCOUNT, false, -$STUDENT_DISCOUNT);
39 if($user->conference_dinner) {
Marc Kupietz8b80c7a2023-03-28 21:41:39 +020040 $invoice->addItem('Conference Dinner' . ($user->vegetarian_dinner ? " (vegetarian option)" : ""), 'The conference dinner takes place on 20 July.', 1, false, $CONFERENCE_DINNER, $CONFERENCE_DINNER * $FULL_VAT, $CONFERENCE_DINNER);
Marc Kupietz7081be92023-03-20 19:46:55 +010041 $vat_sum += $CONFERENCE_DINNER * $FULL_VAT;
42 }
Marc Kupietz79eaa0b2023-03-16 17:33:43 +010043 $lunch_count = 0;
44 $lunch_details = "";
45 $i = 0;
46 if ($user->lunch_day_1) {
47 if ($i > 0)
48 $lunch_details .= ", ";
49 $lunch_count++;
50 $lunch_details .= "Day 1: " . $user->lunch_day_1;
51 $i++;
52 }
53 if ($user->lunch_day_2) {
54 if ($i > 0)
55 $lunch_details .= ", ";
56 $lunch_count++;
57 $lunch_details .= "Day 2: " . $user->lunch_day_2;
58 $i++;
59 }
60 if ($user->lunch_day_3) {
61 if ($i > 0)
62 $lunch_details .= ", ";
63 $lunch_count++;
64 $lunch_details .= "Day 3: " . $user->lunch_day_3;
65 $i++;
66 }
Marc Kupietz7081be92023-03-20 19:46:55 +010067 $vat_sum += $lunch_count * $LUNCH * $FULL_VAT;
Marc Kupietz79eaa0b2023-03-16 17:33:43 +010068
69 if ($lunch_count > 0)
Marc Kupietz7081be92023-03-20 19:46:55 +010070 $invoice->addItem('Lunch', $lunch_details, $lunch_count, false, $LUNCH, $lunch_count * $LUNCH * $FULL_VAT, $lunch_count * $LUNCH);
Marc Kupietz49f677c2023-03-10 08:29:41 +010071 // $invoice->addTotal('Discount', $STUDENT_DISCOUNT);
Marc Kupietza104b602023-03-20 21:29:34 +010072
Marc Kupietz8b80c7a2023-03-28 21:41:39 +020073 if ($user->excursion) {
74 $vat_sum += $EXCURSION * $FULL_VAT;
Marc Kupietz7c7b7a72023-04-14 18:16:34 +020075 $invoice->addItem('Guided City Walk', 'The Guided City Walk takes place in the late afternoon of 21 July.', 1, false, $EXCURSION, $EXCURSION * $FULL_VAT, $EXCURSION);
Marc Kupietz8b80c7a2023-03-28 21:41:39 +020076 }
77
Marc Kupietza104b602023-03-20 21:29:34 +010078 /* Add totals */
79 $invoice->addTotal('Gross', $user->total_due);
80
81 if ($vat_sum > 0) {
82 $invoice->addTotal('incl. VAT', $vat_sum, false);
83 }
Marc Kupietz49f677c2023-03-10 08:29:41 +010084 $invoice->addTotal('Total due', $user->total_due, true);
Marc Kupietzb411f462023-03-09 08:21:11 +010085
Marc Kupietz49f677c2023-03-10 08:29:41 +010086 $invoice->addTitle("Payment Details");
Marc Kupietzb411f462023-03-09 08:21:11 +010087
Marc Kupietz81065d32023-03-10 13:54:21 +010088 $invoice->addParagraph("Please transfer the total amount due to our account: ");
Marc Kupietz49f677c2023-03-10 08:29:41 +010089
90 $invoice->addParagraph("Leibniz-Institute for the German Language
Marc Kupietzb411f462023-03-09 08:21:11 +010091IBAN: DE70 6708 0050 0694 9411 00
92BIC: DRESDEFF670
93Commerzbank Mannheim
Marc Kupietz49f677c2023-03-10 08:29:41 +010094Reference: ICLC-10-" . $user->id . "
Marc Kupietz728885c2023-03-20 19:45:34 +010095
Marc Kupietz42f0c8f2023-03-20 19:47:25 +010096If you have any questions about this invoice, please contact us via buchhaltung@ids-mannheim.de.
Marc Kupietzb411f462023-03-09 08:21:11 +010097");
Marc Kupietz144d82e2023-03-26 15:55:42 +020098 $invoice->setFooterNote("Leibniz Institute for the German Language, Civil Law Foundation, VAT ID: DE 143 845 359");
Marc Kupietz49f677c2023-03-10 08:29:41 +010099
100 /* Render */
Marc Kupietz49f677c2023-03-10 08:29:41 +0100101 $ret = $invoice->render('example4.pdf', 'S'); /* I => Display on browser, D => Force Download, F => local path save, S => return document path */
102 return $ret;
103}
104
105/*
106$user = new User();
107$user->id = 107;
108$user->first_name = "John";
109$user->last_name = "Урсула";
110$user->organization = "Урсула ACME Inc.";
111$user->street = "123 Main St.";
112$user->zip = "12345";
113$user->city = "Mannheim";
114$user->country = "Germany";
Marc Kupietze9bcbc02023-03-20 21:29:59 +0100115$user->total_due = 285.0;
Marc Kupietz49f677c2023-03-10 08:29:41 +0100116$user->student = true;
Marc Kupietz7081be92023-03-20 19:46:55 +0100117$user->lunch_day_1 = "vegan";
118$user->lunch_day_2 = "non-vegetarian";
Marc Kupietz49f677c2023-03-10 08:29:41 +0100119$user->conference_dinner = true;
120create_invoice($user);
121*/
122?>