<?php
class Admins
{
    public $connLink;
    function __construct($url="../manage/connection.php")
    {
        $this->connLink=$url;
    }

    function addAdmin($name,$phone,$email,$password)
    {
        include $this->connLink;

        $add=$connect->query("INSERT INTO admin (fullname, phone, email, password, rank)
        VALUES('$name', '$phone', '$email', '$password', 'supp-admin')");
        if($add)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    function getAdmin($id)
    {
        include $this->connLink;
        $getT=$connect->query("SELECT * FROM admin WHERE id='$id'")->fetch_assoc();
        return $getT;
    }

    function getAllAdmins()
    {
        include $this->connLink;
        $teachers=array();
        $getT=$connect->query("SELECT * FROM admin");
        while($teacher=$getT->fetch_assoc())
        {
            array_push($teachers, $teacher);
        }
        return $teachers;
    }
    function findAdmin($phone)
    {
        include $this->connLink;
        $getT=$connect->query("SELECT * FROM admin WHERE phone='$phone'");
        if($getT->num_rows!=0)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    function updateAdmin($id, $name, $phone, $email, $password)
    {
        include $this->connLink;
        $update=$connect->query("UPDATE admin SET fullname='$name', phone='$phone', email='$email', password='$password' WHERE id='$id'");
        return $update;
        
    }
}
?>