Johannes Zellner 5 anni fa
commit
6321890069
100 ha cambiato i file con 4211 aggiunte e 0 eliminazioni
  1. 20 0
      CloudronManifest.json
  2. 42 0
      Dockerfile
  3. 12 0
      README.md
  4. 36 0
      apache/lamp.conf
  5. 17 0
      apache/mpm_prefork.conf
  6. 85 0
      app/DataBase/Assistant.php
  7. 107 0
      app/DataBase/Bill.php
  8. 110 0
      app/DataBase/Bill_Import.php
  9. 161 0
      app/DataBase/Bill_Product.php
  10. 132 0
      app/DataBase/Bill_Product_Import.php
  11. 82 0
      app/DataBase/Category.php
  12. 120 0
      app/DataBase/Customer.php
  13. 69 0
      app/DataBase/Group.php
  14. 99 0
      app/DataBase/Price.php
  15. 105 0
      app/DataBase/Priceset.php
  16. 163 0
      app/DataBase/Product.php
  17. 71 0
      app/DataBase/Tax.php
  18. 83 0
      app/DataBase/Tour.php
  19. 92 0
      app/DataBase/database.php
  20. 84 0
      app/Druckvorlagen/customer_list.php
  21. 119 0
      app/Druckvorlagen/list.php
  22. 250 0
      app/Druckvorlagen/rechnung.php
  23. 93 0
      app/Druckvorlagen/tour.php
  24. 3 0
      app/Druckvorlagen/zeilen.php
  25. BIN
      app/Icons/Datenauszug aus WordPad-Dokument '_background-colo...'.shs
  26. BIN
      app/Icons/Thumbs.db
  27. BIN
      app/Icons/assistant.png
  28. BIN
      app/Icons/back.png
  29. BIN
      app/Icons/backup.png
  30. BIN
      app/Icons/bill.png
  31. BIN
      app/Icons/category.png
  32. BIN
      app/Icons/configuration.png
  33. BIN
      app/Icons/customer.png
  34. BIN
      app/Icons/date_product.png
  35. BIN
      app/Icons/down.png
  36. BIN
      app/Icons/help.png
  37. BIN
      app/Icons/loading.gif
  38. BIN
      app/Icons/logo.gif
  39. BIN
      app/Icons/mxfilerelatedcache.mxc2
  40. BIN
      app/Icons/print.png
  41. BIN
      app/Icons/product.png
  42. BIN
      app/Icons/product_list.png
  43. BIN
      app/Icons/stat.png
  44. BIN
      app/Icons/sync.png
  45. BIN
      app/Icons/tour.png
  46. BIN
      app/Icons/up.png
  47. 25 0
      app/Modules/Assistant/db_action.php
  48. 127 0
      app/Modules/Assistant/edit_form.php
  49. 124 0
      app/Modules/Assistant/new_form.php
  50. 27 0
      app/Modules/Assistant/toolbar.php
  51. 91 0
      app/Modules/Bill/db_action.php
  52. 130 0
      app/Modules/Bill/edit_form.php
  53. 39 0
      app/Modules/Bill/new_form.php
  54. 27 0
      app/Modules/Bill/toolbar.php
  55. 15 0
      app/Modules/Category/anleitung.txt
  56. 26 0
      app/Modules/Category/db_action.php
  57. 41 0
      app/Modules/Category/edit_form.php
  58. 36 0
      app/Modules/Category/new_form.php
  59. 27 0
      app/Modules/Category/toolbar.php
  60. 25 0
      app/Modules/Configuration/db_action.php
  61. 32 0
      app/Modules/Configuration/group.php
  62. 32 0
      app/Modules/Configuration/priceset.php
  63. 32 0
      app/Modules/Configuration/tax.php
  64. 20 0
      app/Modules/Configuration/toolbar.php
  65. 61 0
      app/Modules/Customer/db_action.php
  66. 139 0
      app/Modules/Customer/edit_form.php
  67. 140 0
      app/Modules/Customer/new_form.php
  68. 27 0
      app/Modules/Customer/toolbar.php
  69. 62 0
      app/Modules/Product/db_action.php
  70. 101 0
      app/Modules/Product/edit_form.php
  71. 96 0
      app/Modules/Product/new_form.php
  72. 37 0
      app/Modules/Product/toolbar.php
  73. 53 0
      app/Modules/Tour/db_action.php
  74. 34 0
      app/Modules/Tour/edit_form.php
  75. 30 0
      app/Modules/Tour/new_form.php
  76. 42 0
      app/Modules/Tour/toolbar.php
  77. 43 0
      app/Modules/Websync/BillSync.php
  78. 72 0
      app/Modules/Websync/CustomerSync.php
  79. 55 0
      app/Modules/Websync/PricesetSync.php
  80. 98 0
      app/Modules/Websync/ProductSync.php
  81. 16 0
      app/Modules/Websync/toolbar.php
  82. 74 0
      app/Modules/toolbar.php
  83. BIN
      app/NTK/Icons/1downarrow.png
  84. BIN
      app/NTK/Icons/1uparrow.png
  85. BIN
      app/NTK/Icons/ascii.png
  86. BIN
      app/NTK/Icons/ascii_small.png
  87. BIN
      app/NTK/Icons/button_cancel.png
  88. BIN
      app/NTK/Icons/button_cancel_small.png
  89. BIN
      app/NTK/Icons/button_ok.png
  90. BIN
      app/NTK/Icons/filenew.png
  91. BIN
      app/NTK/Icons/fileopen.png
  92. BIN
      app/NTK/Icons/fileprint.png
  93. BIN
      app/NTK/Icons/filesave.png
  94. BIN
      app/NTK/Icons/filesaveas.png
  95. BIN
      app/NTK/Icons/folder.png
  96. BIN
      app/NTK/Icons/folder2.png
  97. BIN
      app/NTK/Icons/folder2_yellow.png
  98. BIN
      app/NTK/Icons/folder_home.png
  99. BIN
      app/NTK/Icons/goto.png
  100. BIN
      app/NTK/Icons/undo.png

+ 20 - 0
CloudronManifest.json

@@ -0,0 +1,20 @@
+{
+  "id": "de.nebulon.faursprung",
+  "title": "Ursprung",
+  "author": "Johannes Zellner",
+  "description": "file://DESCRIPTION.md",
+  "tagline": "Some tagline",
+  "version": "1.0.0",
+  "healthCheckPath": "/",
+  "httpPort": 80,
+  "addons": {
+    "localstorage": {},
+    "mysql": {}
+  },
+  "minBoxVersion": "0.0.1",
+  "manifestVersion": 1,
+  "website": "http://nebulon.de",
+  "contactEmail": "johannes@nebulon.de",
+  "icon": "",
+  "mediaLinks": [ ]
+}

+ 42 - 0
Dockerfile

@@ -0,0 +1,42 @@
+FROM cloudron/base:2.0.0@sha256:f9fea80513aa7c92fe2e7bf3978b54c8ac5222f47a9a32a7f8833edf0eb5a4f4
+
+RUN mkdir -p /app/code /app/pkg
+WORKDIR /app/code
+
+# configure apache
+RUN rm /etc/apache2/sites-enabled/*
+RUN sed -e 's,^ErrorLog.*,ErrorLog "|/bin/cat",' -i /etc/apache2/apache2.conf
+COPY apache/mpm_prefork.conf /etc/apache2/mods-available/mpm_prefork.conf
+COPY apache/lamp.conf /etc/apache2/sites-enabled/lamp.conf
+RUN echo "Listen 80" > /etc/apache2/ports.conf
+RUN a2disconf other-vhosts-access-log
+RUN a2enmod rewrite headers rewrite expires cache
+
+# configure mod_php
+RUN crudini --set /etc/php/7.3/apache2/php.ini PHP upload_max_filesize 64M && \
+    crudini --set /etc/php/7.3/apache2/php.ini PHP post_max_size 64M && \
+    crudini --set /etc/php/7.3/apache2/php.ini PHP memory_limit 128M && \
+    crudini --set /etc/php/7.3/apache2/php.ini Session session.save_path /run/app/sessions && \
+    crudini --set /etc/php/7.3/apache2/php.ini Session session.gc_probability 1 && \
+    crudini --set /etc/php/7.3/apache2/php.ini Session session.gc_divisor 100
+
+# supervisor# configure supervisor
+ADD supervisor/ /etc/supervisor/conf.d/
+RUN sed -e 's,^logfile=.*$,logfile=/run/supervisord.log,' -i /etc/supervisor/supervisord.conf
+
+# copy app code
+ADD app /app/code/
+
+# copy website code
+ADD website /app/code/
+
+RUN chown -R www-data.www-data /app/code
+
+ADD start.sh /app/pkg/
+
+# RUN sed -i "s/\$host = \".*\";/\$host = \$_ENV[\"MYSQL_HOST\"];/" /app/code/DataBase/database.php
+# RUN sed -i "s/\$user = \".*\";/\$user = \$_ENV[\"MYSQL_USERNAME\"];/" /app/code/DataBase/database.php
+# RUN sed -i "s/\$password = \".*\";/\$password = \$_ENV[\"MYSQL_PASSWORD\"];/" /app/code/DataBase/database.php
+# RUN sed -i "s/\$db = \".*\";/\$db = \$_ENV[\"MYSQL_DATABASE\"];/" /app/code/DataBase/database.php
+
+CMD [ "/app/pkg/start.sh" ]

+ 12 - 0
README.md

@@ -0,0 +1,12 @@
+
+Drop all existing tables use webterminal and mysql client connection.
+
+https://docs.cloudron.io/guides/import-mysql/#export
+
+Create sql dump with schema, maybe remove database creation and remove `USE <databasename>` from dump.
+
+Upload dump to /app/data/dump.sql and import:
+
+```
+mysql --user=${CLOUDRON_MYSQL_USERNAME} --password=${CLOUDRON_MYSQL_PASSWORD} --host=${CLOUDRON_MYSQL_HOST} ${CLOUDRON_MYSQL_DATABASE} < /app/data/dump.sql
+```

+ 36 - 0
apache/lamp.conf

@@ -0,0 +1,36 @@
+<VirtualHost *:80>
+    DocumentRoot /app/data/public
+
+    ErrorLog "|/bin/cat"
+    CustomLog "|/bin/cat" combined
+
+    <Directory /app/data/public>
+        Options +FollowSymLinks
+        AllowOverride All
+        Require all granted
+    </Directory>
+
+    <IfModule mod_rpaf.c>
+        RPAF_Enable             On
+        RPAF_ProxyIPs           172.18.0.1/16
+        RPAF_SetHostName        On
+        RPAF_SetHTTPS           On
+        RPAF_SetPort            On
+        RPAF_ForbidIfNotProxy   Off
+    </IfModule>
+
+    ## PMA BEGIN
+
+    Alias /phpmyadmin /app/code/phpmyadmin
+
+    <Location /phpmyadmin>
+        AuthType Basic
+        AuthBasicProvider file
+        AuthName "LAMP App Authorization"
+        AuthUserFile /app/data/.phpmyadminauth
+        Require valid-user
+    </Location>
+
+    ## PMA END
+
+</VirtualHost>

+ 17 - 0
apache/mpm_prefork.conf

@@ -0,0 +1,17 @@
+<IfModule mpm_prefork_module>
+    # On startup, start these many servers
+	StartServers	2
+
+    # At any given time, keep atleast these many servers
+	MinSpareServers	2
+
+    # At any given time, keep atmost these many idle servers (this is always >= MinSpareServers+1)
+	MaxSpareServers 3
+
+    # Maximum number of servers at any given instant. Requests will be queued after this
+	MaxRequestWorkers	  15
+
+    # Recycle process after handling these many requests. This protected against accidental memory leaks
+	MaxConnectionsPerChild   100
+</IfModule>
+

+ 85 - 0
app/DataBase/Assistant.php

@@ -0,0 +1,85 @@
+<?php
+
+require_once("DataBase/database.php");
+
+class Assistant
+{
+	function Assistant()
+	{
+		$this->db = new Database();
+	}
+
+	function create($assistant_id, $value)
+	{
+		$query = "INSERT INTO ".$this->db->assistant_table." VALUES('".$assistant_id."'";
+		for($i = 0; $i < count($value); $i++)
+			$query .= ", '".$value[$i]."'";
+		$query .= ")";
+
+		$this->db->query($query);
+	}
+
+	function update($assistant_id, $value)
+	{
+		$query = "UPDATE ".$this->db->assistant_table." SET ";
+		$query .= "prename='".$value[0]."', ";
+		$query .= "postname='".$value[1]."', ";
+		$query .= "street='".$value[2]."', ";
+		$query .= "streetnumber='".$value[3]."', ";
+		$query .= "plz='".$value[4]."', ";
+		$query .= "city='".$value[5]."', ";
+		$query .= "telephone='".$value[6]."', ";
+		$query .= "telefax='".$value[7]."', ";
+		$query .= "email='".$value[8]."', ";
+		$query .= "tax_number='".$value[9]."', ";
+		$query .= "blz='".$value[10]."', ";
+		$query .= "bank_account='".$value[11]."', ";
+		$query .= "additional='".$value[12]."', ";
+		$query .= "utax_id='".$value[13]."', ";
+		$query .= "bank_name='".$value[14]."', ";
+		$query .= "bill_ext='".$value[15]."' ";
+
+		$query .= "WHERE assistant_id='".$assistant_id."'";
+
+		$this->db->query($query);
+	}
+
+	function delete($assistant_id)
+	{
+		$query = "DELETE FROM ".$this->db->assistant_table." WHERE assistant_id='$assistant_id'";
+
+		$this->db->query($query);
+	}
+
+	function get($assistant_id = "", $row_names = array(), $search = "")
+	{
+		if($assistant_id == "")
+		{
+			if(count($row_names) == 0)
+				$query = "SELECT * FROM ".$this->db->assistant_table;
+			else
+			{
+				$query = "SELECT ".$row_names[0];
+				for($i = 1; $i < count($row_names); $i++)
+					$query .= ", ".$row_names[$i];
+				$query .= " FROM ".$this->db->assistant_table;
+			}
+
+			if($search != "")
+				$query .= " WHERE ".$search;
+
+			$query .= " ORDER BY assistant_id ASC";
+
+			return $this->db->fetchRows($this->db->query($query));
+		}
+		else
+		{
+			$query = "SELECT * FROM ".$this->db->assistant_table." WHERE assistant_id='".$assistant_id."'";
+			$query .= " ORDER BY assistant_id ASC";
+
+			return $this->db->fetchRows($this->db->query($query));
+		}
+	}
+}
+
+?>

+ 107 - 0
app/DataBase/Bill.php

@@ -0,0 +1,107 @@
+<?php
+
+require_once("DataBase/database.php");
+
+class Bill
+{
+	function Bill()
+	{
+		$this->db = new Database();
+	}
+	
+	function create($bill_id, $value)
+	{
+		$query = "INSERT INTO ".$this->db->bill_table." VALUES('".$bill_id."'";
+		for($i = 0; $i < count($value); $i++)
+			$query .= ", '".$value[$i]."'";
+		$query .= ")";
+		
+		$this->db->query($query);
+		
+		$query = "SELECT bill_id from ".$this->db->bill_table." ORDER BY bill_id DESC";
+		$tmp = $this->db->fetchRows($this->db->query($query));
+		return $tmp[0][0];
+	}
+	
+	function update($bill_id, $value)
+	{
+		$query = "UPDATE ".$this->db->bill_table." SET ";
+		$query .= "customer_id='".$value[0]."', ";
+		$query .= "tour_id='".$value[1]."', ";
+		$query .= "date='".$value[2]."', ";
+		$query .= "assistant_id='".$value[3]."', ";
+		$query .= "bill_number='".$value[4]."' ";
+		
+		$query .= "WHERE bill_id='".$bill_id."'";
+		$this->db->query($query);
+	}
+	
+	function setNumber($bill_id)
+	{
+		$data = $this->get($bill_id);
+		
+		$query = "UPDATE ".$this->db->bill_table." SET ";
+		$query .= "bill_number='".$this->getNextFreeNumberByAssistant($data[0][4])."' ";
+		
+		$query .= "WHERE bill_id='".$bill_id."'";
+		
+		$this->db->query($query);
+	}
+	
+	function delete($bill_id)
+	{
+		$query = "DELETE FROM ".$this->db->bill_table." WHERE bill_id='$bill_id'";
+		
+		$this->db->query($query);
+	}
+	
+	function get($bill_id = "", $row_names = array(), $search = "")
+	{
+		if($bill_id == "")
+		{
+			if(count($row_names) == 0)
+				$query = "SELECT * FROM ".$this->db->bill_table.", ".$this->db->customer_table;
+			else
+			{
+				$query = "SELECT ".$row_names[0];
+				for($i = 1; $i < count($row_names); $i++)
+					$query .= ", ".$row_names[$i];
+				$query .= " FROM ".$this->db->bill_table.", ".$this->db->customer_table;
+			}
+			
+			$query .= " WHERE bill.customer_id=customer.customer_id ";
+			if($search != "")
+				$query .= " AND ( ".$search." )";
+			
+			$query .= " ORDER BY bill_number ASC";
+			
+			return $this->db->fetchRows($this->db->query($query));
+		}
+		else
+		{
+			$query = "SELECT * FROM ".$this->db->bill_table." WHERE bill_id='".$bill_id."'";
+			$query .= " ORDER BY bill_number ASC";
+			
+			return $this->db->fetchRows($this->db->query($query));
+		}
+	}
+	
+	function getNextFreeNumberByAssistant($assistant_id)
+	{
+		$query = "SELECT bill_number FROM ".$this->db->bill_table." WHERE assistant_id='".$assistant_id."' ORDER BY bill_number DESC";
+		$result = $this->db->fetchRows($this->db->query($query));
+		return $result[0][0]+1;
+	}
+	
+	function hasTimestamp($timestamp)
+	{
+		$query = "SELECT * FROM ".$this->db->bill_table." WHERE timestamp='".$timestamp."'";
+		
+		if(count($this->db->fetchRows($this->db->query($query))) > 0)
+			return True;
+		else
+			return False;
+	}
+}
+
+?>

+ 110 - 0
app/DataBase/Bill_Import.php

@@ -0,0 +1,110 @@
+<?php
+
+require_once("DataBase/database.php");
+
+class Bill_Import
+{
+	function Bill_Import()
+	{
+		$this->db = new Database();
+	}
+
+	function create($bill_id, $value)
+	{
+		$query = "INSERT INTO ".$this->db->bill_import_table." VALUES('".$bill_id."'";
+		for($i = 0; $i < count($value); $i++)
+			$query .= ", '".$value[$i]."'";
+		$query .= ")";
+
+		$this->db->query($query);
+
+		$query = "SELECT bill_id from ".$this->db->bill_import_table." ORDER BY bill_id DESC";
+		$tmp = $this->db->fetchRows($this->db->query($query));
+		return $tmp[0][0];
+	}
+
+	function delete($bill_id)
+	{
+		$query = "DELETE FROM ".$this->db->bill_import_table." WHERE bill_id='$bill_id'";
+
+		$this->db->query($query);
+	}
+
+	function get($bill_id = "")
+	{
+		if($bill_id == "")
+		{
+			$query = "SELECT * FROM ".$this->db->bill_import_table;
+
+			$query .= " ORDER BY bill_number ASC";
+
+			return $this->db->fetchRows($this->db->query($query));
+		}
+		else
+		{
+			$query = "SELECT * FROM ".$this->db->bill_import_table." WHERE bill_id='".$bill_id."'";
+			$query .= " ORDER BY bill_number ASC";
+
+			return $this->db->fetchRows($this->db->query($query));
+		}
+	}
+
+	function clearTable()
+	{
+		$query = "TRUNCATE TABLE ".$this->db->bill_import_table;
+		$this->db->query($query);
+	}
+
+	function hasTimestamp($timestamp)
+	{
+		$query = "SELECT * FROM ".$this->db->bill_import_table." WHERE timestamp='".$timestamp."'";
+
+		if(count($this->db->fetchRows($this->db->query($query))) > 0)
+			return True;
+		else
+			return False;
+	}
+
+	function import($path)
+	{
+		$file_access_ok = true;
+		$file_open = false;
+		$file_handle = false;
+		$data = "";
+
+		clearstatcache();
+
+		try
+		{
+			if (!$file_handle = @fopen($path, "r"))
+				return -1;
+
+			if($file_handle)
+			{
+				while( $zeile = fgets($file_handle, 1024))
+				{
+					$values = explode("|", $zeile);
+					for($i = 0; $i < count($values); $i++)
+						$values[$i] = trim($values[$i]);
+					if(!$this->hasTimestamp($values[6]))
+						$this->create($values[0], array(	$values[1],
+											$values[2],
+											$values[3],
+											$values[4],
+											$values[5],
+											$values[6]));
+				}
+
+				fclose($file_handle);
+			}
+
+			return 0;
+		}
+		catch (Exception $e)
+		{
+			return -1;
+		}
+	}
+}
+
+?>

+ 161 - 0
app/DataBase/Bill_Product.php

@@ -0,0 +1,161 @@
+<?php
+
+require_once("DataBase/database.php");
+
+require_once("DataBase/Customer.php");
+require_once("DataBase/Bill.php");
+require_once("DataBase/Product.php");
+require_once("DataBase/Price.php");
+require_once("DataBase/Tax.php");
+
+class Bill_Product
+{
+	function Bill_Product()
+	{
+		$this->db = new Database();
+	}
+	
+	function create($value)
+	{
+		$query = "INSERT INTO ".$this->db->bill_product_table." VALUES(''";
+		for($i = 0; $i < count($value); $i++)
+			$query .= ", '".$value[$i]."'";
+		$query .= ")";
+		
+		$this->db->query($query);
+	}
+	
+	function update($bill_product_id, $value)
+	{
+		$query = "UPDATE ".$this->db->bill_product_table." SET ";
+		$query .= "bill_id='".$value[0]."', ";
+		$query .= "product_id='".$value[1]."', ";
+		$query .= "amount='".$value[2]."', ";
+		$query .= "details='".$value[3]."', ";
+		$query .= "rabatt='".$value[4]."', ";
+		$query .= "price='".$value[5]."', ";
+		$query .= "tax='".$value[6]."' ";
+		
+		$query .= "WHERE bill_product_id='".$bill_product_id."'";
+		
+		$this->db->query($query);
+	}
+	
+	function delete($bill_product_id)
+	{
+		$query = "DELETE FROM ".$this->db->bill_product_table." WHERE bill_product_id='$bill_product_id'";
+		
+		$this->db->query($query);
+	}
+	
+	function get($bill_product_id = "", $row_names = array(), $search = "")
+	{
+		if($bill_product_id == "")
+		{
+			if(count($row_names) == 0)
+				$query = "SELECT * FROM ".$this->db->bill_product_table;
+			else
+			{
+				$query = "SELECT ".$row_names[0];
+				for($i = 1; $i < count($row_names); $i++)
+					$query .= ", ".$row_names[$i];
+				$query .= " FROM ".$this->db->bill_product_table;
+			}
+			
+			if($search != "")
+				$query .= " WHERE ".$search;
+				
+			$query .= " ORDER BY product_id ASC";
+			
+			return $this->db->fetchRows($this->db->query($query));
+		}
+		else
+		{
+			$query = "SELECT * FROM ".$this->db->bill_product_table." WHERE bill_product_id='".$bill_product_id."'";
+			
+			return $this->db->fetchRows($this->db->query($query));
+		}
+	}
+	
+	function getByBillId($bill_id)
+	{
+		$query = "SELECT * FROM ".$this->db->bill_product_table." WHERE bill_id='".$bill_id."'";
+		$query .= " ORDER BY product_id ASC";
+		
+		return $this->db->fetchRows($this->db->query($query));
+	}
+
+	function getByBillIdAndProductId($bill_id, $product_id)
+	{
+		$query = "SELECT * FROM ".$this->db->bill_product_table." WHERE bill_id='".$bill_id."' AND product_id='".$product_id."'";
+		$query .= " ORDER BY product_id ASC";
+		
+		return $this->db->fetchRows($this->db->query($query));
+	}
+	
+	function getByBillIdsAndProductId($bill_id, $product_id)
+	{
+		$query = "SELECT * FROM ".$this->db->bill_product_table." WHERE product_id='".$product_id."' AND";
+		$query .=" (bill_id='".$bill_id[0][0]."'";
+		for($i=1;$i<count($bill_id); $i++)
+			$query.=" OR bill_id='".$bill_id[$i][0]."'";
+		$query .= ") ORDER BY product_id ASC";
+		
+		return $this->db->fetchRows($this->db->query($query));
+	}
+		
+	function fix($bill_id)
+	{
+		/*$products = $this->getByBillId($bill_id);
+		
+		$product = new Product();
+		$price = new Price();
+		$tax = new Tax();
+		
+		$bill = new Bill();
+		$tmp = $bill->get($bill_id, array("customer_id"));
+		
+		$customer = new Customer();
+		$tmp = $customer->get($tmp[0]);
+		$customer_data = $tmp[0];
+		
+		for($i = 0; $i < count($products); $i++)
+		{
+			$tmp = $this->getByBillIdAndProductId($bill_id, $products[$i][2]);
+			$bill_product_data = $tmp[0];
+			
+			$tmp = $product->get($products[$i][2], array("product_id","tax_id"));
+			$product_data = $tmp[0];
+			
+			$tmp = $price->getPrice($customer_data[11], $product_data[0]);
+			$price_data = $tmp[0];
+			
+			$tmp = $tax->get($product_data[1]);
+			$tax_data = $tmp[0];
+			
+			$this->update($bill_product_data[0], array($bill_product_data[1], $bill_product_data[2], $bill_product_data[3], $bill_product_data[4], $bill_product_data[5], $price_data[3], $tax_data[2]));
+		}*/
+		
+		$query = "SELECT product.product_id,price.price FROM price,customer,product,bill_product,bill WHERE bill.bill_id='".$bill_id."' AND bill_product.bill_id='".$bill_id."' AND bill_product.product_id=product.product_id AND customer.customer_id=bill.customer_id AND customer.pricelist_id=price.priceset_id AND price.product_id=bill_product.product_id";
+		$result = $this->db->fetchRows($this->db->query($query));
+		for($i = 0; $i < count($result); $i++)
+		{
+			$query = "UPDATE bill_product SET price='".$result[$i][1]."' WHERE product_id='".$result[$i][0]."' AND bill_id='".$bill_id."'";
+			$this->db->query($query);
+		}
+	}
+	
+	function getTourZusammenfassung($tour_id, $date)
+	{
+		$query = "SELECT DISTINCT product.product_id, product.name, SUM(bill_product.amount), product.order_number FROM product, bill_product,bill WHERE product.product_id=bill_product.product_id AND bill_product.bill_id=bill.bill_id AND bill_product.amount > 0 AND bill.date='".$date."' AND bill.tour_id=".$tour_id." GROUP BY product.product_id ORDER BY product.product_id";
+		return $this->db->fetchRows($this->db->query($query));
+	}
+	
+	function getTourZusammenfassungFromTo($tour_id, $date_from, $date_to)
+	{
+		$query = "SELECT DISTINCT product.product_id, product.name, SUM(bill_product.amount), product.order_number FROM product, bill_product,bill WHERE product.product_id=bill_product.product_id AND bill_product.bill_id=bill.bill_id AND bill_product.amount > 0 AND bill.date>='".$date_from."' AND bill.date<='".$date_to."' GROUP BY product.product_id ORDER BY product.product_id";
+		return $this->db->fetchRows($this->db->query($query));
+	}
+}
+
+?>

