<?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 bool $excursion;
    public float $total_due;
    public $invoice;
    public bool $presentation_confirmed;
    public $amount_open;

    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->excursion = false;
        $this->total_due = 0.0;
        $this->invoice = "";
        $this->presentation_confirmed = false;
        $this->amount_open = 0.0;
    }

    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;
    }
}