|
|
@@ -9,12 +9,19 @@ class Customer
|
|
|
$this->db = new Database();
|
|
|
}
|
|
|
|
|
|
- function create($customer_id, $value)
|
|
|
+ function create($customer_id, $password, $prename, $postname, $street, $streetnumber, $plz, $city, $telephone, $telefax, $email, $pricelist_id, $tour_id, $rabatt, $details, $bank_name, $bank_account, $blz)
|
|
|
{
|
|
|
- $query = "INSERT INTO ".$this->db->customer_table." VALUES('".$customer_id."'";
|
|
|
- for($i = 0; $i < count($value); $i++)
|
|
|
- $query .= ", '".str_replace("'", "\'", $value[$i])."'";
|
|
|
- $query .= ")";
|
|
|
+ $customer_id = $customer_id ? $customer_id : 0;
|
|
|
+ $plz = $plz ? $plz : 0;
|
|
|
+ $pricelist_id = $pricelist_id ? $pricelist_id : 0;
|
|
|
+ $tour_id = $tour_id ? $tour_id : 0;
|
|
|
+ $rabatt = $rabatt ? $rabatt : 0;
|
|
|
+ $blz = $blz ? $blz : 0;
|
|
|
+
|
|
|
+ $query = "INSERT INTO ".$this->db->customer_table." ";
|
|
|
+ $query .= " (customer_id, password, prename, postname, street, streetnumber, plz, city, telephone, telefax, email, pricelist_id, tour_id, rabatt, details, bank_name, bank_account, blz) ";
|
|
|
+ $query .= " VALUES ";
|
|
|
+ $query .= " (".$customer_id.", '".str_replace("'", "\'", $password)."', '".str_replace("'", "\'", $prename)."', '".str_replace("'", "\'", $postname)."', '".str_replace("'", "\'", $street)."', '".str_replace("'", "\'", $streetnumber)."', ".$plz.", '".str_replace("'", "\'", $city)."', '".str_replace("'", "\'", $telephone)."', '".str_replace("'", "\'", $telefax)."', '".str_replace("'", "\'", $email)."', ".$pricelist_id.", ".$tour_id.", ".$rabatt.", '".str_replace("'", "\'", $details)."', '".str_replace("'", "\'", $bank_name)."', '".str_replace("'", "\'", $bank_account)."', ".$blz.") ";
|
|
|
|
|
|
$this->db->query($query);
|
|
|
}
|
|
|
@@ -24,37 +31,37 @@ class Customer
|
|
|
$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."'";
|
|
|
+ $query .= "postname='".str_replace("'", "\'", $value[2])."', ";
|
|
|
+ $query .= "street='".str_replace("'", "\'", $value[3])."', ";
|
|
|
+ $query .= "streetnumber='".str_replace("'", "\'", $value[4])."', ";
|
|
|
+ $query .= "plz=".$value[5].", ";
|
|
|
+ $query .= "city='".str_replace("'", "\'", $value[6])."', ";
|
|
|
+ $query .= "telephone='".str_replace("'", "\'", $value[7])."', ";
|
|
|
+ $query .= "telefax='".str_replace("'", "\'", $value[8])."', ";
|
|
|
+ $query .= "email='".str_replace("'", "\'", $value[9])."', ";
|
|
|
+ $query .= "pricelist_id=".$value[10].", ";
|
|
|
+ $query .= "tour_id=".$value[11].", ";
|
|
|
+ $query .= "rabatt=".$value[12].", ";
|
|
|
+ $query .= "details='".str_replace("'", "\'", $value[13])."', ";
|
|
|
+ $query .= "bank_name='".str_replace("'", "\'", $value[14])."', ";
|
|
|
+ $query .= "bank_account='".str_replace("'", "\'", $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'";
|
|
|
+ $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."'";
|
|
|
+ $query = "SELECT customer_id FROM ".$this->db->customer_table." WHERE customer_id=".$customer_id."";
|
|
|
|
|
|
$result = $this->db->fetchRows($this->db->query($query));
|
|
|
|
|
|
@@ -97,7 +104,7 @@ class Customer
|
|
|
$query .= " FROM ".$this->db->customer_table;
|
|
|
}
|
|
|
|
|
|
- $query .= " WHERE customer_id='".$customer_id."'";
|
|
|
+ $query .= " WHERE customer_id=".$customer_id."";
|
|
|
$query .= " ORDER BY customer_id ASC";
|
|
|
|
|
|
return $this->db->fetchRows($this->db->query($query));
|
|
|
@@ -110,7 +117,7 @@ class Customer
|
|
|
return false;
|
|
|
|
|
|
/* TODO: use hash (sha512) for password */
|
|
|
- $query = "SELECT * FROM ".$this->db->customer_table." WHERE customer_id='".$customer_id."'";
|
|
|
+ $query = "SELECT * FROM ".$this->db->customer_table." WHERE customer_id=".$customer_id."";
|
|
|
$result = $this->db->fetchRows($this->db->query($query));
|
|
|
if(count($result) == 0)
|
|
|
return false;
|