<?php

class Setting
{
    private $IDSetting;
    private $clubName;
    private $smtpServer;
    private $smtpUser;
    private $smtpPassword;
    private $smtpSSL;

    private $smtpPort;
    private $mailContentParticipiantValidationToRLObject;

    private $mailContentParticipiantValidationToRL;
    private $mailContentParticipiantExcusationToRLObject;

    private $mailContentParticipiantExcusationToRL;

    private $mailContentParticipiantValidationToMemberObject;

    private $mailContentParticipiantValidationToMember;

    private $mailContentParticipiantExcusationToMemberObject;

    private $mailContentParticipiantExcusationToMember;

    private $mailContentRaceStateChangeObject;

    private $mailContentRaceStateChange;

    private static $instance = null;

    private function __construct() {
        $this->loadSetting();
    }

    public static function getInstance()
    {
        if (self::$instance === null) {
            self::$instance = new self();
        }
        return self::$instance;
    }

    function loadSetting()
    {
        global $wpdb;

        $sql = "
           SELECT * FROM cass_setting WHERE IDSetting = 1;
         ";

        $result = $wpdb->get_row($wpdb->prepare($sql));
        $this->setIDSetting($result->IDSetting);
        $this->setClubName($result->clubName);
        $this->setSmtpServer($result->smtpServer);
        $this->setSmtpUser($result->smtpUser);
        $this->setSmtpPassword($result->smtpPassword);
        $this->setSmtpSSL($result->smtpSSL);
        $this->setSmtpPort($result->smtpPort);
        $this->setMailContentParticipiantValidationToRLObject($result->mailContentParticipiantValidationToRLObject);
        $this->setMailContentParticipiantValidationToRL($result->mailContentParticipiantValidationToRL);
        $this->setMailContentParticipiantExcusationToRLObject($result->mailContentParticipiantExcusationToRLObject);
        $this->setMailContentParticipiantExcusationToRL($result->mailContentParticipiantExcusationToRL);
        $this->setMailContentParticipiantValidationToMemberObject($result->mailContentParticipiantValidationToMemberObject);
        $this->setMailContentParticipiantValidationToMember($result->mailContentParticipiantValidationToMember);
        $this->setMailContentParticipiantExcusationToMemberObject($result->mailContentParticipiantExcusationToMemberObject);
        $this->setMailContentParticipiantExcusationToMember($result->mailContentParticipiantExcusationToMember);
        $this->setMailContentRaceStateChange($result->mailContentRaceStateChange);
        $this->setMailContentRaceStateChangeObject($result->mailContentRaceStateChangeObject);
    }
    function updateSetting()
    {
        global $wpdb;

        //New update sql sctipt
        $sql = "
           UPDATE cass_setting
           SET clubName='%s', smtpServer='%s', smtpUser='%s', smtpPassword='%s', smtpSSL='%s',smtpPort='%d', mailContentParticipiantValidationToRLObject='%s', mailContentParticipiantValidationToRL='%s', mailContentParticipiantExcusationToRLObject='%s',mailContentParticipiantExcusationToRL='%s', mailContentParticipiantValidationToMemberObject='%s',mailContentParticipiantValidationToMember='%s', mailContentParticipiantExcusationToMemberObject='%s',mailContentParticipiantExcusationToMember='%s', mailContentRaceStateChangeObject='%s',mailContentRaceStateChange='%s'
           WHERE IDSetting=1;
         ";

        $wpdb->query($wpdb->prepare($sql, $this->getClubName(), $this->getSmtpServer(), $this->getSmtpUser(), $this->getSmtpPassword(), $this->getSmtpSSL(),$this->getSmtpPort(), $this->getMailContentParticipiantValidationToRLObject(), $this->getMailContentParticipiantValidationToRL(), $this->getMailContentParticipiantExcusationToRLObject(), $this->getMailContentParticipiantExcusationToRL(), $this->getMailContentParticipiantValidationToMemberObject(), $this->getMailContentParticipiantValidationToMember(), $this->getMailContentParticipiantExcusationToMemberObject(), $this->getMailContentParticipiantExcusationToMember(), $this->getMailContentRaceStateChangeObject(), $this->getMailContentRaceStateChange()));
        
    }

    public function getIDSetting()
    {
        return $this->IDSetting;
    }

    public function setIDSetting($IDSetting)
    {
        $this->IDSetting = $IDSetting;
    }

    public function getClubName()
    {
        return $this->clubName;
    }

