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

 


class PageKontaktKursAnDozenten extends PageKontakt
{
  
  protected $_kontakt;
  protected $_kurs;
  
  protected $_pdfAsAttachment;

  
  public function __construct($pPageTitle, $pPageId, $pTool, $pUeberschrift, $pBetreff, $pInhaltLabel, $pKurs, $pKontakt, $pPdfAsAttachment = false)
  {
    parent::__construct($pPageTitle, $pPageId, $pTool, $pUeberschrift, $pBetreff, $pInhaltLabel);
    $this->_kurs = $pKurs;
    $this->_kontakt = $pKontakt;
    $this->_pdfAsAttachment = $pPdfAsAttachment;
  }

  
  protected function _getSonstigenFormularinhalt()
  {
    $result = '';
    $result .= '<h3>E-Mail senden an: </h3>';

    $hauptdozent = $this->_kurs->getVarValue('hauptdozent');

    if ($this->tool->getToolId() == \ToolsAPI::TOOL_KURSUEBERSICHT_FA) {
      foreach ($this->_kontakt as $dozenten) {
        foreach ($dozenten as $dozent) {
          $dozent4html = new CleanDatamodulForHtml($dozent);
          if ($hauptdozent->namevorname == $dozent->namevorname) {
            $result .= '<input  type="checkbox"  value="' . $dozent4html->id . '" name="doz[]" checked>' . $dozent4html->namevorname . BR_WT;
          } else {
            $result .= '<input  type="checkbox"  value="' . $dozent4html->id . '" name="doz[]">' . $dozent4html->namevorname . BR_WT;
          }
        }
      }
    } else {
      foreach ($this->_kontakt as $dozent) {
        $dozent4html = new CleanDatamodulForHtml($dozent);
        if ($hauptdozent->namevorname == $dozent->namevorname) {
          $result .= '<input  type="checkbox"  value="' . $dozent4html->id . '" name="doz[]" checked>' . $dozent4html->namevorname . BR_WT;
        } else {
          $result .= '<input  type="checkbox"  value="' . $dozent4html->id . '" name="doz[]">' . $dozent4html->namevorname . BR_WT;
        }
      }
    }

    return $result;
  }

  
  public function getJSDeclarations()
  {
    $result = parent::getJSDeclarations();
    $result .= JsOperations::getDeclarationString('KuferTools.Kontakt.Art', 'Nachricht');

    return $result;
  }

  
  protected function _getAttachments()
  {
    if ($this->_pdfAsAttachment) {
      $anhang = '';

      $anhang .= '<div class="anhaenge">' . "\n";
      $anhang .= '<input  type="checkbox"  id="anhangTn" name="anhangTnList" >'
                 . '<label for="anhangTn">Teilnehmerliste (PDF) als Anhang mitschicken</label>' . BR_WT;
      $anhang .= '</div>' . "\n";

      return $anhang;
    }

    return parent::_getAttachments();
  }
}