Source for file class.ARCHIV.php

Documentation is available at class.ARCHIV.php

  1. <?php
  2.  
  3.  
  4. /**
  5.  * Stellt die Verbindung zur Tabelle 'archiv' her
  6.  *
  7.  * Verwaltet die Archivierung von alten Buchungen
  8.  *
  9.  * @author Kay Koch, <kay.koch@gmx.de>
  10.  * @package src
  11.  * @subpackage foundation_tables
  12.  */
  13.  
  14. if (version_compare(PHP_VERSION'5')) {
  15.     die('This file was generated for PHP 5');
  16. }
  17.  
  18. /**
  19.  * Basisklasse aller Klassen mit Datenbankzugriff.
  20.  *
  21.  * stellt Methoden und Objekte zur Fehlermeldung und zum Datenbankzugriff zur
  22.  *
  23.  * @author Kay Koch
  24.  * @since 1.12.04
  25.  * @version 1.1
  26.  */
  27. require_once('src/foundation/tables/class.PARENTTABLES.php');
  28.  
  29. /**
  30.  * Interface für die Klassen zur Manipulation der Datenbanktabellen
  31.  *
  32.  * @author Kay Koch, <kay.koch@gmx.de>
  33.  */
  34. require_once('src/interfaces/interface.TABLEINTERFACE.php');
  35.  
  36. /* user defined includes */
  37. // section -64--88-122--2-1989b5:1009961f3dd:-7f6b-includes begin
  38. // section -64--88-122--2-1989b5:1009961f3dd:-7f6b-includes end
  39.  
  40. /* user defined constants */
  41. // section -64--88-122--2-1989b5:1009961f3dd:-7f6b-constants begin
  42. // section -64--88-122--2-1989b5:1009961f3dd:-7f6b-constants end
  43.  
  44. /**
  45.  * Stellt die Verbindung zur Tabelle 'archiv' her
  46.  *
  47.  * Verwaltet die Archivierung von alten Buchungen
  48.  *
  49.  * @access public
  50.  * @author Kay Koch, <kay.koch@gmx.de>
  51.  * @package src
  52.  * @subpackage foundation_tables
  53.  */
  54.         implements src_interfaces_TABLEINTERFACE
  55. {
  56.     // --- ATTRIBUTES ---
  57.  
  58.     
  59.     /**
  60.      * Beinhaltet den Datenbanknamen (archiv)
  61.      *
  62.      * @access protected
  63.      * @var string 
  64.      */
  65.     protected $dbTableName = 'archiv';
  66.  
  67.     /**
  68.      * Short description of attribute data
  69.      *
  70.      * @access private
  71.      * @var array 
  72.      */
  73.     private static $data array();
  74.  
  75.  
  76.     /**
  77.      * Short description of attribute buch_id
  78.      *
  79.      * @access public
  80.      * @var int 
  81.      */
  82.     private $endDatum "";
  83.     // --- OPERATIONS ---
  84.  
  85.     
  86.     /**
  87.      * liefert einen (mehrere) Datensatz die durch setzen ser Parameter
  88.      * werden
  89.      *
  90.      * @access public
  91.      * @author Kay Koch, <kay.koch@gmx.de>
  92.      * @return array 
  93.      */
  94.     public function getRow()
  95.     {
  96.         $returnValue array();
  97.  
  98.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fab begin
  99.         if (!empty($this->buch_id))
  100.             $returnValue self::$data[$this->buch_id];
  101.         else
  102.             $returnValue self::$data;
  103.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fab end
  104.  
  105.         return (array) $returnValue;
  106.     }
  107.  
  108.     /**
  109.      * veranlasst ein Update
  110.      *
  111.      * @access public
  112.      * @author Kay Koch, <kay.koch@gmx.de>
  113.      * @param array 
  114.      * @return boolean 
  115.      */
  116.     public function updateRow($data)
  117.     {
  118.         $returnValue = (bool) false;
  119.  
  120.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa9 begin
  121.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa9 end
  122.  
  123.         return (bool) $returnValue;
  124.     }
  125.  
  126.     /**
  127.      * fügt einen neuen Datensatz ein
  128.      *
  129.      * @access public
  130.      * @author Kay Koch, <kay.koch@gmx.de>
  131.      * @param array 
  132.      * @return boolean 
  133.      */
  134.     public function insertRow($data)
  135.     {
  136.         $returnValue = (bool) false;
  137.  
  138.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa6 begin
  139.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa6 end
  140.  
  141.         return (bool) $returnValue;
  142.     }
  143.  
  144.     /**
  145.      * löscht einen Datensatz
  146.      *
  147.      * @access public
  148.      * @author Kay Koch, <kay.koch@gmx.de>
  149.      * @return boolean 
  150.      */
  151.     public function deleteRow()
  152.     {
  153.         $returnValue = (bool) false;
  154.  
  155.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9e begin
  156.         try {
  157.             if     (!empty($this->buch_id)) // bstimmten Eintrag löschen
  158.                $sql "DELETE FROM $this->dbTableName WHERE buch_id = '$this->buch_id ";
  159.             else // alle Einträge der letzten 28 Tage löschen
  160.                $sql "DELETE FROM $this->dbTableName WHERE datum <= SUBDATE(CURDATE(),INTERVAL 28 DAY";
  161.             if (!$this->delete($sql))
  162.                 throw new Exception ();
  163.             $this->updateData();
  164.             $returnValue true;
  165.         }
  166.         catch (Exception $e{;
  167.         }
  168.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9e end
  169.  
  170.         return (bool) $returnValue;
  171.     }
  172.  
  173.     /**
  174.      * aktualisiert die Daten im gegenwertigen Objekt
  175.      *
  176.      * @access public
  177.      * @author Kay Koch, <kay.koch@gmx.de>
  178.      * @return boolean 
  179.      */
  180.     public function updateData()
  181.     {
  182.         $returnValue = (bool) false;
  183.  
  184.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9c begin
  185.         $sql "SELECT * FROM  `buchungen` WHERE `datum` <= '".$this->endDatum."' AND `datum` > SUBDATE('".$this->endDatum."',INTERVAL 7 DAY) ORDER by see_id,datum,stunde ASC";
  186.         self::$data $this->select($sqltrue"buch_id");
  187.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9c end
  188.  
  189.         return (bool) $returnValue;
  190.     }
  191.  
  192.     /**
  193.      * löscht die Parameter, die den gegenwärtigen Datensatz identifizieren
  194.      *
  195.      * @access public
  196.      * @author Kay Koch, <kay.koch@gmx.de>
  197.      * @return void 
  198.      */
  199.     public function unsetParams()
  200.     {
  201.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f97 begin
  202.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f97 end
  203.     }
  204.  
  205.     /**
  206.      * speichert alte Einträge in der Datenbank
  207.      *
  208.      * @access public
  209.      * @author Kay Koch, <kay.koch@gmx.de>
  210.      * @param int 
  211.      * @param string 
  212.      * @return boolean 
  213.      */
  214.     public function saveOldBuchungen($sourceTableName)
  215.     {
  216.         $returnValue = (bool) false;
  217.  
  218.         // section -64--88-122--2-1328c7a:100b92518e4:-7ffc begin
  219.         $weekLimit $this->getFlags()->getWhereWeekLimit();
  220.         $sql "INSERT IGNORE INTO $this->dbTableName SELECT * FROM `$sourceTableName$weekLimit ORDER by see_id,datum ASC";
  221.         if ($this->insert($sql))
  222.             $returnValue true;
  223.         // section -64--88-122--2-1328c7a:100b92518e4:-7ffc end
  224.  
  225.         return (bool) $returnValue;
  226.     }
  227.  
  228.     /**
  229.      * Short description of method __construct
  230.      *
  231.      * @access public
  232.      * @author Kay Koch, <kay.koch@gmx.de>
  233.      * @return void 
  234.      */
  235.     public function __construct()
  236.     {
  237.         // section -64--88-0-1-933bcb:1056263e44b:-7fe9 begin
  238.         parent::__construct();
  239.         $this->endDatum src_tools_TIME::addDays2SQL($this->getFlags()->lastBackupDate,1);
  240.         if (empty(self::$data))
  241.             $this->updateData();
  242.         // section -64--88-0-1-933bcb:1056263e44b:-7fe9 end
  243.     }
  244.     /**
  245.      * setzt die Daten für die aktuelle Bearbeitung
  246.      *
  247.      * @access public
  248.      * @author Kay Koch, <kay.koch@gmx.de>
  249.      * @param string $datum letztes angezeigtes Datum
  250.      * @return void 
  251.      */
  252.     public function setParams($datum)
  253.     {
  254.         // section -64--88-122--2--49bf02f4:103b2814a7e:-7fc5 begin
  255.         $this->endDatum $datum;
  256.         // section -64--88-122--2--49bf02f4:103b2814a7e:-7fc5 end
  257.     }
  258.     /**
  259.      * liefert letztes Datum der letzten, der aktuellen und der nächsten Woche
  260.      *
  261.      * @access public
  262.      * @author Kay Koch, <kay.koch@gmx.de>
  263.      * @return array Beginn der Woche, Ende der Woche, Ende nächste Woche
  264.      */
  265.     public function getDates()
  266.     {
  267.         return array(src_tools_TIME::addDays2SQL($this->endDatum,-7),$this->endDatum,src_tools_TIME::addDays2SQL($this->endDatum,7));
  268.     }
  269. /* end of class src_foundation_tables_ARCHIV */
  270.  
  271. ?>

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