Add paper presentation confirmation

Change-Id: I31b8cc168800d0bae889a2d7cbe7d21116828594
diff --git a/User.php b/User.php
index 8326033..e7efc44 100644
--- a/User.php
+++ b/User.php
@@ -34,6 +34,7 @@
     public $lunch_day_3;
     public float $total_due;
     public $invoice;
+    public bool $presentation_confirmed;
 
     function __construct()
     {
@@ -67,8 +68,23 @@
         $this->lunch_day_3 = "";
         $this->total_due = 0.0;
         $this->invoice = "";
+        $this->presentation_confirmed = false;
     }
 
+    function set_name_and_paper_id($first_name, $last_name, $paper_id): User
+    {
+        $this->first_name = $first_name;
+        $this->last_name = $last_name;
+        $this->accepted_paper_id = $paper_id;
+        return $this;
+    }
+
+    function set_email_and_paper_id($email, $paper_id): User
+    {
+        $this->email = $email;
+        $this->accepted_paper_id = $paper_id;
+        return $this;
+    }
     function __construct1(object $data)
     {
         foreach ($data as $key => $value) {
diff --git a/create_user_table.sql b/create_user_table.sql
index 480b623..d5abe47 100644
--- a/create_user_table.sql
+++ b/create_user_table.sql
@@ -33,5 +33,6 @@
     invoice_reference varchar(32) not null default '',
     paid boolean not null default false,
     paid_when date,
+    presentation_confirmed boolean not null default false,
   primary key (`id`)
 ) engine=innodb AUTO_INCREMENT=100;
diff --git a/db_backend.php b/db_backend.php
index 182a1c7..d028241 100644
--- a/db_backend.php
+++ b/db_backend.php
@@ -34,7 +34,9 @@
                 $a[$key] = $value;
             }
         }
-        $a["participation_confirmed_at"] = date("Y-m-d H:i:s UTC");
+        if ($user->participation_confirmed) {
+            $a["participation_confirmed_at"] = date("Y-m-d H:i:s UTC");
+        }
         $keys = array_keys($a);
         $sql = "INSERT INTO person (" . implode(", ", $keys) . ") \n";
         $sql .= "VALUES ( :" . implode(", :", $keys) . ")";
@@ -55,11 +57,11 @@
             $stmt = $this->pdo->prepare($sql);
             $stmt->bindValue(':table', $table, PDO::PARAM_STR);
             $stmt->execute();
-            $output = array();
+            $persons = array();
             while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
-                $output[$row['COLUMN_NAME']] = $row['COLUMN_NAME'];
+                $persons[$row['COLUMN_NAME']] = $row['COLUMN_NAME'];
             }
-            return $output;
+            return $persons;
         } catch (PDOException $pe) {
             trigger_error('Could not connect to MySQL database. ' . $pe->getMessage(), E_USER_ERROR);
         }
@@ -78,7 +80,7 @@
 
     function mail_count($email)
     {
-        $sql = "SELECT COUNT(*) FROM person WHERE email = :email";
+        $sql = "SELECT COUNT(*) FROM person WHERE email = :email AND participation_confirmed";
         try {
             $stmt = $this->pdo->prepare($sql);
             $stmt->bindValue(':email', $email, PDO::PARAM_STR);
@@ -89,4 +91,23 @@
             trigger_error('Could not connect to MySQL database. ' . $pe->getMessage(), E_USER_ERROR);
         }
     }
+
+    function get_persons($filter)
+    {
+        $sql = "SELECT *, NULL as invoice FROM person " . ($filter?  "WHERE " . $filter : '');   
+
+        try {
+            $stmt = $this->pdo->prepare($sql);
+            $stmt->execute();
+            $persons = array();
+            while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
+                $user = new User();
+                $user->init_from_array($row);
+                $persons[] = $user;
+            }
+            return $persons;
+        } catch (PDOException $pe) {
+            trigger_error('Could not connect to MySQL database. ' . $pe->getMessage(), E_USER_ERROR);
+        }
+    }
 }