+ 132 - 0
app/DataBase/Bill_Product_Import.php

@@ -0,0 +1,132 @@
+<?php
+
+require_once("DataBase/database.php");
+
+require_once("DataBase/Customer.php");
+require_once("DataBase/Bill.php");
+require_once("DataBase/Product.php");
+require_once("DataBase/Price.php");
+require_once("DataBase/Tax.php");
+
+class Bill_Product_Import
+{
+	function Bill_Product_Import()
+	{
+		$this->db = new Database();
+	}
+
+	function create($value)
+	{
+		$query = "INSERT INTO ".$this->db->bill_product_import_table." VALUES(''";
+		for($i = 0; $i < count($value); $i++)
+			$query .= ", '".$value[$i]."'";
+		$query .= ")";
+
+		$this->db->query($query);
+	}
+
+	function delete($bill_product_id)
+	{
+		$query = "DELETE FROM ".$this->db->bill_product_import_table." WHERE bill_product_id='$bill_product_id'";
+
+		$this->db->query($query);
+	}
+
+	function get($bill_product_id = "", $row_names = array(), $search = "")
+	{
+		if($bill_product_id == "")
+		{
+			if(count($row_names) == 0)
+				$query = "SELECT * FROM ".$this->db->bill_product_import_table;
+			else
+			{
+				$query = "SELECT ".$row_names[0];
+				for($i = 1; $i < count($row_names); $i++)
+					$query .= ", ".$row_names[$i];
+				$query .= " FROM ".$this->db->bill_product_import_table;
+			}
+
+			if($search != "")
+				$query .= " WHERE ".$search;
+
+			$query .= " ORDER BY product_id ASC";
+
+			return $this->db->fetchRows($this->db->query($query));
+		}
+		else
+		{
+			$query = "SELECT * FROM ".$this->db->bill_product_import_table." WHERE bill_product_id='".$bill_product_id."'";
+
+			return $this->db->fetchRows($this->db->query($query));
+		}
+	}
+
+	function getByBillId($bill_id)
+	{
+		$query = "SELECT * FROM ".$this->db->bill_product_import_table." WHERE bill_id='".$bill_id."'";
+		$query .= " ORDER BY product_id ASC";
+
+		return $this->db->fetchRows($this->db->query($query));
+	}
+
+	function clearTable()
+	{
+		$query = "TRUNCATE TABLE ".$this->db->bill_product_import_table;
+		$this->db->query($query);
+	}
+
+	function hasTimestampProductPair($timestamp, $product_id)
+	{
+		$query = "SELECT * FROM ".$this->db->bill_product_import_table." WHERE timestamp='".$timestamp."' and product_id='".$product_id."'";
+
+		if(count($this->db->fetchRows($this->db->query($query))) > 0)
+			return True;
+		else
+			return False;
+	}
+
+	function import($path)
+	{
+		$file_access_ok = true;
+		$file_open = false;
+		$file_handle = false;
+		$data = "";
+
+		clearstatcache();
+
+		try
+		{
+			if (!$file_handle = @fopen($path, "r"))
+				return -1;
+
+			if($file_handle)
+			{
+				while( $zeile = fgets($file_handle, 1024))
+				{
+					$values = explode("|", $zeile);
+					for($i = 0; $i < count($values); $i++)
+						$values[$i] = trim($values[$i]);
+					if(!$this->hasTimestampProductPair($values[8], $values[2]))
+						$this->create(array(	$values[1],
+									$values[2],
+									$values[3],
+									$values[4],
+									$values[5],
+									$values[6],
+									$values[7],
+									$values[8]));
+				}
+
+				fclose($file_handle);
+			}
+
+			return 0;
+		}
+		catch (Exception $e)
+		{
+			return -1;
+		}
+	}
+}
+
+?>

+ 82 - 0
app/DataBase/Category.php

@@ -0,0 +1,82 @@
+<?php
+
+require_once("DataBase/database.php");
+
+class Category
+{
+	function Category()
+	{
+		$this->db = new Database();
+	}
+
+	function create($value)
+	{
+		$query = "INSERT INTO ".$this->db->category_table." VALUES('".$value[0]."'";
+		for($i = 1; $i < count($value); $i++)
+			$query .= ", '".$value[$i]."'";
+		$query .= ")";
+
+		$this->db->query($query);
+	}
+
+	function update($category_id, $value)
+	{
+		$query = "UPDATE ".$this->db->category_table." SET ";
+		$query .= "name='".$value[0]."', ";
+		$query .= "details='".$value[1]."' ";
+
+		$query .= "WHERE category_id='".$category_id."'";
+
+		$this->db->query($query);
+	}
+
+	function delete($category_id)
+	{
+		$query = "DELETE FROM ".$this->db->category_table." WHERE category_id='$category_id'";
+
+		$this->db->query($query);
+	}
+
+	function get($category_id = "", $row_names = array(), $search = "")
+	{
+		if($category_id == "")
+		{
+			if(count($row_names) == 0)
+				$query = "SELECT * FROM ".$this->db->category_table;
+			else
+			{
+				$query = "SELECT ".$row_names[0];
+				for($i = 1; $i < count($row_names); $i++)
+					$query .= ", ".$row_names[$i];
+				$query .= " FROM ".$this->db->category_table;
+			}
+
+			if($search != "")
+				$query .= " WHERE ".$search;
+
+			$query .= " ORDER BY category_id ASC";
+
+			return $this->db->fetchRows($this->db->query($query));
+		}
+		else
+		{
+			$query = "SELECT * FROM ".$this->db->category_table." WHERE category_id='".$category_id."' ORDER BY category_id ASC";
+
+			return $this->db->fetchRows($this->db->query($query));
+		}
+	}
+
+	function export($path)
+	{
+		$csv_data = "";
+
+		$query = "SELECT * FROM ".$this->db->category_table;
+		$result = $this->db->query($query);
+		while ($row = mysqli_fetch_assoc($result))
+			$csv_data .= implode('|', $row)."\n";
+
+		$this->db->writeToFile($path, $csv_data);
+	}
+}
+
+?>

+ 120 - 0
app/DataBase/Customer.php

@@ -0,0 +1,120 @@
+<?php
+
+require_once("DataBase/database.php");
+
+class Customer
+{
+	function Customer()
+	{
+		$this->db = new Database();
+	}
+
+	function create($customer_id, $value)
+	{
+		$query = "INSERT INTO ".$this->db->customer_table." VALUES('".$customer_id."'";
+		for($i = 0; $i < count($value); $i++)
+			$query .= ", '".str_replace("'", "\'", $value[$i])."'";
+		$query .= ")";
+
+		$this->db->query($query);
+	}
+
+	function update($customer_id, $value)
+	{
+		$query = "UPDATE ".$this->db->customer_table." SET ";
+		$query .= "password='".str_replace("'", "\'", $value[0])."', ";
+		$query .= "prename='".str_replace("'", "\'", $value[1])."', ";
+		$query .= "postname='".$value[2]."', ";
+		$query .= "street='".$value[3]."', ";
+		$query .= "streetnumber='".$value[4]."', ";
+		$query .= "plz='".$value[5]."', ";
+		$query .= "city='".$value[6]."', ";
+		$query .= "telephone='".$value[7]."', ";
+		$query .= "telefax='".$value[8]."', ";
+		$query .= "email='".$value[9]."', ";
+		$query .= "pricelist_id='".$value[10]."', ";
+		$query .= "tour_id='".$value[11]."', ";
+		$query .= "rabatt='".$value[12]."', ";
+		$query .= "details='".$value[13]."', ";
+		$query .= "bank_name='".$value[14]."', ";
+		$query .= "bank_account='".$value[15]."', ";
+		$query .= "blz='".$value[16]."' ";
+
+		$query .= "WHERE customer_id='".$customer_id."'";
+
+		$this->db->query($query);
+	}
+
+	function delete($customer_id)
+	{
+		$query = "DELETE FROM ".$this->db->customer_table." WHERE customer_id='$customer_id'";
+
+		$this->db->query($query);
+	}
+
+	function exists($customer_id)
+	{
+		$query = "SELECT customer_id FROM ".$this->db->customer_table." WHERE customer_id='".$customer_id."'";
+
+		$result = $this->db->fetchRows($this->db->query($query));
+
+		if(count($result) > 0)
+			return true;
+		else
+			return false;
+	}
+
+	function get($customer_id = "", $row_names = array(), $search = "")
+	{
+		if($customer_id == "")
+		{
+			if(count($row_names) == 0)
+				$query = "SELECT * FROM ".$this->db->customer_table;
+			else
+			{
+				$query = "SELECT ".$row_names[0];
+				for($i = 1; $i < count($row_names); $i++)
+					$query .= ", ".$row_names[$i];
+				$query .= " FROM ".$this->db->customer_table;
+			}
+
+			if($search != "")
+				$query .= " WHERE ".$search;
+
+			$query .= " ORDER BY customer_id ASC";
+
+			return $this->db->fetchRows($this->db->query($query));
+		}
+		else
+		{
+			if(count($row_names) == 0)
+				$query = "SELECT * FROM ".$this->db->customer_table;
+			else
+			{
+				$query = "SELECT ".$row_names[0];
+				for($i = 1; $i < count($row_names); $i++)
+					$query .= ", ".$row_names[$i];
+				$query .= " FROM ".$this->db->customer_table;
+			}
+
+			$query .= " WHERE customer_id='".$customer_id."'";
+			$query .= " ORDER BY customer_id ASC";
+
+			return $this->db->fetchRows($this->db->query($query));
+		}
+	}
+
+	function export($path)
+	{
+		$csv_data = "";
+
+		$query = "SELECT * FROM ".$this->db->customer_table;
+		$result = $this->db->query($query);
+		while ($row = mysqli_fetch_assoc($result))
+			$csv_data .= implode('|', $row)."\n";
+
+		$this->db->writeToFile($path, $csv_data);
+	}
+}
+
+?>

+ 69 - 0
app/DataBase/Group.php

@@ -0,0 +1,69 @@
+<?php
+
+require_once("DataBase/database.php");
+
+class Group
+{
+	function Group()
+	{
+		$this->db = new Database();
+	}
+	
+	function create($group_id, $value)
+	{
+		$query = "INSERT INTO ".$this->db->group_table." VALUES('".$group_id."'";
+		for($i = 0; $i < count($value); $i++)
+			$query .= ", '".$value[$i]."'";
+		$query .= ")";
+		
+		$this->db->query($query);
+	}
+	
+	function update($group_id, $value)
+	{
+		$query = "UPDATE ".$this->db->group_table." SET ";
+		$query .= "name='".$value[0]."' ";
+		
+		$query .= "WHERE group_id='".$group_id."'";
+		
+		$this->db->query($query);
+	}
+	
+	function delete($group_id)
+	{
+		$query = "DELETE FROM ".$this->db->group_table." WHERE group_id='$group_id'";
+		
+		$this->db->query($query);
+	}
+	
+	function get($group_id = "", $row_names = array(), $search = "")
+	{
+		if($group_id == "")
+		{
+			if(count($row_names) == 0)
+				$query = "SELECT * FROM ".$this->db->group_table;
+			else
+			{
+				$query = "SELECT ".$row_names[0];
+				for($i = 1; $i < count($row_names); $i++)
+					$query .= ", ".$row_names[$i];
+				$query .= " FROM ".$this->db->group_table;
+			}
+			
+			if($search != "")
+				$query .= " WHERE ".$search;
+				
+			$query .= " ORDER BY group_id ASC";
+			
+			return $this->db->fetchRows($this->db->query($query));
+		}
+		else
+		{
+			$query = "SELECT * FROM ".$this->db->group_table." WHERE group_id='".$group_id."' ORDER BY group_id ASC";
+			
+			return $this->db->fetchRows($this->db->query($query));
+		}
+	}
+}
+
+?>

+ 99 - 0
app/DataBase/Price.php

@@ -0,0 +1,99 @@
+<?php
+
+require_once("DataBase/database.php");
+
+class Price
+{
+	function Price()
+	{
+		$this->db = new Database();
+	}
+
+	function exists($priceset_id, $product_id)
+	{
+		$query = "SELECT * FROM ".$this->db->price_table." WHERE priceset_id='".$priceset_id."' AND product_id='".$product_id."'";
+
+		if(count($this->db->fetchRows($this->db->query($query))) > 0)
+			return true;
+		else
+			return false;
+	}
+
+	function create($priceset_id, $product_id, $value)
+	{
+		$query = "INSERT INTO ".$this->db->price_table." VALUES('', '".$priceset_id."', '".$product_id."'";
+		for($i = 0; $i < count($value); $i++)
+			$query .= ", '".$value[$i]."'";
+		$query .= ")";
+
+		$this->db->query($query);
+	}
+
+	function update($priceset_id, $product_id, $value)
+	{
+		$query = "UPDATE ".$this->db->price_table." SET ";
+		$query .= "price='".$value[0]."' ";
+
+		$query .= "WHERE priceset_id='".$priceset_id."' AND product_id='".$product_id."'";
+
+		$this->db->query($query);
+	}
+
+	function delete($price_id)
+	{
+		$query = "DELETE FROM ".$this->db->price_table." WHERE price_id='$price_id'";
+
+		$this->db->query($query);
+	}
+
+	function get($price_id = "", $col_names = array(), $search = "")
+	{
+		if($price_id == "")
+		{
+			if(count($col_names) == 0)
+				$query = "SELECT * FROM ".$this->db->price_table;
+			else
+			{
+				$query = "SELECT ".$col_names[0];
+				for($i = 1; $i < count($col_names); $i++)
+					$query .= ", ".$col_names[$i];
+				$query .= " FROM ".$this->db->price_table;
+			}
+
+			if($search != "")
+				$query .= " WHERE ".$search;
+
+			$query .= " ORDER BY price_id ASC";
+
+			return $this->db->fetchRows($this->db->query($query));
+		}
+		else
+		{
+			$query = "SELECT * FROM ".$this->db->price_table." WHERE price_id='".$price_id."'";
+			$query .= " ORDER BY price_id ASC";
+
+			return $this->db->fetchRows($this->db->query($query));
+		}
+	}
+
+	function getPrice($priceset_id, $product_id)
+	{
+		$query = "SELECT * FROM ".$this->db->price_table." WHERE priceset_id='".$priceset_id."' AND product_id='".$product_id."'";
+
+		return $this->db->fetchRows($this->db->query($query));
+	}
+
+	function export($path)
+	{
+		$csv_data = "";
+
+		$query = "SELECT * FROM ".$this->db->price_table;
+		$result = $this->db->query($query);
+		while ($row = mysqli_fetch_assoc($result))
+			$csv_data .= implode('|', $row)."\n";
+
+		$this->db->writeToFile($path, $csv_data);
+	}
+}
+
+?>

