<?php

class email_log {
    private $el_id;
    private $el_message;
    private $el_subject;
    private $el_to_name;
    private $el_to_email;
    private $el_sent_date;
    private $el_exception;
    private $el_email_template_et_id;

    public function set_el_data_by_id($_id) {
        global $sql;
        $el_data_assoc_array = $sql->assoc_array("select * from email_log where el_id = " . $_id);
        $el_data_array = $el_data_assoc_array[0];
        foreach ($el_data_array as $field => $value) {
            $function_name = "set_" . $field;
            $this->$function_name($value);
            if ('el_email_template_et_id' == $field) {
                $new_et = new email_template();
                $new_et->set_et_data_by_id($value);
                $this->set_el_email_template_et_id($new_et);
            }
        }
    }

    public static function create_email_log($_message, $_subject, $_name, $_email, $_et, $_exc = 'null', $_date = null)
    {
        global $sql;

        if (null === $_date) {
            $_date = date('Y-m-d H:i:s');
        }

        return $sql->insert_into('email_log', array(
            'el_message' => $_message,
            'el_subject' => $_subject,
            'el_to_name' => $_name,
            'el_to_email' => $_email,
            'el_email_template_et_id' => $_et,
            'el_exception' => $_exc,
            'el_sent_date' => $_date
        ));
    }

    /**
     * @return mixed
     */
    public function get_el_id()
    {
        return $this->el_id;
    }

    /**
     * @param mixed $el_id
     *
     * @return self
     */
    public function set_el_id($el_id)
    {
        $this->el_id = $el_id;

        return $this;
    }

    /**
     * @return mixed
     */
    public function get_el_message()
    {
        return $this->el_message;
    }

    /**
     * @param mixed $el_message
     *
     * @return self
     */
    public function set_el_message($el_message)
    {
        $this->el_message = $el_message;

        return $this;
    }

    /**
     * @return mixed
     */
    public function get_el_subject()
    {
        return $this->el_subject;
    }

    /**
     * @param mixed $el_subject
     *
     * @return self
     */
    public function set_el_subject($el_subject)
    {
        $this->el_subject = $el_subject;

        return $this;
    }

    /**
     * @return mixed
     */
    public function get_el_to_name()
    {
        return $this->el_to_name;
    }

    /**
     * @param mixed $el_to_name
     *
     * @return self
     */
    public function set_el_to_name($el_to_name)
    {
        $this->el_to_name = $el_to_name;

        return $this;
    }

    /**
     * @return mixed
     */
    public function get_el_to_email()
    {
        return $this->el_to_email;
    }

    /**
     * @param mixed $el_to_email
     *
     * @return self
     */
    public function set_el_to_email($el_to_email)
    {
        $this->el_to_email = $el_to_email;

        return $this;
    }

    /**
     * @return mixed
     */
    public function get_el_sent_date()
    {
        return $this->el_sent_date;
    }

    /**
     * @param mixed $el_sent_date
     *
     * @return self
     */
    public function set_el_sent_date($el_sent_date)
    {
        $this->el_sent_date = $el_sent_date;

        return $this;
    }

    /**
     * @return mixed
     */
    public function get_el_exception()
    {
        return $this->el_exception;
    }

    /**
     * @param mixed $el_exception
     *
     * @return self
     */
    public function set_el_exception($el_exception)
    {
        $this->el_exception = $el_exception;

        return $this;
    }

    /**
     * @return mixed
     */
    public function get_el_email_template_et_id()
    {
        return $this->el_email_template_et_id;
    }

    /**
     * @param mixed $el_email_template_et_id
     *
     * @return self
     */
    public function set_el_email_template_et_id($el_email_template_et_id)
    {
        $this->el_email_template_et_id = $el_email_template_et_id;

        return $this;
    }
}


?>
