blob: 1aa6927ad9b84645c84d36d77cecfd8f6c19d314 [file] [log] [blame]
Marc Kupietz9879bc22023-03-09 08:21:11 +01001<?php
2
Marc Kupietzce676312023-03-10 08:29:41 +01003include_once 'User.php';
4use \User as User;
5
6require 'vendor/autoload.php';
Marc Kupietz9879bc22023-03-09 08:21:11 +01007
8use Konekt\PdfInvoice\InvoicePrinter;
9
Marc Kupietzce676312023-03-10 08:29:41 +010010#include_once '../src/InvoicePrinter.php';
11include 'config.php';
Marc Kupietz8606a7b2023-03-20 19:46:55 +010012$FULL_VAT=0.19;
Marc Kupietzce676312023-03-10 08:29:41 +010013function create_invoice(User $user)
14{
Marc Kupietz8606a7b2023-03-20 19:46:55 +010015 global $FULL_VAT, $SERVICE_ACRONYM, $SERVICE_NAME, $SERVICE_LOGO, $REGULAR_CONFERENCE_FEE, $EARLYBIRD_CONFERENCE_FEE, $STUDENT_DISCOUNT, $CONFERENCE_DINNER, $LUNCH;
16 $vat_sum = 0;
Marc Kupietzce676312023-03-10 08:29:41 +010017 $invoice = new InvoicePrinter("A4", "€", "en");
18 $invoice->lang['product'] = "Item";
Marc Kupietz8606a7b2023-03-20 19:46:55 +010019 $invoice->lang['discount'] = "VAT " . $FULL_VAT * 100 . "%";
Marc Kupietzce676312023-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 Kupietz741a3242023-03-20 21:28:00 +010026 $invoice->lang['to'] = "billing from";
27 $invoice->lang['from'] = "billing to";
28 $invoice->setTo(['ICLC-conference / Administration', 'Leibniz-Institute for the German Language', 'R5 6-13', '68181 Mannheim', 'Germany']);
29 $invoice->setFrom([$user->first_name . ' ' . $user->last_name, $user->organization, $user->street, $user->zip . ' ' . $user->city, $user->country]);
Marc Kupietzce676312023-03-10 08:29:41 +010030 $invoice->setDue(date('Y-m-d', strtotime('+2 weeks')));
31 // $invoice->hide_tofrom();
32 /* Adding Items in table */
33 if ($user->earlybird_registration) {
34 $invoice->addItem( $SERVICE_ACRONYM . ' Early Bird Registration', $SERVICE_NAME, 1, false, $EARLYBIRD_CONFERENCE_FEE, false, $EARLYBIRD_CONFERENCE_FEE);
35 } else
36 $invoice->addItem( $SERVICE_ACRONYM . ' Registration', $SERVICE_NAME, 1, false, $REGULAR_CONFERENCE_FEE, false, $REGULAR_CONFERENCE_FEE);
Marc Kupietz8606a7b2023-03-20 19:46:55 +010037 if($user->student) $invoice->addItem('Student Discount', 'Student discount', 1, false, - $STUDENT_DISCOUNT, false, -$STUDENT_DISCOUNT);
38 if($user->conference_dinner) {
39 $invoice->addItem('Conference Dinner', 'The conference dinner will take place on 20 July.', 1, false, $CONFERENCE_DINNER, $CONFERENCE_DINNER * $FULL_VAT, $CONFERENCE_DINNER);
40 $vat_sum += $CONFERENCE_DINNER * $FULL_VAT;
41 }
Marc Kupietzce676312023-03-10 08:29:41 +010042 /* Add totals */
43 $invoice->addTotal('Total', $user->total_due);
Marc Kupietz8701abd2023-03-16 17:33:43 +010044 $lunch_count = 0;
45 $lunch_details = "";
46 $i = 0;
47 if ($user->lunch_day_1) {
48 if ($i > 0)
49 $lunch_details .= ", ";
50 $lunch_count++;
51 $lunch_details .= "Day 1: " . $user->lunch_day_1;
52 $i++;
53 }
54 if ($user->lunch_day_2) {
55 if ($i > 0)
56 $lunch_details .= ", ";
57 $lunch_count++;
58 $lunch_details .= "Day 2: " . $user->lunch_day_2;
59 $i++;
60 }
61 if ($user->lunch_day_3) {
62 if ($i > 0)
63 $lunch_details .= ", ";
64 $lunch_count++;
65 $lunch_details .= "Day 3: " . $user->lunch_day_3;
66 $i++;
67 }
Marc Kupietz8606a7b2023-03-20 19:46:55 +010068 $vat_sum += $lunch_count * $LUNCH * $FULL_VAT;
Marc Kupietz8701abd2023-03-16 17:33:43 +010069
70 if ($lunch_count > 0)
Marc Kupietz8606a7b2023-03-20 19:46:55 +010071 $invoice->addItem('Lunch', $lunch_details, $lunch_count, false, $LUNCH, $lunch_count * $LUNCH * $FULL_VAT, $lunch_count * $LUNCH);
Marc Kupietzce676312023-03-10 08:29:41 +010072 // $invoice->addTotal('Discount', $STUDENT_DISCOUNT);
73 $invoice->addTotal('Total due', $user->total_due, true);
Marc Kupietz8606a7b2023-03-20 19:46:55 +010074 $invoice->addTotal('incl. VAT', $vat_sum, false);
Marc Kupietz9879bc22023-03-09 08:21:11 +010075
Marc Kupietzce676312023-03-10 08:29:41 +010076 $invoice->addTitle("Payment Details");
Marc Kupietz9879bc22023-03-09 08:21:11 +010077
Marc Kupietzb9763622023-03-10 13:54:21 +010078 $invoice->addParagraph("Please transfer the total amount due to our account: ");
Marc Kupietzce676312023-03-10 08:29:41 +010079
80 $invoice->addParagraph("Leibniz-Institute for the German Language
Marc Kupietz9879bc22023-03-09 08:21:11 +010081IBAN: DE70 6708 0050 0694 9411 00
82BIC: DRESDEFF670
83Commerzbank Mannheim
Marc Kupietzce676312023-03-10 08:29:41 +010084Reference: ICLC-10-" . $user->id . "
Marc Kupietzab634582023-03-20 19:45:34 +010085
86VAT ID: DE 143 845 359
Marc Kupietz43a3ada2023-03-20 19:47:25 +010087
88If you have any questions about this invoice, please contact us via buchhaltung@ids-mannheim.de.
Marc Kupietz9879bc22023-03-09 08:21:11 +010089");
Marc Kupietzce676312023-03-10 08:29:41 +010090 //$invoice->setFooterNote("xx");
91
92 /* Render */
Marc Kupietzce676312023-03-10 08:29:41 +010093 $ret = $invoice->render('example4.pdf', 'S'); /* I => Display on browser, D => Force Download, F => local path save, S => return document path */
94 return $ret;
95}
96
97/*
98$user = new User();
99$user->id = 107;
100$user->first_name = "John";
101$user->last_name = "Урсула";
102$user->organization = "Урсула ACME Inc.";
103$user->street = "123 Main St.";
104$user->zip = "12345";
105$user->city = "Mannheim";
106$user->country = "Germany";
107$user->total_due = 260.0;
108$user->student = true;
Marc Kupietz8606a7b2023-03-20 19:46:55 +0100109$user->lunch_day_1 = "vegan";
110$user->lunch_day_2 = "non-vegetarian";
Marc Kupietzce676312023-03-10 08:29:41 +0100111$user->conference_dinner = true;
112create_invoice($user);
113*/
114?>