+ 105 - 0
app/DataBase/Priceset.php

@@ -0,0 +1,105 @@
+<?php
+
+require_once("DataBase/database.php");
+
+class Priceset
+{
+	function Priceset()
+	{
+		$this->db = new Database();
+	}
+
+	function create($priceset_id, $value)
+	{
+		$query = "INSERT INTO ".$this->db->priceset_table." VALUES('".$priceset_id."'";
+		for($i = 0; $i < count($value); $i++)
+			$query .= ", '".$value[$i]."'";
+		$query .= ")";
+
+		$this->db->query($query);
+	}
+
+	function update($priceset_id, $value)
+	{
+		$query = "UPDATE ".$this->db->priceset_table." SET ";
+		$query .= "name='".$value[0]."', ";
+		$query .= "netto='".$value[1]."' ";
+
+		$query .= "WHERE priceset_id='".$priceset_id."'";
+
+		$this->db->query($query);
+	}
+
+	function delete($priceset_id)
+	{
+		$query = "DELETE FROM ".$this->db->priceset_table." WHERE priceset_id='$priceset_id'";
+
+		$this->db->query($query);
+	}
+
+	function exists($priceset_id)
+	{
+		$query = "SELECT priceset_id FROM ".$this->db->priceset_table." WHERE priceset_id='".$priceset_id."'";
+
+		$result = $this->db->fetchRows($this->db->query($query));
+
+		if(count($result) > 0)
+			return true;
+		else
+			return false;
+	}
+
+	function get($priceset_id = "", $row_names = array(), $search = "")
+	{
+		if($priceset_id == "")
+		{
+			if(count($row_names) == 0)
+				$query = "SELECT * FROM ".$this->db->priceset_table;
+			else
+			{
+				$query = "SELECT ".$row_names[0];
+				for($i = 1; $i < count($row_names); $i++)
+					$query .= ", ".$row_names[$i];
+				$query .= " FROM ".$this->db->priceset_table;
+			}
+
+			if($search != "")
+				$query .= " WHERE ".$search;
+
+			$query .= " ORDER BY priceset_id ASC";
+
+			return $this->db->fetchRows($this->db->query($query));
+		}
+		else
+		{
+			if(count($row_names) == 0)
+			$query = "SELECT * FROM ".$this->db->priceset_table;
+			else
+			{
+				$query = "SELECT ".$row_names[0];
+				for($i = 1; $i < count($row_names); $i++)
+				$query .= ", ".$row_names[$i];
+				$query .= " FROM ".$this->db->priceset_table;
+			}
+
+			$query .= " WHERE priceset_id='".$priceset_id."'";
+			$query .= " ORDER BY priceset_id ASC";
+
+			return $this->db->fetchRows($this->db->query($query));
+		}
+	}
+
+	function export($path)
+	{
+		$csv_data = "";
+
+		$query = "SELECT * FROM ".$this->db->priceset_table;
+		$result = $this->db->query($query);
+		while ($row = mysqli_fetch_assoc($result))
+			$csv_data .= implode('|', $row)."\n";
+
+		$this->db->writeToFile($path, $csv_data);
+	}
+}
+
+?>

+ 163 - 0
app/DataBase/Product.php

@@ -0,0 +1,163 @@
+<?php
+
+require_once("DataBase/database.php");
+
+class Product
+{
+	function Product()
+	{
+		$this->db = new Database();
+	}
+
+	function create($product_id, $value)
+	{
+		$query = "INSERT INTO ".$this->db->product_table." VALUES('".$product_id."'";
+		for($i = 0; $i < count($value); $i++)
+			$query .= ", '".str_replace("'", "\'", $value[$i])."'";
+		$query .= ")";
+
+		$this->db->query($query);
+	}
+
+	function update($product_id, $value)
+	{
+		$query = "UPDATE ".$this->db->product_table." SET ";
+		$query .= "name='".str_replace("'", "\'", $value[0])."', ";
+		$query .= "details='".str_replace("'", "\'", $value[1])."', ";
+		$query .= "category_id='".str_replace("'", "\'", $value[2])."', ";
+		$query .= "tax_id='".str_replace("'", "\'", $value[3])."', ";
+		$query .= "available='".str_replace("'", "\'", $value[4])."', ";
+		$query .= "group_id='".str_replace("'", "\'", $value[5])."', ";
+		$query .= "order_number='".str_replace("'", "\'", $value[6])."', ";
+		$query .= "anmerkung='".str_replace("'", "\'", $value[7])."' ";
+
+		$query .= "WHERE product_id='".$product_id."'";
+
+		$this->db->query($query);
+	}
+
+	function delete($product_id)
+	{
+		$query = "DELETE FROM ".$this->db->product_table." WHERE product_id='$product_id'";
+
+		$this->db->query($query);
+	}
+
+	function exists($product_id, $search = "")
+	{
+		$query = "SELECT product_id FROM ".$this->db->product_table." WHERE product_id='".$product_id."'";
+
+		if($search != "")
+			$query .= " AND ".$search;
+
+		$result = $this->db->fetchRows($this->db->query($query));
+
+		if(count($result) > 0)
+			return true;
+		else
+			return false;
+	}
+
+	function get($product_id = "", $row_names = array(), $search = "")
+	{
+		if($product_id == "")
+		{
+			if(count($row_names) == 0)
+				$query = "SELECT * FROM ".$this->db->product_table;
+			else
+			{
+				$query = "SELECT ".$row_names[0];
+				for($i = 1; $i < count($row_names); $i++)
+					$query .= ", ".$row_names[$i];
+				$query .= " FROM ".$this->db->product_table;
+			}
+
+			if($search != "")
+			{
+				//$search = str_replace("(", "\(", $search);
+				//$search = str_replace(")", "\)", $search);
+				//$search = str_replace("/", "\/", $search);
+				$query .= " WHERE ".$search;
+			}
+
+			$query .= " ORDER BY product_id ASC";
+
+			return $this->db->fetchRows($this->db->query($query));
+		}
+		else
+		{
+			if(count($row_names) == 0)
+				$query = "SELECT * FROM ".$this->db->product_table;
+			else
+			{
+				$query = "SELECT ".$row_names[0];
+				for($i = 1; $i < count($row_names); $i++)
+					$query .= ", ".$row_names[$i];
+				$query .= " FROM ".$this->db->product_table;
+			}
+
+			$query .= " WHERE product_id='".$product_id."'";
+
+			if($search != "")
+				$query .= " AND ".$search;
+
+			$query .= " ORDER BY product_id ASC";
+
+			return $this->db->fetchRows($this->db->query($query));
+		}
+	}
+
+	function getAmountByDate($product_id, $date_from, $date_to, $assistant_id)
+	{
+		$query = "SELECT SUM(".$this->db->bill_product_table.".amount) FROM ".$this->db->bill_table." ";
+		$query .= "RIGHT JOIN ".$this->db->bill_product_table." ON ".$this->db->bill_table.".bill_id=".$this->db->bill_product_table.".bill_id ";
+		$query .= "WHERE ".$this->db->bill_table.".date>='".$date_from."' ";
+		$query .= "AND ".$this->db->bill_table.".date<='".$date_to."' ";
+		$query .= "AND ".$this->db->bill_table.".assistant_id<='".$assistant_id."' ";
+		$query .= "AND ".$this->db->bill_product_table.".product_id='".$product_id."' ";
+
+		$retval = $this->db->fetchRows($this->db->query($query));
+
+		return $retval[0][0];
+	}
+
+	function getBillsByDate($product_id, $date_from, $date_to, $assistant_id)
+	{
+		$query = "SELECT ".$this->db->bill_table.".bill_number,SUM(".$this->db->bill_product_table.".amount) FROM ".$this->db->bill_table." ";
+		$query .= "RIGHT JOIN ".$this->db->bill_product_table." ON ".$this->db->bill_table.".bill_id=".$this->db->bill_product_table.".bill_id ";
+		$query .= "WHERE ".$this->db->bill_table.".date>='".$date_from."' ";
+		$query .= "AND ".$this->db->bill_table.".date<='".$date_to."' ";
+		$query .= "AND ".$this->db->bill_table.".assistant_id<='".$assistant_id."' ";
+		$query .= "AND ".$this->db->bill_product_table.".product_id='".$product_id."' ";
+		$query .= "GROUP BY ".$this->db->bill_table.".customer_id ";
+
+		return $this->db->fetchRows($this->db->query($query));
+	}
+
+	function getCustomersByDate($product_id, $date_from, $date_to, $assistant_id)
+	{
+		$query = "SELECT DISTINCT ".$this->db->bill_table.".customer_id,SUM(".$this->db->bill_product_table.".amount) FROM ".$this->db->bill_table." ";
+		$query .= "RIGHT JOIN ".$this->db->bill_product_table." ON ".$this->db->bill_table.".bill_id=".$this->db->bill_product_table.".bill_id ";
+		$query .= "WHERE ".$this->db->bill_table.".date>='".$date_from."' ";
+		$query .= "AND ".$this->db->bill_table.".date<='".$date_to."' ";
+		$query .= "AND ".$this->db->bill_table.".assistant_id<='".$assistant_id."' ";
+		$query .= "AND ".$this->db->bill_product_table.".product_id='".$product_id."' ";
+		$query .= "GROUP BY ".$this->db->bill_table.".customer_id ";
+
+		return $this->db->fetchRows($this->db->query($query));
+	}
+
+	function export($path)
+	{
+		$csv_data = "";
+
+		$query = "SELECT * FROM ".$this->db->product_table." WHERE available=1";
+		$result = $this->db->query($query);
+		while ($row = mysqli_fetch_assoc($result))
+			$csv_data .= implode('|', $row)."\n";
+
+		$this->db->writeToFile($path, $csv_data);
+	}
+}
+
+?>

+ 71 - 0
app/DataBase/Tax.php

@@ -0,0 +1,71 @@
+<?php
+
+require_once("DataBase/database.php");
+
+class Tax
+{
+	function Tax()
+	{
+		$this->db = new Database();
+	}
+	
+	function create($tax_id, $value)
+	{
+		$query = "INSERT INTO ".$this->db->tax_table." VALUES('".$tax_id."'";
+		for($i = 0; $i < count($value); $i++)
+			$query .= ", '".$value[$i]."'";
+		$query .= ")";
+		
+		$this->db->query($query);
+	}
+	
+	function update($tax_id, $value)
+	{
+		$query = "UPDATE ".$this->db->tax_table." SET ";
+		$query .= "name='".$value[0]."', ";
+		$query .= "tax_rate='".$value[1]."' ";
+		
+		$query .= "WHERE tax_id='".$tax_id."'";
+		
+		$this->db->query($query);
+	}
+	
+	function delete($tax_id)
+	{
+		$query = "DELETE FROM ".$this->db->tax_table." WHERE tax_id='$tax_id'";
+		
+		$this->db->query($query);
+	}
+	
+	function get($tax_id = "", $row_names = array(), $search = "")
+	{
+		if($tax_id == "")
+		{
+			if(count($row_names) == 0)
+				$query = "SELECT * FROM ".$this->db->tax_table;
+			else
+			{
+				$query = "SELECT ".$row_names[0];
+				for($i = 1; $i < count($row_names); $i++)
+					$query .= ", ".$row_names[$i];
+				$query .= " FROM ".$this->db->tax_table;
+			}
+			
+			if($search != "")
+				$query .= " WHERE ".$search;
+				
+			$query .= " ORDER BY tax_id ASC";
+			
+			return $this->db->fetchRows($this->db->query($query));
+		}
+		else
+		{
+			$query = "SELECT * FROM ".$this->db->tax_table." WHERE tax_id='".$tax_id."'";
+			$query .= " ORDER BY tax_id ASC";
+			
+			return $this->db->fetchRows($this->db->query($query));
+		}
+	}
+}
+
+?>

+ 83 - 0
app/DataBase/Tour.php

@@ -0,0 +1,83 @@
+<?php
+
+require_once("DataBase/database.php");
+
+class Tour
+{
+	function Tour()
+	{
+		$this->db = new Database();
+	}
+
+	function create($value)
+	{
+		$query = "INSERT INTO ".$this->db->tour_table." VALUES(''";
+		for($i = 0; $i < count($value); $i++)
+			$query .= ", '".$value[$i]."'";
+		$query .= ")";
+
+		$this->db->query($query);
+	}
+
+	function update($tour_id, $value)
+	{
+		$query = "UPDATE ".$this->db->tour_table." SET ";
+		$query .= "name='".$value[0]."', ";
+		$query .= "assistant_id='".$value[1]."' ";
+
+		$query .= "WHERE tour_id='".$tour_id."'";
+
+		$this->db->query($query);
+	}
+
+	function delete($tour_id)
+	{
+		$query = "DELETE FROM ".$this->db->tour_table." WHERE tour_id='$tour_id'";
+
+		$this->db->query($query);
+	}
+
+	function get($tour_id = "", $row_names = array(), $search = "")
+	{
+		if($tour_id == "")
+		{
+			if(count($row_names) == 0)
+				$query = "SELECT * FROM ".$this->db->tour_table;
+			else
+			{
+				$query = "SELECT ".$row_names[0];
+				for($i = 1; $i < count($row_names); $i++)
+					$query .= ", ".$row_names[$i];
+				$query .= " FROM ".$this->db->tour_table;
+			}
+
+			if($search != "")
+				$query .= " WHERE ".$search;
+
+			$query .= " ORDER BY tour_id ASC";
+
+			return $this->db->fetchRows($this->db->query($query));
+		}
+		else
+		{
+			$query = "SELECT * FROM ".$this->db->tour_table." WHERE tour_id='".$tour_id."'";
+			$query .= " ORDER BY tour_id ASC";
+
+			return $this->db->fetchRows($this->db->query($query));
+		}
+	}
+
+	function getByAssistant($assistant_id)
+	{
+		if($assistant_id == "")
+		{
+			$query = "SELECT * FROM ".$this->db->tour_table;
+			$query .= " WHERE assistant_id='".$assistant_id."' ";
+			$query .= " ORDER BY tour_id ASC";
+
+			return $this->db->fetchRows($this->db->query($query));
+		}
+	}
+}
+
+?>

+ 92 - 0
app/DataBase/database.php

@@ -0,0 +1,92 @@
+<?php
+
+class Database
+{
+	function Database()
+	{
+		$this->customer_table = "customer";
+		$this->category_table = "category";
+		$this->product_table = "product";
+		$this->price_table = "price";
+		$this->priceset_table = "priceset";
+		$this->tax_table = "tax";
+		$this->bill_table = "bill";
+		$this->bill_product_table = "bill_product";
+		$this->tour_table = "tour";
+		$this->assistant_table = "assistant";
+		$this->group_table = "`group`";
+		$this->bill_import_table = "bill_import";
+		$this->bill_product_import_table = "bill_product_import";
+		$this->ready = False;
+	}
+
+	function connectToDb()
+	{
+        $host = getenv('CLOUDRON_MYSQL_HOST');
+        $user = getenv('CLOUDRON_MYSQL_USERNAME');
+        $password = getenv('CLOUDRON_MYSQL_PASSWORD');
+        $db = getenv('CLOUDRON_MYSQL_DATABASE');
+        $port = getenv('CLOUDRON_MYSQL_PORT');
+
+		$this->db_link = mysqli_connect($host, $user, $password, $db, $port);
+
+		if(!$this->db_link) {
+			echo "Error: ".mysqli_connect_error();
+            exit(1);
+        }
+
+		$this->ready = True;
+	}
+
+	function query($query)
+	{
+		if(!$this->ready)
+			$this->connectToDb();
+
+		if(!($result = mysqli_query($this->db_link, $query)))
+			echo "Error: ".mysqli_error($this->db_link);
+
+		return $result;
+	}
+
+	function fetchRows($result)
+	{
+		if(!$this->ready)
+			$this->connectToDb();
+
+		$all_rows = array();
+
+		while($row = mysqli_fetch_row($result))
+				$all_rows[] =	$row;
+
+		return $all_rows;
+	}
+
+	function writeToFile($path, $data)
+	{
+		$file_access_ok = true;
+		$file_open = false;
+
+		clearstatcache();
+
+		if (file_exists($path))
+		if (!is_writable($path))
+			$file_access_ok = false;
+
+		if ($file_access_ok and (!$file_handle = @fopen($path, "w+b")))
+			$file_access_ok = false;
+
+		if ($file_access_ok)
+		{
+			if (!fwrite($file_handle, $data) and ($data != ''))
+			$file_access_ok = false;
+			else
+				$file_open = true;
+		}
+
+		if ($file_open)
+			fclose($file_handle);
+	}
+}
+
+?>

+ 84 - 0
app/Druckvorlagen/customer_list.php

@@ -0,0 +1,84 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<HTML>
+<HEAD>
+	<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-15">
+	
+<style>
+
+.normal
+{
+	font-family: Arial;
+	font-size: 12px;
+}
+
+td.list
+{
+	font-family: Arial;
+	font-size: 12px;
+}
+
+td.list_header
+{
+	font-family: Arial;
+	font-size: 12px;
+	font-weight: bold;
+	border-bottom-style: solid;
+	border-color: #000000;
+	border-bottom-width: 1px;
+	border-top-style: solid;
+ 	border-top-width: 1px;
+}
+
+</style>
+
+</HEAD>
+<BODY>
+<?php
+	if ($tour_data) 
+		echo "Tour: ".$tour_data[0][1]; 
+?>
+<br/>
+<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0>
+	<THEAD>
+		<tr>
+			<td width="1" align="left" class="normal">Kundennummer</td>
+			<td width="1" align="left" class="normal">Name</td>
+			<td width="1" align="left" class="normal">Stra&szlig;e</td>
+			<td width="1" align="left" class="normal">Hausnummer</td>
+			<td width="1" align="left" class="normal">PLZ</td>
+			<td width="1" align="left" class="normal">Ort</td>
+<?php
+	if (!$tour_data) {
+?>
+			<td width="150" align="right" class="normal">Tour</td>
+<?php
+}
+?>
+		</tr>
+	</THEAD>
+	<TBODY>
+<?php	
+	for($i = 0; $i < count($customer_data); $i++)
+	{
+?>
+		<TR>
+			<TD WIDTH="1" align="left" class="list"><?php echo $customer_data[$i][0]; ?>&nbsp;</TD>
+			<TD WIDTH="1" align="left" class="list"><?php echo $customer_data[$i][2]; ?>&nbsp;</TD>
+			<TD WIDTH="1" align="left" class="list"><?php echo $customer_data[$i][4]; ?>&nbsp;</TD>
+			<TD WIDTH="1" align="left" class="list"><?php echo $customer_data[$i][5]; ?>&nbsp;</TD>
+			<TD WIDTH="1" align="left" class="list"><?php echo $customer_data[$i][6]; ?>&nbsp;</TD>
+			<TD WIDTH="1" align="left" class="list"><?php echo $customer_data[$i][7]; ?>&nbsp;</TD>
+<?php
+	if (!$tour_data) {
+                $tour_name = $tour->get($customer_data[$i][12], array(), '');
+?>
+			<TD WIDTH=1 align="right" class="list"><?php echo $tour_name[0][1]; ?></TD>
+<?php
+	}
+}
+?>
+		</TR>
+	</TBODY>
+</TABLE>
+</BODY>
+</HTML>

+ 119 - 0
app/Druckvorlagen/list.php

