Add $CONFERENCE_REGISTRATION flag and for fields

Change-Id: I296f5350fb4a5f34c39a15bcbabc511f735f2fc6
diff --git a/config.php.example b/config.php.example
index db94b43..7d58bc2 100755
--- a/config.php.example
+++ b/config.php.example
@@ -14,6 +14,15 @@
 $ENCRYPT_PASSWORDS = false;
 
 $SERVICE_ACRONYM = "Test Service";
+#$CONFERENCE_REGISTRATION = true;
+$SERVICE_LOGO = "./static/Test_Logo.svg";
+$SERVICE_NAME = "International Test Corpus";
+
+$REGULAR_CONFERENCE_FEE = 280;
+$EARLYBIRD_CONFERENCE_FEE = 240;
+$CONFERENCE_DINNER = 60;
+$STUDENT_DISCOUNT = 80;
+$EARLYBIRD_DEADLINE = "15 May 2023"; // HAWAIAN TIME (HST) is used :)
 
 // Redis password
 $REDIS_PASS = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
diff --git a/static/main.js b/static/main.js
index e381ac6..a07eb52 100644
--- a/static/main.js
+++ b/static/main.js
@@ -2,6 +2,7 @@
 (function () {
     'use strict';
     window.addEventListener('load', function () {
+        update_total_costs();
         // Fetch all the forms we want to apply custom Bootstrap validation styles to
         var forms = document.getElementsByClassName('needs-validation');
         // Loop over them and prevent submission
@@ -17,6 +18,37 @@
     }, false);
 })();
 
