<?php
require_once 'vendor/autoload.php';
include_once 'utils.php';

class User
{
    public $id;
    public $username;
    public $title;
    public $first_name;
    public $last_name;
    public $organization;
    public $user_hash;
    public $password;
    public $street;
    public $zip;
    public $city;
    public $country;
    public $email;
    public $phone;
    public bool $eula_signed;
    public bool $privacy_policy_signed;
    public bool $author;
    public $accepted_paper_id;
    public bool $participation_confirmed;
    public $participation_confirmed_at;
    public bool $student;
    public bool $conference_dinner;
    public bool $vegetarian_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;
    public bool $presentation_confirmed;

    function __construct()
    {
        $this->id = "";
        $this->username = "";
        $this->title = "";
        $this->first_name = "";
        $this->last_name = "";
        $this->email = "";
        $this->organization = "";
        $this->user_hash = "";
        $this->password = "";
        $this->city = "";
        $this->country = "";
        $this->zip = "";
        $this->street = "";
        $this->phone = "";
        $this->eula_signed = false;
        $this->privacy_policy_signed = false;
        $this->author = false;
        $this->accepted_paper_id = "";
        $this->participation_confirmed = false;
        $this->participation_confirmed_at = "";
        $this->student = false;
        $this->conference_dinner = false;
        $this->vegetarian_dinner = false;
        $this->registered_at = date("Y-m-d H:i:s") . "UTC";
        $this->earlybird_registration = false;
        $this->lunch_day_1 = "";
        $this->lunch_day_2 = "";
        $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) {
            if (array_key_exists($key, (array) $this))
                $this->{$key} = $value;
        }
        if (isset($data->password)) $this->set_password($data->password);
    }

    function init_from_object(object $data)
    {
        foreach ($data as $key => $value) {
            if (array_key_exists($key, (array) $this))
                $this->{$key} = $value;
        }
        if (isset($data->password)) $this->set_password($data->password);
    }

    function init_from_array(array $data)
    {
        foreach ($data as $key => $value) {
            if (array_key_exists($key, (array) $this)) {
                if (is_bool(gettype($this->{$key})) && is_string($value))
                    $this->{$key} = !empty($value);
                else
                    $this->{$key} = $value;
            }
        }
        if (!empty($data["password"])) $this->set_password($data["password"]);
    }


    function set_password(string $password)
    {
        include 'config.php';
        if ($CONFERENCE_REGISTRATION) {
            $this->password = generateRandomString(32);
            # $this->user_hash = "{SHA}" .  base64_encode(sha1($password, true));
        } else {
            if ($ENCRYPT_PASSWORDS) {
                $this->user_hash = "{crypt}" . crypt($password, '$6$' . generateSalt(10) . '$');
                # $this->user_hash = "{SHA}" .  base64_encode(sha1($password, true));
            } else {
                $this->user_hash = "{CLEAR}" . $password;
            }
            $this->password = $this->user_hash;
        }
    }

    function to_string()
    {
        $tmp_user = $this;
        $tmp_user->invoice = "";
        $tmp_user->password = "***";
        $tmp_user->user_hash = "***";
        return  json_encode($tmp_user);
    }

    function backup_in_session()
    {
        global $_SESSION;
        foreach ($this as $key => $value) {
            $_SESSION[$key] = $value;
        }
    }

    function to_table() {
        $table = "<table  style='border: 1px solid #e1e4e8; border-collapse: collapse; width: 100%;'>";
        foreach ($this as $key => $value) {
            if ($key != "password" && $key != "user_hash" && !empty($value) && $key != "invoice") {
                if (is_bool($value)) {
                    if ($value) $value = "yes";
                    else $value = "no";
                } elseif(is_float($value)) {
                    $key .= " €";
                    $value = number_format($value, 2, '.', ' ');
                }
                $value = str_replace("\r\n", "<br>", $value);
                $key = str_replace("_", " ", ucfirst($key));
                $table .= " <tr>
  <td style='border: 1px solid #e1e4e8; padding: 6px 13px;'><strong>$key</strong></td>
  <td style='border: 1px solid #e1e4e8; padding: 6px 13px;'>$value</td>
 </tr>\n";
            }
        }
        $table .= "</table>";
        return $table;
    }
}