Add lunch options

Change-Id: Ic4569fce73d8b33f5084e95d44797cba735914d5
diff --git a/User.php b/User.php
index 6a9e2cf..642e894 100644
--- a/User.php
+++ b/User.php
@@ -27,6 +27,9 @@
     public bool $conference_dinner;
     public $registered_at;
     public bool $earlybird_registration;
+    public $lunch_day_1;
+    public $lunch_day_2;
+    public $lunch_day_3;
     public float $total_due;
     public $invoice;
 
diff --git a/create_user_table.sql b/create_user_table.sql
index ae935dc..453be4e 100644
--- a/create_user_table.sql
+++ b/create_user_table.sql
@@ -21,6 +21,9 @@
     earlybird_registration boolean not null default false,
     student boolean not null default false,
     conference_dinner boolean not null default false,
+    lunch_day_1 varchar(16) not null default '',
+    lunch_day_2 varchar(16) not null default '',
+    lunch_day_3 varchar(16) not null default '',
     total_due decimal(10,2) not null default 0.00,
     registered_at timestamp default '0000-00-00 00:00:00', 
     updated_at timestamp default now() on update now(),
diff --git a/invoice.php b/invoice.php
index 7537753..d0beef2 100644
--- a/invoice.php
+++ b/invoice.php
@@ -12,7 +12,7 @@
 
 function create_invoice(User $user)
 {
-    global $SERVICE_ACRONYM, $SERVICE_NAME, $SERVICE_LOGO, $REGULAR_CONFERENCE_FEE, $EARLYBIRD_CONFERENCE_FEE, $STUDENT_DISCOUNT, $CONFERENCE_DINNER;
+    global $SERVICE_ACRONYM, $SERVICE_NAME, $SERVICE_LOGO, $REGULAR_CONFERENCE_FEE, $EARLYBIRD_CONFERENCE_FEE, $STUDENT_DISCOUNT, $CONFERENCE_DINNER, $LUNCH;
 
     $invoice = new InvoicePrinter("A4", "€", "en");
     $invoice->lang['product'] = "Item";
@@ -36,6 +36,33 @@
         $invoice->addItem('Conference Dinner', 'The conference dinner will take place on 20 July.', 1, false, $CONFERENCE_DINNER, false, $CONFERENCE_DINNER);
     /* Add totals */
     $invoice->addTotal('Total', $user->total_due);
+    $lunch_count = 0;
+    $lunch_details = "";
+    $i = 0;
+    if ($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) {
+        if ($i > 0)
+            $lunch_details .= ", ";
+        $lunch_count++;
+        $lunch_details .= "Day 2: " . $user->lunch_day_2;
+        $i++;
+    }
+    if ($user->lunch_day_3) {
+        if ($i > 0)
+            $lunch_details .= ", ";
+        $lunch_count++;
+        $lunch_details .= "Day 3: " . $user->lunch_day_3;
+        $i++;
+    }
+
+    if ($lunch_count > 0)
+        $invoice->addItem('Lunch', $lunch_details, $lunch_count, false, $LUNCH, false, $lunch_count * $LUNCH);
     // $invoice->addTotal('Discount', $STUDENT_DISCOUNT);
     $invoice->addTotal('Total due', $user->total_due, true);
 
diff --git a/static/main.js b/static/main.js
index 0f0025e..62ccf4e 100644
--- a/static/main.js
+++ b/static/main.js
@@ -31,6 +31,12 @@
         if ($('#conference_dinner').is(":checked")) {
             costs += parseInt($("#conference_dinner_price").text(), 10);
         }
+        const lunches = ["lunch_day_1", "lunch_day_2", "lunch_day_3"];
+        lunches.forEach(function(lunch) {
+            if ($("input[name='" + lunch + "']:checked").val() != "--") {
+                costs += parseInt($("#lunch_costs").text().replace(/[^0-9]/g, ''), 10) / 100;
+            }
+        });
     }
     $("#total_due").val(costs.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 }));
 }
diff --git a/templates/register.htm b/templates/register.htm
index 1aaa151..c9abd28 100644
--- a/templates/register.htm
+++ b/templates/register.htm
@@ -491,13 +491,82 @@
     </div>
 
     <div class="form-outline mb-3">
