Source for file class.EINGABE.php

Documentation is available at class.EINGABE.php

  1. <?php
  2.  
  3. /**
  4.  * erstellt die HTML_Seite zur Eingabe der Benutzerdaten.
  5.  * Die Daten werden auf Vollständigkeit überprüft
  6.  * Die Daten werden in die Datenbank übernommen
  7.  *
  8.  * @author Kay Koch
  9.  * @package src
  10.  * @since 15.12.04
  11.  * @subpackage foundation_user
  12.  * @version 1
  13.  */
  14.  
  15. if (version_compare(PHP_VERSION'5'))
  16. {
  17.     die('This file was generated for PHP 5');
  18. }
  19.  
  20. /**
  21.  * Basisklasse der ausführenden Klassen
  22.  * Stellt Methoden und Eigenschaften zur Ein- und Ausgabe über das Webinterface
  23.  * Verfügung
  24.  *
  25.  * @author Kay Koch
  26.  * @since 15.12.04
  27.  * @version 1
  28.  */
  29. require_once ('src/foundation/user/class.PARENTUSER.php');
  30.  
  31. /* user defined includes */
  32. // section -64--88-122--2-1328c7a:100b87cbb1c:-7fd3-includes begin
  33. // section -64--88-122--2-1328c7a:100b87cbb1c:-7fd3-includes end
  34.  
  35. /* user defined constants */
  36. // section -64--88-122--2-1328c7a:100b87cbb1c:-7fd3-constants begin
  37. // section -64--88-122--2-1328c7a:100b87cbb1c:-7fd3-constants end
  38.  
  39. /**
  40.  * erstellt die HTML_Seite zur Eingabe der Benutzerdaten.
  41.  * Die Daten werden auf Vollständigkeit überprüft
  42.  * Die Daten werden in die Datenbank übernommen
  43.  *
  44.  * @access public
  45.  * @author Kay Koch
  46.  * @package src
  47.  * @since 15.12.04
  48.  * @subpackage foundation_user
  49.  * @version 1
  50.  */
  51. {
  52.     // --- ATTRIBUTES ---
  53.  
  54.     
  55.     /**
  56.      * Array mit Übergabewerten
  57.      *
  58.      * @access protected
  59.      * @var array 
  60.      */
  61.     //protected $data = array();
  62.  
  63.     
  64.     /**
  65.      * @var array Array mit den Feldnamen der aktuellen Datebank
  66.      * @access protected
  67.      */
  68.     protected $arrKeys = array ();
  69.  
  70.     /**
  71.      * @var src_foundation_tables_BREVETS Objekt der Klasse Brevets
  72.      * @access private
  73.      */
  74.     private $oBrevet null;
  75.  
  76.     /**
  77.      * @var src_foundation_tables_VEREINE Objekt der Klasse VEREINE
  78.      * @access private
  79.      */
  80.     private $oVerein null;
  81.  
  82.     /**
  83.      * @var array Übergebene Daten
  84.      * @access public
  85.      */
  86.     public $data = array ();
  87.  
  88.     // --- OPERATIONS ---
  89.  
  90.     
  91.     /**
  92.      * überprüft die Daten auf Vollständigkeit.
  93.      * übereben wird das Feld GLOBAL, das alle Parameter über ein HTML-Formular
  94.      *
  95.      * @access private
  96.      * @author Kay Koch, <kay.koch@gmx.de>
  97.      * @return boolean 
  98.      */
  99.     private function checkData()
  100.     {
  101.         $returnValue = (bool) false;
  102.  
  103.         // section -64--88-122--2-933bcb:100f60e4e57:-7fd1 begin
  104.         try
  105.         {
  106.             if (!src_tools_CHECK :: checkName($this->data['name']))
  107.                 throw new Exception("20,Name");
  108.             if (!src_tools_CHECK :: checkName($this->data['vorname']))
  109.                 throw new Exception("22,Vorname");
  110.             if (!src_tools_CHECK :: checkMail($this->data['email']))
  111.                 throw new Exception("24,Email");
  112.             if (!src_tools_CHECK :: checkVnum($this->data['verein_nr']))
  113.                 throw new Exception("26,VereinNr");
  114.             if (!src_tools_CHECK :: checkID($this->data['brevet_id'])) // nur Zahlen
  115.                 throw new Exception("19,Brevet");
  116.             if (!src_tools_CHECK :: checkAnzahl($this->data['anzahl'])) // nur Zahlen
  117.                 throw new Exception("28,Anzahl");
  118.             if (!src_tools_CHECK :: checkAnzahl($this->data['anzahlZahler'])) // nur Zahlen
  119.                 throw new Exception("29,Anzahl Zahler");
  120.             if ($this->data['anzahl'$this->data['anzahlZahler'])
  121.                 throw new Exception("30,Anzahl Zahler");
  122.             if (!src_tools_CHECK :: checkPhone($this->data['telefon'])) // nur Zahlen Klammer minus plus
  123.                 throw new Exception("31,Telefon");
  124.             $oPermit new src_foundation_tables_BEFUGNISSE;
  125.             if (!$oPermit->canDive($this->data['see_id']$this->data['datum']$this->data['stunde']$this->data['verein_nr']))
  126.                 throw new Exception($oPermit->getErrNr(",VereinNr. ");
  127.             $returnValue true;
  128.         catch (Exception $e)
  129.         {
  130.             $message explode(","$e->getMessage());
  131.             $this->errorMsg "<b>[" $message[1"] : </b>" src_tools_ERROR :: getErrTxt($message[0]);
  132.             $this->data['error'src_tools_TEMPLATE :: getTemplate('error'$this);
  133.         }
  134.         // section -64--88-122--2-933bcb:100f60e4e57:-7fd1 end
  135.  
  136.         return (bool) $returnValue;
  137.     }
  138.  
  139.     /**
  140.      * Konstruktor
  141.      *
  142.      * überprüft die übergebenen Werte auf Vollständigkeit
  143.      * und initialisiert den Seitenaufbau
  144.      *
  145.      * @access public
  146.      * @author Kay Koch, <kay.koch@gmx.de>
  147.      * @param string 
  148.      * @param string 
  149.      * @return void 
  150.      */
  151.  
  152.     public function __construct($todo$data '')
  153.     {
  154.         // section -64--88-122--2-1328c7a:101ce91d1f9:-7ff1 begin
  155.         parent :: __construct();
  156.         try
  157.         {
  158.             if (empty ($todo))
  159.                 throw new Exception(6);
  160.             if (empty ($data))
  161.                 throw new Exception(6);
  162.             src_tools_CHECK :: checkID($data['see_id']true);
  163.             src_tools_CHECK :: checkDatum($data['datum']true);
  164.             src_tools_CHECK :: checkHour($data['stunde']true);
  165.             src_foundation_tables_PARENTTABLES:: setSea($data['see_id']);
  166.             src_foundation_tables_PARENTTABLES::getSea()->checkDiveRange($data['datum']src_foundation_tables_PARENTTABLES::getFlags()->lastBackupDate);
  167.             $this->oBrevet new src_foundation_tables_BREVETS();
  168.             $this->oBuchung new src_foundation_tables_BUCHUNGEN();
  169.             $this->setInputVariables($data);
  170.             $this->makePage($todo);
  171.         catch (Exception $e)
  172.         {
  173.             src_tools_ERROR :: setError($e__METHOD__);
  174.         }
  175.         // section -64--88-122--2-1328c7a:101ce91d1f9:-7ff1 end
  176.     }
  177.  
  178.     /**
  179.      * erstellt die benötigten PullDownMenus
  180.      *
  181.      * @access private
  182.      * @author Kay Koch, <kay.koch@gmx.de>
  183.      * @return void 
  184.      */
  185.     private function setOptionMenus()
  186.     {
  187.         // section -64--88-122--2-1a4ded3:10259d7c267:-7ff8 begin
  188.         // auslesen der Restplätze zum gewählten Zeitpunkt
  189.         if (src_foundation_tables_PARENTTABLES:: getSea()->buchbarProTag)
  190.         {
  191.             $arrPlaces $this->oNF->getUsedPerDay($this->data['datum']);
  192.             $this->restPlaetze $arrPlaces['rest'][$this->data['datum']];
  193.         else
  194.         {
  195.             $arrPlaces $this->oNF->getUsedPerHour($this->data['datum']$this->data['stunde']);
  196.             $this->restPlaetze $arrPlaces['rest'][$this->data['stunde']];
  197.         }
  198.         // maximale Anzahl der freien, erlaubten Plätze pro Anmeldung
  199.         $max min(src_foundation_tables_PARENTTABLES:: getSea()->maxPerOrder$this->restPlaetze);
  200.         // erstellen des PullDownMenus 'Gesamtanzahl' (Minimum = 2)
  201.         $this->optAnzahl $this->getOptionList(2$max$this->data['anzahl']);
  202.         // erstellen des PullDownMenus Anzahl der nicht LVST'ler
  203.         $this->optAnzahlZahler $this->getOptionList(0$max$this->data['anzahlZahler']);
  204.         // auslesen der einzelnen Brevetstufen und erstellen des PullDownMenus 'Brevet'
  205.         $this->optBrevet $this->oBrevet->getOptionList($this->data['brevet_id']);
  206.         // section -64--88-122--2-1a4ded3:10259d7c267:-7ff8 end
  207.     }
  208.  
  209.     /**
  210.      * wandelt die Daten in das notwendige Format zur Ausgabe um
  211.      *
  212.      * @access private
  213.      * @author Kay Koch, <kay.koch@gmx.de>
  214.      * @param array 
  215.      * @return void 
  216.      */
  217.     private function setInputVariables($inData)
  218.     {
  219.         // section -64--88-122--2-1a4ded3:10259d7c267:-7fe6 begin
  220.         foreach ($this->oBuchung->getArrKeys(as $key)
  221.             $this->data[$key"";
  222.         $this->data = array_merge(array ("brevet_id" => """error" => "")$this->data$inData)// Eingabewerte
  223.         $this->data['seename'src_foundation_tables_PARENTTABLES:: getSea()->name// Seename
  224.         $this->data['realdatum'src_tools_TIME :: sqlT2realT($this->data['datum']"%A - %d. %B %Y")// Datum in normaler Form
  225.         $this->hiddenToken src_tools_TOKEN :: getInputToken()// Token zum Reload verhindern
  226.         if (src_foundation_tables_PARENTTABLES:: getSea()->buchbarProTag)
  227.         // Anzeige der Uhrzeit bei ganztägiger Anmeldung
  228.             $startTime src_foundation_tables_PARENTTABLES:: getSea()->getStartTime($this->data['datum'])// erste erlaubte Uhrzeit
  229.             $endTime src_foundation_tables_PARENTTABLES:: getSea()->getEndTime($this->data['datum'])// letzte erlaubte Uhrzeit
  230.             $this->data['realstunde'$startTime " - " $endTime " Uhr";
  231.         else
  232.             if ($this->data['stunde'== '24:00')
  233.             // 24:00 - 01:00 Uhr
  234.                 $this->data['realstunde'$this->data['stunde'" -  01:00 Uhr";
  235.             else
  236.             // gewählte Uhrzeit - (gewählte Uhrzeit + eine Stunde)
  237.                 $this->data['realstunde'$this->data['stunde'" - " (substr($this->data['stunde']021":00 Uhr";
  238.             }
  239.         // section -64--88-122--2-1a4ded3:10259d7c267:-7fe6 end
  240.     }
  241.  
  242.     /**
  243.      * Hilfsfunktion zur Erstellung der PullDownMenüs
  244.      *
  245.      * @access private
  246.      * @author Kay Koch, <kay.koch@gmx.de>
  247.      * @param int 
  248.      * @param int 
  249.      * @param int 
  250.      * @return string 
  251.      */
  252.     private function getOptionList($min$max 0$index 0)
  253.     {
  254.         $returnValue = (string) '';
  255.  
  256.         // section -64--88-122--2-1328c7a:1027db0d532:-7fe4 begin
  257.         $returnValue "";
  258.         for ($i $min$i <= $max$i++)
  259.         {
  260.             $selected ($i == $index"SELECTED" "";
  261.             $returnValue .= "<option $selected value='$i "'>" $i "</option>\n";
  262.         }
  263.         // section -64--88-122--2-1328c7a:1027db0d532:-7fe4 end
  264.  
  265.         return (string) $returnValue;
  266.     }
  267.  
  268.     /**
  269.      * Erstellt eine HTML-Seite zur Eingabe der Anmeldung
  270.      *
  271.      * @access private
  272.      * @author Kay Koch, <kay.koch@gmx.de>
  273.      * @param string 
  274.      * @return void 
  275.      */
  276.     private function makePage($todo)
  277.     {
  278.         // section -64--88-122--2-3f9fc877:104611dccfe:-7fb5 begin
  279.         $tpl "eingabe";
  280.         $isError false;
  281.         $this->noCache false;
  282.         switch ($todo)
  283.         {
  284.             case "control" // überprüfen der Eingabedaten
  285.                 if ($this->checkData())
  286.                 {
  287.                     $this->todo "insert";
  288.                     $this->btnControl "Abschicken";
  289.                     $this->btnChange src_tools_TEMPLATE :: getTemplate('changeButton');
  290.                     $this->noCache true;
  291.                 }else
  292.                     $isError true;
  293.                 break;
  294.             case "insert" // Einfügen der Daten in Datenbank
  295.                 if ($this->checkData())
  296.                 {
  297.                     $this->oBrevet->setParams($this->data['brevet_id']);
  298.                     $this->data['brevet'$this->oBrevet->name;
  299.                     $oVerein new src_foundation_tables_VEREINE();
  300.                     $oVerein->setParams($this->data['verein_nr']);
  301.                     $oVerband new src_foundation_tables_VERBAENDE();
  302.                     $oVerband->setParams($this->data['verein_nr']);
  303.                     $this->data['verein'$oVerein->name;
  304.                     $this->data['verband'$oVerband->name;
  305.                     $tpl ($this->oBuchung->insertBuchung($this->data)) "gesendet" "fehler_buchung";
  306.                 }else
  307.                     $isError true;
  308.                 break;
  309.             default:
  310.                 break;
  311.         // switch
  312.         if ($isError or $todo == "show")
  313.             $this->prepareControlButton()// Buttons setzen
  314.         if ($isError or $todo != "insert")
  315.             $this->setOptionMenus()// Optionsmenus erzeugen
  316.         // Formatieren der Ausgabe
  317.         $content src_tools_TEMPLATE :: getTemplate($tpl$this);
  318.         // Ausgabe der Seite
  319.         $this->printPage($content);
  320.         // section -64--88-122--2-3f9fc877:104611dccfe:-7fb5 end
  321.     }
  322.     /**
  323.      * erstellt einen Controlbutton zur überprüfung der Daten
  324.      *
  325.      * @access private
  326.      * @author Kay Koch, <kay.koch@gmx.de>
  327.      * @return void 
  328.      */
  329.     private function prepareControlButton()
  330.     {
  331.         // section -64--88-122--2-3f9fc877:104611dccfe:-7fb2 begin
  332.         $this->todo "control";
  333.         $this->btnControl "überprüfen";
  334.         $this->btnChange "";
  335.         // section -64--88-122--2-3f9fc877:104611dccfe:-7fb2 end
  336.     }
  337.  
  338. /* end of class src_foundation_user_EINGABE */
  339. ?>

Documentation generated on Sat, 24 Mar 2007 09:59:08 +0100 by phpDocumentor 1.3.1