<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */

namespace Kufer\KuferTools\Basis\Kursdetails\DetailsReiter\Termine\TerminVerlaengernDialog\AbweichendeKurstage;

use Kufer\KuferTools\Utils\StatusMessages\StatusMessage;
use Kufer\Mail\Sender\IEMailSender;
use Kufer\Mail\EMail\IEMail;
use Kufer\Mail\Sender\Result\EMailSentResult;

abstract class TerminVerlaengernAbsendenEMailUseCase extends \Kufer\KuferTools\Basis\Kursdetails\DetailsReiter\Termine\TerminVerlaengernDialog\TerminVerlaengernAbsendenEMailUseCase
{
  protected function getTeilnehmer()
  {
    return array();
  }

  protected function getDozenten(): array
  {
    return array();
  }

  protected function sendEMail(IEMailSender $sender, IEMail $mail): EMailSentResult
  {
    $result = new EMailSentResult(array());

    $firmenToolSettings = \ToolSettingsAPI::getToolSettings(\ToolsAPI::TOOL_KURSUEBERSICHT_FA);
    $emailFirmendienst = $firmenToolSettings->terminStonierenEMailFirmendienst;
    if ($emailFirmendienst !== '') {
      $resultEmailFirmenservice = $sender->send($mail, $this->getUser(), array(new \Kufer\Mail\Address\EMailAddress('Firmendienst', $emailFirmendienst)), 'Firmendienst');
      $result = $result->merge($resultEmailFirmenservice);

      $recipient = \ArrayOperations::firstValue($resultEmailFirmenservice->getRecipients());
      if ($resultEmailFirmenservice->hasError()) {
        $this->statusMessageContainer->addStatusMessageObj(StatusMessage::getErrorMessageObj($recipient->getReadableMessage()));
      } else {
        $this->statusMessageContainer->addStatusMessageObj(StatusMessage::getSuccessMessageObj($recipient->getReadableMessage()));
      }
    }

    return $result;
  }

  public function getResponseForEMail()
  {
    parent::getResponseForEMail();
    $this->response->mentionAbweichendeKurstage = $this->request->isAbweichendeKurstage;

    return $this->response;
  }

  protected function doSendKopieAnAbsender()
  {
    return false;
  }

  protected function shouldSendMail2Einrichtung(): bool
  {
    return false;
  }

  protected function shouldSendMail2PlanendenMitarbeiter(): bool
  {
    return false;
  }

  protected function shouldSendMail2VerwaltendemMitarbeiter(): bool
  {
    return false;
  }
}