-        <label class="form-label fw-bold" for="participate">Conference Dinner</label>
+        <label class="form-label fw-bold" for="conference_dinner">Conference Dinner</label>
         <div class="form-group form-check">
             <input type="checkbox" class="form-check-input" name="conference_dinner" id="conference_dinner" <?php echo isset($_POST[ 'conference_dinner']) ? 'checked' : '' ?> oninput="update_total_due()" value="conference_dinner">
             <label class="form-check-label fs-4" for="conference_dinner">I will be attending the conference dinner on 20 July at 8pm at the Rheinterrassen for the price of <strong>€&#160;<span id="conference_dinner_price"><?php echo $CONFERENCE_DINNER; ?></span></strong>.
             </label>
         </div>
     </div>
+
+    <label class="form-label fw-bold" for="participate">Lunch Options</label>
+    <div id="lunchHelp " class="form-text fs-4 ">You can optionally pre-order a small lunch for <strong>€ <span id="lunch_costs"><?php echo number_format($LUNCH,2); ?></span></strong> each including a drink. Alternatively, you can choose one of the <a href="https://www.google.de/maps/search/Universität+Mannheim,+Mannheim+restaurants/@49.4832116,8.458566,16z/data=!3m1!4b1">many restaurants nearby</a>.
+        The food is packed in a way that is easy to transport, so that you can easily take it into town or to the green spaces behind the University on the banks of the Rhine.</div>
+    <div id="lunch-1" class="form-outline col-md-4">
+        <label class="form-label" for="pw2">Wednesday, 19 July</label>
+        <div class="form-check">
+            <input class="form-check-input" oninput="update_total_due()" type="radio" name="lunch_day_1" id="lunch_day_1" value="--" checked>
+            <label class="form-check-label" for="lunch_day_1">
+              --
+            </label>
+        </div>
+        <div class="form-check">
+            <input class="form-check-input" oninput="update_total_due()" type="radio" name="lunch_day_1" id="lunch_day_1a" value="non-vegetarian">
+            <label class="form-check-label" for="lunch_day_1a">
+              non-vegetarian
+            </label>
+        </div>
+        <div class="form-check">
+            <input class="form-check-input" oninput="update_total_due()" type="radio" name="lunch_day_1" id="lunch_day_1b" value="vegan">
+            <label class="form-check-label" for="lunch_day_1b">
+              vegan
+            </label>
+        </div>
+    </div>
+    <div id="lunch-2" class="form-outline col-md-4">
+        <label class="form-label" for="pw2">Thursday, 20 July</label>
+        <div class="form-check">
+            <input class="form-check-input" oninput="update_total_due()" type="radio" name="lunch_day_2" id="lunch_day_2" value="--" checked>
+            <label class="form-check-label" for="lunch_day_2">
+              --
+            </label>
+        </div>
+        <div class="form-check">
+            <input class="form-check-input" oninput="update_total_due()" type="radio" name="lunch_day_2" id="lunch_day_2a" value="non-vegetarian">
+            <label class="form-check-label" for="lunch_day_2a">
+              non-vegetarian
+            </label>
+        </div>
+        <div class="form-check">
+            <input class="form-check-input" oninput="update_total_due()" type="radio" name="lunch_day_2" id="lunch_day_2b" value="vegan">
+            <label class="form-check-label" for="lunch_day_2b">
+              vegan
+            </label>
+        </div>
+    </div>
+    <div id="lunch-3" class="form-outline col-md-4">
+        <label class="form-label" for="pw2">Friday, 21 July</label>
+        <div class="form-check">
+            <input class="form-check-input" oninput="update_total_due()" type="radio" name="lunch_day_3" id="lunch_day_3a" value="--" checked>
+            <label class="form-check-label" for="lunch_day_3a">
+              --
+            </label>
+        </div>
+        <div class="form-check">
+            <input class="form-check-input" oninput="update_total_due()" type="radio" name="lunch_day_3" id="lunch_day_3b" value="non-vegetarian">
+            <label class="form-check-label" for="lunch_day_3b">
+              non-vegetarian
+            </label>
+        </div>
+        <div class="form-check">
+            <input class="form-check-input" oninput="update_total_due()" type="radio" name="lunch_day_3" id="lunch_day_3c" value="vegan">
+            <label class="form-check-label" for="lunch_day_3c">
+              vegan
+            </label>
+        </div>
+    </div>
+    <div id="lunchHelp2" class="form-text fs-4">Please note that lunch must be ordered and paid for in advance and unfortunately cannot be purchased spontaneously on site.</div>
+
     <div class="form-outline col-md-12">
         <label class="form-label fw-bold" for="exampleInputAmount">Total Amount in Euro to be paid</label>
         <div class="input-group">