@@ -0,0 +1,119 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<HTML>
+<HEAD>
+	<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-15">
+	
+<style>
+
+.normal
+{
+	font-family: Arial;
+	font-size: 10px;
+}
+
+td.list
+{
+	font-family: Arial;
+	font-size: 10px;
+}
+
+td.list_header
+{
+	font-family: Arial;
+	font-size: 10px;
+	font-weight: bold;
+	border-bottom-style: solid;
+	border-color: #000000;
+	border-bottom-width: 1px;
+	border-top-style: solid;
+ 	border-top-width: 1px;
+}
+
+</style>
+
+</HEAD>
+<BODY>
+
+<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0>
+	<THEAD>
+		<tr>
+			<td colspan="6">
+				<table width="100%" border=0 CELLPADDING=1 CELLSPACING=0>
+					<TR>
+						<TD align="left" style="font-weight: bold; font-family: Arial; font-size: 20px;">URSPRUNG</TD>
+						<TD align="center" width="100%" style="font-weight: bold; font-family: Arial; font-size: 20px;"><?php echo $priceset_data[1]; ?></TD>
+					</TR>
+					<TR>
+						<TD colspan="2" align="left" class="normal">Waren f&uuml;r Mensch und Natur</TD>
+					</TR>
+					<TR>
+						<TD colspan="2" align="left" class="normal"><?php echo $assistant_data[0][1]." ".$assistant_data[0][2]; ?></TD>
+					</TR>
+					<TR>
+						<TD colspan="2" align="left" class="normal"><?php echo $assistant_data[0][3]." ".$assistant_data[0][4]; ?>, <?php echo $assistant_data[0][5]." ".$assistant_data[0][6]; ?></TD>
+					</TR>
+					<TR>
+						<TD colspan="2" align="left" class="normal"><?php echo "Tel.: ".$assistant_data[0][7]." Fax: ".$assistant_data[0][8]; ?></TD>
+					</TR>
+				</TABLE>	
+			</td>
+		</tr>
+		<TR>
+			<TD WIDTH="1" align="center" class="list_header">Produktnr.</TD>
+			<TD WIDTH="80%" align="center" class="list_header">Bezeichnung</TD>
+			<TD WIDTH="1" align="center" class="list_header">Anmerkung</TD>
+<?php
+	require_once("util.php");
+					
+	if($priceset_data[2] == 1)
+	{
+?>
+			<TD WIDTH="1" align="center" class="list_header">Inkl.Ust.</TD>
+<?php
+	}
+	else
+	{
+?>
+			<TD WIDTH="1" align="center" class="list_header">Exkl.Ust.</TD>
+<?php
+	}
+?>
+			<TD WIDTH="1" align="center" class="list_header">Steuer</TD>
+			
+		</TR>
+	</THEAD>
+	<TBODY>
+<?php
+	for($i = 0; $i < count($product_data); $i++)
+	{
+		$price_data = $price->getPrice(var_post("priceset", ""), $product_data[$i][0]);
+		$tax_data = $tax->get($product_data[$i][4]);
+?>
+		<TR VALIGN=TOP>
+			<TD WIDTH="1" align="center" class="list"><?php echo $product_data[$i][0]."&nbsp;"; ?></TD>
+			<TD WIDTH="80%" align="left" class="list"><?php echo $product_data[$i][1]."&nbsp;"; ?></TD>
+			<TD WIDTH="1" align="left" class="list"><?php echo $product_data[$i][2]."&nbsp;"; ?></TD>
+			
+<?php
+	if($priceset_data[2] == 1)
+	{
+?>
+			<TD WIDTH="1" align="center" class="list"><?php echo round($price_data[0][3]+$price_data[0][3]*$tax_data[0][2], 2); ?></TD>
+<?php
+	}
+	else
+	{
+?>
+			<TD WIDTH="1" align="center" class="list"><?php echo $price_data[0][3]."&nbsp;"; ?></TD>
+<?php
+	}
+?>
+			<TD WIDTH="1" align="center" class="list"><?php echo $tax_data[0][2]."&nbsp;"; ?></TD>
+		</TR>
+<?php
+	}
+?>
+	</TBODY>
+</TABLE>
+</BODY>
+</HTML>

+ 250 - 0
app/Druckvorlagen/rechnung.php

@@ -0,0 +1,250 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<HTML>
+<HEAD>
+	<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1">
+
+<style>
+
+.normal
+{
+	font-family: Arial;
+	font-size: 12px;
+}
+
+td.list
+{
+	font-family: Arial;
+	font-size: 10px;
+}
+
+td.list_header
+{
+	font-family: Arial;
+	font-size: 10px;
+	font-weight: bold;
+	border-bottom-style: solid;
+	border-color: #000000;
+	border-bottom-width: 1px;
+	border-top-style: solid;
+ 	border-top-width: 1px;
+}
+
+
+</style>
+
+</HEAD>
+<BODY LANG="de-DE" DIR="LTR">
+<DIV ALIGN=RIGHT>
+	<TABLE WIDTH="100%" BORDER=0 CELLPADDING=1 CELLSPACING=0>
+			<TR>
+				<TD ROWSPAN=3 COLSPAN=2 WIDTH=161 align="left" style="font-weight: bold; font-family: Arial; font-size: 22px;">URSPRUNG</TD>
+				<TD ROWSPAN=3 COLSPAN=4 WIDTH=274 align="left" style="font-weight: bold; font-family: Arial; font-size: 16px;"><?php echo $assistant_data[13]; ?></TD>
+				<TD COLSPAN=2 WIDTH=1 align="right" class="normal">Ust.-ID.Nr.</TD>
+				<TD COLSPAN=2 WIDTH=1 align="left" class="normal"><?php echo $assistant_data[14]; ?></TD>
+			</TR>
+			<TR>
+				<TD COLSPAN=2 WIDTH=1 align="right" class="normal">SteuerNr.</TD>
+				<TD COLSPAN=2 WIDTH=1 align="left" class="normal"><?php echo $assistant_data[10]; ?></TD>
+			</TR>
+			<TR>
+				<TD COLSPAN=4 WIDTH=1 align="center" class="normal"><?php echo $assistant_data[16]; ?></TD>
+			</TR>
+			<TR>
+				<TD COLSPAN=2 WIDTH=161 align="left" class="normal"><b>Waren f&uuml;r Mensch und Natur</b></TD>
+				<TD ROWSPAN=10 COLSPAN=8 WIDTH=465 align="center" style="font-weight: bold; font-family: Arial; font-size: 22px;">Rechnung <?php echo $bill_data[5]; ?>
+					<P ALIGN=CENTER style="font-weight: normal; font-family: Arial; font-size: 14px;">Kundennummer: <?php echo $customer_data[0]; ?></P>
+					<P ALIGN=CENTER style="font-weight: normal; font-family: Arial; font-size: 14px;"><?php echo $assistant_data[6]; ?>,	den <?php echo $bill_data[3]; ?></P>
+				</TD>
+			</TR>
+			<TR>
+				<TD COLSPAN=2 WIDTH=161 align="left" class="normal"><?php echo $assistant_data[1]." ".$assistant_data[2]; ?></TD>
+			</TR>
+			<TR>
+				<TD COLSPAN=2 WIDTH=161 align="left" class="normal"><?php echo $assistant_data[3]." ".$assistant_data[4]; ?></TD>
+			</TR>
+			<TR>
+				<TD COLSPAN=2 WIDTH=161 align="left" class="normal"><?php echo $assistant_data[5]." ".$assistant_data[6]; ?></TD>
+			</TR>
+			<TR>
+				<TD COLSPAN=2 WIDTH=161 align="left" class="normal">Tel: <?php echo $assistant_data[7]; ?></TD>
+			</TR>
+			<TR>
+				<TD COLSPAN=2 WIDTH=161 align="left" class="normal">Fax: <?php echo $assistant_data[8]; ?></TD>
+			</TR>
+			<TR>
+				<TD COLSPAN=2 WIDTH=161 align="left" class="normal">&nbsp;
+				</TD>
+			</TR>
+			<TR>
+				<TD COLSPAN=2 WIDTH=161 align="left" class="normal"><?php echo $customer_data[2]." ".$customer_data[3]; ?></TD>
+			</TR>
+			<TR>
+				<TD COLSPAN=2 WIDTH=161 align="left" class="normal"><?php echo $customer_data[4]." ".$customer_data[5]; ?></TD>
+			</TR>
+			<TR>
+				<TD COLSPAN=2 WIDTH=161 align="left" class="normal"><?php echo $customer_data[6]." ".$customer_data[7]; ?></TD>
+			</TR>
+			<TR>
+				<TD COLSPAN=2 WIDTH=161 align="left" class="normal">Tel: <?php echo $customer_data[8]; ?></TD>
+				<TD COLSPAN=4 WIDTH=274 class="normal">&nbsp;</TD>
+				<TD COLSPAN=4 WIDTH=1 align="left" class="normal">Rechnungsdatum = Lieferdatum</TD>
+			</TR>
+			<TR>
+				<TD COLSPAN=2 WIDTH=161 align="left" class="normal">Fax: <?php echo $customer_data[9]; ?></TD>
+				<TD COLSPAN=4 WIDTH=274 class="normal">&nbsp;</TD>
+				<TD COLSPAN=4 WIDTH=1 align="left" class="normal">Bezahlung per Lastschrifteinzug</TD>
+			</TR>
+	</table>
+	<br>
+	<TABLE WIDTH="100%" border="0" CELLPADDING=4 CELLSPACING=0>
+		<THEAD>
+			<TR>
+				<TD align="left" class="normal">Rechnung: <?php echo $bill_data[5]; ?></TD>
+				<TD colspan="10" align="right" class="normal">Kundennummer: <?php echo $customer_data[0]; ?></TD>
+			</TR>
+			<TR>
+				<TD WIDTH="1%" align="center" class="list_header">Artikelnummer</TD>
+				<TD COLSPAN=2 WIDTH="80%" align="center" class="list_header">Bezeichnung</TD>
+				<TD WIDTH="1%" align="center" class="list_header">Menge</TD>
+				<TD WIDTH="20%" align="center" class="list_header">Anmerkung</TD>
+				<TD WIDTH="1%" align="center" class="list_header">Einzelpreis</TD>
+				<TD COLSPAN=2 WIDTH="1%" align="center" class="list_header">Rab.</TD>
+				<TD COLSPAN=2 WIDTH="1%" align="center" class="list_header">MwSt.</TD>
+				<TD WIDTH="1%" align="center" class="list_header">Gesamt</TD>
+			</TR>
+		</THEAD>
+		<TBODY>
+<?php
+	$netto = 0;
+	$taxes = $tax->get();
+
+	for($i = 0; $i < count($bill_product_data); $i++)
+	{
+		$product_data = $product->get($bill_product_data[$i][2]);
+		if($bill_data[5] == -1)
+		{
+			$price_data = $price->getPrice($customer_data[11], $bill_product_data[$i][2]);
+			$tax_data = $tax->get($product_data[0][4]);
+		}
+		else
+		{
+			$price_data = array(array('','','',$bill_product_data[$i][6]));
+			//$tax_data = array(array('', '', $bill_product_data[$i][7]));
+			$tax_data = $tax->get($product_data[0][4]);
+		}
+
+		$price_netto = $price_data[0][3];
+		$price_netto_rab = $price_data[0][3] + round($price_data[0][3] * $bill_product_data[$i][5], 2);
+
+		$price_brutto = $price_netto + round($price_netto * $tax_data[0][2], 2);
+		$price_brutto_rab = $price_brutto + round($price_brutto * $bill_product_data[$i][5], 2);
+
+		$price_brutto_full = round($price_brutto_rab * $bill_product_data[$i][3],2);
+		$price_netto_full = round($price_netto_rab * $bill_product_data[$i][3],2);
+
+		for($j = 0; $j < count($taxes); $j++)
+		{
+			if($taxes[$j][0] == $tax_data[0][0])
+			{
+				// add needed array fields for tax sum
+				while(count($taxes[$j]) < 4)
+					$taxes[$j] [] = 0;
+
+				if($priceset_data[2] == 1)
+					$taxes[$j][3] += $price_brutto_full/($taxes[$j][2]+1);
+				else
+					$taxes[$j][3] += $price_netto_full;
+			}
+		}
+
+		if($priceset_data[2] == 1)
+			$netto += $price_netto_full;
+		else
+			$netto += $price_brutto_full;
+?>
+			<TR VALIGN=TOP>
+				<TD WIDTH="1%" align="center" class="list"><?php echo $product_data[0][0]; ?></TD>
+				<TD COLSPAN=2 WIDTH="80%" align="center" class="list"><?php echo $product_data[0][1]; ?></TD>
+				<TD WIDTH="1%" align="center" class="list"><?php echo $bill_product_data[$i][3]; ?></TD>
+				<TD WIDTH="20%" align="center" class="list"><?php echo $bill_product_data[$i][4]; ?></TD>
+<?php
+	if($priceset_data[2] == 1)
+	{
+?>
+				<TD WIDTH="1%" align="center" class="list"><?php echo $price_brutto; ?></TD>
+				<TD COLSPAN=2 WIDTH="1%" align="center" class="list"><?php echo $bill_product_data[$i][5]; ?></TD>
+				<TD COLSPAN=2 WIDTH="1%" align="center" class="list"><?php echo $tax_data[0][2]; ?></TD>
+				<TD WIDTH="1%" align="center" class="list"><?php echo $price_brutto_full; ?></TD>
+<?php
+	}
+	else
+	{
+?>
+				<TD WIDTH="1%" align="center" class="list"><?php echo $price_netto; ?></TD>
+				<TD COLSPAN=2 WIDTH="1%" align="center" class="list"><?php echo $bill_product_data[$i][5]; ?></TD>
+				<TD COLSPAN=2 WIDTH="1%" align="center" class="list"><?php echo $tax_data[0][2]; ?></TD>
+				<TD WIDTH="1%" align="center" class="list"><?php echo $price_netto_full; ?></TD>
+<?php
+	}
+?>
+
+			</TR>
+<?php
+	}
+
+?>
+			<TR>
+				<TD COLSPAN=11 WIDTH="100%" align="center" class="list" style="border-bottom-style: solid; border-bottom-color: #000000; border-bottom-width: 1px;">&nbsp;</TD>
+			</TR>
+		</TBODY>
+	</table>
+	<TABLE WIDTH="100%" border="0" CELLPADDING=4 CELLSPACING=0>
+<?php
+	$tax_overall = 0;
+	$netto_overall = 0;
+
+	for($i = 0; $i < count($taxes); $i++)
+	{
+		if(count($taxes[$i]) >= 4)
+		{
+
+		$tax_overall += round($taxes[$i][3]*$taxes[$i][2], 2);
+		$netto_overall += round($taxes[$i][3], 2);
+?>
+
+			<TR>
+				<TD align="right" class="normal">&nbsp;</TD>
+				<TD align="left" class="normal">&nbsp;</TD>
+				<TD WIDTH=150 align="right" class="normal">Steuer <?php echo round($taxes[$i][2]*100, 2); ?>% MwSt. aus</TD>
+				<TD WIDTH=84 align="right" class="normal"><?php echo round($taxes[$i][3], 2); ?></TD>
+				<TD WIDTH=84 align="right" class="normal"><?php echo round($taxes[$i][3]*$taxes[$i][2], 2); ?></TD>
+			</TR>
+<?php
+		}
+	}
+?>
+			<TR>
+				<TD width=1 align="right" class="normal">Bankverbindung: </TD>
+				<TD align="left" class="normal"><?php echo $assistant_data[15]; ?></TD>
+				<TD align="right" class="normal">Steuer gesamt:</TD>
+				<TD WIDTH=84 align="center" class="normal">&nbsp;</TD>
+				<TD WIDTH=84 align="right" class="normal"><?php echo $tax_overall; ?></TD>
+			</TR>
+			<TR>
+				<TD width=1 align="right" class="normal">BLZ: </TD>
+				<TD align="left" class="normal"><?php echo $assistant_data[11]; ?></TD>
+				<TD align="right" class="normal">&nbsp;</TD>
+				<TD WIDTH=84 align="center" class="normal">&nbsp;</TD>
+				<TD WIDTH=84 align="right" class="normal">&nbsp;</TD>
+			</TR>
+			<TR>
+				<TD width=1 align="right" class="normal">Kontonummer: </TD>
+				<TD align="left" class="normal"><?php echo $assistant_data[12]; ?></TD>
+				<TD align="right" class="normal"><b>Rechnungssumme:</b></TD>
+				<TD WIDTH=84 align="center" class="normal">&nbsp;</TD>
+				<TD WIDTH=84 align="right" class="normal"><b><?php echo $tax_overall+$netto_overall; ?></b></TD>
+			</TR>
+	</TABLE>
+</DIV>
+</BODY>
+</HTML>

+ 93 - 0
app/Druckvorlagen/tour.php

@@ -0,0 +1,93 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<HTML>
+<HEAD>
+	<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-15">
+	
+<style>
+
+.normal
+{
+	font-family: Arial;
+	font-size: 12px;
+}
+
+td.list
+{
+	font-family: Arial;
+	font-size: 12px;
+}
+
+td.list_header
+{
+	font-family: Arial;
+	font-size: 12px;
+	font-weight: bold;
+	border-bottom-style: solid;
+	border-color: #000000;
+	border-bottom-width: 1px;
+	border-top-style: solid;
+ 	border-top-width: 1px;
+}
+
+</style>
+
+</HEAD>
+<BODY>
+<TABLE WIDTH=100% BORDER=0 CELLPADDING=4 CELLSPACING=0>
+	<THEAD>
+		<tr>
+			<td width="1" align="left" class="normal"><?php echo $tour_data[1]; ?></td>
+<?php
+	require_once("util.php");
+		
+	$date = var_get_post("date", "");
+	$tour_id = var_get_post("tour_id", "");
+	$date_from = var_get_post("date_from", "");
+	$date_to = var_get_post("date_to", "");
+	
+	if($date != "")
+{
+?>
+		<td width="100%" colspan="2" align="right" class="normal"><?php echo $date; ?></td>
+		<td width="1" align="right" class="normal"><?php echo $date; ?></td>
+<?php
+}
+	else
+{
+?>
+		<td width="100%" colspan="2" align="right" class="normal"><?php echo $date; ?></td>
+		<td width="1" align="right" class="normal"><?php echo $date; ?></td>
+<?php
+}
+?>
+		</tr>
+		<TR>
+			<TD WIDTH=1 align="center" class="list_header">Produktnr.</TD>
+			<TD WIDTH="100%" align="center" class="list_header">Bezeichnung</TD>
+			<TD WIDTH=1 align="center" class="list_header">Menge</TD>
+			<TD WIDTH=1 align="center" class="list_header">Bestellnr.</TD>
+		</TR>
+	</THEAD>
+	<TBODY>
+<?php	
+	if($date != "")
+		$result = $bill_product->getTourZusammenfassung($tour_id, $date);
+	else
+		$result = $bill_product->getTourZusammenfassungFromTo($tour_id, $date_from, $date_to);
+	
+	for($i = 0; $i < count($result); $i++)
+	{
+?>
+		<TR>
+			<TD WIDTH=1 align="center" class="list"><?php echo $result[$i][0]; ?></TD>
+			<TD WIDTH="100%" align="center" class="list"><?php echo $result[$i][1]; ?></TD>
+			<TD WIDTH=1 align="center" class="list"><?php echo round($result[$i][2], 2); ?></TD>
+			<TD WIDTH=1 align="center" class="list"><?php echo $result[$i][3]; ?>&nbsp;</TD>
+		</TR>
+<?php		
+	}
+?>
+	</TBODY>
+</TABLE>
+</BODY>
+</HTML>

+ 3 - 0
app/Druckvorlagen/zeilen.php

@@ -0,0 +1,3 @@
+<?php
+	$zeilen = 29;
+?>

BIN
app/Icons/Datenauszug aus WordPad-Dokument '_background-colo...'.shs


BIN
app/Icons/Thumbs.db


BIN
app/Icons/assistant.png


BIN
app/Icons/back.png


BIN
app/Icons/backup.png


BIN
app/Icons/bill.png


BIN
app/Icons/category.png


BIN
app/Icons/configuration.png


BIN
app/Icons/customer.png


BIN
app/Icons/date_product.png


BIN
app/Icons/down.png


BIN
app/Icons/help.png


BIN
app/Icons/loading.gif


BIN
app/Icons/logo.gif


BIN
app/Icons/mxfilerelatedcache.mxc2


BIN
app/Icons/print.png


BIN
app/Icons/product.png


BIN
app/Icons/product_list.png


BIN
app/Icons/stat.png


BIN
app/Icons/sync.png


BIN
app/Icons/tour.png


BIN
app/Icons/up.png


+ 25 - 0
app/Modules/Assistant/db_action.php

