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