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