@@ -0,0 +1,25 @@
+<?php
+
+require_once("util.php");
+
+require_once("DataBase/Assistant.php");
+
+$db_action = var_get_post("db_action", "");
+
+$assistant = new Assistant();
+
+switch($db_action)
+{
+	case "new":
+		$assistant->create(var_post("assistant_id", ""), array(var_post("prename", ""), var_post("postname", ""), var_post("street", ""), var_post("streetnumber", ""), var_post("plz", ""), var_post("city", ""), var_post("telephone", ""), var_post("telefax", ""), var_post("email", ""), var_post("tax_number", ""), var_post("blz", ""), var_post("bank_account", ""), var_post("additional", ""), var_post("utax_id", ""), var_post("bank_name", ""), var_post("bill_ext", "")));
+		break;
+	case "edit":
+		$assistant->update(var_post("assistant_id", ""), array(var_post("prename", ""), var_post("postname", ""), var_post("street", ""), var_post("streetnumber", ""), var_post("plz", ""), var_post("city", ""), var_post("telephone", ""), var_post("telefax", ""), var_post("email", ""), var_post("tax_number", ""), var_post("blz", ""), var_post("bank_account", ""), var_post("additional", ""), var_post("utax_id", ""), var_post("bank_name", ""), var_post("bill_ext", "")));
+		break;
+	case "delete":
+		$assistant->delete(var_get("assistant_id", ""));
+		break;
+}
+
+
+?>

+ 127 - 0
app/Modules/Assistant/edit_form.php

@@ -0,0 +1,127 @@
+<?php
+
+$table = new NTKTable("table", 11, 4, False);
+
+$prename_label = new NTKLabel("", "Vorname:");
+$table->add($prename_label, 0, 0);
+
+$prename_entry = new NTKEntry("prename", $data[0][1]);
+$table->add($prename_entry, 0, 1); 
+$onload .= "document.getElementById('prename').focus();";
+
+$postname_label = new NTKLabel("", "Nachname:");
+$table->add($postname_label, 0, 2);
+
+$postname_entry = new NTKEntry("postname", $data[0][2]);
+$table->add($postname_entry, 0, 3); 
+
+
+$street_label = new NTKLabel("", "Stra&szlig;e:");
+$table->add($street_label, 1, 0);
+
+$street_entry = new NTKEntry("street", $data[0][3]);
+$table->add($street_entry, 1, 1); 
+
+$street_number_label = new NTKLabel("", "Hausnummer:");
+$table->add($street_number_label, 1, 2);
+
+$street_number_entry = new NTKEntry("streetnumber", $data[0][4]);
+$table->add($street_number_entry, 1, 3); 
+
+
+$plz_label = new NTKLabel("", "PLZ:");
+$table->add($plz_label, 2, 0);
+
+$plz_entry = new NTKEntry("plz", $data[0][5]);
+$table->add($plz_entry, 2, 1); 
+
+$city_label = new NTKLabel("", "Ort:");
+$table->add($city_label, 2, 2);
+
+$city_entry = new NTKEntry("city", $data[0][6]);
+$table->add($city_entry, 2, 3); 
+
+
+$telephone_label = new NTKLabel("", "Telefon:");
+$table->add($telephone_label, 3, 0);
+
+$telephone_entry = new NTKEntry("telephone", $data[0][7]);
+$table->add($telephone_entry, 3, 1); 
+
+$fax_label = new NTKLabel("", "Telefax:");
+$table->add($fax_label, 3, 2);
+
+$fax_entry = new NTKEntry("telefax", $data[0][8]);
+$table->add($fax_entry, 3, 3);
+
+
+$email_label = new NTKLabel("", "E-Mail:");
+$table->add($email_label, 4, 0);
+
+$email_entry = new NTKEntry("email", $data[0][9]);
+$table->add($email_entry, 4, 1);
+
+
+$tax_number_label = new NTKLabel("", "Steuernummer:");
+$table->add($tax_number_label, 5, 0);
+
+$tax_number_entry = new NTKEntry("tax_number", $data[0][10]);
+$table->add($tax_number_entry, 5, 1); 
+
+$utax_id_label = new NTKLabel("", "Umsatzsteuer:");
+$table->add($utax_id_label, 5, 2);
+
+$utax_id_entry = new NTKEntry("utax_id", $data[0][14]);
+$table->add($utax_id_entry, 5, 3); 
+
+
+$blz_label = new NTKLabel("", "BLZ:");
+$table->add($blz_label, 6, 0);
+
+$blz_entry = new NTKEntry("blz", $data[0][11]);
+$table->add($blz_entry, 6, 1); 
+
+$bank_account_label = new NTKLabel("", "Kontonummer:");
+$table->add($bank_account_label, 6, 2);
+
+$bank_account_entry = new NTKEntry("bank_account", $data[0][12]);
+$table->add($bank_account_entry, 6, 3); 
+
+
+$bank_name_label = new NTKLabel("", "Bankverbindung:");
+$table->add($bank_name_label, 7, 0);
+
+$bank_name_entry = new NTKEntry("bank_name", $data[0][15]);
+$table->add($bank_name_entry, 7, 1);
+
+$additional_label = new NTKLabel("", "Zusatz:");
+$table->add($additional_label, 7, 2);
+
+$additional_entry = new NTKEntry("additional", $data[0][13]);
+$table->add($additional_entry, 7, 3); 
+
+$bill_ext_label = new NTKLabel("", "&Ouml;kokontrollstelle:");
+$table->add($bill_ext_label, 8, 0);
+
+$bill_ext_entry = new NTKEntry("bill_ext", $data[0][16]);
+$table->add($bill_ext_entry, 8, 1); 
+
+
+
+$delete_button = new NTKButton("delete", "L&ouml;schen", "if(confirm('Wirklich loeschen?')) location.href = 'assistant.php?db_action=delete&assistant_id=".$data[0][0]."';");
+$table->add($delete_button, 10, 1);
+
+$cancel_button = new NTKButton("cancel", "Abbrechen", "location.href = 'assistant.php';");
+$table->add($cancel_button, 10, 2);
+
+$submit_button = new NTKButton("submit", "Speichern", "document.forms['assistant'].submit();");
+$table->add($submit_button, 10, 3);
+
+
+
+$form = new NTKForm("assistant", "assistant.php", $table);
+$form->addAttribute("db_action", "edit");
+$form->addAttribute("assistant_id", $data[0][0]);
+$main_box->add($form, False, True, "background-color: #dfe7f3; vertical-align: middle; align: center;");
+
+?>

+ 124 - 0
app/Modules/Assistant/new_form.php

@@ -0,0 +1,124 @@
+<?php
+
+$table = new NTKTable("table", 11, 4, False);
+
+$prename_label = new NTKLabel("", "Vorname:");
+$table->add($prename_label, 0, 0);
+
+$prename_entry = new NTKEntry("prename");
+$table->add($prename_entry, 0, 1);
+$onload .= "document.getElementById('prename').focus();";
+
+$postname_label = new NTKLabel("", "Nachname:");
+$table->add($postname_label, 0, 2);
+
+$postname_entry = new NTKEntry("postname");
+$table->add($postname_entry, 0, 3); 
+
+
+$street_label = new NTKLabel("", "Stra&szlig;e:");
+$table->add($street_label, 1, 0);
+
+$street_entry = new NTKEntry("street");
+$table->add($street_entry, 1, 1); 
+
+$street_number_label = new NTKLabel("", "Hausnummer:");
+$table->add($street_number_label, 1, 2);
+
+$street_number_entry = new NTKEntry("streetnumber");
+$table->add($street_number_entry, 1, 3); 
+
+
+$plz_label = new NTKLabel("", "PLZ:");
+$table->add($plz_label, 2, 0);
+
+$plz_entry = new NTKEntry("plz");
+$table->add($plz_entry, 2, 1); 
+
+$city_label = new NTKLabel("", "Ort:");
+$table->add($city_label, 2, 2);
+
+$city_entry = new NTKEntry("city");
+$table->add($city_entry, 2, 3); 
+
+
+$telephone_label = new NTKLabel("", "Telefon:");
+$table->add($telephone_label, 3, 0);
+
+$telephone_entry = new NTKEntry("telephone");
+$table->add($telephone_entry, 3, 1); 
+
+$fax_label = new NTKLabel("", "Telefax:");
+$table->add($fax_label, 3, 2);
+
+$fax_entry = new NTKEntry("telefax");
+$table->add($fax_entry, 3, 3);
+
+
+$email_label = new NTKLabel("", "E-Mail:");
+$table->add($email_label, 4, 0);
+
+$email_entry = new NTKEntry("email");
+$table->add($email_entry, 4, 1); 
+
+
+$tax_number_label = new NTKLabel("", "Steuernummer:");
+$table->add($tax_number_label, 5, 0);
+
+$tax_number_entry = new NTKEntry("tax_number");
+$table->add($tax_number_entry, 5, 1); 
+
+$utax_id_label = new NTKLabel("", "Umsatzsteuer:");
+$table->add($utax_id_label, 5, 2);
+
+$utax_id_entry = new NTKEntry("utax_id");
+$table->add($utax_id_entry, 5, 3); 
+
+
+$blz_label = new NTKLabel("", "BLZ:");
+$table->add($blz_label, 6, 0);
+
+$blz_entry = new NTKEntry("blz");
+$table->add($blz_entry, 6, 1); 
+
+$bank_account_label = new NTKLabel("", "Kontonummer:");
+$table->add($bank_account_label, 6, 2);
+
+$bank_account_entry = new NTKEntry("bank_account");
+$table->add($bank_account_entry, 6, 3); 
+
+
+$bank_name_label = new NTKLabel("", "Bankverbindung:");
+$table->add($bank_name_label, 7, 0);
+
+$bank_name_entry = new NTKEntry("bank_name");
+$table->add($bank_name_entry, 7, 1);
+
+$additional_label = new NTKLabel("", "Zusatz:");
+$table->add($additional_label, 7, 2);
+
+$additional_entry = new NTKEntry("additional");
+$table->add($additional_entry, 7, 3); 
+
+
+$bill_ext_label = new NTKLabel("", "&Ouml;kokontrollstelle:");
+$table->add($bill_ext_label, 8, 2);
+
+$bill_ext_entry = new NTKEntry("bill_ext");
+$table->add($bill_ext_entry, 8, 3); 
+
+
+$cancel_button = new NTKButton("cancel", "Abbrechen", "location.href = 'assistant.php';");
+$table->add($cancel_button, 10, 2);
+
+$submit_button = new NTKButton("submit", "Mitarbeiter erstellen", "document.forms['assistant'].submit();");
+$table->add($submit_button, 10, 3);
+
+
+
+$form = new NTKForm("assistant", "assistant.php", $table);
+$form->addAttribute("db_action", "new");
+$form->addAttribute("assistant_id", "");
+$main_box->add($form, False, True, "background-color: #dfe7f3; vertical-align: middle; align: center;");
+
+?>

+ 27 - 0
app/Modules/Assistant/toolbar.php

@@ -0,0 +1,27 @@
+<?php
+
+$small_toolbar_box = new NTKHBox("small_toolbar_box", 5, 0, False);
+
+$new_button = new NTKButton("assistant_new_button", "Neuen Mitarbeiter eintragen", "location.replace('assistant.php?action=new');");
+$small_toolbar_box->add($new_button, 250);
+
+$small_toolbar_box->add($spacer);
+
+
+$search_toolbar = new NTKHBox("search_toolbar", 2, 0, False);
+
+$customer_search_entry = new NTKEntry("search_entry");
+$search_toolbar->add($customer_search_entry, 150);
+
+$customer_search_button = new NTKButton("customer_search_button", "Suchen", "document.forms['search'].submit();");
+$search_toolbar->add($customer_search_button, 80);
+
+$search_form = new NTKForm("search", "assistant.php", $search_toolbar);
+$search_form->addAttribute("action", "search");
+
+$small_toolbar_box->add($search_form, 240);
+
+$main_box->add($small_toolbar_box, True, False, "background-color: #dfe7f3;");
+
+
+?>

+ 91 - 0
app/Modules/Bill/db_action.php

@@ -0,0 +1,91 @@
+<?php
+
+require_once("DataBase/Bill.php");
+require_once("DataBase/Bill_Product.php");
+require_once("DataBase/Tour.php");
+require_once("DataBase/Assistant.php");
+require_once("DataBase/Product.php");
+require_once("DataBase/Customer.php");
+require_once("DataBase/Price.php");
+require_once("DataBase/Tax.php");
+
+$db_action = var_get_post("db_action", "");
+
+$bill = new Bill();
+$tour = new Tour();
+$assistant = new Assistant();
+$bill_product = new Bill_Product();
+$product = new Product();
+$customer = new Customer();
+$price = new Price();
+$tax = new Tax();
+
+switch($db_action)
+{
+	case "new":
+		$customer_data = $customer->get(var_post("customer_id", ""));
+		if(count($customer_data) > 0)
+		{
+			$tour_data = $tour->getByAssistant($customer_data[0][12]);
+			if(count($tour_data) > 0)
+			{
+				$bill_id = $bill->create(var_post("bill_id", ""), array(var_post("customer_id", ""), $customer_data[0][12], var_post("date", ""), $tour_data[0][2], -1, 0));
+			}
+			else
+			{
+				$bill_id = $bill->create(var_post("bill_id", ""), array(var_post("customer_id", ""), $customer_data[0][12], var_post("date", ""), 1, -1, 0));
+			}
+		}
+		else
+			$bill_id = $bill->create(var_post("bill_id", ""), array(var_post("customer_id", ""), '', var_post("date", ""), var_post("assistant_id", "1"), -1, 0));
+		$action = "edit";
+		break;
+	case "edit":
+		$bill->update(var_post("bill_id", ""), array(var_post("customer_id", ""), var_post("tour_id", ""), var_post("date", ""), var_post("assistant_id", ""), var_post("bill_number", "")));
+		if($fp_tour_id != "")
+			$onload .= "location.href = 'tour.php?action=list_tour&tour_id=".$fp_tour_id."&date=".$fp_date."';";
+		break;
+	case "set_number":
+		$bill->setNumber(var_get("bill_id", ""));
+		$bill_product->fix(var_get("bill_id", ""));
+		global $onload;
+		$onload .= "window.open('print_bill.php?bill_id=".var_get("bill_id", "")."', '', '');";
+		break;
+	case "delete":
+		$bill->delete(var_get("bill_id", ""));
+		if($fp_tour_id != "")
+			$onload .= "location.href = 'tour.php?action=list_tour&tour_id=".$fp_tour_id."&date=".$fp_date."';";
+		break;
+	case "position_add":
+		$bill_data = $bill->get(var_post("bill_id", ""));
+
+		/* autoset anmerkung vom produkt, wenn nichts als anmerkung gegeben */
+		$details = var_post("details", "");
+		if($details == "")
+		{
+			$product_data = $product->get(var_post("product_id", ""));
+			$details = $product_data[0][8];
+		}
+
+		if($bill_data[0][5] == -1)
+			$bill_product->create(array(var_post("bill_id", ""), var_post("product_id", ""), var_post("amount", ""), $details, var_post("rabatt", ""), 0, 0));
+		else
+		{
+			$customer_data = $customer->get($bill_data[0][1]);
+			$price_data = $price->getPrice($customer_data[0][11], var_post("product_id", ""));
+			$product_data = $product->get(var_post("product_id", ""));
+			$tax_data = $tax->get($product_data[0][4]);
+
+			$bill_product->create(array(var_post("bill_id", ""), var_post("product_id", ""), var_post("amount", ""), $details, var_post("rabatt", ""), $price_data[0][3], $tax_data[0][2]));
+		}
+		break;
+	case "position_delete":
+		$bill_product->delete(var_get("bill_product_id", ""));
+		break;
+	case "position_edit":
+		$bill_product->update(var_post("bill_product_id", ""), array(var_post("bill_id", ""), var_post("product_id", ""), var_post("amount", ""), var_post("details", ""), var_post("rabatt", ""), var_post("price", ""), var_post("tax", "")));
+		break;
+}
+
+
+?>

+ 130 - 0
app/Modules/Bill/edit_form.php

@@ -0,0 +1,130 @@
+<?php
+
+$bill_box = new NTKVBox("bill_box", 0, 0, False);
+
+$customer_data = $customer->get($data[0][1]);
+
+$label = new NTKLabel("bill_label", "<b>Rechung: ".$data[0][5]."<br>".$customer_data[0][2]." ".$customer_data[0][3]."</b><br><br>");
+$bill_box->add($label);
+
+$bill_list = $bill_product->getByBillId($data[0][0]);
+
+$bill_pos_table = new NTKTable("", count($bill_list)+2, 7, False);
+
+$bill_pos_table->add(new NTKLabel("", "Produktnummer"), 0, 0,100);
+$bill_pos_table->add(new NTKLabel("", "Produkt"), 0, 1);
+$bill_pos_table->add(new NTKLabel("", "St&uuml;ck"), 0, 2,60);
+$bill_pos_table->add(new NTKLabel("", "Anmerkung"), 0, 3, 200);
+$bill_pos_table->add(new NTKLabel("", "Rabatt"), 0, 4, 60);
+
+$bill_pos_table->addFormRow("bill_product_form_new", "bill.php", 1, array(array('db_action','position_add'),array('bill_product_id',''),array('bill_id',$data[0][0]),array('action','edit'),array('from_page',$from_page),array('fp_tour_id',$fp_tour_id),array('fp_date',$fp_date)));
+$product_id_entry = new NTKEntry("product_id", "");
+$product_id_entry->addEvent("onkeyup","parent.frames['action'].location.href='action_product.php?form=bill_product_form_new&entry=product_id&next=amount&search='+this.value;");
+$onload .= "document.getElementById('product_id').focus();";
+$bill_pos_table->add($product_id_entry, 1, 0, 100);
+$bill_pos_table->add(new NTKLabel("", "&nbsp;"), 1, 1);
+$bill_pos_table->add(new NTKEntry("amount", ""), 1, 2, 60);
+$bill_pos_table->add(new NTKEntry("details", ""), 1, 3, 200);
+$bill_pos_table->add(new NTKEntry("rabatt", ""), 1, 4, 60);
+$bill_pos_table->add(new NTKButton("", "hinzuf&uuml;gen", "document.forms['bill_product_form_new'].submit();"), 1, 6);
+
+for($i = 0; $i < count($bill_list); $i++)
+{
+	$product_data = $product->get($bill_list[$i][2]);
+	$bill_pos_table->addFormRow("bill_product_form_".$bill_list[$i][0], "bill.php", $i+2, array(array('db_action','position_edit'),array('bill_product_id',$bill_list[$i][0]),array('bill_id',$bill_list[$i][1]),array('action','edit'),array('price',$bill_list[$i][6]),array('tax',$bill_list[$i][7]),array('from_page',$from_page),array('fp_tour_id',$fp_tour_id),array('fp_date',$fp_date)));
+	$product_id_entry = new NTKEntry("product_id", $bill_list[$i][2]);
+	$product_id_entry->addEvent("onkeyup","parent.frames['action'].location.href='action_product.php?form=bill_product_form_".$bill_list[$i][0]."&entry=product_id&next=amount&search='+this.value;");
+	$bill_pos_table->add($product_id_entry, $i+2, 0, 100);
+	$bill_pos_table->add(new NTKLabel("", $product_data[0][1]), $i+2, 1);
+	$bill_pos_table->add(new NTKEntry("amount", $bill_list[$i][3]), $i+2, 2, 60);
+	$bill_pos_table->add(new NTKEntry("details", $bill_list[$i][4]), $i+2, 3, 200);
+	$bill_pos_table->add(new NTKEntry("rabatt", $bill_list[$i][5]), $i+2, 4, 60);
+	$bill_pos_table->add(new NTKButton("", "ok", "document.forms['bill_product_form_".$bill_list[$i][0]."'].submit();"), $i+2, 5);
+	$bill_pos_table->add(new NTKButton("", "l&ouml;schen", "if(confirm('Wirklich loeschen?')) location.href = 'bill.php?action=edit&bill_id=".$bill_list[$i][1]."&db_action=position_delete&bill_product_id=".$bill_list[$i][0]."&from_page=$from_page&fp_date=$fp_date&fp_tour_id=$fp_tour_id';"), $i+2, 6);
+}
+
+$main_box->add($bill_pos_table, -1, -1, "background-color: #dfe7f3; vertical-align: top;");
+
+$table = new NTKTable("table", 5, 4, False);
+
+if($data[0][5] == -1)
+{
+	$number_label = new NTKLabel("", "Rechnungsnummer:");
+	$table->add($number_label, 0, 0);
+	$number_entry = new NTKButton("bill_number", "Nummer setzen", "location.href = 'bill.php?db_action=set_number&bill_id=".$data[0][0]."';");
+	$table->add($number_entry, 0, 1, 150);
+}
+elseif($data[0][5] == -2)
+{
+	$number_label = new NTKLabel("", "kommt von der Homepage", "color: #00ff00;");
+	$table->add($number_label, 0, 0);
+}
+else
+{
+	$number_label = new NTKLabel("", "Rechnungsnummer:");
+	$table->add($number_label, 0, 0);
+	$number_entry = new NTKLabel("bill_number", $data[0][5]);
+	$table->add($number_entry, 0, 1, 150);
+}
+
+$date_label = new NTKLabel("", "Datum (2006-01-30):");
+$table->add($date_label, 1, 2);
+
+$date_entry = new NTKEntry("date", $data[0][3]);
+$table->add($date_entry, 1, 3);
+
+$customer_id_label = new NTKLabel("", "Kundennummer:");
+$table->add($customer_id_label, 1, 0);
+
+$customer_id_entry = new NTKEntry("customer_id", $data[0][1]);
+$customer_id_entry->addEvent("onkeyup", "parent.frames['action'].location.href='action_customer.php?form=bill_form&entry=customer_id&next=date&search='+this.value;");
+$table->add($customer_id_entry, 1, 1);
+
+$tour_id_label = new NTKLabel("", "Tour:");
+$table->add($tour_id_label, 2, 2);
+
+$tour_id_entry = new NTKComboBox("tour_id", $tour->get(), $data[0][2]);
+$table->add($tour_id_entry, 2, 3);
+
+$assistant_id_label = new NTKLabel("", "Mitarbeiter:");
+$table->add($assistant_id_label, 2, 0);
+if($data[0][5] == -1)
+{
+	$assistant_id_entry = new NTKComboBox("assistant_id", $assistant->get(), $data[0][4]);
+	$table->add($assistant_id_entry, 2, 1);
+}
+else
+{
+	$assistant_id_entry = new NTKLabel("assistant_id", $data[0][4]);
+	$table->add($assistant_id_entry, 2, 1, 150);
+}
+
+$delete_button = new NTKButton("delete", "L&ouml;schen", "if(confirm('Wirklich loeschen?')) location.href = 'bill.php?db_action=delete&bill_id=".$data[0][0]."&from_page=$from_page&fp_date=$fp_date&fp_tour_id=$fp_tour_id';");
+$table->add($delete_button, 4, 1);
+
+$cancel_button = new NTKButton("cancel", "Abbrechen", "location.href = 'bill.php';");
+$table->add($cancel_button, 4, 2);
+
+if($data[0][5] == -2)
+	$submit_button = new NTKButton("submit", "Speichern/RechnungsNr. -1", "document.forms['bill_form'].submit();");
+else
+	$submit_button = new NTKButton("submit", "Speichern", "document.forms['bill_form'].submit();");
+$table->add($submit_button, 4, 3);
+
+
+
+$form = new NTKForm("bill_form", "bill.php", $table);
+if($data[0][5] == -2)
+	$form->addAttribute("bill_number", -1);
+else
+	$form->addAttribute("bill_number", $data[0][5]);
+if($data[0][5] != -1)
+	$form->addAttribute("assistant_id", $data[0][4]);
+$form->addAttribute("db_action", "edit");
+$form->addAttribute("bill_id", $data[0][0]);
+$form->addAttribute("from_page", $from_page);
+$form->addAttribute("fp_tour_id", $fp_tour_id);
+$form->addAttribute("fp_date", $fp_date);
+$main_box->add($form, -1, -1, "background-color: #dfe7f3; vertical-align: middle; align: center;");
+
+?>

