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


class PageSammelSmsAnPersonen extends PageKontaktSms
{
  protected $personenMobilNummerArray;

  

  
  public function __construct(
    $pPageTitle,
    $pPageId,
    $pTool,
    $pUeberschrift,
    $pBetreff,
    $pInhaltLabel,
    $pInhalt,
    $pPersonenMobilNummerArray,
    $pErrorMessage = '',
    $pSuccessMessage = '',
    $pMaxLength = 160
  ) {
    
    
    parent::__construct(
      $pPageTitle,
      $pPageId,
      $pTool,
      $pUeberschrift,
      $pBetreff,
      $pInhaltLabel,
      $pInhalt,
      $pErrorMessage,
      $pSuccessMessage,
      $pMaxLength
    );
    $this->personenMobilNummerArray = $pPersonenMobilNummerArray;
  }

  
  protected function _getSonstigenFormularinhalt()
  {
    $result = $this->_getMessages();
    $result .= '<h3>SMS senden an: </h3>';
    $result .= '<ul id="PersonenListeSammelSms">';
    foreach ($this->personenMobilNummerArray as $personenMobilNummer) {
      $person4Html = new CleanDatamodulForHtml($personenMobilNummer[0]);

      $result .= '<li>';

      $result .= '<span>' . $person4Html->namevorname . BR_WT . '</span>';
      $result .= '<input type="hidden" name="allepersonen[]" value="' . $person4Html->id . '">';
      $result .= '<ul>';
      if (count($personenMobilNummer[1]) == 0) {
        $result .= '<li style="color: #FF0000">keine bzw. keine gültige Mobilnummer angegeben</li>';
      }
      foreach ($personenMobilNummer[1] as $mobilnummer => $isselected) {
        $checked = $isselected ? 'checked' : '';
        $result .= '<li><input  type="checkbox"  value="' . $person4Html->id . '_' . CleanOperations::cleanStringForHtml($mobilnummer) . '" name="mobilnummern[]" ' . $checked . '>' . CleanOperations::cleanStringForHtml($mobilnummer) . '</li>';
      }
      $result .= '</ul>';

      $result .= '</li>';
    }
    $result .= '</ul>';

    return $result;
  }

  
  protected function _getSendButton()
  {
    $sendButton = '';
    
    if ($this->tool->isRefreshed()) {
      return;
    }
    if (!empty($this->personenMobilNummerArray)) {
      $sendButton .= '<input type="image" name="Absenden" src="layout/button_send.gif" title="Absenden">';
    }

    return $sendButton;
  }
}