<?php
// require_once('basic-function.php');
class support extends basicFunction 
{
    use table_names;

    public function create($title,$message,$user_id)
    {
        $vals = [$title,$message];
        $if_empty = $this->if_empty($vals);
        if (!$if_empty) {
            return $this->errorMsgs(1);
        }

        $unique_id = $this->rand_id();
        $date_created = $this->todayDate();
        $query = "INSERT INTO $this->support_tb VALUES (null,
        '".mysqli_real_escape_string($this->connectDb(),$unique_id)."',
        '".mysqli_real_escape_string($this->connectDb(),$unique_id)."',
        '".mysqli_real_escape_string($this->connectDb(),$user_id)."',
        '".mysqli_real_escape_string($this->connectDb(),$title)."',
        '".mysqli_real_escape_string($this->connectDb(),$message)."',
        '".mysqli_real_escape_string($this->connectDb(),1)."',
        '".mysqli_real_escape_string($this->connectDb(),0)."',
        '".mysqli_real_escape_string($this->connectDb(),$date_created)."',
        '".mysqli_real_escape_string($this->connectDb(),$date_created)."') ";
        mysqli_close($this->connectDb());
        if($this->sqlQuery($query)){
            return $this->successMsg('Ticket');
        }else{
            return $this->errorMsgs(14);
        }
    }

    public function create_Reply($title,$message,$main_id,$user_id)
    {
        $vals = [$title,$message];
        $if_empty = $this->if_empty($vals);
        if (!$if_empty) {
            return $this->errorMsgs(1);
        }

        $unique_id = $this->rand_id();
        $date_created = $this->todayDate();
        $query = "INSERT INTO $this->support_tb VALUES (null,
        '".mysqli_real_escape_string($this->connectDb(),$unique_id)."',
        '".mysqli_real_escape_string($this->connectDb(),$main_id)."',
        '".mysqli_real_escape_string($this->connectDb(),$user_id)."',
        '".mysqli_real_escape_string($this->connectDb(),$title)."',
        '".mysqli_real_escape_string($this->connectDb(),$message)."',
        '".mysqli_real_escape_string($this->connectDb(),0)."',
        '".mysqli_real_escape_string($this->connectDb(),0)."',
        '".mysqli_real_escape_string($this->connectDb(),$date_created)."',
        '".mysqli_real_escape_string($this->connectDb(),$date_created)."') ";
        mysqli_close($this->connectDb());
        if($this->sqlQuery($query)){
            return $this->successMsg3('Ticket Sent');
        }else{
            return $this->errorMsgs(14);
        }
    }
    public function create_reply_admin($title,$message,$main_id,$user_id)
    {
        $vals = [$title,$message];
        $if_empty = $this->if_empty($vals);
        if (!$if_empty) {
            return $this->errorMsgs(1);
        }

        $unique_id = $this->rand_id();
        $date_created = $this->todayDate();
        $query = "INSERT INTO $this->support_tb VALUES (null,
        '".mysqli_real_escape_string($this->connectDb(),$unique_id)."',
        '".mysqli_real_escape_string($this->connectDb(),$main_id)."',
        '".mysqli_real_escape_string($this->connectDb(),'ADMIN')."',
        '".mysqli_real_escape_string($this->connectDb(),$title)."',
        '".mysqli_real_escape_string($this->connectDb(),$message)."',
        '".mysqli_real_escape_string($this->connectDb(),0)."',
        '".mysqli_real_escape_string($this->connectDb(),0)."',
        '".mysqli_real_escape_string($this->connectDb(),$date_created)."',
        '".mysqli_real_escape_string($this->connectDb(),$date_created)."') ";
        mysqli_close($this->connectDb());
        if($this->sqlQuery($query)){
            return $this->successMsg3('Ticket Sent');
        }else{
            return $this->errorMsgs(14);
        }
    }
    
}
$support = new support();