<?
if (!defined('IN_BANDTOPIA'))
{
	exit;
}

class ArtistObj
{
	/*************************************************************/
	/* List Artists
	/*************************************************************/
	public function ArtistList()
	{
		$query = <<<EOD
			SELECT
				*
			FROM
				Artists AS a
			INNER JOIN 
				Accounts AS ac
					ON ac.AccountId = a.AccountId
EOD;
		if(isset($this->StatusId))
		{
			$query .= " AND ac.StatusId = {$this->StatusId} ";
		}
		$query .= " ORDER BY a.Name ";
				
		$result = mysql_query($query) or die(mysql_error()."<br>$query");
		$artistArray = array();
		while($row = mysql_fetch_assoc($result)) {
			$tempObj = new ArtistObj;
			$tempObj -> ArtistId($row['ArtistId']);
			$tempObj -> AccountId($row['AccountId']);
			$tempObj -> Name($row['Name']);
			$tempObj -> Bio($row['Bio']);
			$tempObj -> Email($row['Email']);
			$tempObj -> Phone($row['Phone']);
			$tempObj -> URL($row['URL']);
			$tempObj -> Address($row['Address']);
			$tempObj -> City($row['City']);
			$tempObj -> State($row['State']);
			$tempObj -> Zip($row['Zip']);
			$tempObj -> Active($row['Active']);
			$artistArray[] = $tempObj;
		}
		return $artistArray;
	}
	
	/*************************************************************/
	/* Get Artist
	/*************************************************************/
	public function GetArtist()
	{
		$query = <<<EOD
			SELECT
				*
			FROM
				Artists AS a
			WHERE
				a.ArtistId = {$this->int_ArtistId}
EOD;
		$result = mysql_query($query) or die(mysql_error()."<br>$query");
		$row = mysql_fetch_assoc($result);
		$this -> set_ArtistId($row['ArtistId']);
		$this -> set_Name($row['Name']);
		$this -> set_Bio($row['Bio']);
		$this -> set_Email($row['Email']);
		$this -> set_Phone($row['Phone']);
		$this -> set_URL($row['URL']);
		$this -> set_Address($row['Address']);
		$this -> set_City($row['City']);
		$this -> set_State($row['State']);
		$this -> set_Zip($row['Zip']);
		$this -> set_Active($row['Active']);
	}
	
	/*************************************************************/
	/* Update Artist
	/*************************************************************/
	public function updateArtist()
	{
		if($this->int_ArtistId != '')
		{
			$query = <<<EOD
				UPDATE
					Artists
				SET
					Name = '{$this->int_Name}',
					Bio = '{$this->int_Bio}',
					Email = '{$this->int_Email}',
					Phone = '{$this->int_Phone}',
					URL = '{$this->int_URL}',
					Address = '{$this->int_Address}',
					City = '{$this->int_City}',
					State = '{$this->int_State}',
					Zip = '{$this->int_Zip}'
				WHERE
					ArtistId = {$this->int_ArtistId}
EOD;
			$result = mysql_query($query);
			$artistMsg = "Artist information has successfully updated.";
		}
		else
		{
			$query = <<<EOD
				INSERT INTO
					Artists
					(
					 	Name, 
						Bio, 
						Email,
						Phone,
						URL,
						Address,
						City,
						State,
						Active
					)
				VALUES
					(
					 	'{$this->int_Name}',
						'{$this->int_Bio}',
						'{$this->int_Email}',
						'{$this->int_Phone}',
						'{$this->int_URL}',
						'{$this->int_Address}',
						'{$this->int_City}',
						'{$this->int_State}',
						1
					)
EOD;
			$result = mysql_query($query) or die(mysql_error()."<br>$query");
			$this->int_ArtistId = mysql_insert_id();
			
			$query = <<<EOD
				INSERT INTO
					ArtistUsers
					(
						ArtistId,
						UserId
					)
				VALUES
					(
						{$this->int_ArtistId},
						{$this->int_UserId}
					)
EOD;
			$result = mysql_query($query);
			$artistMsg = "Artist has been added successfully.";
		}
		if(mysql_error() != '') {
			$artistMsg = "An error has occurred while attempting your request.  Please try again.  If you continue to experience problems, please contact the site administrator<br>";
			$artistMsg .= mysql_error()."<br>$query";
		}
		return $artistMsg;
	}
	