    public function setClubName($clubName)
    {
        $this->clubName = $clubName;
    }

    public function getSmtpServer()
    {
        return $this->smtpServer;
    }

    public function setSmtpServer($smtpServer)
    {
        $this->smtpServer = $smtpServer;
    }

    public function getSmtpUser()
    {
        return $this->smtpUser;
    }

    public function setSmtpUser($smtpUser)
    {
        $this->smtpUser = $smtpUser;
    }

    public function getSmtpPassword()
    {
        return $this->smtpPassword;
    }

    public function setSmtpPassword($smtpPassword)
    {
        $this->smtpPassword = $smtpPassword;
    }

    public function getSmtpSSL()
    {
        return $this->smtpSSL;
    }

    public function setSmtpSSL($smtpSSL)
    {
        $this->smtpSSL = $smtpSSL;
    }

    public function getSmtpPort()
    {
        return $this->smtpPort;
    }
    public function setSmtpPort($smtpPort)
    {
        $this->smtpPort = $smtpPort;
    }

    public function getMailContentParticipiantValidationToRLObject()
    {
        return $this->mailContentParticipiantValidationToRLObject;
    }

    public function setMailContentParticipiantValidationToRLObject($mailContentParticipiantValidationToRLObject)
    {
        $this->mailContentParticipiantValidationToRLObject = $mailContentParticipiantValidationToRLObject;
    }
    public function getMailContentParticipiantValidationToRL()
    {
        return $this->mailContentParticipiantValidationToRL;
    }

    public function setMailContentParticipiantValidationToRL($mailContentParticipiantValidationToRL)
    {
        $this->mailContentParticipiantValidationToRL = $mailContentParticipiantValidationToRL;
    }

    public function getMailContentParticipiantExcusationToRLObject()
    {
        return $this->mailContentParticipiantExcusationToRLObject;
    }

    public function setMailContentParticipiantExcusationToRLObject($mailContentParticipiantExcusationToRLObject)
    {
        $this->mailContentParticipiantExcusationToRLObject = $mailContentParticipiantExcusationToRLObject;
    }

    public function getMailContentParticipiantExcusationToRL()
    {
        return $this->mailContentParticipiantExcusationToRL;
    }

    public function setMailContentParticipiantExcusationToRL($mailContentParticipiantExcusationToRL)
    {
        $this->mailContentParticipiantExcusationToRL = $mailContentParticipiantExcusationToRL;
    }

    public function getMailContentParticipiantValidationToMemberObject()
    {
        return $this->mailContentParticipiantValidationToMemberObject;
    }

    public function setMailContentParticipiantValidationToMemberObject($mailContentParticipiantValidationToMemberObject)
    {
        $this->mailContentParticipiantValidationToMemberObject = $mailContentParticipiantValidationToMemberObject;
    }

    public function getMailContentParticipiantValidationToMember()
    {
        return $this->mailContentParticipiantValidationToMember;
    }

    public function setMailContentParticipiantValidationToMember($mailContentParticipiantValidationToMember)
    {
        $this->mailContentParticipiantValidationToMember = $mailContentParticipiantValidationToMember;
    }

    public function getMailContentParticipiantExcusationToMemberObject()
    {
        return $this->mailContentParticipiantExcusationToMemberObject;
    }

    public function setMailContentParticipiantExcusationToMemberObject($mailContentParticipiantExcusationToMemberObject)
    {
        $this->mailContentParticipiantExcusationToMemberObject = $mailContentParticipiantExcusationToMemberObject;
    }

    public function getMailContentParticipiantExcusationToMember()
    {
        return $this->mailContentParticipiantExcusationToMember;
    }

    public function setMailContentParticipiantExcusationToMember($mailContentParticipiantExcusationToMember)
    {
        $this->mailContentParticipiantExcusationToMember = $mailContentParticipiantExcusationToMember;
    }

    public function getMailContentRaceStateChangeObject()
    {
        return $this->mailContentRaceStateChangeObject;
    }

    public function setMailContentRaceStateChangeObject($mailContentRaceStateChangeObject)
    {
        $this->mailContentRaceStateChangeObject = $mailContentRaceStateChangeObject;
    }

    public function getMailContentRaceStateChange()
    {
        return $this->mailContentRaceStateChange;
    }

    public function setMailContentRaceStateChange($mailContentRaceStateChange)
    {
        $this->mailContentRaceStateChange = $mailContentRaceStateChange;
    }
}