+ 39 - 0
app/Modules/Bill/new_form.php

@@ -0,0 +1,39 @@
+<?php
+
+$table = new NTKTable("table", 4, 4, False);
+
+$number_label = new NTKLabel("", "Rechnungsnummer:");
+$table->add($number_label, 0, 0);
+
+$number_label = new NTKLabel("", "fortlaufend");
+$table->add($number_label, 0, 1);
+
+$date_label = new NTKLabel("", "Datum:");
+$table->add($date_label, 1, 2);
+
+$date = getdate(time());
+$date_entry = new NTKEntry("date", $date['year']."-".$date['mon']."-".$date['mday']);
+$table->add($date_entry, 1, 3);
+
+$customer_id_label = new NTKLabel("", "Kundennummer:");
+$table->add($customer_id_label, 1, 0);
+
+$customer_id_entry = new NTKEntry("customer_id");
+$onload .= "document.getElementById('customer_id').focus();";
+$customer_id_entry->addEvent("onkeyup", "parent.frames['action'].location.href='action_customer.php?form=bill_form&entry=customer_id&next=date&search='+this.value;");
+$table->add($customer_id_entry, 1, 1);
+
+
+$cancel_button = new NTKButton("cancel", "Abbrechen", "location.href = 'bill.php';");
+$table->add($cancel_button, 3, 2);
+
+$submit_button = new NTKButton("submit", "Rechnung eintragen", "document.forms['bill_form'].submit();");
+$table->add($submit_button, 3, 3);
+
+
+$form = new NTKForm("bill_form", "bill.php", $table);
+$form->addAttribute("db_action", "new");
+$form->addAttribute("action", "edit");
+$main_box->add($form, False, True, "background-color: #dfe7f3; vertical-align: middle; align: center;");
+
+?>

+ 27 - 0
app/Modules/Bill/toolbar.php

@@ -0,0 +1,27 @@
+<?php
+
+$small_toolbar = new NTKHBox("small_toolbar", 5, 0, False);
+
+$new_button = new NTKButton("new_button", "Neue Rechnung eintragen", "location.replace('bill.php?action=new');");
+$small_toolbar->add($new_button, 230);
+
+$small_toolbar->add($spacer);
+
+
+$search_toolbar = new NTKHBox("search_toolbar", 2, 0, False);
+
+$search_entry = new NTKEntry("search_entry");
+$search_toolbar->add($search_entry, 150);
+
+$search_button = new NTKButton("search_button", "Suchen", "document.forms['search'].submit();");
+$search_toolbar->add($search_button, 80);
+
+$search_form = new NTKForm("search", "bill.php", $search_toolbar);
+$search_form->addAttribute("action", "search");
+
+$small_toolbar->add($search_form, 240);
+
+$main_box->add($small_toolbar, True, False, "background-color: #dfe7f3;");
+
+
+?>

+ 15 - 0
app/Modules/Category/anleitung.txt

@@ -0,0 +1,15 @@
+Hallo Rudi
+
+Im Anhang befinden sich die benötigten Dateien:
+
+*alle Dateien musst du überschreiben*
+
+- Catgory.php        Diese Datei musst du in den Ordner "c:\apache\htdocs\DataBase\"     kopieren
+- new_form.php und db_action.php         Beide Dateien kommen in den Ordner "c:\apache\htdocs\Modules\Category\"
+
+Falls es dann immer noch nicht klappt, antworte auf die Email, mit der eventuell auftretenden Fehlermeldung.
+
+Danke.
+
+Viel Spass,
+   Johannes 

+ 26 - 0
app/Modules/Category/db_action.php

@@ -0,0 +1,26 @@
+<?php
+
+require_once("util.php");
+require_once("NTK/NTK.php");
+
+require_once("DataBase/Category.php");
+
+$db_action = var_get_post("db_action", "");
+
+$category = new Category();
+
+switch($db_action)
+{
+	case "new":
+		$category->create(array(var_post("category_id", ""), var_post("name", ""), var_post("details", "")));
+		break;
+	case "edit":
+		$category->update(var_post("category_id", ""), array(var_post("name", ""), var_post("details", "")));
+		break;
+	case "delete":
+		$category->delete(var_get("category_id", ""));
+		break;
+}
+
+
+?>

+ 41 - 0
app/Modules/Category/edit_form.php

@@ -0,0 +1,41 @@
+<?php
+
+$table = new NTKTable("table", 3, 4, False);
+
+$number_label = new NTKLabel("", "Kategorienummer:");
+$table->add($number_label, 0, 0);
+
+$number_entry = new NTKLabel("category_id", $data[0][0]);
+$table->add($number_entry, 0, 1, 150); 
+
+$name_label = new NTKLabel("", "Bezeichner:");
+$table->add($name_label, 1, 0);
+
+$name_entry = new NTKEntry("name", $data[0][1]);
+$table->add($name_entry, 1, 1); 
+$onload .= "document.getElementById('name').focus();";
+
+$details_label = new NTKLabel("", "Beschreibung:");
+$table->add($details_label, 1, 2);
+
+$details_entry = new NTKEntry("details", $data[0][2]);
+$table->add($details_entry, 1, 3); 
+
+
+$delete_button = new NTKButton("delete", "L&ouml;schen", "if(confirm('Wirklich loeschen?')) location.href = 'category.php?db_action=delete&category_id=".$data[0][0]."';");
+$table->add($delete_button, 2, 1);
+
+$cancel_button = new NTKButton("cancel", "Abbrechen", "location.href = 'category.php';");
+$table->add($cancel_button, 2, 2);
+
+$submit_button = new NTKButton("submit", "Speichern", "document.forms['category'].submit();");
+$table->add($submit_button, 2, 3);
+
+
+
+$form = new NTKForm("category", "category.php", $table);
+$form->addAttribute("db_action", "edit");
+$form->addAttribute("category_id", $data[0][0]);
+$main_box->add($form, False, True, "background-color: #dfe7f3; vertical-align: middle; align: center;");
+
+?>

+ 36 - 0
app/Modules/Category/new_form.php

@@ -0,0 +1,36 @@
+<?php
+
+$table = new NTKTable("table", 3, 4, False);
+
+$category_id_label = new NTKLabel("", "Kategorienummer:");
+$table->add($category_id_label, 0, 0);
+
+$category_id_entry = new NTKEntry("category_id");
+$table->add($category_id_entry, 0, 1); 
+$onload .= "document.getElementById('category_id').focus();";
+
+$prename_label = new NTKLabel("", "Bezeichner:");
+$table->add($prename_label, 1, 0);
+
+$prename_entry = new NTKEntry("name");
+$table->add($prename_entry, 1, 1); 
+
+$postname_label = new NTKLabel("", "Beschreibung:");
+$table->add($postname_label, 1, 2);
+
+$postname_entry = new NTKEntry("details");
+$table->add($postname_entry, 1, 3); 
+
+
+$cancel_button = new NTKButton("cancel", "Abbrechen", "location.href = 'category.php';");
+$table->add($cancel_button, 2, 2);
+
+$submit_button = new NTKButton("submit", "Kategorie erstellen", "document.forms['category'].submit();");
+$table->add($submit_button, 2, 3);
+
+
+$form = new NTKForm("category", "category.php", $table);
+$form->addAttribute("db_action", "new");
+$main_box->add($form, False, True, "background-color: #dfe7f3; vertical-align: middle; align: center;");
+
+?>

+ 27 - 0
app/Modules/Category/toolbar.php

@@ -0,0 +1,27 @@
+<?php
+
+$small_toolbar = new NTKHBox("small_toolbar", 5, 0, False);
+
+$new_button = new NTKButton("new_button", "Neue Kategorie eintragen", "location.replace('category.php?action=new');");
+$small_toolbar->add($new_button, 230);
+
+$small_toolbar->add($spacer);
+
+
+$search_toolbar = new NTKHBox("search_toolbar", 2, 0, False);
+
+$search_entry = new NTKEntry("search_entry");
+$search_toolbar->add($search_entry, 150);
+
+$search_button = new NTKButton("search_button", "Suchen", "document.forms['search'].submit();");
+$search_toolbar->add($search_button, 80);
+
+$search_form = new NTKForm("search", "category.php", $search_toolbar);
+$search_form->addAttribute("action", "search");
+
+$small_toolbar->add($search_form, 240);
+
+$main_box->add($small_toolbar, True, False, "background-color: #dfe7f3;");
+
+
+?>

+ 25 - 0
app/Modules/Configuration/db_action.php

@@ -0,0 +1,25 @@
+<?php
+
+require_once("util.php");
+require_once("NTK/NTK.php");
+
+require_once("DataBase/Category.php");
+
+$db_action = var_get_post("db_action", "");
+$category = new Category();
+
+switch($db_action)
+{
+	case "new":
+		$category->create(var_post("category_id", ""), array(var_post("name", ""), var_post("details", "")));
+		break;
+	case "edit":
+		$category->update(var_post("category_id", ""), array(var_post("name", ""), var_post("details", "")));
+		break;
+	case "delete":
+		$category->delete(var_get("category_id", ""));
+		break;
+}
+
+
+?>

+ 32 - 0
app/Modules/Configuration/group.php

@@ -0,0 +1,32 @@
+<?php
+
+require_once("util.php");
+
+	$group = new Group();
+	
+	if($action == "new")
+		$group->create(var_post("group_id", ""), array(var_post("group_name", "")));
+	elseif($action == "edit")
+		$group->update(var_post("group_id", ""), array(var_post("group_name", "")));
+	elseif($action == "delete")
+		$group->delete(var_get("group_id", ""));
+
+	$group_box = new NTKVBox("group_box", 0, 0, False);
+	
+	$label = new NTKLabel("group_label", "<h3>Gruppen</h3>");
+	$group_box->add($label);
+
+	$group_list = $group->get('');
+	for($i = 0; $i < count($group_list); $i++)
+	{
+		$group_box->add(new NTKEGroup($group_list[$i][0], $group_list[$i][1]));
+	}
+	
+	$label = new NTKLabel("group_label", "<h4>neue Gruppe</h4>");
+	$group_box->add($label);
+	
+	$group_box->add(new NTKEGroup("", "", True), -1);
+	
+	$main_box->add($group_box, -1, -1, "background-color: #dfe7f3; vertical-align: top;");
+
+?>

+ 32 - 0
app/Modules/Configuration/priceset.php

@@ -0,0 +1,32 @@
+<?php
+
+require_once("util.php");
+
+	$priceset = new Priceset();
+	
+	if($action == "new")
+		$priceset->create(var_post("priceset_id", ""), array(var_post("priceset_name", ""), var_post("priceset_netto", "")));
+	elseif($action == "edit")
+		$priceset->update(var_post("priceset_id", ""), array(var_post("priceset_name", ""), var_post("priceset_netto", "")));
+	elseif($action == "delete")
+		$priceset->delete(var_get("priceset_id", ""));
+
+	$priceset_box = new NTKVBox("priceset_box", 0, 1, False);
+	
+	$label = new NTKLabel("priceset_label", "<h3>Preiss&auml;tze</h3>");
+	$priceset_box->add($label);
+
+	$priceset_list = $priceset->get('');
+	for($i = 0; $i < count($priceset_list); $i++)
+	{
+		$priceset_box->add(new NTKEPriceset($priceset_list[$i][0], $priceset_list[$i][1], $priceset_list[$i][2]));
+	}
+	
+	$label = new NTKLabel("priceset_label", "<h4>neuer Preissatz</h4>");
+	$priceset_box->add($label);
+	
+	$priceset_box->add(new NTKEPriceset("", "", 1, True), -1);
+	
+	$main_box->add($priceset_box, -1, -1, "background-color: #dfe7f3; vertical-align: top;");
+
+?>

+ 32 - 0
app/Modules/Configuration/tax.php

@@ -0,0 +1,32 @@
+<?php
+
+require_once("util.php");
+
+	$tax = new Tax();
+	
+	if($action == "new")
+		$tax->create(var_post("tax_id", ""), array(var_post("tax_name", ""), var_post("tax_rate", "")));
+	elseif($action == "edit")
+		$tax->update(var_post("tax_id", ""), array(var_post("tax_name", ""), var_post("tax_rate", "")));
+	elseif($action == "delete")
+		$tax->delete(var_get("tax_id", ""));
+
+	$tax_box = new NTKVBox("tax_box", 0, 0, False);
+	
+	$label = new NTKLabel("tax_label", "<h3>Steuers&auml;tze</h3>");
+	$tax_box->add($label);
+
+	$taxlist = $tax->get('');
+	for($i = 0; $i < count($taxlist); $i++)
+	{
+		$tax_box->add(new NTKETax($taxlist[$i][0], $taxlist[$i][1], $taxlist[$i][2]));
+	}
+	
+	$label = new NTKLabel("tax_label", "<h4>neuer Steuersatz</h4>");
+	$tax_box->add($label);
+	
+	$tax_box->add(new NTKETax("", "", "", True), -1);
+	
+	$main_box->add($tax_box, -1, -1, "background-color: #dfe7f3; vertical-align: top;");
+	
+?>

+ 20 - 0
app/Modules/Configuration/toolbar.php

@@ -0,0 +1,20 @@
+<?php
+
+$small_toolbar = new NTKHBox("small_toolbar", 5, 0, False);
+
+$group_button = new NTKButton("group_button", "Gruppen", "location.replace('configuration.php?page=group');");
+$small_toolbar->add($group_button, 230);
+
+$tax_button = new NTKButton("tax_button", "Steuer", "location.replace('configuration.php?page=tax');");
+$small_toolbar->add($tax_button, 230);
+
+$priceset_button = new NTKButton("priceset_button", "Preiss&auml;tze", "location.replace('configuration.php?page=priceset');");
+$small_toolbar->add($priceset_button, 230);
+
+$small_toolbar->add($spacer);
+
+
+$main_box->add($small_toolbar, True, False, "background-color: #dfe7f3;");
+
+
+?>

+ 61 - 0
app/Modules/Customer/db_action.php

@@ -0,0 +1,61 @@
+<?php
+
+require_once("util.php");
+
+require_once("DataBase/Customer.php");
+require_once("DataBase/Tour.php");
+require_once("DataBase/Priceset.php");
+
+$db_action = var_get_post("db_action", "");
+
+$customer = new Customer();
+$tour = new Tour();
+$priceset = new Priceset();
+
+switch($db_action)
+{
+	case "new":
+		$customer->create(var_post("customer_number", ""), array(	var_post("password", ""),
+										var_post("prename", ""),
+										var_post("postname", ""),
+										var_post("street", ""),
+										var_post("streetnumber", ""),
+										var_post("plz", ""),
+										var_post("city", ""),
+										var_post("telephone", ""),
+										var_post("telefax", ""),
+										var_post("email", ""),
+										var_post("pricelist_id", ""),
+										var_post("tour_id", ""),
+										var_post("rabatt", ""),
+										var_post("details", ""),
+										var_post("bank_name", ""),
+										var_post("bank_account", ""),
+										var_post("blz", "")));
+		break;
+	case "edit":
+		$customer->update(var_post("customer_number", ""),array(	var_post("password", ""),
+										var_post("prename", ""),
+										var_post("postname", ""),
+										var_post("street", ""),
+										var_post("streetnumber", ""),
+										var_post("plz", ""),
+										var_post("city", ""),
+										var_post("telephone", ""),
+										var_post("telefax", ""),
+										var_post("email", ""),
+										var_post("pricelist_id", ""),
+										var_post("tour_id", ""),
+										var_post("rabatt", ""),
+										var_post("details", ""),
+										var_post("bank_name", ""),
+										var_post("bank_account", ""),
+										var_post("blz", "")));
+		break;
+	case "delete":
+		$customer->delete(var_get("customer_id", ""));
+		break;
+}
+
+
+?>

+ 139 - 0
app/Modules/Customer/edit_form.php

