<?php

namespace GriffinForms\Includes\MailTemplates;

class AdminSubmissionAlert extends \GriffinForms\Includes\MailTemplates\Format
{
    protected $subject = 'New Form Submission';
    protected $content = 'A new form submission has been received.';

    // Set the subject of the admin alert
    public function setSubject($subject)
    {
        $this->subject = $subject;
    }

    // Get the subject of the admin alert
    public function getSubject()
    {
        return $this->subject;
    }

    // Set the content of the admin alert
    public function setContent($content)
    {
        $this->content = $content;
    }

    // Get the content of the admin alert
    public function getContent()
    {
        return $this->content;
    }

    protected function processSubject()
    {
        $form_name = $this->getFormName();
    
        // Translators: %s is the form name.
        $subject = sprintf(
            /* translators: %s is the form name */
            __('New Submission for %s', 'griffinforms-form-builder'),
            $form_name
        );
    
        $this->subject = $subject;
    }

    protected function processContent()
    {
        $form_name = $this->getFormName();
        $site_name = get_bloginfo('name');
        $time = $this->getSubmissionTime();
        $timezone = wp_timezone_string();
        $submission_id = $this->data['submission']['id'];
        $submission_link = admin_url(add_query_arg([
        'page' => 'griffinforms-submission',
        'id' => $submission_id
        ], 'admin.php'));

        // Translators: %1$s is the site name, %2$s is the form name, %3$s is the submission time, %4$s is the timezone, %5$s is the submission link.
        $content = sprintf(__('<p>A new submission has been received on website <em>%1$s</em> for the form <em>%2$s</em>. The submission was made on <em>%3$s (%4$s)</em>.</p><p>You can also view the submission <a href="%5$s">here</a>.</p>','griffinforms-form-builder'),
            $site_name,
            $form_name,
            $time,
            $timezone,
            $submission_link
        );

        $this->content = $content;
    }
}