Source for file class.ADMINNACHTTERMINE.php

Documentation is available at class.ADMINNACHTTERMINE.php

  1. <?php
  2.  
  3. /**
  4.  * Verwaltet die Adminitration der Datenbanktabelle 'nachttermine'
  5.  *
  6.  * @author Kay Koch, <kay.koch@gmx.de>
  7.  * @package src
  8.  * @subpackage foundation_admin
  9.  */
  10.  
  11. if (version_compare(PHP_VERSION'5')) {
  12.     die('This file was generated for PHP 5');
  13. }
  14.  
  15. /**
  16.  * Parentklasse zur Administration der Tabellen
  17.  *
  18.  * @author Kay Koch, <kay.koch@gmx.de>
  19.  */
  20. require_once ('src/foundation/admin/class.PARENTADMIN.php');
  21.  
  22. /**
  23.  * Interface zur Administration der Datenbank
  24.  *
  25.  * @author Kay Koch
  26.  * @since 06.2005
  27.  * @version 1.0
  28.  */
  29. require_once ('src/interfaces/interface.ADMININTERFACE.php');
  30.  
  31. /* user defined includes */
  32. // section -64--88-122--2-3ef144c5:103f62d89fa:-7f9e-includes begin
  33. // section -64--88-122--2-3ef144c5:103f62d89fa:-7f9e-includes end
  34.  
  35. /* user defined constants */
  36. // section -64--88-122--2-3ef144c5:103f62d89fa:-7f9e-constants begin
  37. // section -64--88-122--2-3ef144c5:103f62d89fa:-7f9e-constants end
  38.  
  39. /**
  40.  * Verwaltet die Adminitration der Datenbanktabelle 'nachttermine'
  41.  *
  42.  * @access public
  43.  * @author Kay Koch, <kay.koch@gmx.de>
  44.  * @package src
  45.  * @subpackage foundation_admin
  46.  */
  47.     // --- ATTRIBUTES ---
  48.  
  49.     
  50.     /**
  51.      * Objekt der aktellen Datenbankklasse
  52.      *
  53.      * @access private
  54.      * @var NACHTTERMINE 
  55.      */
  56.     private $oNTGnull;
  57.  
  58.     /**
  59.      * Array mit den Feldnamen der aktuellen Datebank
  60.      *
  61.      * @access protected
  62.      * @var array 
  63.      */
  64.     protected $arrKeysarray ();
  65.  
  66.     /**
  67.      * Name des Haupttemplates
  68.      *
  69.      * @access protected
  70.      * @var string 
  71.      */
  72.     protected $pageTemplate'';
  73.  
  74.     /**
  75.      * Uhrzeit des ersten Nachttauchgangs
  76.      *
  77.      * @access protected
  78.      * @var string 
  79.      */
  80.     protected $firstNightdiveTime'21:00';
  81.     // --- OPERATIONS ---
  82.  
  83.     
  84.     /**
  85.      * zeigt alle Einträge einer Tabelle
  86.      *
  87.      * @access public
  88.      * @author Kay Koch, <kay.koch@gmx.de>
  89.      * @return void 
  90.      */
  91.     public function show({
  92.         // section -64--88-122--2--6176e79b:103fa06a375:-7fad begin
  93.         if ($this->loginOK{
  94.             $this->todo"change";
  95.             $this->rows"";
  96.             $this->oNTG->unsetParams();
  97.             $arrTmp$this->oNTG->getRow();
  98.             foreach ($arrTmp as $see_id => $arrSee{
  99.                 $this->seename$this->oSeen-> $see_id->name;
  100.                 foreach ($arrSee as $this->data{
  101.                     //$this->data['realdatum'] = src_tools_TIME::sqlT2realT($this->data['datum'], "%A - %d. %B %Y");
  102.                     $this->timeRows$this->prepareTimeRows("admin_time_row");
  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.         // section -64--88-122--2--6176e79b:103fa06a375:-7fa9 begin
  123.         if ($this->loginOK{
  124.             if (!empty ($this->oNTG->see_id)) {
  125.                 $this->todo"update";
  126.                 $this->data$this->oNTG->getRow();
  127.                 list ($this->data['jahr']$m$d)split("-"$this->data['datum']);
  128.                 $hour$this->data['uhrzeitEnde'];
  129.             else {
  130.                 $this->todo"insert";
  131.                 $this->data['jahr']date("Y");
  132.                 $mdate("m");
  133.                 $d"1";
  134.                 $hour"21:00";
  135.             }
  136.             $this->rows$this->prepareTimeRows("admin_time_input"true);
  137.             $this->seeOptionList$this->oSeen->getOptionList($this->oNTG->see_id);
  138.             $this->monthOptionListsrc_tools_TIME :: getMonthOL($m);
  139.             $this->dayOptionListsrc_tools_TIME :: getDayOL($d);
  140.             $this->hourOptionListsrc_tools_TIME :: getHourOL("$hour"$this->firstNightdiveTime);
  141.             $this->makePage("admin_" $this->pageTemplate . "_input");
  142.         }
  143.         // section -64--88-122--2--6176e79b:103fa06a375:-7fa9 end
  144.     }
  145.  
  146.     /**
  147.      * Aktualisieet den vorher durch setzen der Parameter ausgewählten
  148.      *
  149.      * Die Neuen Daten befinden sich im Übergabefeld $data
  150.      *
  151.      * @access public
  152.      * @author Kay Koch, <kay.koch@gmx.de>
  153.      * @param array 
  154.      * @return void 
  155.      */
  156.     public function update($data{
  157.         // section -64--88-122--2--6176e79b:103fa06a375:-7f83 begin
  158.         if ($this->loginOK{
  159.             if ($this->checkData($data)) {
  160.                 $this->updateNochfrei($this->oNTG->getRow(),true);
  161.                 $this->oNTG->updateRow($data);
  162.                 $this->updateNochfrei($data);
  163.                 $this->show();
  164.             else
  165.                 $this->change();
  166.         }
  167.         // section -64--88-122--2--6176e79b:103fa06a375:-7f83 end
  168.     }
  169.  
  170.     /**
  171.      * Löscht den Datensatz der vorher durch Parameter ausgewählt wurde
  172.      *
  173.      * @access public
  174.      * @author Kay Koch, <kay.koch@gmx.de>
  175.      * @return void 
  176.      */
  177.     public function delete({
  178.         // section -64--88-122--2--6176e79b:103fa06a375:-7f7f begin
  179.         if ($this->loginOK{
  180.             $this->updateNochfrei($this->oNTG->getRow(),true);
  181.             $this->oNTG->deleteRow();
  182.             $this->show();
  183.         }
  184.         // section -64--88-122--2--6176e79b:103fa06a375:-7f7f end
  185.     }
  186.  
  187.     /**
  188.      * Fügt einen neuen datensatz mit den Werten des Übergabeparameter $data
  189.      *
  190.      * @access public
  191.      * @author Kay Koch, <kay.koch@gmx.de>
  192.      * @param array 
  193.      * @return void 
  194.      */
  195.     public function insert($data{
  196.         // section -64--88-122--2--6176e79b:103fa06a375:-7f7d begin
  197.         if ($this->loginOK{
  198.             if ($this->checkData($data)) {
  199.                 $this->oNTG->insertRow($data);
  200.                 $this->updateNochfrei($data);
  201.                 $this->show();
  202.             else {
  203.                 $this->data$data;
  204.                 $this->change();
  205.             }
  206.         }
  207.         // section -64--88-122--2--6176e79b:103fa06a375:-7f7d end
  208.     }
  209.  
  210.     /**
  211.      * überprüft die Korrektheit der eingebenen bzw. geänderten Daten
  212.      *
  213.      * @access public
  214.      * @author Kay Koch, <kay.koch@gmx.de>
  215.      * @param void 
  216.      * @return boolean 
  217.      */
  218.     public function checkData($data{
  219.         $returnValue= (bool) false;
  220.  
  221.         // section -64--88-122--2--62c31de:1048594e50f:-7fef begin
  222.         try {
  223.             if (!src_tools_CHECK :: checkID($data['see_id']))
  224.                 throw new Exception("19,Seename");
  225.             if (empty ($data['tag']or empty ($data['monat']or empty ($data['jahr']))
  226.                 throw new Exception("49,Datum");
  227.             if (!isset($data['datum']or empty($data['datum']) ){
  228.                     $data['datum'src_tools_TIME::formatDate($data['tag'],$data['monat'],$data['jahr']);
  229.                 }
  230.             if (!src_tools_CHECK :: checkDatum($data['datum'])) // YYYY-MM-TT
  231.                 throw new Exception("51,Datum");
  232.             if (!src_tools_CHECK :: checkHour($data['uhrzeitEnde'])) //hh:mm
  233.                 throw new Exception("52,letzte Anmeldung");
  234.             foreach ($data as $key => $anzahl{
  235.                 if (src_tools_CHECK :: checkHour($key)) //hh:mm
  236.                     if (!src_tools_CHECK :: checkAnzahl($anzahl)) // int
  237.                         $data[$key]0;
  238.                     }
  239.                 }
  240.             }
  241.             $returnValuetrue;
  242.         catch (Exception $e{
  243.             $messageexplode(","$e->getMessage());
  244.             $this->errorMsg"<b>[" $message[1"] : </b>" src_tools_ERROR :: getErrTxt($message[0]);
  245.             $this->errorsrc_tools_TEMPLATE :: getTemplate('error'$this);
  246.         }
  247.         // section -64--88-122--2--62c31de:1048594e50f:-7fef end
  248.  
  249.         return (bool) $returnValue;
  250.     }
  251.  
  252.     /**
  253.      * Konstruktor
  254.      *
  255.      * erstellt ein Obejkt der zu beabeitenden Klassen
  256.      * list alle erlaubten Datenbankschlüssel ein
  257.      * liest das Template
  258.      *
  259.      * @access public
  260.      * @author Kay Koch, <kay.koch@gmx.de>
  261.      * @param string 
  262.      * @param int 
  263.      * @param date 
  264.      * @return void 
  265.      */
  266.     public function __construct($token$see_id0$datumnull{
  267.         // section -64--88-122--2-3ef144c5:103f62d89fa:-7f98 begin
  268.         parent :: __construct($token);
  269.         $this->oNTGnew src_foundation_tables_NACHTTERMINE();
  270.         $this->oNTG->setParams($see_id$datum);
  271.         $this->see_id$see_id;
  272.         $this->datum$datum;
  273.         $this->setStartParameters($this$this->oNTG);
  274.         // section -64--88-122--2-3ef144c5:103f62d89fa:-7f98 end
  275.     }
  276.  
  277.     /**
  278.      * estellt aus den Zeitdaten  HTML Reihen
  279.      *
  280.      * @access private
  281.      * @author Kay Koch, <kay.koch@gmx.de>
  282.      * @param string 
  283.      * @param boolean 
  284.      * @param boolean 
  285.      * @return string 
  286.      */
  287.     private function prepareTimeRows($tpl$isInputfalse{
  288.         $returnValue= (string) '';
  289.  
  290.         // section -64--88-122--2-556c3468:1044bd6a64b:-7fb6 begin
  291.         $rowTplsrc_tools_TEMPLATE :: getTemplate($tpl)// Template einladen
  292.         foreach ($this->arrKeys as $key// alle Datenbankfelder durchlaufen
  293.             if (isset ($this->data[$key]AND src_tools_CHECK :: checkHour($key)) // Feld ist Uhrzeit
  294.                 if ($isInput// Eingabeseite
  295.                     $returnValue .= sprintf($rowTpl$key$key$this->data[$key]);
  296.                 else // Ausgabeseite
  297.                     $returnValue .= sprintf($rowTpl$this->data[$key]);
  298.             }
  299.         }
  300.         // section -64--88-122--2-556c3468:1044bd6a64b:-7fb6 end
  301.  
  302.         return (string) $returnValue;
  303.     }
  304.  
  305.     /**
  306.      *
  307.      * updateNochfrei
  308.      *
  309.      * @author kaykoch
  310.      * @access public
  311.      * @since 1.0 - 08.02.2007
  312.      * @param array $data Daten
  313.      * @return array Daten
  314.      *
  315.      */
  316.     private function updateNochfrei($data$sub=false{
  317.         $returnValue"";
  318.         $oNFnew src_foundation_tables_NOCHFREI();
  319.         $ft= (int) substr($this->firstNightdiveTime03)// erste Uhrzeit für NTGs
  320.         $lt= (int) substr($data['uhrzeitEnde']03)// letzte Uhrzeit für NTGs
  321.         $sub ($sub)? -1:1;
  322.         try {
  323.             for ($h$ft$h <= $lt$h++{
  324.                 if (!$oNF->increase($data['see_id']$data['datum']$h ":00"$sub*$data[$h ":00"]))
  325.                     throw new Exception(8);
  326.             }
  327.         catch (Exception $e{
  328.             src_tools_ERROR :: setError($e__METHOD__);
  329.         }
  330.  
  331.         return $returnValue;
  332.     }
  333.  
  334. /* end of class src_foundation_admin_ADMINNACHTTERMINE */
  335. ?>

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