@@ -0,0 +1,139 @@
+<?php
+
+$table = new NTKTable("table", 15, 4, False);
+
+$number_label = new NTKLabel("", "Kundennummer:");
+$table->add($number_label, 0, 0);
+
+$number_entry = new NTKLabel("", $data[0][0]);
+$table->add($number_entry, 0, 1, 150);
+
+$password_label = new NTKLabel("", "Passwort:");
+$table->add($password_label, 0, 2);
+
+$password_entry = new NTKEntry("password", $data[0][1]);
+$table->add($password_entry, 0, 3, 150);
+
+
+$prename_label = new NTKLabel("", "Name:");
+$table->add($prename_label, 2, 0);
+
+$prename_entry = new NTKEntry("prename", $data[0][2]);
+$table->add($prename_entry, 2, 1);
+$onload .= "document.getElementById('prename').focus();";
+
+$postname_label = new NTKLabel("", "Details:");
+$table->add($postname_label, 2, 2);
+
+$postname_entry = new NTKEntry("postname", $data[0][3]);
+$table->add($postname_entry, 2, 3);
+
+
+$street_label = new NTKLabel("", "Stra&szlig;e:");
+$table->add($street_label, 3, 0);
+
+$street_entry = new NTKEntry("street", $data[0][4]);
+$table->add($street_entry, 3, 1);
+
+$street_number_label = new NTKLabel("", "Hausnummer:");
+$table->add($street_number_label, 3, 2);
+
+$street_number_entry = new NTKEntry("streetnumber", $data[0][5]);
+$table->add($street_number_entry, 3, 3);
+
+
+$plz_label = new NTKLabel("", "PLZ:");
+$table->add($plz_label, 4, 0);
+
+$plz_entry = new NTKEntry("plz", $data[0][6]);
+$table->add($plz_entry, 4, 1);
+
+$city_label = new NTKLabel("", "Ort:");
+$table->add($city_label, 4, 2);
+
+$city_entry = new NTKEntry("city", $data[0][7]);
+$table->add($city_entry, 4, 3);
+
+
+$telephone_label = new NTKLabel("", "Telefon:");
+$table->add($telephone_label, 5, 0);
+
+$telephone_entry = new NTKEntry("telephone", $data[0][8]);
+$table->add($telephone_entry, 5, 1);
+
+$fax_label = new NTKLabel("", "Telefax:");
+$table->add($fax_label, 5, 2);
+
+$fax_entry = new NTKEntry("telefax", $data[0][9]);
+$table->add($fax_entry, 5, 3);
+
+
+$email_label = new NTKLabel("", "E-Mail:");
+$table->add($email_label, 6, 0);
+
+$email_entry = new NTKEntry("email", $data[0][10]);
+$table->add($email_entry, 6, 1);
+
+$rabatt_label = new NTKLabel("", "Rabatt:");
+$table->add($rabatt_label, 6, 2);
+
+$rabatt_entry = new NTKEntry("rabatt", $data[0][13]);
+$table->add($rabatt_entry, 6, 3);
+
+
+$price_list_label = new NTKLabel("", "Preisliste:");
+$table->add($price_list_label, 8, 0);
+
+$price_list_list = new NTKComboBox("pricelist_id", $priceset->get(), $data[0][11]);
+$table->add($price_list_list, 8, 1);
+
+$tour_label = new NTKLabel("", "Tour:");
+$table->add($tour_label, 8, 2);
+
+$tour_list = new NTKComboBox("tour_id", $tour->get(), $data[0][12]);
+$table->add($tour_list, 8, 3);
+
+# Anmerkung
+$details_label = new NTKLabel("", "Anmerkung:");
+$table->add($details_label, 9, 0);
+
+$details_entry = new NTKEntry("details", $data[0][14]);
+$table->add($details_entry, 9, 1);
+
+#Bank
+$blz_label = new NTKLabel("", "BLZ:");
+$table->add($blz_label, 11, 0);
+
+$blz_entry = new NTKEntry("blz", $data[0][17]);
+$table->add($blz_entry, 11, 1);
+
+$ktno_label = new NTKLabel("", "Kontonummer:");
+$table->add($ktno_label, 11, 2);
+
+$ktno_entry = new NTKEntry("bank_account", $data[0][16]);
+$table->add($ktno_entry, 11, 3);
+
+$bankname_label = new NTKLabel("", "Bankverbindung:");
+$table->add($bankname_label, 12, 0);
+
+$bankname_entry = new NTKEntry("bank_name", $data[0][15]);
+$table->add($bankname_entry, 12, 1);
+
+
+$delete_button = new NTKButton("delete", "L&ouml;schen", "if(confirm('Wirklich loeschen?')) location.href = 'customer.php?db_action=delete&customer_id=".$data[0][0]."';");
+$table->add($delete_button, 14, 1);
+
+$cancel_button = new NTKButton("cancel", "Abbrechen", "location.href = 'customer.php';");
+$table->add($cancel_button, 14, 2);
+
+$submit_button = new NTKButton("submit", "Speichern", "document.forms['customer'].submit();");
+$table->add($submit_button, 14, 3);
+
+
+
+$form = new NTKForm("customer", "customer.php", $table);
+$form->addAttribute("db_action", "edit");
+$form->addAttribute("customer_number", $data[0][0]);
+$main_box->add($form, False, True, "background-color: #dfe7f3; vertical-align: middle; align: center;");
+
+?>

+ 140 - 0
app/Modules/Customer/new_form.php

@@ -0,0 +1,140 @@
+<?php
+
+$table = new NTKTable("table", 15, 4, False);
+
+
+$number_label = new NTKLabel("", "Kundennummer:");
+$table->add($number_label, 0, 0);
+
+$number_entry = new NTKEntry("customer_number");
+$table->add($number_entry, 0, 1, 150);
+$onload .= "document.getElementById('customer_number').focus();";
+
+$password_label = new NTKLabel("", "Passwort:");
+$table->add($password_label, 0, 2);
+
+$password_entry = new NTKEntry("password");
+$table->add($password_entry, 0, 3, 150);
+
+
+$prename_label = new NTKLabel("", "Name:");
+$table->add($prename_label, 2, 0);
+
+$prename_entry = new NTKEntry("prename");
+$table->add($prename_entry, 2, 1);
+
+$postname_label = new NTKLabel("", "Details:");
+$table->add($postname_label, 2, 2);
+
+$postname_entry = new NTKEntry("postname");
+$table->add($postname_entry, 2, 3);
+
+
+$street_label = new NTKLabel("", "Stra&szlig;e:");
+$table->add($street_label, 3, 0);
+
+$street_entry = new NTKEntry("street");
+$table->add($street_entry, 3, 1);
+
+$street_number_label = new NTKLabel("", "Hausnummer:");
+$table->add($street_number_label, 3, 2);
+
+$street_number_entry = new NTKEntry("streetnumber");
+$table->add($street_number_entry, 3, 3);
+
+
+$plz_label = new NTKLabel("", "PLZ:");
+$table->add($plz_label, 4, 0);
+
+$plz_entry = new NTKEntry("plz");
+$table->add($plz_entry, 4, 1);
+
+$city_label = new NTKLabel("", "Ort:");
+$table->add($city_label, 4, 2);
+
+$city_entry = new NTKEntry("city");
+$table->add($city_entry, 4, 3);
+
+
+$telephone_label = new NTKLabel("", "Telefon:");
+$table->add($telephone_label, 5, 0);
+
+$telephone_entry = new NTKEntry("telephone");
+$table->add($telephone_entry, 5, 1);
+
+$fax_label = new NTKLabel("", "Telefax:");
+$table->add($fax_label, 5, 2);
+
+$fax_entry = new NTKEntry("telefax");
+$table->add($fax_entry, 5, 3);
+
+
+$email_label = new NTKLabel("", "E-Mail:");
+$table->add($email_label, 6, 0);
+
+$email_entry = new NTKEntry("email");
+$table->add($email_entry, 6, 1);
+
+$rabatt_label = new NTKLabel("", "Rabatt:");
+$table->add($rabatt_label, 6, 2);
+
+$rabatt_entry = new NTKEntry("rabatt");
+$table->add($rabatt_entry, 6, 3);
+
+
+
+$price_list_label = new NTKLabel("", "Preisliste:");
+$table->add($price_list_label, 8, 0);
+
+
+$price_list_list = new NTKComboBox("pricelist_id", $priceset->get());
+$table->add($price_list_list, 8, 1);
+
+
+$tour_label = new NTKLabel("", "Tour:");
+$table->add($tour_label, 8, 2);
+
+$tour_list = new NTKComboBox("tour_id", $tour->get());
+$table->add($tour_list, 8, 3);
+
+
+$details_label = new NTKLabel("", "Anmerkung:");
+$table->add($details_label, 9, 0);
+
+$details_entry = new NTKEntry("details");
+$table->add($details_entry, 9, 1);
+
+
+$blz_label = new NTKLabel("", "BLZ:");
+$table->add($blz_label, 11, 0);
+
+$blz_entry = new NTKEntry("blz");
+$table->add($blz_entry, 11, 1);
+
+$ktno_label = new NTKLabel("", "Kontonummer:");
+$table->add($ktno_label, 11, 2);
+
+$ktno_entry = new NTKEntry("bank_account");
+$table->add($ktno_entry, 11, 3);
+
+$bankname_label = new NTKLabel("", "Bankverbindung:");
+$table->add($bankname_label, 12, 0);
+
+$bankname_entry = new NTKEntry("bank_name");
+$table->add($bankname_entry, 12, 1);
+
+
+
+
+$cancel_button = new NTKButton("cancel", "Abbrechen", "location.href = 'customer.php';");
+$table->add($cancel_button, 14, 2);
+
+$submit_button = new NTKButton("submit", "Kunde erstellen", "document.forms['customer'].submit();");
+$table->add($submit_button, 14, 3);
+
+
+$form = new NTKForm("customer", "customer.php", $table);
+$form->addAttribute("db_action", "new");
+$main_box->add($form, False, True, "background-color: #dfe7f3; vertical-align: middle; align: center;");
+
+?>

+ 27 - 0
app/Modules/Customer/toolbar.php

@@ -0,0 +1,27 @@
+<?php
+
+$small_toolbar_box = new NTKHBox("small_toolbar_box", 5, 0, False);
+
+$customer_new_button = new NTKButton("customer_new_button", "Neuen Kunden eintragen", "location.replace('customer.php?action=new');");
+$small_toolbar_box->add($customer_new_button, 230);
+
+$small_toolbar_box->add($spacer);
+
+
+$search_toolbar = new NTKHBox("search_toolbar", 2, 0, False);
+
+$customer_search_entry = new NTKEntry("search_entry");
+$search_toolbar->add($customer_search_entry, 150);
+
+$customer_search_button = new NTKButton("customer_search_button", "Suchen", "document.forms['search'].submit();");
+$search_toolbar->add($customer_search_button, 80);
+
+$search_form = new NTKForm("search", "customer.php", $search_toolbar);
+$search_form->addAttribute("action", "search");
+
+$small_toolbar_box->add($search_form, 240);
+
+$main_box->add($small_toolbar_box, True, False, "background-color: #dfe7f3;");
+
+
+?>

+ 62 - 0
app/Modules/Product/db_action.php

@@ -0,0 +1,62 @@
+<?php
+
+require_once("util.php");
+
+require_once("DataBase/Product.php");
+require_once("DataBase/Tax.php");
+require_once("DataBase/Category.php");
+require_once("DataBase/Priceset.php");
+require_once("DataBase/Group.php");
+require_once("DataBase/Price.php");
+
+
+$db_action = var_get_post("db_action", "");
+
+
+$product = new Product();
+$tax = new Tax();
+$category = new Category();
+$priceset = new Priceset();
+$price = new Price();
+$group = new Group();
+
+switch($db_action)
+{
+	case "new":
+		$product->create(var_post("product_id", ""), array(	var_post("name", ""),
+				 					var_post("details", ""),
+									var_post("category_id", ""),
+									var_post("tax_id", ""),
+									var_post("available", ""),
+									var_post("group_id", ""),
+									var_post("order_number", ""),
+									var_post("anmerkung", "")));
+		$priceset_list = $priceset->get();
+		for($i = 0; $i < count($priceset_list); $i++)
+			$price->create(var_post("priceset_id_".$i, ""), var_post("product_id", ""), array(var_post("priceset_price_".$i, "")));
+		break;
+	case "edit":
+		$product->update(var_post("product_id", ""), array(	var_post("name", ""),
+									var_post("details", ""),
+									var_post("category_id", ""),
+									var_post("tax_id", ""),
+									var_post("available", ""),
+									var_post("group_id", ""),
+									var_post("order_number", ""),
+									var_post("anmerkung", "")));
+		$priceset_list = $priceset->get();
+		for($i = 0; $i < count($priceset_list); $i++)
+		{
+			if($price->exists(var_post("priceset_id_".$i, ""), var_post("product_id", "")))
+				$price->update(var_post("priceset_id_".$i, ""), var_post("product_id", ""), array(var_post("priceset_price_".$i, "")));
+			else
+				$price->create(var_post("priceset_id_".$i, ""), var_post("product_id", ""), array(var_post("priceset_price_".$i, "")));
+		}
+		break;
+	case "delete":
+		$product->delete(var_get("product_id", ""));
+		break;
+}
+
+
+?>

+ 101 - 0
app/Modules/Product/edit_form.php

@@ -0,0 +1,101 @@
+<?php
+
+$priceset_list = $priceset->get();
+
+$table = new NTKTable("table", 7 + count($priceset_list), 4, False);
+
+$number_label = new NTKLabel("", "Produktnummer:");
+$table->add($number_label, 0, 0);
+
+$number_entry = new NTKLabel("product_id", $data[0][0]);
+$table->add($number_entry, 0, 1, 150);
+
+$name_label = new NTKLabel("", "Bezeichnung:");
+$table->add($name_label, 2, 0);
+
+$name_entry = new NTKEntry("name", $data[0][1]);
+$table->add($name_entry, 2, 1);
+
+$details_label = new NTKLabel("", "Details:");
+$table->add($details_label, 2, 2);
+
+$details_entry = new NTKEntry("details", $data[0][2]);
+$table->add($details_entry, 2, 3);
+
+
+$category_id_label = new NTKLabel("", "Kategorie:");
+$table->add($category_id_label, 3, 0);
+
+$category_id_entry = new NTKComboBox("category_id", $category->get(), $data[0][3]);
+$table->add($category_id_entry, 3, 1);
+
+$tax_label = new NTKLabel("", "Steuer:");
+$table->add($tax_label, 3, 2);
+
+$tax_entry = new NTKComboBox("tax_id", $tax->get(), $data[0][4]);
+$table->add($tax_entry, 3, 3);
+
+$avilable_id_label = new NTKLabel("", "Zur Zeit verf&uuml;gbar:");
+$table->add($avilable_id_label, 4, 0);
+
+$avilable_id_entry = new NTKCheckbox("available", 1, $data[0][5]);
+$table->add($avilable_id_entry, 4, 1);
+
+$group_id_label = new NTKLabel("", "Gruppe:");
+$table->add($group_id_label, 4, 2);
+
+$group_id_entry = new NTKComboBox("group_id", $group->get(), $data[0][6]);
+$table->add($group_id_entry, 4, 3);
+
+
+$order_number_label = new NTKLabel("", "Bestellnummer:");
+$table->add($order_number_label, 5, 0);
+
+$order_number_entry = new NTKEntry("order_number", $data[0][7]);
+$table->add($order_number_entry, 5, 1);
+
+$anmerkung_label = new NTKLabel("", "Anmerkung:");
+$table->add($anmerkung_label, 5, 2);
+
+$anmerkung_entry = new NTKEntry("anmerkung", $data[0][8]);
+$table->add($anmerkung_entry, 5, 3);
+
+// adding dynamic-pricesets
+$row = 6;
+
+for($i = 0; $i < count($priceset_list); $i++)
+{
+	$priceset_label = new NTKLabel("", $priceset_list[$i][1].":");
+	$table->add($priceset_label, $row, 0);
+
+	$tmp_price = $price->getPrice($priceset_list[$i][0], $data[0][0]);
+
+	if(count($tmp_price) > 0)
+		$priceset_entry = new NTKEntry("priceset_price_".$i, $tmp_price[0][3]);
+	else
+		$priceset_entry = new NTKEntry("priceset_price_".$i, 0);
+	$table->add($priceset_entry, $row, 1);
+
+	$row++;
+}
+
+
+$delete_button = new NTKButton("delete", "L&ouml;schen", "if(confirm('Wirklich loeschen?')) location.href = 'product.php?db_action=delete&product_id=".$data[0][0]."';");
+$table->add($delete_button, $row, 1);
+
+$cancel_button = new NTKButton("cancel", "Abbrechen", "location.href = 'product.php';");
+$table->add($cancel_button, $row, 2);
+
+$submit_button = new NTKButton("submit", "Speichern", "document.forms['product'].submit();");
+$table->add($submit_button, $row, 3);
+
+
+
+$form = new NTKForm("product", "product.php", $table);
+$form->addAttribute("db_action", "edit");
+$form->addAttribute("product_id", $data[0][0]);
+for($i = 0; $i < count($priceset_list); $i++)
+	$form->addAttribute("priceset_id_".$i, $priceset_list[$i][0]);
+$main_box->add($form, False, True, "background-color: #dfe7f3; vertical-align: middle; align: center;");
+
+?>

+ 96 - 0
app/Modules/Product/new_form.php

@@ -0,0 +1,96 @@
+<?php
+
+$priceset_list = $priceset->get();
+
+$table = new NTKTable("table", 7 + count($priceset_list), 4, False);
+
+$number_label = new NTKLabel("", "Produktnummer:");
+$table->add($number_label, 0, 0);
+
+$number_entry = new NTKEntry("product_id");
+$onload .= "document.getElementById('product_id').focus();";
+$table->add($number_entry, 0, 1, 150);
+
+$name_label = new NTKLabel("", "Bezeichnung:");
+$table->add($name_label, 2, 0);
+
+$name_entry = new NTKEntry("name");
+$table->add($name_entry, 2, 1);
+
+$details_label = new NTKLabel("", "Details:");
+$table->add($details_label, 2, 2);
+
+$details_entry = new NTKEntry("details");
+$table->add($details_entry, 2, 3);
+
+
+$category_id_label = new NTKLabel("", "Kategorie:");
+$table->add($category_id_label, 3, 0);
+
+$category_id_entry = new NTKComboBox("category_id", $category->get());
+$table->add($category_id_entry, 3, 1);
+
+$tax_label = new NTKLabel("", "Steuer:");
+$table->add($tax_label, 3, 2);
+
+$tax_entry = new NTKComboBox("tax_id", $tax->get());
+$table->add($tax_entry, 3, 3);
+
+$avilable_id_label = new NTKLabel("", "Zur Zeit verf&uuml;gbar:");
+$table->add($avilable_id_label, 4, 0);
+
+$avilable_id_entry = new NTKCheckbox("available", 1, True);
+$table->add($avilable_id_entry, 4, 1);
+
+$group_id_label = new NTKLabel("", "Gruppe:");
+$table->add($group_id_label, 4, 2);
+
+$group_id_entry = new NTKComboBox("group_id", $group->get());
+$table->add($group_id_entry, 4, 3);
+
+
+$order_number_label = new NTKLabel("", "Bestellnummer:");
+$table->add($order_number_label, 5, 0);
+
+$order_number_entry = new NTKEntry("order_number");
+$table->add($order_number_entry, 5, 1);
+
+$anmerkung_label = new NTKLabel("", "Anmerkung:");
+$table->add($anmerkung_label, 5, 2);
+
+$anmerkung_entry = new NTKEntry("anmerkung");
+$table->add($anmerkung_entry, 5, 3);
+
+// adding dynamic-pricesets
+$row = 6;
+
+for($i = 0; $i < count($priceset_list); $i++)
+{
+	$priceset_label = new NTKLabel("", $priceset_list[$i][1].":");
+	$table->add($priceset_label, $row, 0);
+
+	$tmp_price = $price->getPrice($priceset_list[$i][0], "");
+
+	$priceset_entry = new NTKEntry("priceset_price_".$i, "");
+	$table->add($priceset_entry, $row, 1);
+
+	$row++;
+}
+
+
+$cancel_button = new NTKButton("cancel", "Abbrechen", "location.href = 'product.php';");
+$table->add($cancel_button, $row, 2);
+
+$submit_button = new NTKButton("submit", "Produkt erstellen", "document.forms['product'].submit();");
+$table->add($submit_button, $row, 3);
+
+
+
+$form = new NTKForm("product", "product.php", $table);
+$form->addAttribute("db_action", "new");
+// $form->addAttribute("product_id", $data[0][0]);
+for($i = 0; $i < count($priceset_list); $i++)
+	$form->addAttribute("priceset_id_".$i, $priceset_list[$i][0]);
+$main_box->add($form, False, True, "background-color: #dfe7f3; vertical-align: middle; align: center;");
+
+?>

+ 37 - 0
app/Modules/Product/toolbar.php

@@ -0,0 +1,37 @@
+<?php
+
+$small_toolbar = new NTKHBox("small_toolbar", 5, 0, False);
+
+$new_button = new NTKButton("new_button", "Neues Produkt eintragen", "location.replace('product.php?action=new');");
+$small_toolbar->add($new_button, 230);
+
+$small_toolbar->add($spacer);
+
+
+$search_toolbar = new NTKHBox("search_toolbar", 2, 0, False);
+
+$search_label = new NTKLabel("search_label", "Suchen in/nicht in: ");
+$search_toolbar->add($search_label, 160);
+
+$search_toggle = new NTKCheckbox("search_toggle", 1);
+$search_toolbar->add($search_toggle, 30);
+
+$search_category = new NTKComboBox("search_category", $category->get());
+$search_category->setMultiple(True);
+$search_toolbar->add($search_category, 150);
+
+$search_entry = new NTKEntry("search_entry");
+$search_toolbar->add($search_entry, 150);
+
+$search_button = new NTKButton("search_button", "Suchen", "document.forms['search'].submit();");
+$search_toolbar->add($search_button, 80);
+
+$search_form = new NTKForm("search", "product.php", $search_toolbar);
+$search_form->addAttribute("action", "search");
+
+$small_toolbar->add($search_form, 600);
+
+$main_box->add($small_toolbar, True, False, "background-color: #dfe7f3;");
+
+
+?>

