|
@@ -9,30 +9,27 @@ class Bill
|
|
|
$this->db = new Database();
|
|
$this->db = new Database();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function create($bill_id, $value)
|
|
|
|
|
|
|
+ function create($customer_id, $tour_id, $assistant_id, $bill_number)
|
|
|
{
|
|
{
|
|
|
- $query = "INSERT INTO ".$this->db->bill_table." VALUES('".$bill_id."'";
|
|
|
|
|
- for($i = 0; $i < count($value); $i++)
|
|
|
|
|
- $query .= ", '".$value[$i]."'";
|
|
|
|
|
- $query .= ")";
|
|
|
|
|
-
|
|
|
|
|
|
|
+ $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())";
|
|
|
$this->db->query($query);
|
|
$this->db->query($query);
|
|
|
|
|
|
|
|
$query = "SELECT bill_id from ".$this->db->bill_table." ORDER BY bill_id DESC";
|
|
$query = "SELECT bill_id from ".$this->db->bill_table." ORDER BY bill_id DESC";
|
|
|
$tmp = $this->db->fetchRows($this->db->query($query));
|
|
$tmp = $this->db->fetchRows($this->db->query($query));
|
|
|
|
|
+
|
|
|
return $tmp[0][0];
|
|
return $tmp[0][0];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function update($bill_id, $value)
|
|
function update($bill_id, $value)
|
|
|
{
|
|
{
|
|
|
$query = "UPDATE ".$this->db->bill_table." SET ";
|
|
$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 .= "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."'";
|
|
|
|
|
|
|
+ $query .= "WHERE bill_id=".$bill_id."";
|
|
|
$this->db->query($query);
|
|
$this->db->query($query);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -41,16 +38,16 @@ class Bill
|
|
|
$data = $this->get($bill_id);
|
|
$data = $this->get($bill_id);
|
|
|
|
|
|
|
|
$query = "UPDATE ".$this->db->bill_table." SET ";
|
|
$query = "UPDATE ".$this->db->bill_table." SET ";
|
|
|
- $query .= "bill_number='".$this->getNextFreeNumberByAssistant($data[0][4])."' ";
|
|
|
|
|
|
|
+ $query .= "bill_number=".$this->getNextFreeNumberByAssistant($data[0][4])." ";
|
|
|
|
|
|
|
|
- $query .= "WHERE bill_id='".$bill_id."'";
|
|
|
|
|
|
|
+ $query .= "WHERE bill_id=".$bill_id."";
|
|
|
|
|
|
|
|
$this->db->query($query);
|
|
$this->db->query($query);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function delete($bill_id)
|
|
function delete($bill_id)
|
|
|
{
|
|
{
|
|
|
- $query = "DELETE FROM ".$this->db->bill_table." WHERE bill_id='$bill_id'";
|
|
|
|
|
|
|
+ $query = "DELETE FROM ".$this->db->bill_table." WHERE bill_id=".$bill_id."";
|
|
|
|
|
|
|
|
$this->db->query($query);
|
|
$this->db->query($query);
|
|
|
}
|
|
}
|
|
@@ -79,7 +76,7 @@ class Bill
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- $query = "SELECT * FROM ".$this->db->bill_table." WHERE bill_id='".$bill_id."'";
|
|
|
|
|
|
|
+ $query = "SELECT * FROM ".$this->db->bill_table." WHERE bill_id=".$bill_id."";
|
|
|
$query .= " ORDER BY bill_number ASC";
|
|
$query .= " ORDER BY bill_number ASC";
|
|
|
|
|
|
|
|
return $this->db->fetchRows($this->db->query($query));
|
|
return $this->db->fetchRows($this->db->query($query));
|
|
@@ -88,7 +85,7 @@ class Bill
|
|
|
|
|
|
|
|
function getNextFreeNumberByAssistant($assistant_id)
|
|
function getNextFreeNumberByAssistant($assistant_id)
|
|
|
{
|
|
{
|
|
|
- $query = "SELECT bill_number FROM ".$this->db->bill_table." WHERE assistant_id='".$assistant_id."' ORDER BY bill_number DESC";
|
|
|
|
|
|
|
+ $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));
|
|
$result = $this->db->fetchRows($this->db->query($query));
|
|
|
return $result[0][0]+1;
|
|
return $result[0][0]+1;
|
|
|
}
|
|
}
|