Source for file class.NACHTTERMINE.php

Documentation is available at class.NACHTTERMINE.php

  1. <?php
  2.  
  3. /**
  4.  * Ernöglicht den Zugang zur Datenbank Nachtauchen
  5.  *
  6.  * @author Kay Koch, <kay.koch@gmx.de>
  7.  * @package src
  8.  * @subpackage foundation_tables
  9.  */
  10.  
  11. if (version_compare(PHP_VERSION'5'))
  12. {
  13.     die('This file was generated for PHP 5');
  14. }
  15.  
  16. /**
  17.  * Basisklasse aller Klassen mit Datenbankzugriff.
  18.  *
  19.  * stellt Methoden und Objekte zur Fehlermeldung und zum Datenbankzugriff zur
  20.  *
  21.  * @author Kay Koch
  22.  * @since 1.12.04
  23.  * @version 1.1
  24.  */
  25. require_once ('src/foundation/tables/class.PARENTTABLES.php');
  26.  
  27. /**
  28.  * Interface für die Klassen zur Manipulation der Datenbanktabellen
  29.  *
  30.  * @author Kay Koch, <kay.koch@gmx.de>
  31.  */
  32. require_once ('src/interfaces/interface.TABLEINTERFACE.php');
  33.  
  34. /* user defined includes */
  35. // section -64--88-122--2--264ee0f5:103e4c700eb:-7fdd-includes begin
  36. // section -64--88-122--2--264ee0f5:103e4c700eb:-7fdd-includes end
  37.  
  38. /* user defined constants */
  39. // section -64--88-122--2--264ee0f5:103e4c700eb:-7fdd-constants begin
  40. // section -64--88-122--2--264ee0f5:103e4c700eb:-7fdd-constants end
  41.  
  42. /**
  43.  * Ernöglicht den Zugang zur Datenbank Nachtauchen
  44.  *
  45.  * @access public
  46.  * @author Kay Koch, <kay.koch@gmx.de>
  47.  * @package src
  48.  * @subpackage foundation_tables
  49.  */
  50. {
  51.     // --- ATTRIBUTES ---
  52.  
  53.     
  54.     /**
  55.      * Beinhaltet den Datenbanknamen (nachttauchen)
  56.      *
  57.      * @access protected
  58.      * @var string 
  59.      */
  60.     protected $dbTableName = 'nachttermine';
  61.  
  62.     /**
  63.      * array mit allen Nachttauchterminen und dem geänderten Anmeldeschluss
  64.      *
  65.      * @access private
  66.      * @var array 
  67.      */
  68.     private static $data array ();
  69.  
  70.     /**
  71.      * aktuelle see_id
  72.      *
  73.      * @access public
  74.      * @var int 
  75.      */
  76.     public $see_id = 0;
  77.  
  78.     /**
  79.      * aktuelles Datum
  80.      *
  81.      * @access public
  82.      * @var date 
  83.      */
  84.     public $datum = null;
  85.  
  86.     // --- OPERATIONS ---
  87.  
  88.     
  89.     /**
  90.      * liefert einen (mehrere) Datensatz die durch setzen ser Parameter
  91.      * werden
  92.      *
  93.      * @access public
  94.      * @author Kay Koch, <kay.koch@gmx.de>
  95.      * @return array 
  96.      */
  97.     public function getRow()
  98.     {
  99.         $returnValue array ();
  100.  
  101.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fab begin
  102.         if (!empty ($this->datumAND !empty ($this->see_id))
  103.             $returnValue self :: $data[$this->see_id][$this->datum];
  104.         else
  105.             if (!empty ($this->see_id))
  106.                 $returnValue self :: $data[$this->see_id];
  107.             else
  108.                 $returnValue self :: $data;
  109.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fab end
  110.  
  111.         return (array) $returnValue;
  112.     }
  113.  
  114.     /**
  115.      * veranlasst ein Update
  116.      *
  117.      * @access public
  118.      * @author Kay Koch, <kay.koch@gmx.de>
  119.      * @param array 
  120.      * @return boolean 
  121.      */
  122.     public function updateRow($data)
  123.     {
  124.         $returnValue = (bool) false;
  125.  
  126.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa9 begin
  127.         try
  128.         {
  129.             $sum $data['21:00'$data['22:00'$data['23:00'$data['24:00'];
  130.             $sql "UPDATE IGNORE $this->dbTableName
  131.                                 SET `see_id` = '$data['see_id'"',
  132.                                      `datum` = '" $data['datum'"',
  133.                                      `uhrzeitEnde` = '" $data['uhrzeitEnde'"',
  134.                                      `sumTag` = '" $sum "',
  135.                                      `21:00` = '" $data['21:00'"',
  136.                                      `22:00` = '" $data['22:00'"',
  137.                                      `23:00` = '" $data['23:00'"',
  138.                                      `24:00` = '" $data['24:00'"'
  139.                                 WHERE see_id = '$this->see_idAND datum='$this->datum'";
  140.             if (!$this->update($sql))
  141.                 throw new Exception();
  142.             $this->updateData();
  143.             $returnValue true;
  144.         catch (Exception $e)
  145.         {
  146.         }
  147.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa9 end
  148.  
  149.         return (bool) $returnValue;
  150.     }
  151.  
  152.     /**
  153.      * fügt einen neuen Datensatz ein
  154.      *
  155.      * @access public
  156.      * @author Kay Koch, <kay.koch@gmx.de>
  157.      * @param array 
  158.      * @return boolean 
  159.      */
  160.     public function insertRow($data)
  161.     {
  162.         $returnValue = (bool) false;
  163.  
  164.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa6 begin
  165.         try
  166.         {
  167.             $sum $data['21:00'$data['22:00'$data['23:00'$data['24:00'];
  168.             $sql "INSERT IGNORE INTO $this->dbTableName
  169.                                 SET `see_id` = '$data['see_id'"',
  170.                                     `datum` = '" $data['datum'"',
  171.                                     `uhrzeitEnde` = '" $data['uhrzeitEnde'"',
  172.                                     `sumTag` = '" $sum "',
  173.                                     `21:00` = '" $data['21:00'"',
  174.                                     `22:00` = '" $data['22:00'"',
  175.                                     `23:00` = '" $data['23:00'"',
  176.                                     `24:00` = '" $data['24:00'"'";
  177.             if (!$this->insert($sql))
  178.                 throw new Exception();
  179.             $this->updateData();
  180.             $returnValue true;
  181.         catch (Exception $e)
  182.         {
  183.             ;
  184.         }
  185.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa6 end
  186.  
  187.         return (bool) $returnValue;
  188.     }
  189.  
  190.     /**
  191.      * löscht einen Datensatz
  192.      *
  193.      * @access public
  194.      * @author Kay Koch, <kay.koch@gmx.de>
  195.      * @return boolean 
  196.      */
  197.     public function deleteRow()
  198.     {
  199.         $returnValue = (bool) false;
  200.  
  201.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9e begin
  202.         try
  203.         {
  204.             $whereit (empty ($this->datum)) "" "AND datum='$this->datum'";
  205.             $sql "DELETE FROM $this->dbTableName WHERE see_id = '$this->see_id$whereit";
  206.             if (!$this->delete($sql))
  207.                 throw new Exception();
  208.             $this->updateData();
  209.             $returnValue true;
  210.         catch (Exception $e)
  211.         {
  212.         }
  213.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9e end
  214.  
  215.         return (bool) $returnValue;
  216.     }
  217.  
  218.     /**
  219.      * aktualisiert die Daten im gegenwertigen Objekt
  220.      *
  221.      * @access public
  222.      * @author Kay Koch, <kay.koch@gmx.de>
  223.      * @return boolean 
  224.      */
  225.     public function updateData()
  226.     {
  227.         $returnValue = (bool) false;
  228.  
  229.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9c begin
  230.         $sql "SELECT * FROM  $this->dbTableName";
  231.         self :: $data $this->select($sqltrue"see_id""datum");
  232.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9c end
  233.  
  234.         return (bool) $returnValue;
  235.     }
  236.  
  237.     /**
  238.      * löscht die Parameter, die den gegenwärtigen Datensatz identifizieren
  239.      *
  240.      * @access public
  241.      * @author Kay Koch, <kay.koch@gmx.de>
  242.      * @return void 
  243.      */
  244.     public function unsetParams()
  245.     {
  246.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f97 begin
  247.         unset ($this->see_id);
  248.         unset ($this->datum);
  249.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f97 end
  250.     }
  251.  
  252.     /**
  253.      * liefert die geänderten freien Plätze
  254.      *
  255.      * Wenn für das Datum kein Termin vorliegt, wird ein leeres array
  256.      *
  257.      * @access public
  258.      * @author Kay Koch, <kay.koch@gmx.de>
  259.      * @return array 
  260.      */
  261.     public function getMaxNightPlaces()
  262.     {
  263.         $returnValue array ();
  264.  
  265.         // section -64--88-122--2--264ee0f5:103e4c700eb:-7fd7 begin
  266.         if (isset (self :: $data[$this->see_id][$this->datum]))
  267.         {
  268.             $returnValue self :: $data[$this->see_id][$this->datum];
  269.             unset ($returnValue['see_id']);
  270.             unset ($returnValue['datum']);
  271.             unset ($returnValue['uhrzeitEnde']);
  272.             foreach ($returnValue as $key => $places)
  273.                 if ($places == 0)
  274.                     unset ($returnValue[$key]);
  275.         }
  276.         // section -64--88-122--2--264ee0f5:103e4c700eb:-7fd7 end
  277.  
  278.         return (array) $returnValue;
  279.     }
  280.  
  281.     /**
  282.      * liefert das geänderte Ende des Tauchtages
  283.      *
  284.      * @access public
  285.      * @author Kay Koch, <kay.koch@gmx.de>
  286.      * @return time 
  287.      */
  288.     public function getChangedEnd()
  289.     {
  290.         $returnValue null;
  291.  
  292.         // section -64--88-122--2--264ee0f5:103e4c700eb:-7fcc begin
  293.         $returnValue self :: $data[$this->see_id][$this->datum]['uhrzeitEnde'];
  294.         // section -64--88-122--2--264ee0f5:103e4c700eb:-7fcc end
  295.  
  296.         return $returnValue;
  297.     }
  298.  
  299.     /**
  300.      * überprüft ob an dem aktuellen Tag ein Nachtauchgang durchgeführt werden
  301.      *
  302.      * @access public
  303.      * @author Kay Koch, <kay.koch@gmx.de>
  304.      * @return boolean 
  305.      */
  306.     public function isNightDive($stunde="")
  307.     {
  308.         $returnValue = (bool) false;
  309.         // section -64--88-122--2--264ee0f5:103e4c700eb:-7fc1 begin
  310.         if(empty($stunde))
  311.             $returnValue = isset (self :: $data[$this->see_id][$this->datum]);
  312.         else if(isset (self :: $data[$this->see_id][$this->datum][$stunde]))
  313.             $returnValue self :: $data[$this->see_id][$this->datum][$stunde]>0;
  314.         // section -64--88-122--2--264ee0f5:103e4c700eb:-7fc1 end
  315.  
  316.         return (bool) $returnValue;
  317.     }
  318.  
  319.     /**
  320.      * setzt die Daten für die aktuelle Bearbeitung
  321.      *
  322.      * @access public
  323.      * @author Kay Koch, <kay.koch@gmx.de>
  324.      * @param int 
  325.      * @param date 
  326.      * @return void 
  327.      */
  328.     public function setParams($see_id$datum null)
  329.     {
  330.         // section -64--88-122--2-339007d5:1043cd4e8c9:-7fa5 begin
  331.         $this->see_id = $see_id;
  332.         if (!empty ($datum))
  333.             $this->datum = $datum;
  334.         // section -64--88-122--2-339007d5:1043cd4e8c9:-7fa5 end
  335.     }
  336.  
  337.     /**
  338.      * Konstruktor
  339.      *
  340.      * lädt alle Nachttermine
  341.      *
  342.      * @access public
  343.      * @author Kay Koch, <kay.koch@gmx.de>
  344.      * @return void 
  345.      */
  346.     public function __construct()
  347.     {
  348.         // section -64--88-122--2-7471698e:1046ab3b89c:-7fef begin
  349.         parent :: __construct();
  350.         if (empty (self :: $data))
  351.             $this->updateData();
  352.         // section -64--88-122--2-7471698e:1046ab3b89c:-7fef end
  353.     }
  354.  
  355. /* end of class src_foundation_tables_NACHTTERMINE */
  356. ?>

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