Index: /mods/wpsg_mod_rechnungen.class.php
===================================================================
--- /mods/wpsg_mod_rechnungen.class.php	(revision 6728)
+++ /mods/wpsg_mod_rechnungen.class.php	(revision 6729)
@@ -1306,93 +1306,151 @@
 			
 		} // private function copyTemp($file, $r_id)
-		
-		/**
-		 * Startet den Download einer Rechnung wird im Frontend wie im Backend verwendet
-		 */
-		private function doDownload($r_id)
-		{
-			
-			$rechnung = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_RECHNUNGEN."` WHERE `id` = '".wpsg_q($r_id)."'");
-			
-			if ($rechnung['gnr'] != "")
-			{
-				
-				/**
-				 * Damit alte Rechnungskorrekturen noch angezeigt werden
-				 */
-				if (file_exists($this->getFilePath($rechnung['o_id']).$rechnung['id'].'.pdf'))
-				{
-					
-					$file = $this->getFilePath($rechnung['o_id']).$rechnung['id'].'.pdf';
-					header('Content-Disposition: attachment; filename="'.$rechnung['gnr'].'.pdf"');
-					
-				}
-				else if (file_exists($this->getFilePath($rechnung['o_id']).$rechnung['gnr'].'.pdf'))
-				{
-					
-					$file = $this->getFilePath($rechnung['o_id']).$rechnung['gnr'].'.pdf';
-					header('Content-Disposition: attachment; filename="'.$rechnung['gnr'].'.pdf"');
-				
-				}
-				else if (file_exists($this->getFilePath($rechnung['o_id']).'G'.$rechnung['id'].'.pdf'))
-				{
-					
-					$file = $this->getFilePath($rechnung['o_id']).'G'.$rechnung['id'].'.pdf';
-					header('Content-Disposition: attachment; filename="'.$rechnung['gnr'].'.pdf"');
-					
-				}
-				else
-				{	
-									
-					$file = $this->getFilePath($rechnung['o_id']).'G'.$rechnung['gnr'].'.pdf';
-					header('Content-Disposition: attachment; filename="'.$rechnung['gnr'].'.pdf"');
-					
-				}
-				
-			}
-			else 
-			{
-				
-				/**
-				 * Damit alte Rechnungen noch angezeigt werden
-				 */
-				if (file_exists($this->getFilePath($rechnung['o_id']).$rechnung['id'].'.pdf'))
-				{
-						
-					$file = $this->getFilePath($rechnung['o_id']).$rechnung['id'].'.pdf';
-					header('Content-Disposition: attachment; filename="'.$rechnung['rnr'].'.pdf"');
-						
-				}
-				else if (file_exists($this->getFilePath($rechnung['o_id']).$rechnung['rnr'].'.pdf'))
-				{
-					
-					$file = $this->getFilePath($rechnung['o_id']).$rechnung['rnr'].'.pdf';
-					header('Content-Disposition: attachment; filename="'.$rechnung['rnr'].'.pdf"');						
-					
-				}
-				else if (file_exists($this->getFilePath($rechnung['o_id']).'R'.$rechnung['id'].'.pdf'))
-				{
-					
-					$file = $this->getFilePath($rechnung['o_id']).'R'.$rechnung['id'].'.pdf';
-					header('Content-Disposition: attachment; filename="'.$rechnung['rnr'].'.pdf"');
-					
-				}
-				else
-				{
-					
-					$file = $this->getFilePath($rechnung['o_id']).'R'.$rechnung['rnr'].'.pdf'; 
-					header('Content-Disposition: attachment; filename="'.$rechnung['rnr'].'.pdf"');
-					
-				}
-				
-			}
-			
-			header("Cache-Control: no-cache, must-revalidate");
-			header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); 
-			header('Content-type: application/pdf'); 
-				
-			die(file_get_contents($file));
-			
-		} // private function doDownload($r_id)
+
+        /**
+         * Startet den Download einer Rechnung wird im Frontend wie im Backend verwendet
+         */
+        private function doDownload($r_id)
+        {
+
+            $rechnung = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_RECHNUNGEN."` WHERE `id` = '".wpsg_q($r_id)."'");
+
+            $file_path_old = str_replace('/wpsg/', '/', $this->getFilePath()).$rechnung['o_id'].'/';
+
+            if ($rechnung['gnr'] != "")
+            {
+
+                /**
+                 * Damit alte Rechnungskorrekturen noch angezeigt werden
+                 */
+                if (file_exists($this->getFilePath($rechnung['o_id']).$rechnung['id'].'.pdf'))
+                {
+
+                    $file = $this->getFilePath($rechnung['o_id']).$rechnung['id'].'.pdf';
+                    header('Content-Disposition: attachment; filename="'.$rechnung['gnr'].'.pdf"');
+
+                }
+                else if (file_exists($this->getFilePath($rechnung['o_id']).$rechnung['gnr'].'.pdf'))
+                {
+
+                    $file = $this->getFilePath($rechnung['o_id']).$rechnung['gnr'].'.pdf';
+                    header('Content-Disposition: attachment; filename="'.$rechnung['gnr'].'.pdf"');
+
+                }
+                else if (file_exists($this->getFilePath($rechnung['o_id']).'G'.$rechnung['id'].'.pdf'))
+                {
+
+                    $file = $this->getFilePath($rechnung['o_id']).'G'.$rechnung['id'].'.pdf';
+                    header('Content-Disposition: attachment; filename="'.$rechnung['gnr'].'.pdf"');
+
+                }
+                else if (file_exists($this->getFilePath($rechnung['o_id']).'G'.$rechnung['gnr'].'.pdf'))
+                {
+
+                    $file = $this->getFilePath($rechnung['o_id']).'G'.$rechnung['gnr'].'.pdf';
+                    header('Content-Disposition: attachment; filename="'.$rechnung['gnr'].'.pdf"');
+
+                } //
+                else if (file_exists($file_path_old.'/'.$rechnung['id'].'.pdf'))
+                {
+
+                    $file = $file_path_old.'/'.$rechnung['id'].'.pdf';
+                    header('Content-Disposition: attachment; filename="'.$rechnung['gnr'].'.pdf"');
+
+                }
+                else if (file_exists($file_path_old.'/R'.$rechnung['gnr'].'.pdf'))
+                {
+
+                    $file = $file_path_old.'/R'.$rechnung['gnr'].'.pdf';
+                    header('Content-Disposition: attachment; filename="'.$rechnung['gnr'].'.pdf"');
+
+                }
+                else if (file_exists($file_path_old.'/R'.$rechnung['id'].'.pdf'))
+                {
+
+                    $file = $file_path_old.'/R'.$rechnung['id'].'.pdf';
+                    header('Content-Disposition: attachment; filename="'.$rechnung['gnr'].'.pdf"');
+
+                }
+                else if (file_exists($file_path_old.'/'.$rechnung['gnr'].'.pdf'))
+                {
+
+                    $file = $file_path_old.'/'.$rechnung['gnr'].'.pdf';
+                    header('Content-Disposition: attachment; filename="'.$rechnung['gnr'].'.pdf"');
+
+                }
+
+            }
+            else
+            {
+
+                /**
+                 * Damit alte Rechnungen noch angezeigt werden
+                 */
+                if (file_exists($this->getFilePath($rechnung['o_id']).$rechnung['id'].'.pdf'))
+                {
+
+                    $file = $this->getFilePath($rechnung['o_id']).$rechnung['id'].'.pdf';
+                    header('Content-Disposition: attachment; filename="'.$rechnung['rnr'].'.pdf"');
+
+                }
+                else if (file_exists($this->getFilePath($rechnung['o_id']).$rechnung['rnr'].'.pdf'))
+                {
+
+                    $file = $this->getFilePath($rechnung['o_id']).$rechnung['rnr'].'.pdf';
+                    header('Content-Disposition: attachment; filename="'.$rechnung['rnr'].'.pdf"');
+
+                }
+                else if (file_exists($this->getFilePath($rechnung['o_id']).'R'.$rechnung['id'].'.pdf'))
+                {
+
+                    $file = $this->getFilePath($rechnung['o_id']).'R'.$rechnung['id'].'.pdf';
+                    header('Content-Disposition: attachment; filename="'.$rechnung['rnr'].'.pdf"');
+
+                }
+                else if (file_exists($this->getFilePath($rechnung['o_id']).'R'.$rechnung['rnr'].'.pdf'))
+                {
+
+                    $file = $this->getFilePath($rechnung['o_id']).'R'.$rechnung['rnr'].'.pdf';
+                    header('Content-Disposition: attachment; filename="'.$rechnung['rnr'].'.pdf"');
+
+                }
+                else if (file_exists($file_path_old.'/'.$rechnung['id'].'.pdf'))
+                {
+
+                    $file = $file_path_old.'/'.$rechnung['id'].'.pdf';
+                    header('Content-Disposition: attachment; filename="'.$rechnung['rnr'].'.pdf"');
+
+                }
+                else if (file_exists($file_path_old.'/R'.$rechnung['rnr'].'.pdf'))
+                {
+
+                    $file = $file_path_old.'/R'.$rechnung['rnr'].'.pdf';
+                    header('Content-Disposition: attachment; filename="'.$rechnung['rnr'].'.pdf"');
+
+                }
+                else if (file_exists($file_path_old.'/R'.$rechnung['id'].'.pdf'))
+                {
+
+                    $file = $file_path_old.'/R'.$rechnung['id'].'.pdf';
+                    header('Content-Disposition: attachment; filename="'.$rechnung['rnr'].'.pdf"');
+
+                }
+                else if (file_exists($file_path_old.'/'.$rechnung['rnr'].'.pdf'))
+                {
+
+                    $file = $file_path_old.'/'.$rechnung['rnr'].'.pdf';
+                    header('Content-Disposition: attachment; filename="'.$rechnung['rnr'].'.pdf"');
+
+                }
+
+            }
+
+            header("Cache-Control: no-cache, must-revalidate");
+            header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
+            header('Content-type: application/pdf');
+
+            die(file_get_contents($file));
+
+        } // private function doDownload($r_id)
 		
 		/**
