<?php
class ComplaintDetail{
    private $conn;
    private $table_name = "`complaint_detail`";
 
	public $id;
	public $complaint_id;
	public $answer_date;
	public $answer_by;
	public $remark;
	public $answer_entry_by;
	public $answer_date_time;

    public function __construct($db){
        $this->conn = $db;
    }

	function create(){
		$query = "INSERT INTO " . $this->table_name . " SET complaint_id=:complaint_id, answer_date=:answer_date,answer_by=:answer_by,remark=:remark,answer_entry_by=:answer_entry_by,answer_date_time=:answer_date_time";
		$stmt = $this->conn->prepare($query);

		$stmt->bindParam(":complaint_id", $this->complaint_id);
		$stmt->bindParam(":answer_date", $this->answer_date);
		$stmt->bindParam(":answer_by", $this->answer_by);
		$stmt->bindParam(":remark", $this->remark);
		$stmt->bindParam(":answer_entry_by", $this->answer_entry_by);
		$stmt->bindParam(":answer_date_time", $this->answer_date_time);
		
		if($stmt->execute()){
			$this->id = $this->conn->lastInsertId();
			return true;
		}
		return false;
	}

	function getOneComplaint(){
		$query = "SELECT * FROM " . $this->table_name . " where complaint_id=:complaint_id order by id desc";
		$stmt = $this->conn->prepare( $query );
		$stmt->bindParam(":complaint_id", $this->complaint_id);
		$stmt->execute();
		return $stmt;
	}
}
?>
