Explorar o código

One more to go

Johannes Zellner %!s(int64=5) %!d(string=hai) anos
pai
achega
22bd4756d0

+ 1 - 1
website/Class/ShoppingCart.php

@@ -197,7 +197,7 @@ class ShoppingCart
 		}
 
 		$tour_data = $tour->get($customer_data[0][12]);
-		$bill_id = $bill->create($this->customer_id, $customer_data[0][12], $tour_data[0][2], -2);
+		$bill_id = $bill->create($this->customer_id, $customer_data[0][12], $tour_data[0][2], -2, date("Y-m-d"));
 
 		$list = $this->getItems();
 

+ 3 - 3
website/DataBase/Bill.php

@@ -9,9 +9,9 @@ class Bill
 		$this->db = new Database();
 	}
 
-	function create($customer_id, $tour_id, $assistant_id, $bill_number)
+	function create($customer_id, $tour_id, $assistant_id, $bill_number, $date)
 	{
-		$query = "INSERT INTO ".$this->db->bill_table." (customer_id, tour_id, date, assistant_id, bill_number, timestamp) VALUES(".$customer_id.", ".$tour_id.",CURRENT_DATE(),".$assistant_id.",".$bill_number.",CURRENT_TIMESTAMP())";
+		$query = "INSERT INTO ".$this->db->bill_table." (customer_id, tour_id, assistant_id, bill_number, timestamp, date) VALUES(".$customer_id.", ".$tour_id.",".$assistant_id.",".$bill_number.",CURRENT_TIMESTAMP(),'".$date."')";
 		$this->db->query($query);
 
 		$query = "SELECT bill_id from ".$this->db->bill_table." ORDER BY bill_id DESC";
@@ -25,7 +25,7 @@ class Bill
 		$query = "UPDATE ".$this->db->bill_table." SET ";
 		$query .= "customer_id=".$value[0].", ";
 		$query .= "tour_id=".$value[1].", ";
-		$query .= "date=".$value[2].", ";
+		$query .= "date='".$value[2]."', ";
 		$query .= "assistant_id=".$value[3].", ";
 		$query .= "bill_number=".$value[4]." ";
 

+ 25 - 3
website/DataBase/Customer.php

@@ -22,8 +22,8 @@ class Customer
 	function update($customer_id, $value)
 	{
 		$query = "UPDATE ".$this->db->customer_table." SET ";
-		$query .= "password='".$value[0]."', ";
-		$query .= "prename='".$value[1]."', ";
+		$query .= "password='".str_replace("'", "\'", $value[0])."', ";
+		$query .= "prename='".str_replace("'", "\'", $value[1])."', ";
 		$query .= "postname='".$value[2]."', ";
 		$query .= "street='".$value[3]."', ";
 		$query .= "streetnumber='".$value[4]."', ";
@@ -52,6 +52,18 @@ class Customer
 		$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 == "")
@@ -75,7 +87,17 @@ class Customer
 		}
 		else
 		{
-			$query = "SELECT * FROM ".$this->db->customer_table." WHERE customer_id='".$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;
+			}
+
+			$query .= " WHERE customer_id='".$customer_id."'";
 			$query .= " ORDER BY customer_id ASC";
 
 			return $this->db->fetchRows($this->db->query($query));

+ 0 - 107
website/app/DataBase/Bill.php

@@ -1,107 +0,0 @@
-<?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;
-	}
-}
-
-?>

+ 2 - 2
website/app/DataBase/Bill_Product.php

@@ -2,8 +2,8 @@
 
 require_once("../DataBase/database.php");
 
-require_once("DataBase/Customer.php");
-require_once("DataBase/Bill.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");

+ 0 - 108
website/app/DataBase/Customer.php

@@ -1,108 +0,0 @@
-<?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));
-		}
-	}
-}
-
-?>

+ 5 - 5
website/app/Modules/Bill/db_action.php

@@ -1,11 +1,11 @@
 <?php
 
-require_once("DataBase/Bill.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/Customer.php");
 require_once("../DataBase/Price.php");
 require_once("../DataBase/Tax.php");
 
@@ -29,15 +29,15 @@ switch($db_action)
 			$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));
+				$bill_id = $bill->create(var_post("customer_id", ""), $customer_data[0][12], $tour_data[0][2], -1, var_post("date", ""));
 			}
 			else
 			{
-				$bill_id = $bill->create(var_post("bill_id", ""), array(var_post("customer_id", ""), $customer_data[0][12], var_post("date", ""), 1, -1, 0));
+				$bill_id = $bill->create(var_post("customer_id", ""), $customer_data[0][12], 1, -1, var_post("date", ""));
 			}
 		}
 		else