+ 53 - 0
app/Modules/Tour/db_action.php

@@ -0,0 +1,53 @@
+<?php
+
+require_once("util.php");
+require_once("NTK/NTK.php");
+
+require_once("DataBase/Tour.php");
+require_once("DataBase/Bill.php");
+require_once("DataBase/Assistant.php");
+require_once("DataBase/Bill_Product.php");
+
+$db_action = var_get_post("db_action", "");
+
+$tour = new Tour();
+$bill = new Bill();
+$assistant = new Assistant();
+
+switch($db_action)
+{
+	case "new":
+		$tour->create(array(var_post("name", ""), var_post("assistant_id", "")));
+		break;
+	case "edit":
+		$tour->update(var_post("tour_id", ""), array(var_post("name", ""), var_post("assistant_id", "")));
+		break;
+	case "delete":
+		$tour->delete(var_get("tour_id", ""));
+		break;
+	case "tour_to_bill":
+		$tour = new Tour();
+		$tmp = $tour->get(var_get("tour_id", ""));
+		$tour_data = $tmp[0];
+
+		$bill = new Bill();
+
+		$new_bill_id = $bill->create('', array(var_post("customer_id", ""), var_post("tour_id", ""), var_post("date", ""), var_post("assistant_id", ""), -1, 0));
+
+		$bill_product = new Bill_Product();
+
+		$product = new Product();
+		$product_data = $product->get();
+
+		$result = $bill_product->getTourZusammenfassung(var_post("current_tour_id", ""), var_post("date", ""));
+
+		for($i = 0; $i < count($result); $i++)
+		{
+			$bill_product->create(array($new_bill_id, $result[$i][0], $result[$i][2], '', '', '', ''));
+		}
+
+		break;
+}
+
+
+?>

+ 34 - 0
app/Modules/Tour/edit_form.php

@@ -0,0 +1,34 @@
+<?php
+
+$table = new NTKTable("table", 2, 4, False);
+
+$name_label = new NTKLabel("", "Bezeichner:");
+$table->add($name_label, 0, 0);
+
+$name_entry = new NTKEntry("name", $data[0][1]);
+$table->add($name_entry, 0, 1);
+
+$assistant_id_label = new NTKLabel("", "Mitarbeiter:");
+$table->add($assistant_id_label, 0, 2);
+
+$assistant_id_entry = new NTKComboBox("assistant_id", $assistant->get(), $data[0][2]);
+$table->add($assistant_id_entry, 0, 3);
+
+
+$delete_button = new NTKButton("delete", "L&ouml;schen", "if(confirm('Wirklich loeschen?')) location.href = 'tour.php?db_action=delete&tour_id=".$data[0][0]."';");
+$table->add($delete_button, 1, 1);
+
+$cancel_button = new NTKButton("cancel", "Abbrechen", "location.href = 'tour.php';");
+$table->add($cancel_button, 1, 2);
+
+$submit_button = new NTKButton("submit", "Speichern", "document.forms['tour'].submit();");
+$table->add($submit_button, 1, 3);
+
+
+
+$form = new NTKForm("tour", "tour.php", $table);
+$form->addAttribute("db_action", "edit");
+$form->addAttribute("tour_id", $data[0][0]);
+$main_box->add($form, False, True, "background-color: #dfe7f3; vertical-align: middle; align: center;");
+
+?>

+ 30 - 0
app/Modules/Tour/new_form.php

@@ -0,0 +1,30 @@
+<?php
+
+$table = new NTKTable("table", 2, 4, False);
+
+$name_label = new NTKLabel("", "Bezeichner:");
+$table->add($name_label, 0, 0);
+
+$name_entry = new NTKEntry("name");
+$table->add($name_entry, 0, 1);
+$onload .= "document.getElementById('name').focus();";
+
+$assistant_id_label = new NTKLabel("", "Mitarbeiter:");
+$table->add($assistant_id_label, 0, 2);
+
+$assistant_id_entry = new NTKComboBox("assistant_id", $assistant->get());
+$table->add($assistant_id_entry, 0, 3);
+
+$cancel_button = new NTKButton("cancel", "Abbrechen", "location.href = 'tour.php';");
+$table->add($cancel_button, 1, 2);
+
+$submit_button = new NTKButton("submit", "Tour erstellen", "document.forms['tour'].submit();");
+$table->add($submit_button, 1, 3);
+
+
+$form = new NTKForm("tour", "tour.php", $table);
+$form->addAttribute("db_action", "new");
+$form->addAttribute("tour_id", "");
+$main_box->add($form, False, True, "background-color: #dfe7f3; vertical-align: middle; align: center;");
+
+?>

+ 42 - 0
app/Modules/Tour/toolbar.php

@@ -0,0 +1,42 @@
+<?php
+
+$small_toolbar = new NTKHBox("small_toolbar", 5, 0, False);
+
+$small_toolbar->add(new NTKButton("new_button", "Neue Tour eintragen", "location.replace('tour.php?action=new');"), 230, True);
+
+$small_toolbar->add($spacer);
+
+$show_toolbar = new NTKHBox("show_toolbar", 2, 0);
+
+$show_toolbar->add(new NTKLabel("show_label", "Tour:"));
+$show_toolbar->add(new NTKComboBox("tour_id", $tour->get(), ""));
+$show_toolbar->add(new NTKLabel("show_label", "Datum:"));
+
+$date = getdate(time());
+$show_toolbar->add(new NTKEntry("date", $date['year']."-".$date['mon']."-".$date['mday']), 100);
+$show_toolbar->add(new NTKButton("show_button", "Anzeigen", "document.forms['show'].submit();"));
+
+$show_form = new NTKForm("show", "tour.php", $show_toolbar);
+$show_form->addAttribute("action", "list_tour");
+
+$small_toolbar->add($show_form, 600, True);
+
+$small_toolbar->add($spacer);
+
+$search_toolbar = new NTKHBox("search_toolbar", 2, 0, False);
+
+$search_entry = new NTKEntry("search_entry");
+$search_toolbar->add($search_entry, 150);
+
+$search_button = new NTKButton("search_button", "Suchen", "document.forms['search'].submit();");
+$search_toolbar->add($search_button, 80);
+
+$search_form = new NTKForm("search", "tour.php", $search_toolbar);
+$search_form->addAttribute("action", "search");
+
+$small_toolbar->add($search_form, 240, True);
+
+$main_box->add($small_toolbar, False, False, "background-color: #dfe7f3;");
+
+
+?>

+ 43 - 0
app/Modules/Websync/BillSync.php

@@ -0,0 +1,43 @@
+<?php
+
+require_once("DataBase_Net/Bill_Net.php");
+require_once("DataBase_Net/Bill_Product_Net.php");
+require_once("DataBase/Bill.php");
+require_once("DataBase/Bill_Product.php");
+
+// sync Bill database
+$bill = new Bill();
+$bill_net = new Bill_Net();
+$bill_product = new Bill_Product();
+$bill_product_net = new Bill_Product_Net();
+
+$new_bills_count = 0;
+$new_position_count = 0;
+
+// fetch all remote bills
+$remote_bills = $bill_net->getPlainBills();
+foreach($remote_bills as $tmp)
+{
+	$new_bill_id = $bill->create("", array_slice($tmp, 1));
+	$new_bills_count++;
+	
+	// check for bill_products
+	$remote_bill_products =  $bill_product_net->getByBillId($tmp[0]);
+	foreach($remote_bill_products as $tmp1)
+	{
+		$tmp1[1] = $new_bill_id;
+		$bill_product->create(array_slice($tmp1, 1));
+		$new_position_count++;
+	}
+}
+
+$main_box->add(new NTKLabel("", "neue Rechnungen: ".$new_bills_count), 200, 0, "background-color: #dfe7f3;");
+$main_box->add(new NTKLabel("", "neue Positionen: ".$new_position_count), 200, 0, "background-color: #dfe7f3;");
+
+// now we should have added all bills let's delete them remote
+$bill_net->clearTable();
+$bill_product_net->clearTable();
+
+
+
+?>

+ 72 - 0
app/Modules/Websync/CustomerSync.php

@@ -0,0 +1,72 @@
+<?php
+
+require_once("DataBase_Net/Customer_Net.php");
+require_once("DataBase/Customer.php");
+
+// sync Customer database
+$customer = new Customer();
+$customer_net = new Customer_Net();
+
+$new_customer_count = 0;
+$del_customer_count = 0;
+
+// fetch all remote customers
+$remote_customers = $customer_net->get('', array('customer_id'));
+foreach($remote_customers as $tmp)
+{
+	if($customer->exists($tmp[0]) == false)
+	{
+		$customer_net->delete($tmp[0]);
+		$del_customer_count++;
+	}
+}
+
+$remote_customers = $customer_net->get('', array('customer_id'));
+$local_customers = $customer->get('', array('customer_id'));
+foreach($local_customers as $tmp)
+{
+	$found = false;
+	
+	foreach($remote_customers as $remote_tmp)
+	{
+		if($remote_tmp[0] == $tmp[0])
+		{
+			$found = true;
+			break;
+		}
+	}
+	
+	$tmp_data = $customer->get($tmp[0], array(	"password",
+							"prename",
+							"postname",
+							"street",
+							"streetnumber",
+							"plz",
+							"city",
+							"telephone",
+							"telefax",
+							"email",
+							"pricelist_id",
+							"tour_id",
+							"rabatt",
+							"details",
+							"bank_name",
+							"bank_account",
+							"blz"));
+	
+	if(!$found)
+	{
+		$customer_net->create($tmp[0], $tmp_data[0]);
+		$new_customer_count++;
+	}
+	else
+	{
+		$customer_net->update($tmp[0], $tmp_data[0]);
+	}
+}
+
+$main_box->add(new NTKLabel("", "neue Kunden online: ".$new_customer_count), 200, 0, "background-color: #dfe7f3;");
+$main_box->add(new NTKLabel("", "Kunden online gel&ouml;scht: ".$del_customer_count), 200, 0, "background-color: #dfe7f3;");
+
+
+?>

+ 55 - 0
app/Modules/Websync/PricesetSync.php

@@ -0,0 +1,55 @@
+<?php
+
+require_once("DataBase_Net/Priceset_Net.php");
+require_once("DataBase/Priceset.php");
+
+// sync Priceset database
+$priceset = new Priceset();
+$priceset_net = new Priceset_Net();
+
+$new_priceset_count = 0;
+$del_priceset_count = 0;
+
+$remote_pricesets = $priceset_net->get('', array('priceset_id'));
+foreach($remote_pricesets as $tmp)
+{
+	if($priceset->exists($tmp[0]) == false)
+	{
+		$priceset_net->delete($tmp[0]);
+		$del_priceset_count++;
+	}
+}
+
+$remote_pricesets = $priceset_net->get('', array('priceset_id'));
+$local_pricesets = $priceset->get('', array('priceset_id'));
+foreach($local_pricesets as $tmp)
+{
+	$found = false;
+	
+	foreach($remote_pricesets as $remote_tmp)
+	{
+		if($remote_tmp[0] == $tmp[0])
+		{
+			$found = true;
+			break;
+		}
+	}
+	
+	$tmp_data = $priceset->get($tmp[0], array(	"name",
+							"netto"));
+	
+	if(!$found)
+	{
+		$priceset_net->create($tmp[0], $tmp_data[0]);
+		$new_priceset_count++;
+	}
+	else
+	{
+		$priceset_net->update($tmp[0], $tmp_data[0]);
+	}
+}
+
+$main_box->add(new NTKLabel("", "neue Pricesets online: ".$new_priceset_count), 200, 0, "background-color: #dfe7f3;");
+$main_box->add(new NTKLabel("", "online Pricesets gel&ouml;scht: ".$del_priceset_count), 200, 0, "background-color: #dfe7f3;");
+
+?>

+ 98 - 0
app/Modules/Websync/ProductSync.php

@@ -0,0 +1,98 @@
+<?php
+
+require_once("DataBase_Net/Product_Net.php");
+require_once("DataBase/Product.php");
+require_once("DataBase_Net/Price_Net.php");
+require_once("DataBase/Price.php");
+require_once("DataBase/Priceset.php");
+
+// sync Product database
+$product = new Product();
+$product_net = new Product_Net();
+$price = new Price();
+$price_net = new Price_Net();
+$priceset = new Priceset();
+
+$new_product_count = 0;
+$del_product_count = 0;
+
+// delete remote products if not locally available anymore
+$remote_product = $product_net->get('', array('product_id'));
+foreach($remote_product as $tmp)
+{
+	if($product->exists($tmp[0], " available=1 ") == false)
+	{
+		$product_net->delete($tmp[0]);
+		
+		// delete also the prices
+		$local_pricesets = $priceset->get('');
+		foreach($local_pricesets as $tmp_priceset)
+		{
+			$tmp_price = $price_net->getPrice($tmp_priceset[0], $tmp[0]);
+			if(count($tmp_price) > 0)
+				$price_net->delete($tmp_price[0][0]);
+		}
+		$del_product_count++;
+	}
+}
+
+// add products remote if newly available locally
+$remote_products = $product_net->get('', array('product_id'));
+$local_products = $product->get('', array('product_id'), " available=1 ");
+foreach($local_products as $tmp)
+{
+	$found = false;
+	
+	foreach($remote_products as $remote_tmp)
+	{
+		if($remote_tmp[0] == $tmp[0])
+		{
+			$found = true;
+			break;
+		}
+	}
+	
+	$tmp_data = $product->get($tmp[0], array(	"name",
+							"details",
+							"category_id",
+							"tax_id",
+							"available",
+							"group_id",
+							"order_number",
+							"anmerkung"));
+	
+	if(!$found)
+	{
+		$product_net->create($tmp[0], $tmp_data[0]);
+		$new_product_count++;
+	}
+	else
+	{
+		$product_net->update($tmp[0], $tmp_data[0]);
+	}
+}
+
+$main_box->add(new NTKLabel("", "neue Produkte online: ".$new_product_count), 200, 0, "background-color: #dfe7f3;");
+$main_box->add(new NTKLabel("", "online Produkte gel&ouml;scht: ".$del_product_count), 200, 0, "background-color: #dfe7f3;");
+
+// check for prices on products
+$local_products = $product->get('', array('product_id'), " available=1 ");
+$local_pricesets = $priceset->get('');
+
+foreach($local_products as $tmp)
+{
+	foreach($local_pricesets as $tmp_priceset)
+	{
+		$tmp_price = $price->getPrice($tmp_priceset[0], $tmp[0]);
+		
+		if(count($tmp_price) <= 0)
+			continue;
+		
+		if($price_net->exists($tmp_priceset[0], $tmp[0]))
+			$price_net->update($tmp_priceset[0], $tmp[0], array_slice($tmp_price[0], 3));
+		else
+			$price_net->create($tmp_priceset[0], $tmp[0], array_slice($tmp_price[0], 3));
+	}
+}
+
+?>

+ 16 - 0
app/Modules/Websync/toolbar.php

@@ -0,0 +1,16 @@
+<?php
+
+$small_toolbar = new NTKHBox("small_toolbar", 5, 0, False);
+
+$download_button = new NTKButton("download_button", "Neue Rechnungen herunterladen", "location.replace('websync.php?action=download_0');"); //"location.replace('bill.php?action=new');");
+$small_toolbar->add($download_button, 500);
+
+$small_toolbar->add($spacer);
+
+$upload_button = new NTKButton("upload_button", "Neue Produkte / Preise online stellen", "ntk_show_splash('bitte warten ...'); location.replace('websync.php?action=upload_0');");
+$small_toolbar->add($upload_button, 500);
+
+$main_box->add($small_toolbar, True, False, "background-color: #dfe7f3;");
+
+
+?>

+ 74 - 0
app/Modules/toolbar.php

@@ -0,0 +1,74 @@
+<?php
+
+$spacer = new NTKSpacer();
+
+$toolbar_box = new NTKHBox("toolbar_box", 5, 0, False);
+
+if($page == "customer") $style = "background-color: #dfe7f3;";
+else $style = "";
+$customer_button = new NTKImageButton("customer_button", "Icons/customer.png", "Kunden", "location.replace('customer.php');", "Kunden");
+$toolbar_box->add($customer_button, 60, 60, $style);
+
+if($page == "bill") $style = "background-color: #dfe7f3;";
+else $style = "";
+$bill_button = new NTKImageButton("bill_button", "Icons/bill.png", "Rechnungen", "location.replace('bill.php');", "Rechnungen");
+$toolbar_box->add($bill_button, 60, 60, $style);
+
+if($page == "tour") $style = "background-color: #dfe7f3;";
+else $style = "";
+$tour_button = new NTKImageButton("tour_button", "Icons/tour.png", "Touren", "location.replace('tour.php');", "Touren");
+$toolbar_box->add($tour_button, 60, 60, $style);
+
+if($page == "product") $style = "background-color: #dfe7f3;";
+else $style = "";
+$product_button = new NTKImageButton("product_button", "Icons/product.png", "Produkte", "location.replace('product.php');", "Produkte");
+$toolbar_box->add($product_button, 60, 60, $style);
+
+if($page == "category") $style = "background-color: #dfe7f3;";
+else $style = "";
+$category_button = new NTKImageButton("category_button", "Icons/category.png", "Kategorien", "location.replace('category.php');", "Kategorien");
+$toolbar_box->add($category_button, 60, 60, $style);
+
+if($page == "assistant") $style = "background-color: #dfe7f3;";
+else $style = "";
+$assistant_button = new NTKImageButton("assistant_button", "Icons/assistant.png", "Mitarbeiter", "location.replace('assistant.php');", "Mitarbeiter");
+$toolbar_box->add($assistant_button, 60, 60, $style);
+
+$toolbar_box->add($spacer);
+
+if($page == "stat") $style = "background-color: #dfe7f3;";
+else $style = "";
+$sync_button = new NTKImageButton("stat_button", "Icons/stat.png", "Auswertungen", "parent.location.replace('stat.php');", "Auswertungen");
+$toolbar_box->add($sync_button, 60, 60, $style);
+
+if($printfile != "")
+{
+	$print_button = new NTKImageButton("print_button", "Icons/print.png", "Drucken", "window.open('".$printfile."', '', '');", "aktuelle Seite drucken");
+	$toolbar_box->add($print_button, 60, 60, "background-color: #dfe7f3;");
+}
+else
+{
+// 	$print_button = new NTKImageButton("print_button", "Icons/print.png", "Drucken", "window.open('print.php', '', '');", "Druckerdialog");
+// 	$toolbar_box->add($print_button, 60, 60);
+}
+
+if($page == "sync") $style = "background-color: #dfe7f3;";
+else $style = "";
+$sync_button = new NTKImageButton("sync_button", "Icons/backup.png", "Datensicherung", "location.replace('backup.php');", "Datensicherung");
+$toolbar_box->add($sync_button, 60, 60, $style);
+
+if($page == "configuration") $style = "background-color: #dfe7f3;";
+else $style = "";
+$configuration_button = new NTKImageButton("configuration_button", "Icons/configuration.png", "Einstellungen", "location.replace('configuration.php');", "Einstellungen");
+$toolbar_box->add($configuration_button, 60, 60, $style);
+
+$toolbar_box->add($spacer);
+
+if($page == "websync") $style = "background-color: #dfe7f3;";
+else $style = "";
+$configuration_button = new NTKImageButton("websync_button", "Icons/sync.png", "Internet Synchronisation", "location.replace('websync.php');", "Internet Synchronisation");
+$toolbar_box->add($configuration_button, 60, 60, $style);
+
+$main_box->add($toolbar_box, True, False);
+
+?>

BIN
app/NTK/Icons/1downarrow.png


BIN
app/NTK/Icons/1uparrow.png


BIN
app/NTK/Icons/ascii.png


BIN
app/NTK/Icons/ascii_small.png


BIN
app/NTK/Icons/button_cancel.png


BIN
app/NTK/Icons/button_cancel_small.png


BIN
app/NTK/Icons/button_ok.png


BIN
app/NTK/Icons/filenew.png


BIN
app/NTK/Icons/fileopen.png


BIN
app/NTK/Icons/fileprint.png


BIN
app/NTK/Icons/filesave.png


BIN
app/NTK/Icons/filesaveas.png


BIN
app/NTK/Icons/folder.png


BIN
app/NTK/Icons/folder2.png


BIN
app/NTK/Icons/folder2_yellow.png


BIN
app/NTK/Icons/folder_home.png


BIN
app/NTK/Icons/goto.png


BIN
app/NTK/Icons/undo.png


Some files were not shown because too many files changed in this diff