blob: 75377537418a725cb2d59d747e0109e1e052bd03 [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 Kupietzb411f462023-03-09 08:21:11 +010012
Marc Kupietz49f677c2023-03-10 08:29:41 +010013function create_invoice(User $user)
14{
15 global $SERVICE_ACRONYM, $SERVICE_NAME, $SERVICE_LOGO, $REGULAR_CONFERENCE_FEE, $EARLYBIRD_CONFERENCE_FEE, $STUDENT_DISCOUNT, $CONFERENCE_DINNER;
Marc Kupietzb411f462023-03-09 08:21:11 +010016
Marc Kupietz49f677c2023-03-10 08:29:41 +010017 $invoice = new InvoicePrinter("A4", "€", "en");
18 $invoice->lang['product'] = "Item";
19 /* Header Settings */
20 $invoice->setLogo(str_replace(".svg", ".png", $SERVICE_LOGO));
21 $invoice->setColor('#4bb044');
22 $invoice->setType('Invoice');
23 $invoice->setReference('ICLC-10-' . $user->id);
24 $invoice->setDate(date('Y-m-d', time()));
25 $invoice->setFrom(['', 'Leibniz-Institute for the German Language', 'R5 6-13', '68181 Mannheim', 'Germany']);
26 $invoice->setTo([$user->first_name . ' ' . $user->last_name, $user->organization, $user->street, $user->zip . ' ' . $user->city, $user->country]);
27 $invoice->setDue(date('Y-m-d', strtotime('+2 weeks')));
28 // $invoice->hide_tofrom();
29 /* Adding Items in table */
30 if ($user->earlybird_registration) {
31 $invoice->addItem( $SERVICE_ACRONYM . ' Early Bird Registration', $SERVICE_NAME, 1, false, $EARLYBIRD_CONFERENCE_FEE, false, $EARLYBIRD_CONFERENCE_FEE);
32 } else
33 $invoice->addItem( $SERVICE_ACRONYM . ' Registration', $SERVICE_NAME, 1, false, $REGULAR_CONFERENCE_FEE, false, $REGULAR_CONFERENCE_FEE);
34 if($user->student) $invoice->addItem('Student Discount', 'Student discount', 1, false, "", $STUDENT_DISCOUNT, -$STUDENT_DISCOUNT);
35 if($user->conference_dinner)
36 $invoice->addItem('Conference Dinner', 'The conference dinner will take place on 20 July.', 1, false, $CONFERENCE_DINNER, false, $CONFERENCE_DINNER);
37 /* Add totals */
38 $invoice->addTotal('Total', $user->total_due);
39 // $invoice->addTotal('Discount', $STUDENT_DISCOUNT);
40 $invoice->addTotal('Total due', $user->total_due, true);
Marc Kupietzb411f462023-03-09 08:21:11 +010041
Marc Kupietz49f677c2023-03-10 08:29:41 +010042 $invoice->addTitle("Payment Details");
Marc Kupietzb411f462023-03-09 08:21:11 +010043
Marc Kupietz81065d32023-03-10 13:54:21 +010044 $invoice->addParagraph("Please transfer the total amount due to our account: ");
Marc Kupietz49f677c2023-03-10 08:29:41 +010045
46 $invoice->addParagraph("Leibniz-Institute for the German Language
Marc Kupietzb411f462023-03-09 08:21:11 +010047IBAN: DE70 6708 0050 0694 9411 00
48BIC: DRESDEFF670
49Commerzbank Mannheim
Marc Kupietz49f677c2023-03-10 08:29:41 +010050
51Reference: ICLC-10-" . $user->id . "
Marc Kupietzb411f462023-03-09 08:21:11 +010052");
Marc Kupietz49f677c2023-03-10 08:29:41 +010053 //$invoice->setFooterNote("xx");
54
55 /* Render */
Marc Kupietz49f677c2023-03-10 08:29:41 +010056 $ret = $invoice->render('example4.pdf', 'S'); /* I => Display on browser, D => Force Download, F => local path save, S => return document path */
57 return $ret;
58}
59
60/*
61$user = new User();
62$user->id = 107;
63$user->first_name = "John";
64$user->last_name = "Урсула";
65$user->organization = "Урсула ACME Inc.";
66$user->street = "123 Main St.";
67$user->zip = "12345";
68$user->city = "Mannheim";
69$user->country = "Germany";
70$user->total_due = 260.0;
71$user->student = true;
72$user->conference_dinner = true;
73create_invoice($user);
74*/
75?>