<?php
/**
 * @copyright (c) Kufer Software GmbH, Oderstraße 7, D-84453 Mühldorf
 */

namespace Kufer\Web\KuferTools\Basis\Kursdetails\Detailsreiter\Termine\TerminVerlaengernDialog\AbweichendeKurstage;

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

abstract class TerminVerlaengernAbsendenEMailUseCase extends \Kufer\Web\KuferTools\Basis\Kursdetails\Detailsreiter\Termine\TerminVerlaengernDialog\TerminVerlaengernAbsendenEMailUseCase
{
  protected function getTeilnehmer(): array
  {
    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(PlainStatusMessage::getErrorMessageObj($recipient->getReadableMessage()));
      } else {
        $this->statusMessageContainer->addStatusMessageObj(PlainStatusMessage::getSuccessMessageObj($recipient->getReadableMessage()));
      }
    }

    return $result;
  }

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

    return $this->response;
  }

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

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

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

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