-			$bill_id = $bill->create(var_post("bill_id", ""), array(var_post("customer_id", ""), '', var_post("date", ""), var_post("assistant_id", "1"), -1, 0));
+			$bill_id = $bill->create(var_post("customer_id", ""), '', var_post("assistant_id", "1"), -1, var_post("date", ""));
 		$action = "edit";
 		break;
 	case "edit":

+ 1 - 1
website/app/Modules/Customer/db_action.php

@@ -2,7 +2,7 @@
 
 require_once("util.php");
 
-require_once("DataBase/Customer.php");
+require_once("../DataBase/Customer.php");
 require_once("../DataBase/Tour.php");
 require_once("../DataBase/Priceset.php");
 

+ 1 - 1
website/app/Modules/Tour/db_action.php

@@ -4,7 +4,7 @@ require_once("util.php");
 require_once("NTK/NTK.php");
 
 require_once("../DataBase/Tour.php");
-require_once("DataBase/Bill.php");
+require_once("../DataBase/Bill.php");
 require_once("../DataBase/Assistant.php");
 require_once("DataBase/Bill_Product.php");
 

+ 2 - 2
website/app/action_customer.php

@@ -3,14 +3,14 @@
 require_once("util.php");
 require_once("NTK/NTK.php");
 
-require_once("DataBase/Customer.php");
+require_once("../DataBase/Customer.php");
 
 ?>
 
 <html>
 <head>
 	<title> Index </title>
-	
+
 <?php
 
 echo getHead();

+ 1 - 1
website/app/print.php

@@ -10,7 +10,7 @@ require_once("../DataBase/Price.php");
 require_once("../DataBase/Category.php");
 require_once("../DataBase/Tax.php");
 require_once("../DataBase/Assistant.php");
-require_once("DataBase/Bill.php");
+require_once("../DataBase/Bill.php");
 require_once("DataBase/Bill_Product.php");
 
 $group = new Group();

+ 2 - 2
website/app/print_bill.php

@@ -2,9 +2,9 @@
 
 require_once("util.php");
 
-require_once("DataBase/Bill.php");
+require_once("../DataBase/Bill.php");
 require_once("../DataBase/Assistant.php");
-require_once("DataBase/Customer.php");
+require_once("../DataBase/Customer.php");
 require_once("../DataBase/Product.php");
 require_once("DataBase/Bill_Product.php");
 require_once("../DataBase/Price.php");

+ 1 - 1
website/app/print_dialog.php

@@ -10,7 +10,7 @@ require_once("../DataBase/Price.php");
 require_once("../DataBase/Category.php");
 require_once("../DataBase/Tax.php");
 require_once("../DataBase/Assistant.php");
-require_once("DataBase/Bill.php");
+require_once("../DataBase/Bill.php");
 require_once("DataBase/Bill_Product.php");
 
 $group = new Group();

+ 1 - 1
website/app/print_tour.php

@@ -3,7 +3,7 @@
 require_once("util.php");
 
 require_once("../DataBase/Product.php");
-require_once("DataBase/Bill.php");
+require_once("../DataBase/Bill.php");
 require_once("../DataBase/Tour.php");
 require_once("DataBase/Bill_Product.php");
 

+ 1 - 1
website/app/stat_bill_merge.php

@@ -10,7 +10,7 @@ require_once("../DataBase/Price.php");
 require_once("../DataBase/Category.php");
 require_once("../DataBase/Tax.php");
 require_once("../DataBase/Assistant.php");
-require_once("DataBase/Bill.php");
+require_once("../DataBase/Bill.php");
 require_once("DataBase/Bill_Product.php");
 
 $group = new Group();

+ 1 - 1
website/app/stat_customer_list.php

@@ -3,7 +3,7 @@
 require_once("util.php");
 require_once("NTK/NTK.php");
 
-require_once("DataBase/Customer.php");
+require_once("../DataBase/Customer.php");
 require_once("../DataBase/Tour.php");
 
 $customer = new Customer();

+ 1 - 1
website/app/stat_product_date_count.php

@@ -10,7 +10,7 @@ require_once("../DataBase/Price.php");
 require_once("../DataBase/Category.php");
 require_once("../DataBase/Tax.php");
 require_once("../DataBase/Assistant.php");
-require_once("DataBase/Bill.php");
+require_once("../DataBase/Bill.php");
 require_once("DataBase/Bill_Product.php");
 
 $group = new Group();

+ 1 - 1
website/app/stat_product_list.php

@@ -10,7 +10,7 @@ require_once("../DataBase/Price.php");
 require_once("../DataBase/Category.php");
 require_once("../DataBase/Tax.php");
 require_once("../DataBase/Assistant.php");
-require_once("DataBase/Bill.php");
+require_once("../DataBase/Bill.php");
 require_once("DataBase/Bill_Product.php");
 
 $group = new Group();