<?php
	require_once 'Cliente.php';
	class ClienteDatos{
		public static function compareCliente($obj1, $obj2){
			if($obj1 == NULL || $obj2 == NULL)return false;
			$id1 = "";
			$id2 = "";
			if($obj1 instanceof Cliente){
				$id1 = $obj1->getId();
			}else{
				$id1 = $obj1->getCliente()->getId();
			}
			if($obj2 instanceof Cliente){
				$id2 = $obj2->getId();
			}else{
				$id2 = $obj2->getCliente()->getId();
			}
			if(strcmp($id1,$id2) === 0){
				return true;
			}else{
				return false;
			}
		}
		public static function getClienteById($id):Cliente{
			if($id == "-1" || $id == -1){
				return new Cliente("-1","Admin");
			}else{
				$con = getConnection();
				$query = "SELECT * FROM vicidial_user_groups WHERE user_group LIKE '".$id."%' LIMIT 1";								
				$result = sv_mysqli_query($con,$query);
				$resp = NULL;
				if($row = sv_mysqli_fetch_array($result)){
					$resp = new Cliente($id, $row["group_name"]);
				}
				sv_mysqli_close($con);
				return $resp;
			}
		}
	}
?>