<?php

/*
 * Copyright (C) 2021 Echedey López Romero <elr@disroot.org>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

class Person {

    private $Id;
    private $Name;
    private $Profile;
    private $Gender;
    private $Birthday;
    private $Origin;
    private $Biography;
    private $ImageURL;
    private $DefaultImage;

    public function __construct($Id, $Name, $Profile, $Gender, $Birthday,
            $Origin, $Biography, $ImageURL, $DefaultImage) {
        $this->Id = $Id;
        $this->Name = $Name;
        $this->Profile = $Profile;
        $this->Gender = $Gender;
        $this->Birthday = $Birthday;
        $this->Origin = $Origin;
        $this->Biography = $Biography;
        $this->ImageURL = $ImageURL;
        $this->DefaultImage = $DefaultImage;
    }

    public function RenderContent() {
        $HTML = '';

        $HTML .= '<div class="col-lg-10 col-12 mx-auto px-0">' . PHP_EOL;
        $HTML .= '<div class="container-fluid border border-primary rounded">'
                . PHP_EOL;
        $HTML .= '<div class="row my-3">' . PHP_EOL;
        $HTML .= '<div class="col"></div>' . PHP_EOL;
        $HTML .= '<h2 class="col-xl-6 col-lg-4 col-md-5 col-12 mb-lg-0 mb-2 '
                . 'text-center">Person</h2>' . PHP_EOL;
        $HTML .= '<div class="col text-center">' . PHP_EOL;
        $HTML .= '<a class="h-100 btn btn-block btn-secondary t-large" '
                . 'href=".">Return</a>' . PHP_EOL;
        $HTML .= '</div>' . PHP_EOL;
        $HTML .= '</div>' . PHP_EOL;
        $HTML .= '<div class="row">' . PHP_EOL;
        $HTML .= '<div class="col-lg-4 col-md-6 col-12 mx-auto mb-3">'
                . PHP_EOL;

        if ($this->Profile !== null && $this->Profile !== '') {
            $HTML .= '<img src="' . $this->ImageURL . $this->Profile . '" '
                    . 'class="d-block w-100 mx-auto" alt="' . $this->Name
                    . '"/>' . PHP_EOL;
        } else {
            $HTML .= '<img src="' . $this->DefaultImage . '" class="d-block '
                    . 'w-100 mx-auto" alt="Not specified"/>' . PHP_EOL;
        }

        $HTML .= '</div>' . PHP_EOL;

        $HTML .= '<div class="col-lg-8 col-12 mb-3">' . PHP_EOL;
        $HTML .= '<div class="container-fluid border border-secondary '
                . 'rounded">' . PHP_EOL;

        $HTML .= '<div class="row my-3">' . PHP_EOL;
        $HTML .= '<h3 class="col-12 mb-0">' . PHP_EOL;
        $HTML .= $this->Name . PHP_EOL;
        $HTML .= '</h3>' . PHP_EOL;
        $HTML .= '</div>' . PHP_EOL;

        $HTML .= '<div class="row mb-3">' . PHP_EOL;
        $HTML .= '<span class="col-sm-6 col-12 mb-sm-0 mb-3"><span '
                . 'class="t-large">Gender:</span> ' . PHP_EOL;
        $HTML .= $this->Gender . PHP_EOL;
        $HTML .= '</span>' . PHP_EOL;
        $HTML .= '<span class="col-sm-6 col-12"><span class="t-large">'
                . 'Birthday:</span> ' . PHP_EOL;

        if ($this->Birthday !== null && $this->Birthday !== '') {
            $HTML .= date("d/m/Y",
                            strtotime(str_replace('-"', '/', $this->Birthday)))
                    . PHP_EOL;
        } else {
            $HTML .= 'Not specified' . PHP_EOL;
        }

        $HTML .= '</span>' . PHP_EOL;
        $HTML .= '</div>' . PHP_EOL;

        $HTML .= '<div class="row mb-3">' . PHP_EOL;
        $HTML .= '<span class="col-12"><span class="t-large">Origin:</span> '
                . PHP_EOL;

        if ($this->Origin !== null && $this->Origin !== '') {
            $HTML .= $this->Origin . PHP_EOL;
        } else {
            $HTML .= 'Not specified' . PHP_EOL;
        }

        $HTML .= '</span>' . PHP_EOL;
        $HTML .= '</div>' . PHP_EOL;

        $HTML .= '<div class="row mb-3">' . PHP_EOL;
        $HTML .= '<div class="col-12">' . PHP_EOL;
        $HTML .= '<div class="container">' . PHP_EOL;

        $HTML .= '<div class="row mb-2">' . PHP_EOL;
        $HTML .= '<h4 class="col-12 mb-0 px-0">Biography</h4>' . PHP_EOL;
        $HTML .= '</div>' . PHP_EOL;

        $HTML .= '<div class="row">' . PHP_EOL;
        $HTML .= '<p class="col-12 mb-0 px-0">' . PHP_EOL;

        if ($this->Biography !== null && $this->Biography !== '') {
            $HTML .= $this->Biography . PHP_EOL;
        } else {
            $HTML .= 'Not specified' . PHP_EOL;
        }

        $HTML .= '</p>' . PHP_EOL;
        $HTML .= '</div>' . PHP_EOL;

        $HTML .= '</div>' . PHP_EOL;
        $HTML .= '</div>' . PHP_EOL;
        $HTML .= '</div>' . PHP_EOL;

        $HTML .= '</div>' . PHP_EOL;

        $HTML .= '</div>' . PHP_EOL;
        $HTML .= '</div>' . PHP_EOL;
        $HTML .= '</div>' . PHP_EOL;
        $HTML .= '</div>' . PHP_EOL;
        $HTML .= '</div>' . PHP_EOL;

        return $HTML;
    }

}