	/*************************************************************/
	/* Delete(Deactivate) Artist
	/*************************************************************/
	public function delArtist()
	{
		$query = <<<EOD
			UPDATE
				Artists
			SET
				Active = 0
			WHERE
				ArtistId = {$this->int_ArtistId}
EOD;
		$artistMsg = "Artist has successfully been removed.  If this was done in error, please contact your website administrator.";
		$result = mysql_query($query);
		if(mysql_error() != '') {
			$artistMsg = "An error has occurred while attempting your request.  Please try again.  If you continue to experience problems, please contact the site administrator<br>";
			$artistMsg .= mysql_error()."<br>$query";
		}
		return $artistMsg;
	}
	
	
	// Get Artist Id
	public function get_ArtistId()
	{
		return $this->int_ArtistId;
	}
	// Set Artist Id
	public function set_ArtistId($value)
	{
		$this->int_ArtistId = $value;
	}
	
	// Get Artist name
	public function get_Name()
	{
		return $this->int_Name;
	}
	// Set Artist Name
	public function set_Name($value)
	{
		$this->int_Name = $value;
	}
	
	// Get Artist Band
	public function get_artist_band()
	{
		return $this->int_artist_band;
	}
	// Set Artist_band
	public function set_artist_band($value)
	{
		if($value == '')
		{
			$value = 0;
		}
		$this->int_artist_band = $value;
	}
	
	// Get Artist Bio
	public function get_Bio()
	{
		return $this->int_Bio;
	}
	// Set Artist Bio
	public function set_Bio($value)
	{
		$this->int_Bio = $value;
	}
	
	// Get Artist Sample Mp3
	public function get_artist_sample_mp3()
	{
		return $this->int_artist_sample_mp3;
	}
	// Set Artist Sample mp3
	public function set_artist_sample_mp3($value)
	{
		$this->int_artist_sample_mp3 = $value;
	}
	
	// Get Artist Profile Pic
	public function get_artist_profile_pic()
	{
		return $this->int_artist_profile_pic;
	}
	// Set Artist Profile Pic
	public function set_artist_profile_pic($value)
	{
		$this->int_artist_profile_pic = $value;
	}
	
	// Get Artist Banner
	public function get_artist_banner()
	{
		return $this->int_artist_banner;
	}
	// Set Artist Banner
	public function set_artist_banner($value)
	{
		$this->int_artist_banner = $value;
	}
	
	//Get Artist Email
	public function get_Email()
	{
		return $this->int_Email;
	}
	// Set Artist Email
	public function set_Email($value)
	{
		$this->int_Email = $value;
	}
	
	// Get Artist Phone
	public function get_Phone()
	{
		return $this->int_Phone;
	}
	// Set Artist Phone
	public function set_Phone($value)
	{
		$this->int_Phone = $value;
	}
	
	// Get Artist URL
	public function get_URL()
	{
		return $this->int_URL;
	}
	// Set Artist URL
	public function set_URL($value)
	{
		$this->int_URL = $value;
	}
	
	// Get Artist MySpace
	public function get_artist_myspace()
	{
		return $this->int_artist_myspace;
	}
	// Set Artist MySpace
	public function set_artist_myspace($value)
	{
		$this->int_artist_myspace = $value;
	}
	
	// Get Artist Address
	public function get_Address()
	{
		return $this->int_Address;
	}
	// Set Artist Address
	public function set_Address($value)
	{
		$this->int_Address = $value;
	}
	
	// Get Artist City
	public function get_City()
	{
		return $this->int_City;
	}
	// Set Artist City
	public function set_City($value)
	{
		$this->int_City = $value;
	}
	
	// Get Artist State
	public function get_State()
	{
		return $this->int_State;
	}
	// Set Artist State
	public function set_State($value)
	{
		$this->int_State = $value;
	}
	
	// Get Artist Zip
	public function get_Zip()
	{
		return $this->int_Zip;
	}
	// Set Artist Zip
	public function set_Zip($value)
	{
		$this->int_Zip = $value;
	}
	
	// Get Artist Active
	public function get_Active()
	{
		return $this->int_Active;
	}
	// Set Artist Active
	public function set_Active($value)
	{
		if($value == '')
		{
			$value = 1;
		}
		$this->int_Active = $value;
	}
	
	public function get_UserId()
	{
		return $this->int_UserId;
	}
	public function set_UserId($value)
	{
		$this->int_UserId = $value;
	}

}

?>