Source for file class.ADMINMAXFREI.php

Documentation is available at class.ADMINMAXFREI.php

  1. <?php
  2.  
  3.  
  4. /**
  5.  * Verwaltet die Adminitration der Datenbanktabelle 'maxfrei'
  6.  *
  7.  * @author Kay Koch, <kay.koch@gmx.de>
  8.  * @package src
  9.  * @subpackage foundation_admin
  10.  */
  11.  
  12. if (version_compare(PHP_VERSION'5')) {
  13.     die('This file was generated for PHP 5');
  14. }
  15.  
  16. /**
  17.  * Parentklasse zur Administration der Tabellen
  18.  *
  19.  * @author Kay Koch, <kay.koch@gmx.de>
  20.  */
  21. require_once('src/foundation/admin/class.PARENTADMIN.php');
  22.  
  23. /**
  24.  * Interface zur Administration der Datenbank
  25.  *
  26.  * @author Kay Koch
  27.  * @since 06.2005
  28.  * @version 1.0
  29.  */
  30. require_once('src/interfaces/interface.ADMININTERFACE.php');
  31.  
  32. /* user defined includes */
  33. // section -64--88-122--2-556c3468:1044bd6a64b:-7fd5-includes begin
  34. // section -64--88-122--2-556c3468:1044bd6a64b:-7fd5-includes end
  35.  
  36. /* user defined constants */
  37. // section -64--88-122--2-556c3468:1044bd6a64b:-7fd5-constants begin
  38. // section -64--88-122--2-556c3468:1044bd6a64b:-7fd5-constants end
  39.  
  40. /**
  41.  * Verwaltet die Adminitration der Datenbanktabelle 'maxfrei'
  42.  *
  43.  * @access public
  44.  * @author Kay Koch, <kay.koch@gmx.de>
  45.  * @package src
  46.  * @subpackage foundation_admin
  47.  */
  48.         implements src_interfaces_ADMININTERFACE
  49. {
  50.     // --- ATTRIBUTES ---
  51.  
  52.     
  53.     /**
  54.      * Objekt der aktellen Datenbankklasse
  55.      *
  56.      * @access private
  57.      * @var MAXFREI 
  58.      */
  59.     private $oMaxfrei null;
  60.  
  61.     /**
  62.      * Array mit den Feldnamen der aktuellen Datebank
  63.      *
  64.      * @access protected
  65.      * @var array 
  66.      */
  67.     protected $arrKeys = array();
  68.  
  69.     /**
  70.      * Name des Haupttemplates
  71.      *
  72.      * @access protected
  73.      * @var string 
  74.      */
  75.     protected $pageTemplate = '';
  76.  
  77.     // --- OPERATIONS ---
  78.  
  79.     
  80.     /**
  81.      * zeigt alle Einträge einer Tabelle
  82.      *
  83.      * @access public
  84.      * @author Kay Koch, <kay.koch@gmx.de>
  85.      * @return void 
  86.      */
  87.     public function show()
  88.     {
  89.         // section -64--88-122--2--6176e79b:103fa06a375:-7fad begin
  90.         if ($this->loginOK{
  91.             $this->todo "change";
  92.             $this->rows "";
  93.             $this->oMaxfrei->unsetParams();
  94.             $arrTmp $this->oMaxfrei->getRow();
  95.             $arrTimeRange $this->oSeen->getTimeRanges();
  96.             $this->timeHeader $this->prepareTimeHeader($arrTimeRange);
  97.             foreach ($arrTmp as $see_id => $arrSee// alle Seen
  98.                 $oSee $this->oSeen-> $see_id;
  99.                 $this->seename $oSee->name;
  100.                 foreach($arrSee as $this->data// alle Wochentage
  101.                     $this->wochentagName src_tools_TIME::dayNr2dayName($this->data['wochentag']);
  102.                     $this->timeRows $this->prepareTimeRows("admin_time_row"$oSee$arrTimeRange);
  103.                     $this->rows .= src_tools_TEMPLATE::getTemplate("admin_" $this->pageTemplate . "_row"$this);
  104.                 }
  105.             }
  106.             $this->makePage("admin_" $this->pageTemplate);
  107.         }
  108.         // section -64--88-122--2--6176e79b:103fa06a375:-7fad end
  109.     }
  110.  
  111.     /**
  112.      * liefert ein Formular zur Änderung bzw. Neueingabe eines Datensatzes
  113.      *
  114.      * Wenn die Tabellenspezifischen Parameter vorhergesetzt wurden wird der
  115.      * Datensatz ausgegeben. Ansonsten erscheint ein leeres Formular
  116.      *
  117.      * @access public
  118.      * @author Kay Koch, <kay.koch@gmx.de>
  119.      * @return void 
  120.      */
  121.     public function change()
  122.     {
  123.         // section -64--88-122--2--6176e79b:103fa06a375:-7fa9 begin
  124.         if ($this->loginOK{
  125.             if ((!empty($this->oMaxfrei->see_id))) {
  126.                 $this->todo "update";
  127.                 $this->data $this->oMaxfrei->getRow();
  128.                 $oSee new src_foundation_tables_EINSEE($this->oMaxfrei->see_id);
  129.                 $this->seename $oSee->name;
  130.                 $this->wochentagName src_tools_TIME::dayNr2dayName($this->oMaxfrei->wochentag);
  131.                 $this->timeRows $this->prepareTimeRows("admin_time_input"$oSee);
  132.                 $this->makePage("admin_" $this->pageTemplate . "_input");
  133.             }
  134.         }
  135.         // section -64--88-122--2--6176e79b:103fa06a375:-7fa9 end
  136.     }
  137.  
  138.     /**
  139.      * Aktualisieet den vorher durch setzen der Parameter ausgewählten
  140.      *
  141.      * Die Neuen Daten befinden sich im Übergabefeld $data
  142.      *
  143.      * @access public
  144.      * @author Kay Koch, <kay.koch@gmx.de>
  145.      * @param array 
  146.      * @return void 
  147.      */
  148.     public function update($data)
  149.     {
  150.         // section -64--88-122--2--6176e79b:103fa06a375:-7f83 begin
  151.         if ($this->loginOK{
  152.             if ($this->checkData($data)) {
  153.                 $this->oMaxfrei->updateRow($data);
  154.                 $this->show();
  155.             else
  156.                 $this->change();
  157.         }
  158.         // section -64--88-122--2--6176e79b:103fa06a375:-7f83 end
  159.     }
  160.  
  161.     /**
  162.      * Löscht den Datensatz der vorher durch Parameter ausgewählt wurde
  163.      *
  164.      * @access public
  165.      * @author Kay Koch, <kay.koch@gmx.de>
  166.      * @return void 
  167.      */
  168.     public function delete()
  169.     {
  170.         // section -64--88-122--2--6176e79b:103fa06a375:-7f7f begin
  171.         if ($this->loginOK{
  172.             $this->oMaxfrei->deleteRow();
  173.             $this->show();
  174.         }
  175.         // section -64--88-122--2--6176e79b:103fa06a375:-7f7f end
  176.     }
  177.  
  178.     /**
  179.      * Fügt einen neuen datensatz mit den Werten des Übergabeparameter $data
  180.      *
  181.      * @access public
  182.      * @author Kay Koch, <kay.koch@gmx.de>
  183.      * @param array 
  184.      * @return void 
  185.      */
  186.     public function insert($data)
  187.     {
  188.         // section -64--88-122--2--6176e79b:103fa06a375:-7f7d begin
  189.         if ($this->loginOK{
  190.             $this->show();
  191.         }
  192.         // section -64--88-122--2--6176e79b:103fa06a375:-7f7d end
  193.     }
  194.  
  195.     /**
  196.      * überprüft die Korrektheit der eingebenen bzw. geänderten Daten
  197.      *
  198.      * @access public
  199.      * @author Kay Koch, <kay.koch@gmx.de>
  200.      * @param void 
  201.      * @return boolean 
  202.      */
  203.     public function checkData(&$data)
  204.     {
  205.         $returnValue = (bool) false;
  206.  
  207.         // section -64--88-122--2--62c31de:1048594e50f:-7fef begin
  208.         try {
  209.             if (isset($data['sumTag'])) {
  210.                 if (!src_tools_CHECK::checkAnzahl($data['sumTag'])) // hh:mm:ss
  211.                     throw new Exception ("55,Gesamt");
  212.                 else {
  213.                     foreach($data as $key => $anzahl{
  214.                         if (src_tools_CHECK::checkHour($key)) //hh:mm
  215.                             if (!src_tools_CHECK::checkAnzahl($anzahl)) {
  216.                                 throw new Exception ("55,$key");
  217.                             }
  218.                         }
  219.                     }
  220.                 }
  221.             }
  222.             $returnValue true;
  223.         }
  224.         catch (Exception $e{
  225.             $message explode(","$e->getMessage());
  226.             $this->errorMsg "<b>[" $message[1"] : </b>" src_tools_ERROR::getErrTxt($message[0]);
  227.             $this->error src_tools_TEMPLATE::getTemplate('error'$this);
  228.         }
  229.         // section -64--88-122--2--62c31de:1048594e50f:-7fef end
  230.  
  231.         return (bool) $returnValue;
  232.     }
  233.  
  234.     /**
  235.      * Konstruktor
  236.      *
  237.      * erstellt ein Obejkt der zu beabeitenden Klassen
  238.      * list alle erlaubten Datenbankschlüssel ein
  239.      * liest das Template
  240.      *
  241.      * @access public
  242.      * @author Kay Koch, <kay.koch@gmx.de>
  243.      * @param string 
  244.      * @param int 
  245.      * @param int 
  246.      * @return void 
  247.      */
  248.     public function __construct($token$see_id 0$wochentag 0)
  249.     {
  250.         // section -64--88-122--2-556c3468:1044bd6a64b:-7fca begin
  251.         parent::__construct($token);
  252.         $this->oMaxfrei new src_foundation_tables_MAXFREI();
  253.         $this->oMaxfrei->setParams($see_id""$wochentag);
  254.         $this->see_id $see_id;
  255.         $this->wochentag $wochentag;
  256.         $this->setStartParameters ($this,$this->oMaxfrei);
  257.         // section -64--88-122--2-556c3468:1044bd6a64b:-7fca end
  258.     }
  259.  
  260.     /**
  261.      * estellt aus den Zeitdaten  HTML Reihen
  262.      *
  263.      * @access private
  264.      * @author Kay Koch, <kay.koch@gmx.de>
  265.      * @param string 
  266.      * @param EINSEE 
  267.      * @param array 
  268.      * @return string 
  269.      */
  270.     private function prepareTimeRows($tpl$oSee$arrTimeRange null)
  271.     {
  272.         $returnValue = (string) '';
  273.  
  274.         // section -64--88-122--2-556c3468:1044bd6a64b:-7fbb begin
  275.         $rowTpl src_tools_TEMPLATE::getTemplate($tpl)// Template einladen
  276.         $isInput (isset($arrTimeRange))false true;
  277.         if ($oSee->buchbarProTag// ganzer Tag buchbar
  278.             if ($isInput// Eingabeformular
  279.                 $this->readonly ""// Gesamtanzahl kann editiert werden
  280.                 $this->sumKey "data[sumTag]";
  281.             else // Gesamtdarstellung
  282.                 $nr = (int)$arrTimeRange[1- (int)$arrTimeRange[0];
  283.                 for ($i 1;$i <= $nr 1;$i++$returnValue .= sprintf($rowTpl"");
  284.             }
  285.         else // stundenweise Anmeldung
  286.             $this->readonly "readonly"// Gesamtanzahl kann nicht editiert werden
  287.             $this->sumKey "";
  288.             $startTime $oSee->getStartTime(""$this->data['wochentag'])// erste angezeigte Uhrzeit
  289.             $endTime $oSee->getEndTime(""$this->data['wochentag'])// letzte angezeigt Uhrzeit
  290.             foreach ($this->arrKeys as $key// alle Datenbankfelder durchlaufen
  291.                 if (isset($this->data[$key]AND src_tools_CHECK::checkHour($key))// Feld ist Uhrzeit
  292.                     if ($isInput// Eingabeformular
  293.                         if ($key >= $startTime AND $key <= $endTime// erlaubte Uhrzeit und Eingabeformular
  294.                             $returnValue .= sprintf($rowTpl$key $key$this->data[$key]);
  295.                         }
  296.                     else // Gesamtdarstellung
  297.                         if ((int)$key < (int)$arrTimeRange[0OR (int)$key > (int)$arrTimeRange[1]// außerhalb jeder Tauchzeit
  298.                             continue;
  299.                         else if ($key $startTime OR $key $endTime or $this->data[$key== 0// außerhalb der Tauchzeit für diesen See
  300.                             $returnValue .= sprintf($rowTpl"");
  301.                         else {
  302.                             $returnValue .= sprintf($rowTpl$this->data[$key]);
  303.                         }
  304.                     }
  305.                 }
  306.             }
  307.         }
  308.         // section -64--88-122--2-556c3468:1044bd6a64b:-7fbb end
  309.  
  310.         return (string) $returnValue;
  311.     }
  312.  
  313.     /**
  314.      * estellt aus den Zeitdaten  HTML überschriften für eine Tabelle
  315.      *
  316.      * @access private
  317.      * @author Kay Koch, <kay.koch@gmx.de>
  318.      * @param void 
  319.      * @return string 
  320.      */
  321.     private function prepareTimeHeader($arrTimeRange)
  322.     {
  323.         $returnValue = (string) '';
  324.  
  325.         // section -64--88-122--2-556c3468:1044bd6a64b:-7faa begin
  326.         list($min$max$arrTimeRange;
  327.         for($hour = (int)$min$hour <= (int)$max$hour++{
  328.             $returnValue .= "<th>" $hour ":00 h</th>\n";
  329.         }
  330.         // section -64--88-122--2-556c3468:1044bd6a64b:-7faa end
  331.  
  332.         return (string) $returnValue;
  333.     }
  334.  
  335. /* end of class src_foundation_admin_ADMINMAXFREI */
  336.  
  337. ?>

Documentation generated on Sat, 24 Mar 2007 09:58:41 +0100 by phpDocumentor 1.3.1