<?php

// No direct access.

defined('_JEXEC') or die;

class ClubsClub extends AbstractClubsModel
{
    protected $id;
    protected $name;
    protected $address;
    protected $city;
    protected $homepage;
    protected $mail;
    protected $iban;
    protected $bic;
    protected $charitable;
    protected $president;
    
    /**
     * @return string
     */
    public function getAddress()
    {
        return $this->address;
    }

    /**
     * @return string
     */
    public function getCity()
    {
        return $this->city;
    }

    /**
     * @return string
     */
    public function getHomepage()
    {
        return $this->homepage;
    }

    /**
     * @return string
     */
    public function getMail()
    {
        return $this->mail;
    }

    /**
     * @return string
     */
    public function getIban()
    {
        return $this->iban;
    }

    /**
     * @return string
     */
    public function getBic()
    {
        return $this->bic;
    }

    /**
     * @return bool
     */
    public function isCharitable()
    {
        return $this->charitable;
    }

    /**
     * @return int
     */
    public function getPresidentId()
    {
        return $this->president->getId();
    }
    
    /**
     * @return ClubsUser
     */
    public function getPresident()
    {
        return $this->president;
    }

    /**
     * @param string $address
     */
    public function setAddress( $address)
    {
        $this->address = $address;
    }

    /**
     * @param string $city
     */
    public function setCity($city)
    {
        $this->city = $city;
    }

    /**
     * @param string $homapge
     */
    public function setHomepage($homapge)
    {
        $this->homepage = $homapge;
    }

    /**
     * @param string $mail
     */
    public function setMail($mail)
    {
        $this->mail = $mail;
    }

    /**
     * @param string $iban
     */
    public function setIban($iban)
    {
        $this->iban = $iban;
    }

    /**
     * @param string $bic
     */
    public function setBic($bic)
    {
        $this->bic = $bic;
    }

    /**
     * @param bool $charitable
     */
    public function setCharitable(bool $charitable)
    {
        $this->charitable = $charitable;
    }

    /**
     * @param int $presidentId
     */
    public function setPresidentId(int $presidentId)
    {
        $this->president = ClubsUser::loadUser($presidentId);
    }
    
    /**
     * @param ClubsUser $user
     */
    public function setPresident(ClubsUser $user)
    {
        $this->president = $user;
    }

    /**
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * @param string $name
     */
    public function setName($name)
    {
        $this->name = $name;
    }
    
    
    
    public static function loadClubs()
    {
        return self::loadElements(self::tableName, self::className);
    }
    
    public static function loadClub($id)
    {
        return self::loadElement($id, self::tableName, self::className);
    }
    
    protected function __construct()
    {}
    
    public static function createClub()
    {
        $club = new ClubsClub();
        $club->id = 'new';
        return $club;
    }
    
    
    
    
    
    public function getPlaces()
    {
        return ClubsPlace::loadPlacesOfClub($this->id);
    }
    

    public function getOffers()
    {
        return 0;
    }
    
    
    protected function loadCustomData($assoc)
    {
        parent::loadCustomData($assoc);
        $this->president = ClubsUser::loadUser($assoc['president']);
    }
    
    protected function postQuoteFilter(&$values)
    {
        parent::postQuoteFilter($values);
        $values['president'] = $this->president->getId();
    }
    
    protected function prepareDelete($dbo)
    {}
    
    protected function getDataMappings()
    {
        return array('name', 'address', 'city', 'homepage', 'mail', 'iban', 'bic', 'charitable', 'president');
    }

    protected function getRequiredDataMappings()
    {
        return array('name', 'address', 'city', 'mail', 'iban', 'bic');
    }
    
    private const tableName = '#__club_clubs';
    private const className = 'ClubsClub';
    protected function getTableName()
    {
        return self::tableName;
    }

    
    
}