+function update_total_costs() {
+    var costs = 0;
+
+
+    if ($('#participate').is(":checked")) {
+        costs += parseInt($("#conference_fee").text(),10);
+        if ($('#student').is(":checked")) {
+            costs -= parseInt($("#student_discount").text(), 10);
+        }
+        if ($('#conference_dinner').is(":checked")) {
+            costs += parseInt($("#conference_dinner_price").text(), 10);
+        }
+    }
+    $("#total_costs").val(costs.toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2}));
+}
+
+function update_paper_id_field() {
+    var paper_id = $("#paper_id");
+    if ($('#author').is(":checked")) {
+        paper_id.removeAttr('disabled');
+        paper_id.attr('placeholder', '0000');
+        paper_id.attr('pattern', '\\d{4}');
+        paper_id.attr('required', 'required');
+    } else {
+        paper_id.val('');
+        paper_id.attr('disabled', 'disabled');
+        paper_id.removeAttr('placeholder');
+        paper_id.removeAttr('pattern');
+        paper_id.removeAttr('required');
+    }
+}
 
 function check_password_match() {
     pass = $("#pw1").val();
diff --git a/templates/register.htm b/templates/register.htm
index a295016..8645c1b 100644
--- a/templates/register.htm
+++ b/templates/register.htm
@@ -1,46 +1,53 @@
-<div class="container ml-0 pl-0">
-    <header class="d-flex flex-wrap py-340 mb-8 border-bottom">
-        <div class="col-md-12 justify-content-start pb-5 float-start">
-            <a href="/">
-                <img class="" width="340" src="<?php echo $SERVICE_LOGO;?>" alt="<?php echo $SERVICE_NAME; ?>" />
-            </a>
-        </div>
 
-        <div class="col-md-12 bold navbar-expand-lg mt-5 ml-5  pl-5 bg-primary" data-bs-theme="dark">
-            <ul class="nav nav-pills justify-content-start fs-4">
-                <li class="nav-item"><a href="https://korpus.cz/icc" class="nav-link">Home</a></li>
-                <li class="nav-item"><a href="#" class="nav-link active" aria-current="page">Sign up</a></li>
-                <li class="nav-item"><a href="#" class="nav-link">Query</a></li>
-            </ul>
-        </div>
-    </header>
-</div>
-
-  <h1>Sign up for 
-    <?php echo $SERVICE_ACRONYM;?>
-</h1>
+<header class="d-flex flex-wrap py-340 mb-8 pb-5">
+    <div class="col-md-2 justify-content-start align-self-center pb-1 float-start">
+        <a href="/">
+            <img class="" width="80" src="<?php echo $SERVICE_LOGO;?>" alt="<?php echo $SERVICE_NAME; ?>" />
+        </a>
+    </div>
+    <div class="col-md-10 justify-content-start pb-1 align-self-center float-start">
+        <h1 class=" fw-bold">
+            <?php echo $SERVICE_NAME; ?>
+        </h1>
+    </div>
+    
+            <div class="col-md-12 bold navbar-expand-lg mt-5 ml-5  pl-5 bg-primary" data-bs-theme="dark">
+                <ul class="nav nav-pills justify-content-start fs-4">
+                    <li class="nav-item"><a href="https://korpus.cz/icc" class="nav-link">Home</a></li>
+                    <li class="nav-item"><a href="#" class="nav-link active" aria-current="page">Sign up</a></li>
+                    <li class="nav-item"><a href="#" class="nav-link">Query</a></li>
+                </ul>
+            </div>
+    <div class="col-md-12 justify-content-start align-self-center pb-1 float-start">
+            <h2 class="text-center fw-bold">
+        <?php echo $SERVICE_ACRONYM;?> Registration
+    </h2>
+    </div>
+</header>
 
 <form class="row g-3 needs-validation" novalidate data-toggle="validator" action="" method="POST">
+    <?php if(! $CONFERENCE_REGISTRATION ): ?>
     <!-- Username input -->
     <div class="col-md-4">
-        <label class="form-label font-weight-bold" for="form3Example3">Username</label>
+        <label class="form-label fw-bold" for="form3Example3">Username</label>
         <input pattern="[^\s]{<?php echo $VAL_USER->min_username.','.$VAL_USER->max_username;?>}" required
             title="At least 5 not whitespace characters" name="username" type="text" id="form3Example0"
-            class="form-control <?php if(isset($error) && $error && !isset($_POST['username'])){echo 'border-danger';}?>"
+            class="form-control fs-4 <?php if(isset($error) && $error && !isset($_POST['username'])){echo 'border-danger';}?>"
             placeholder="johndoe"
             value="<?php echo isset($_POST['username']) ? htmlspecialchars($_POST['username']) : '' ?>" />
         <div class="invalid-feedback">
             Please choose a username with at least 5 not whitespace characters.
         </div>
     </div>
+    <?php endif; ?>
     <!-- 2 column grid layout with text inputs for the first and last names -->
         <div class="col-md-4">
             <div class="form-outline">
-                <label class="form-label font-weight-bold" for="form3Example1">First name</label>
+                <label class="form-label fw-bold" for="form3Example1">First name</label>
                 <input pattern="[^\s]{<?php echo $VAL_USER->min_first_name.','.$VAL_USER->max_first_name;?>}" required
                     title="At least 2 not whitespace characters" name="first_name" type="text" id="form3Example1"
-                    class="form-control <?php if(isset($error) && $error && !isset($_POST['first_name'])){echo 'border-danger';}?>"
-                    placeholder="John"
+                    class="form-control fs-4 <?php if(isset($error) && $error && !isset($_POST['first_name'])){echo 'border-danger';}?>"
+                    placeholder="Jane"
                     value="<?php echo isset($_POST['first_name']) ? htmlspecialchars($_POST['first_name']) : '' ?>" />
                 <div class="invalid-feedback">
                         Please provide a first name with at least 2 characters.
@@ -49,10 +56,10 @@
         </div>
         <div class="col-md-4">
             <div class="form-outline">
-                <label class="form-label font-weight-bold" for="form3Example2">Last name</label>
+                <label class="form-label fs-4 fs-4 fw-bold" for="form3Example2">Last name</label>
                 <input pattern="[^\s]{<?php echo $VAL_USER->min_last_name.','.$VAL_USER->max_last_name;?>}" required
                     title="At least 2 not whitespace characters" name="last_name" type="text" id="form3Example2"
-                    class="form-control <?php if(isset($error) && $error && !isset($_POST['last_name'])){echo 'border-danger';}?>"
+                    class="form-control fs-4 <?php if(isset($error) && $error && !isset($_POST['last_name'])){echo 'border-danger';}?>"
                     placeholder="Doe"
                     value="<?php echo isset($_POST['last_name']) ? htmlspecialchars($_POST['last_name']) : '' ?>" />
                 <div class="invalid-feedback">
@@ -62,9 +69,9 @@
         </div>
 
     <div class="form-outline md-6">
-        <label class="form-label font-weight-bold" for="organization">Institution / Organization</label>
+        <label class="form-label fw-bold" for="organization">Affiliation</label>
         <input required name="organization" type="text" id="organization"
-            class="form-control <?php if(isset($error) && $error && !isset($_POST['organization'])){echo 'border-danger';}?>"
+            class="form-control fs-4 <?php if(isset($error) && $error && !isset($_POST['organization'])){echo 'border-danger';}?>"
             placeholder="Example University"
             pattern=".{3,64}"
             type="text"
@@ -76,15 +83,15 @@
 
     <!--
     <div class="form-outline col-md-6">
-        <label for="address-line-1" class="form-label form-label font-weight-bold">Address line 1</label>
-        <input name="address-line-1" type="text" class="form-control" id="address-line-1"/>
+        <label for="address-line-1" class="form-label form-label fw-bold">Address line 1</label>
+        <input name="address-line-1" type="text" class="form-control fs-4" id="address-line-1"/>
     </div>
     Address line 1-->
 
     <!-- Street -->
     <div class="form-outline col-md-12">
-        <label for="street" class="form-label form-label font-weight-bold">Street</label>
-        <input name="street" type="text" class="form-control" id="street"
+        <label for="street" class="form-label form-label fw-bold">Street</label>
+        <input name="street" type="text" class="form-control fs-4" id="street"
         placeholder="1234 Main St"
         value="<?php echo isset($_POST['street']) ? htmlspecialchars($_POST['street']) : '' ?>"
         required/>
@@ -95,8 +102,8 @@
 
     <!-- Zip code -->
     <div class="form-outline col-md-3">
-        <label for="zip-code" class="form-label form-label font-weight-bold">Zip</label>
-        <input name="zip" type="text" class="form-control" id="zip-code"
+        <label for="zip-code" class="form-label form-label fw-bold">Zip</label>
+        <input name="zip" type="text" class="form-control fs-4" id="zip-code"
         value="<?php echo isset($_POST['zip']) ? htmlspecialchars($_POST['zip']) : '' ?>"
         required/>
         <div class="invalid-feedback">
@@ -106,8 +113,8 @@
 
     <!-- City -->
     <div class="form-outline col-md-5">
-        <label for="city" class="form-label form-label font-weight-bold">City</label>
-        <input name="city" type="text" class="form-control" id="city"
+        <label for="city" class="form-label form-label fw-bold">City</label>
+        <input name="city" type="text" class="form-control fs-4" id="city"
         value="<?php echo isset($_POST['city']) ? htmlspecialchars($_POST['city']) : '' ?>"
         required/>
         <div class="invalid-feedback">
@@ -117,8 +124,8 @@
 
     <!-- Country -->
     <div class="form-outline col-md-6">
-        <label for="country" class="form-label form-label font-weight-bold">Country</label>
-        <input class="form-control" list="countries" name="country" id="country" 
+        <label for="country" class="form-label form-label fw-bold">Country</label>
+        <input class="form-control fs-4" list="countries" name="country" id="country" 
         value="<?php echo isset($_POST['country']) ? htmlspecialchars($_POST['country']) : '' ?>"
         required placeholder="Type to search your country...">
         <datalist id="countries">
@@ -379,9 +386,9 @@
 
     <!-- Email input -->
     <div class="form-outline md-6">
-        <label class="form-label font-weight-bold" for="email">Email address</label>
+        <label class="form-label fw-bold" for="email">Email address</label>
         <input required name="email" type="email" id="email"
-            class="form-control <?php if(isset($error) && $error && !isset($_POST['email'])){echo 'border-danger';}?>"
+            class="form-control fs-4 <?php if(isset($error) && $error && !isset($_POST['email'])){echo 'border-danger';}?>"
             type="email"
             pattern="^[^\s@]+@[^\s@]+\.[^\s@]+$"
             placeholder="myemail@example.org"
@@ -393,9 +400,9 @@
 
     <!-- Phone number -->
     <div class="form-outline md-6">
-        <label class="form-label font-weight-bold" for="phone">Phone number</label>
+        <label class="form-label fw-bold" for="phone">Phone number</label>
         <input required name="phone" type="tel" id="phone"
-            class="form-control <?php if(isset($error) && $error && !isset($_POST['phone'])){echo 'border-danger';}?>"
+            class="form-control fs-4 <?php if(isset($error) && $error && !isset($_POST['phone'])){echo 'border-danger';}?>"
             pattern="\+\d[\s\d-]+$"
             placeholder="+1 234 567 890"
             value="<?php echo isset($_POST['phone']) ? htmlspecialchars($_POST['phone']) : '' ?>" 
@@ -406,18 +413,19 @@
             </div>
     </div>
 
+    <?php if(! $CONFERENCE_REGISTRATION ): ?>
     <!-- Password input -->
     <div id="password-div" class="col-md-8">
-        <label class="form-label font-weight-bold" for="pw1">Password</label>
+        <label class="form-label fw-bold" for="pw1">Password</label>
         <input required
             title="Combination of upper and lowercase letters, numbers, punctuation, and special symbols" name="password" type="password" id="pw1"
-            class="form-control"
+            class="form-control fs-4"
             placeholder="********"  oninput="check_password_match()"
             value="<?php echo isset($_POST['password']) ? htmlspecialchars($_POST['password']) : '' ?>" />
     </div>
     <div class="col-md-4">
         <label class="form-label" for="pwqinfo">Rating</label>
-        <input class="form-control" type="text" id="pwqinfo" readonly />
+        <input class="form-control fs-4" type="text" id="pwqinfo" readonly />
     </div>
 
     <div class="col-md-12">
@@ -430,7 +438,7 @@
     <!--
     <div class="form-group">
         <label for="pwqinfo">Password rating</label>
-        <input class="form-control" type="text" name="pwqinfo" id="pwqinfo" readonly>
+        <input class="form-control fs-4" type="text" name="pwqinfo" id="pwqinfo" readonly>
         <div class="progress mt-2">
             <div class="progress-bar bg-danger" role="progressbar" id="pwqbar2" aria-valuenow="0" aria-valuemin="0"
                 aria-valuemax="100"></div>
@@ -439,42 +447,121 @@
     -->
     <!-- Password confirmation input -->
     <div id="pwconfirm" class="form-outline col-md-8">
-        <label class="form-label font-weight-bold" for="pw2">Confirm your Password</label>
+        <label class="form-label fw-bold" for="pw2">Confirm your Password</label>
         <input  required
             name="password_confirm" type="password" id="pw2"
-            class="form-control <?php if(isset($error) && $error && !isset($_POST['password_confirm'])){echo 'border-danger';}?>"
+            class="form-control fs-4 <?php if(isset($error) && $error && !isset($_POST['password_confirm'])){echo 'border-danger';}?>"
             placeholder="********" oninput="check_password_match()" 
             value="<?php echo isset($_POST['password_confirm']) ? htmlspecialchars($_POST['password_confirm']) : '' ?>" />
             <div class="invalid-feedback">
                 Passwords do not match.
             </div>
-    </div> 
+    </div>
     <div class="form-outline mb-3">
-        <label class="form-label font-weight-bold" for="eula">End User License Agreement</label>
+        <label class="form-label fw-bold" for="eula">End User License Agreement</label>
         <div class="form-group form-check">
             <input type="checkbox" class="form-check-input" name="eula_signed" id="eula" required
                 title="You need to agree to the EULA in order to proceed"
                 <?php echo isset($_POST['eula_signed']) ? 'checked' : '' ?>
                 value="eula">
-            <label class="form-check-label" for="eula">I have read and agree to to the
+            <label class="form-check-label fs-4" for="eula">I have read and agree to to the
                 <?php echo $SERVICE_ACRONYM; ?> <a
                     href="https://www2.ids-mannheim.de/cosmas2/projekt/register/license_agreement.html">End User License
-                    Agreement</a> and will use
-                <?php echo $SERVICE_ACRONYM; ?> only for academic and non-commercial purposes.
+                    Agreement</a> and will use the
+                <?php echo $SERVICE_ACRONYM; ?> services only for academic and non-commercial purposes.
             </label>
             <div class="invalid-feedback">
                 You need to agree to the EULA in order to proceed.
             </div>
         </div>
     </div>
+    <?php endif; ?>
+     <?php if( $CONFERENCE_REGISTRATION ): ?>
+     <div class="form-outline col-md-7">
+        <label class="form-label fw-bold" for="student">Author Status</label>
+        <div class="form-group form-check">
+            <input type="checkbox" class="form-check-input" name="author" id="author"
+                <?php echo isset($_POST['author']) ? 'checked' : '' ?>
+                oninput="update_paper_id_field()"
+                value="author">
+            <label class="form-check-label fs-4" for="author">I am an author of a paper accepted for the conference.
+            </label>
+        </div>
+    </div>
+
+    <div class="form-outline col-md-5">
+        <label class="form-label fw-bold" for="student">Paper ID</label>
+        <input type="text" class="form-control fs-4" name="accepted_paper_id" id="paper_id"
+            <?php echo isset($_POST['author']) ? 'placeholder="0000"' : 'disabled' ?>
+            value="<?php echo isset($_POST['paper_id']) ? htmlspecialchars($_POST['paper_id']) : '' ?>" />
+            <div class="invalid-feedback">
+                Please provide the 4 digits ID of your accepted paper.
+            </div>
+    </div>
+
     <div class="form-outline mb-3">
-        <label class="form-label font-weight-bold" for="privacy_policy">Privacy Policy</label>
+        <label class="form-label fw-bold" for="participate">Confirmation of Participation</label>
+        <div class="form-group form-check">
+            <input type="checkbox" class="form-check-input" name="participation_confirmed" id="participate" required
+                <?php echo isset($_POST['participation_confirmed']) ? 'checked' : '' ?>
+                oninput="update_total_costs()"
+                value="participation_confirmed">
+            <label class="form-check-label fs-4" for="participation_confirmed">I confirm that I will be attending the <?php echo $SERVICE_ACRONYM; ?> conference. 
+                <?php if(new DateTimeImmutable("now") <= new DateTimeImmutable($EARLYBIRD_DEADLINE." 23:59:59 HST")) {
+                    echo "The early bird conference fee of <strong>€ <span id='conference_fee'>". $EARLYBIRD_CONFERENCE_FEE."</span></strong> is still valid until ".$EARLYBIRD_DEADLINE.".
+                     (afterwards the fee fee will be € <span id='conference_fee'>". $REGULAR_CONFERENCE_FEE.")";
+                    } else {
+                        echo "The conference fee is <strong>€ <span id='conference_fee'>". $REGULAR_CONFERENCE_FEE."</span></strong>.";
+                    } ?>
+            </label>
+            <div class="invalid-feedback">
+                You need to confirm your participation in order to proceed.
+            </div>
+        </div>
+    </div>
+
+
+     <div class="form-outline mb-3">
+        <label class="form-label fw-bold" for="student">Student Discount</label>
+        <div class="form-group form-check">
+            <input type="checkbox" class="form-check-input" name="student" id="student"
+                <?php echo isset($_POST['student']) ? 'checked' : '' ?>
+                oninput="update_total_costs()"
+                value="student">
+            <label class="form-check-label fs-4" for="student">I am student and will therefore benefit from student discount of <strong>€ <span id="student_discount"><?php echo $STUDENT_DISCOUNT; ?></span></strong>.
+            </label>
+        </div>
+    </div>
+
+    <div class="form-outline mb-3">
+        <label class="form-label fw-bold" for="participate">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_costs()"
+                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>€ <span id="conference_dinner_price"><?php echo $CONFERENCE_DINNER; ?></span></strong>.
+            </label>
+        </div>
+    </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">
+              <div class="input-group-text fs-3">€</div>
+              <input lang="en" name="total_costs" id="total_costs" class="form-control text-end fw-bold fs-3" readonly>
+            </div>
+            <div id="totalHelp" class="form-text">Only bank transfer is available as a payment method. After submitting the form, you will be asked to confirm your e-mail address. After you have confirmed it, you will receive an invoice and the bank details.</div>
+    </div>
+
+    <?php endif; ?>
+    <div class="form-outline mb-3">
+        <label class="form-label fw-bold" for="privacy_policy">Privacy Policy</label>
         <div class="form-group form-check">
             <input type="checkbox" class="form-check-input" name="privacy_policy_signed" id="privacy_policy" required
                 title="You need to agree to the privacy policy in order to proceed"
                 <?php echo isset($_POST['privacy_policy_signed']) ? 'checked' : '' ?>
                 value="privacy_policy">
-            <label class="form-check-label" for="privacy_policy">I have read and agree
+            <label class="form-check-label fs-4" for="privacy_policy">I have read and agree
                 to to the
                 <?php echo $SERVICE_ACRONYM; ?> <a
                     href="https://www2.ids-mannheim.de/cosmas2/web-app/datenschutz.html">Privacy Policy</a>.
@@ -488,7 +575,7 @@
     <?php if($CAPTCHA_LENGTH > 0): ?>
     <!--captcha here-->
     <div class="form-outline mb-3">
-        <label class="form-label font-weight-bold" for="form3Example4">Captcha</label>
+        <label class="form-label fw-bold" for="form3Example4">Captcha</label>
         <div class="container mb-2 offset-md-2">
             <img id="captcha" src="<?php echo $BASE_URL.'/captcha.php?token='.$_SESSION['captcha_token']; ?>" />
             <div id="reload_captcha">
@@ -498,7 +585,7 @@
         </div>
         <input pattern="[^\s]{<?php echo $CAPTCHA_LENGTH; ?>,}" required
             title="Please fill the captcha. It has <?php echo $CAPTCHA_LENGTH; ?> characters" name="captcha" type="text" id="form3Example6"
-            class="form-control" placeholder="Type what you see on the image above" />
+            class="form-control fs-4" placeholder="Type what you see on the image above" />
             <div class="invalid-feedback">
                 Type what you see on the image above.
             </div>
@@ -506,9 +593,7 @@
     <?php endif; ?>
 
     <!-- Submit button -->
-    <div class="container mt-2 text-right">
-    <button name="type" value="register" type="submit" class="btn btn-primary font-weight-bold fs-4">Sign up</button>
-        </div>
+    <button name="type" value="register" type="submit" class="btn btn-primary float-right fs-3 fw-bold" style="border: #42b23cff; background-color: #42b23cff;"">Register for <?php echo $SERVICE_ACRONYM; ?></button>
 
 </form>
 </div>