Source for file class.FLAGS.php

Documentation is available at class.FLAGS.php

  1. <?php
  2.  
  3. /**
  4.  * überprüft, ob eine Woche vorüber ist und veranlasst Updates.
  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.     die('This file was generated for PHP 5');
  13. }
  14.  
  15. /**
  16.  * Basisklasse aller Klassen mit Datenbankzugriff.
  17.  *
  18.  * stellt Methoden und Objekte zur Fehlermeldung und zum Datenbankzugriff zur
  19.  *
  20.  * @author Kay Koch
  21.  * @since 1.12.04
  22.  * @version 1.1
  23.  */
  24. require_once ('src/foundation/tables/class.PARENTTABLES.php');
  25.  
  26. /**
  27.  * Interface für die Klassen zur Manipulation der Datenbanktabellen
  28.  *
  29.  * @author Kay Koch, <kay.koch@gmx.de>
  30.  */
  31. require_once ('src/interfaces/interface.TABLEINTERFACE.php');
  32.  
  33. /* user defined includes */
  34. // section -64--88-122--2-933bcb:100f60e4e57:-7fda-includes begin
  35. // section -64--88-122--2-933bcb:100f60e4e57:-7fda-includes end
  36.  
  37. /* user defined constants */
  38. // section -64--88-122--2-933bcb:100f60e4e57:-7fda-constants begin
  39. // section -64--88-122--2-933bcb:100f60e4e57:-7fda-constants end
  40.  
  41. /**
  42.  * überprüft, ob eine Woche vorüber ist und veranlasst Updates.
  43.  *
  44.  * @access public
  45.  * @author Kay Koch, <kay.koch@gmx.de>
  46.  * @package src
  47.  * @subpackage foundation_tables
  48.  */
  49.     // --- ATTRIBUTES ---
  50.  
  51.     
  52.     /**
  53.      * Beinhaltet den Datenbanknamen (flags)
  54.      *
  55.      * @access protected
  56.      * @var string 
  57.      */
  58.     protected $dbTableName'flags';
  59.  
  60.     /**
  61.      * beinhaltet einen Datensatz der zuständigen Tabelle aus der Datenbank
  62.      *
  63.      * @access private
  64.      * @var array 
  65.      */
  66.     private $dataarray ();
  67.  
  68.     /**
  69.      * aktuelle flag_id
  70.      *
  71.      * @access public
  72.      * @var int 
  73.      */
  74.     public $flag_id1;
  75.  
  76.     // --- OPERATIONS ---
  77.  
  78.     
  79.     /**
  80.      * liefert einen (mehrere) Datensatz die durch setzen ser Parameter
  81.      * werden
  82.      *
  83.      * @access public
  84.      * @author Kay Koch, <kay.koch@gmx.de>
  85.      * @return array 
  86.      */
  87.     public function getRow({
  88.         $returnValuearray ();
  89.  
  90.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fab begin
  91.         $returnValue$this->data;
  92.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fab end
  93.  
  94.         return (array) $returnValue;
  95.     }
  96.  
  97.     /**
  98.      * veranlasst ein Update admin_id = '" . $data['admin_id'] . "'
  99.      *
  100.      * @access public
  101.      * @author Kay Koch, <kay.koch@gmx.de>
  102.      * @param array 
  103.      * @return boolean 
  104.      */
  105.     public function updateRow($data{
  106.         $returnValue= (bool) false;
  107.  
  108.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa9 begin
  109.         try {
  110.             $sql"UPDATE IGNORE $this->dbTableName
  111.                                             SET dayOfChange = '$data['dayOfChange'"',
  112.                                                 timeOfChange = '" $data['timeOfChange'"',
  113.                                                 prizePerPerson = '" $data['prizePerPerson'"',
  114.                                                 lvstResp_id = '" $data['lvstResp_id'"',
  115.                                                 admin_id = '" $data['admin_id'"',
  116.                                                 info = '" $data['info'"',
  117.                                                 isError = '" $data['isError'"'
  118.                                             WHERE flag_id = '1'";
  119.             if (!$this->update($sql))
  120.                 throw new Exception();
  121.             $this->updateData();
  122.             $returnValuetrue;
  123.         catch (Exception $e{
  124.             ;
  125.         }
  126.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa9 end
  127.  
  128.         return (bool) $returnValue;
  129.     }
  130.  
  131.     /**
  132.      * fügt einen neuen Datensatz ein
  133.      *
  134.      * @access public
  135.      * @author Kay Koch, <kay.koch@gmx.de>
  136.      * @param array 
  137.      * @return boolean 
  138.      */
  139.     public function insertRow($data{
  140.         $returnValue= (bool) false;
  141.  
  142.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa6 begin
  143.         die(__METHOD__ . " not implemented");
  144.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa6 end
  145.  
  146.         return (bool) $returnValue;
  147.     }
  148.  
  149.     /**
  150.      * löscht einen Datensatz
  151.      *
  152.      * @access public
  153.      * @author Kay Koch, <kay.koch@gmx.de>
  154.      * @return boolean 
  155.      */
  156.     public function deleteRow({
  157.         $returnValue= (bool) false;
  158.  
  159.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9e begin
  160.         die(__METHOD__ . " not implemented");
  161.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9e end
  162.  
  163.         return (bool) $returnValue;
  164.     }
  165.  
  166.     /**
  167.      * aktualisiert die Daten im gegenwertigen Objekt
  168.      *
  169.      * @access public
  170.      * @author Kay Koch, <kay.koch@gmx.de>
  171.      * @return boolean 
  172.      */
  173.     public function updateData({
  174.         $returnValue= (bool) false;
  175.  
  176.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9c begin
  177.         $sql"SELECT *,
  178.                                        ADDDATE(lastBackupDate,INTERVAL timeOfChange HOUR_SECOND) AS lastBackupDateTime,
  179.                                        ADDDATE(lastDaycheckDate, INTERVAL timeOfChange HOUR_SECOND) AS lastDaycheckDateTime,
  180.                                        (now() > SUBDATE(`saisonStart`,INTERVAL 14 DAY) AND now() <= `saisonEnde`) AS isSaison,
  181.                                        now() AS now
  182.                                 FROM " $this->dbTableName . " LIMIT 1";
  183.         $this->data$this->select($sqlfalse)// einlesen der aktuellen Daten
  184.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9c end
  185.  
  186.         return (bool) $returnValue;
  187.     }
  188.  
  189.     /**
  190.      * löscht die Parameter, die den gegenwärtigen Datensatz identifizieren
  191.      *
  192.      * @access public
  193.      * @author Kay Koch, <kay.koch@gmx.de>
  194.      * @return void 
  195.      */
  196.     public function unsetParams({
  197.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f97 begin
  198.         unset ($this->flag_id);
  199.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f97 end
  200.     }
  201.  
  202.     /**
  203.      * überprüft ob ein neuer Tag angebrochen ist
  204.      *
  205.      * @access public
  206.      * @author Kay Koch, <kay.koch@gmx.de>
  207.      * @return boolean 
  208.      */
  209.     public function isNewDay({
  210.         $returnValue= (bool) false;
  211.  
  212.         // section -64--88-122--2--5ee49331:10456be0103:-7fce begin
  213.         try {
  214.             if (!($this->data['now'$this->data['lastDaycheckDateTime']))
  215.                 throw new Exception();
  216.             $returnValuetrue;
  217.         catch (Exception $e{
  218.         }
  219.         // section -64--88-122--2--5ee49331:10456be0103:-7fce end
  220.  
  221.         return (bool) $returnValue;
  222.     }
  223.  
  224.     /**
  225.      * überprüft ob eine neue Woche angebrochen ist
  226.      *
  227.      * @access public
  228.      * @author Kay Koch, <kay.koch@gmx.de>
  229.      * @return boolean 
  230.      */
  231.     public function isNewWeek({
  232.         $returnValue= (bool) false;
  233.  
  234.         if ($this->data['now'$this->data['lastBackupDateTime']{
  235.             $this->optimizeDB()// Datenbank optimieren
  236.             $returnValuetrue;
  237.         }
  238.  
  239.         return (bool) $returnValue;
  240.     }
  241.     /**
  242.      * überprüft ob die Saison begonnen hat
  243.      *
  244.      * @access public
  245.      * @author Kay Koch, <kay.koch@gmx.de>
  246.      * @return boolean 
  247.      */
  248.     public function isSaison({
  249.         return (bool) ($this->data['isSaison']);
  250.     }
  251.  
  252.     /**
  253.      * aktualisiert das Datum für die tägliche überprüfung
  254.      *
  255.      * @access public
  256.      * @author Kay Koch, <kay.koch@gmx.de>
  257.      * @return void 
  258.      */
  259.     public function updateDayCheck({
  260.         // section -64--88-122--2--5ee49331:10456be0103:-7fc0 begin
  261.         $sql"UPDATE  $this->dbTableName
  262.                SET `lastDaycheckDate` = DATE_ADD(CURDATE(), INTERVAL 1 DAY)
  263.                WHERE flag_id = '1'";
  264.         $this->update($sql);
  265.         // section -64--88-122--2--5ee49331:10456be0103:-7fc0 end
  266.     }
  267.  
  268.     /**
  269.      * aktualisiert das Datum für die wöchentliche überprüfung
  270.      *
  271.      * @access public
  272.      * @author Kay Koch, <kay.koch@gmx.de>
  273.      * @return void 
  274.      */
  275.     public function updateWeekCheck({
  276.         // section -64--88-122--2--5ee49331:10456be0103:-7fbe begin
  277.         $sql"UPDATE  $this->dbTableName
  278.                SET `lastBackupDate` = DATE_ADD(CURDATE(), INTERVAL (7 - (mod(TO_DAYS(now())-TO_DAYS(`lastBackupDate`),7))) DAY)
  279.                WHERE flag_id = '1'";
  280.         $this->update($sql);
  281.         // section -64--88-122--2--5ee49331:10456be0103:-7fbe end
  282.     }
  283.  
  284.     /**
  285.      * liefert die WHERE-Abfrage eines Datenbankzugriffs
  286.      * größer als LastBackup+1Tag und kleiner LastbackUp+8 Tage
  287.      *
  288.      * @access public
  289.      * @author Kay Koch, <kay.koch@gmx.de>
  290.      * @param string 
  291.      * @return string 
  292.      */
  293.     public function getWhereWeekLimit({
  294.         $returnValue= (string) '';
  295.         //
  296.         $returnValue" WHERE ( `datum` >  ADDDATE('" $this->data['lastBackupDate'"',INTERVAL 1 DAY) " .
  297.         " AND `datum` <= ADDDATE('" $this->data['lastBackupDate'"',INTERVAL 8 DAY) ) ";
  298.         //
  299.         return ($returnValue);
  300.     }
  301.     /**
  302.      * Konstruktor
  303.      *
  304.      * lädt alle flags
  305.      *
  306.      * @access public
  307.      * @author Kay Koch, <kay.koch@gmx.de>
  308.      * @return void 
  309.      */
  310.     public function __construct({
  311.         // section -64--88-122--2-7471698e:1046ab3b89c:-7fe9 begin
  312.         parent :: __construct();
  313.         if (empty ($this->data))
  314.             $this->updateData();
  315.         // section -64--88-122--2-7471698e:1046ab3b89c:-7fe9 end
  316.     }
  317.  
  318.     /**
  319.      * liefert den Inhalt eines Feldes mit Namen Index
  320.      *
  321.      * @access public
  322.      * @author Kay Koch, <kay.koch@gmx.de>
  323.      * @param string 
  324.      * @return string 
  325.      */
  326.     private function __get($index{
  327.         $returnValue= (string) '';
  328.         //
  329.         try {
  330.             if (empty ($index))
  331.                 throw new Exception(4);
  332.             if (!isset ($this->data[$index]))
  333.                 throw new Exception(4);
  334.             $returnValue$this->data[$index];
  335.         catch (Exception $e{
  336.             src_tools_ERROR :: setError($e__METHOD__);
  337.         }
  338.         //
  339.         return ($returnValue);
  340.     }
  341.  
  342.     /**
  343.      *
  344.      * schreibt den Beginn und das Ende der Buchungstermine
  345.      *
  346.      * @author kaykoch
  347.      * @access public
  348.      * @since 1.0 - 10.02.2007
  349.      * @param string $minDate frühstes Beginndatum
  350.      * @param string $maxDate spätestes Enddatum
  351.      * @return boolean 
  352.      *
  353.      */
  354.     function setSaisonDates($minDate$maxDate{
  355.         $returnValuefalse;
  356.         // Differenz des ersten Termins zum vorherigen Wechseltermin
  357.         $diff$this->data['dayOfChange'src_tools_TIME :: sqlT2realT($minDate"%w"7;
  358.         // nächster Wechsel
  359.         $nextBackupDatesrc_tools_TIME :: addDays2SQL($minDate$diff);
  360.         $sql"UPDATE  $this->dbTableName
  361.                                 SET `saisonStart` = '$minDate', `saisonEnde` = '$maxDate',`lastBackupDate`= '$nextBackupDate'
  362.                                 WHERE flag_id = '1'";
  363.         $returnValue$this->update($sql);
  364.         return $returnValue;
  365.     }
  366. /* end of class src_foundation_tables_FLAGS */
  367. ?>

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