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

if(ADMIN_FULL == "admin" || ADMIN_RADIO == "radio") 
{
	$nav .= '&nbsp;&gt;&nbsp;<a href="index.php?action=radio">Radio Admin</a>';
	
	/******************************************************/
	/*  Radio Admin Main Page
	/******************************************************/
	if($_GET['function'] == '')
	{
		$template -> assign_block_vars("radio_main", array());
	}
/**********************************************************/
/*--------------------------------------------------------*/
/*  Station Admin Pages
/*--------------------------------------------------------*/
/**********************************************************/

	/******************************************************/
	/*  Station List Page
	/******************************************************/
	elseif($_GET['function'] == 'stationlist')
	{
		$nav .= '&nbsp;&gt;&nbsp;<a href="index.php?action=radio&function=stationlist">Station List</a>';
		$stationObj = new StationObj();
		$stationlist = $stationObj -> listStation();
		$template -> assign_block_vars("station_list", array());
		if(count($stationlist) > 0)
		{
			foreach($stationlist as $key => $value)
			{
				$template -> assign_block_vars("station_list.station", array(
					"STATION_ID" => $value->get_station_id(),
					"STATION_LETTERS" => $value->get_station_letters(),
					"STATION_CITY" => $value->get_station_city(),
					"STATION_STATE" => $value->get_station_state(),
					"STATION_CONTACT" => $value->get_station_contact(),
					"STATION_EMAIL" => $value->get_station_email(),
					"STATION_URL" => $value->get_station_url(),
					"STATION_NETWORK_LETTERS" => $value->get_station_network_letters()));
			}
		}
	}
	/******************************************************/
	/*  Station View/Edit Page
	/******************************************************/
	elseif($_GET['function'] == 'stationview' || $_GET['function'] == 'stationedit' || $_GET['function'] == 'stationadd' || $_GET['function'] == 'stationcityadd')
	{
		$nav .= '&nbsp;&gt;&nbsp;<a href="index.php?action=radio&function=stationlist">Station List</a>';
		// Add/Update Station Info in DB
		if($_POST['post_form'] == 'true' && ($_POST['stationadd'] == 'true' || $_POST['station_id'] != '') && $_POST['stationcityadd'] == '')
		{
			$stationObj = new StationObj();
			$stationObj->set_station_id($_POST['station_id']);
			$stationObj->set_station_letters($_POST['station_letters']);
			$stationObj->set_station_network($_POST['station_network']);
			$stationObj->set_station_city($_POST['station_city']);
			$stationObj->set_station_state($_POST['station_state']);
			$stationObj->set_station_country($_POST['station_country']);
			$stationObj->set_station_contact($_POST['station_contact']);
			$stationObj->set_station_email($_POST['station_email']);
			$stationObj->set_station_url($_POST['station_url']);
			$radioMsg = $stationObj->updateStation();
			
			// Update Promoter info for Station
			$promoterObj = new PromoterObj();
			$promoterList = $promoterObj->listPromoter();
			foreach($promoterList AS $key => $value)
			{
				$stationPromoterObj = new StationPromoterObj();
				$stationPromoterObj->set_station_id($stationObj->get_station_id());
				$stationPromoterObj->set_promoter_id($value->get_promoter_id());
				$permission = $stationPromoterObj->getPromoterPermission();
				if($_POST['promoter_id_'.$value->get_promoter_id()] == $value->get_promoter_id() && $permission == false)
				{
					$stationPromoterObj->set_action("insert");
					$stationPromoterObj->updatePromoterPermission();
				}
				elseif($_POST['promoter_id_'.$value->get_promoter_id()] != $value->get_promoter_id() && $permission == true)
				{
					$stationPromoterObj->set_action("remove");
					$stationPromoterObj->updatePromoterPermission();
				}
			}
			
			// Update Chart info for Station
			$chartObj = new ChartObj();
			$chartList = $chartObj->listChart();
			foreach($chartList AS $key => $value)
			{
				$stationChartObj = new StationChartObj();
				$stationChartObj->set_station_id($stationObj->get_station_id());
				$stationChartObj->set_chart_id($value->get_chart_id());
				$permission = $stationChartObj->getChartPermission();
				if($_POST['chart_id_'.$value->get_chart_id()] == $value->get_chart_id() && $permission == false)
				{
					$stationChartObj->set_action("insert");
					$stationChartObj->updateChartPermission();
				}
				elseif($_POST['chart_id_'.$value->get_chart_id()] != $value->get_chart_id() && $permission == true)
				{
					$stationChartObj->set_action("remove");
					$stationChartObj->updateChartPermission();
				}
			}
			
			$template -> assign_block_vars("radio_msg", array(
				"RADIO_MSG" => $radioMsg));
		}
		// Add a covered city to the station's coverage area
		elseif ($_POST['post_form'] == 'true' && $_POST['stationcityadd'] == 'true' && $_POST['station_id'] != '')
		{
			$nav .= '&nbsp;&gt;&nbsp;<a href="index.php?action=radio&function=stationview&station_id='.$_GET['station_id'].'">Station View</a>';
		
			$stationCityObj = new StationCityObj();
			$stationCityObj->set_station_id($_POST['station_id']);
			$stationCityObj->set_city_name($_POST['city_name']);
			$stationCityObj->set_city_st($_POST['city_state']);
			$stationCityObj->set_station_city_strength($_POST['station_city_strength']);
			$stationCityObj->set_action("insert");
			$radioMsg = $stationCityObj->updateCityPermission();
			
			$template -> assign_block_vars("radio_msg", array(
				"RADIO_MSG" => $radioMsg));
		}
		else
		{
			//  Display form to add a station
			if($_GET['function'] == 'stationadd')
			{
				$template -> assign_block_vars("station_view", array(
					"DISABLED" => " DISABLED"));
				$template -> assign_block_vars("station_view.edit", array());
				$template -> assign_block_vars("station_view.add", array());
				$stationObj2 = new StationObj();
				$stationList2 = $stationObj2->listStation();
				foreach($stationList2 as $key => $value) {
					$template -> assign_block_vars("station_view.edit.station", array(
						"STATION_ID" => $value->get_station_id(),
						"STATION_LETTERS" => $value->get_station_letters()));
				}
				
				$selected = "false";
				
				// Pull in Promoters
				$promoterObj = new PromoterObj();
				$promoterList = $promoterObj->listPromoter();
				foreach($promoterList AS $key => $value)
				{
					$template -> assign_block_vars("station_view.promoter", array(
						"PROMOTER_ID" => $value->get_promoter_id(),
						"PROMOTER_NAME" => $value->get_promoter_name()));
					$template -> assign_block_vars("station_view.promoter.edit", array());
				}
				
				// Pull in Charts
				$chartObj = new ChartObj();
				$chartList = $chartObj->listChart();
				foreach($chartList AS $key => $value)
				{
					$template -> assign_block_vars("station_view.chart", array(
						"CHART_ID" => $value->get_chart_id(),
						"CHART_NAME" => $value->get_chart_name()." - ".$value->get_chart_spin_imp()));
					$template -> assign_block_vars("station_view.chart.edit", array());
				}
			}
			elseif($_GET['station_id'] == '' && $_POST['station_id'] == '')
			{
				header("Location: index.php?action=station&function=stationlist");
			}
			else
			{	
				// Edit or View station
				$stationObj = new StationObj();
				$stationObj->set_station_id($_GET['station_id']);
				$stationObj->getStation();
				if($stationObj->get_station_letters() == '')
				{
					$template -> assign_block_vars("page_error",array());
					$template -> assign_block_vars("page_error.error_msg", array(
						"ERROR_MSG" => "No station found with the provided id.  Please try again."));
				}
				elseif ($_GET['function'] == 'stationcityadd')
				{
					$template -> assign_block_vars("station_city_add", array(
						"STATION_ID" => $stationObj->get_station_id(),
						"STATION_LETTERS" => $stationObj->get_station_letters(),
						"STATION_CITY" => $stationObj->get_station_city(),
						"STATION_STATE" => $stationObj->get_station_state(),
						"STATION_COUNTRY" => $stationObj->get_station_country(),
						"STATION_CONTACT" => $stationObj->get_station_contact(),
						"STATION_EMAIL" => $stationObj->get_station_email(),
						"STATION_URL" => $stationObj->get_station_url(),
						"STATION_NETWORK_LETTERS" => $stationObj->get_station_network_letters()));
						
					// Display Cities covered by Station
					$stationCityObj = new StationCityObj();
					$stationCityObj->set_station_id($stationObj->get_station_id());
					$stationCityList = $stationCityObj->listStationCity();
					foreach($stationCityList AS $key => $value)
					{
						$template -> assign_block_vars("station_city_add.city", array(
							"STATION_CITY_ID" => $value->get_station_city_id(),
							"CITY_NAME" => $value->get_city_name(),
							"CITY_ST" => $value->get_city_st(),
							"STATION_CITY_STRENGTH" => $value->get_station_city_strength()));
					}
						
					$stateObj = new CityObj();
					$stateList = $stateObj->listState();
					foreach($stateList AS $key => $value)
					{
						$template -> assign_block_vars("station_city_add.state", array(
								"CITY_STATE" => $value->get_city_st()));
					}
				}
				else
				{
					$template -> assign_block_vars("station_view", array(
						"STATION_ID" => $stationObj->get_station_id(),
						"STATION_LETTERS" => $stationObj->get_station_letters(),
						"STATION_NETWORK" => $stationObj->get_station_network(),
						"STATION_CITY" => $stationObj->get_station_city(),
						"STATION_STATE" => $stationObj->get_station_state(),
						"STATION_COUNTRY" => $stationObj->get_station_country(),
						"STATION_CONTACT" => $stationObj->get_station_contact(),
						"STATION_EMAIL" => $stationObj->get_station_email(),
						"STATION_URL" => $stationObj->get_station_url(),
						"STATION_NETWORK_LETTERS" => $stationObj->get_station_network_letters()));
					
					// Pull in Promoters	
					$promoterObj = new PromoterObj();
					$promoterList = $promoterObj->listPromoter();
					foreach($promoterList AS $key => $value)
					{
						// If Promoter is assigned to Station, mark it checked
						$stationPromoterObj = new StationPromoterObj();
						$stationPromoterObj->set_station_id($stationObj->get_station_id());
						$stationPromoterObj->set_promoter_id($value->get_promoter_id());
						$permission = $stationPromoterObj->getPromoterPermission();
						if($permission != true)
						{
							$checked = "";
							$imgCheck = "<img src='images/gray_x.png'>";
						}
						else
						{
							$checked = " CHECKED";
							$imgCheck = "<img src='images/grn_check.png'>";
						}
						$template -> assign_block_vars("station_view.promoter", array(
							"PROMOTER_ID" => $value->get_promoter_id(),
							"PROMOTER_NAME" => $value->get_promoter_name(),
							"CHECKED" => $checked,
							"IMGCHECK" => $imgCheck));
						
						if($_GET['function'] == 'stationedit') 
						{
							$template -> assign_block_vars("station_view.promoter.edit", array());
						}
						else
						{
							$template -> assign_block_vars("station_view.promoter.view", array());
						}
					}
					// Pull in Charts	
					$chartObj = new ChartObj();
					$chartList = $chartObj->listChart();
					foreach($chartList AS $key => $value)
					{
						// If Chart is assigned to Station, mark it checked
						$stationChartObj = new StationChartObj();
						$stationChartObj->set_station_id($stationObj->get_station_id());
						$stationChartObj->set_chart_id($value->get_chart_id());
						$permission = $stationChartObj->getChartPermission();
						if($permission != true)
						{
							$checked = "";
							$imgCheck = "<img src='images/gray_x.png'>";
						}
						else
						{
							$checked = " CHECKED";
							$imgCheck = "<img src='images/grn_check.png'>";
						}
						$template -> assign_block_vars("station_view.chart", array(
							"CHART_ID" => $value->get_chart_id(),
							"CHART_NAME" => $value->get_chart_name()." - ".$value->get_chart_spin_imp(),
							"CHECKED" => $checked,
							"IMGCHECK" => $imgCheck));
						
						if($_GET['function'] == 'stationedit') 
						{
							$template -> assign_block_vars("station_view.chart.edit", array());
						}
						else
						{
							$template -> assign_block_vars("station_view.chart.view", array());
						}
					}
					// Display Cities covered by Station
					$stationCityObj = new StationCityObj();
					$stationCityObj->set_station_id($stationObj->get_station_id());
					$stationCityList = $stationCityObj->listStationCity();
					foreach($stationCityList AS $key => $value)
					{
						$template -> assign_block_vars("station_view.city", array(
							"STATION_CITY_ID" => $value->get_station_city_id(),
							"CITY_NAME" => $value->get_city_name(),
							"CITY_ST" => $value->get_city_st(),
							"STATION_CITY_STRENGTH" => $value->get_station_city_strength()));
					}
					if($_GET['function'] == 'stationedit') 
					{
						// Displays the Edit station form
						$template -> assign_block_vars("station_view.edit", array());
						$stationObj2 = new StationObj();
						$stationList2 = $stationObj2->listStation();
						foreach($stationList2 as $key => $value) {
							if($value->get_station_id() == $stationObj->get_station_id())
							{
								$selected = " SELECTED";
							}
							else
							{
								$selected = "";
							}
							$template -> assign_block_vars("station_view.edit.station", array(
								"STATION_ID" => $value->get_station_id(),
								"STATION_LETTERS" => $value->get_station_letters(),
								"SELECTED" => $selected));
						}
						$nav .= '&nbsp;&gt;&nbsp;<a href="index.php?action=radio&function=stationview&station_id='.$_GET['station_id'].'">Station View</a>';
					}
					else
					{
						// Displays the station view
						$template -> assign_block_vars("station_view.view", array());
					}
				}
			}
		}
	}
	/******************************************************/
	/*  Station Import(from file)
	/******************************************************/
	elseif($_GET['function'] == 'stationimport')
	{
		$nav .= '&nbsp;&gt;&nbsp;<a href="index.php?action=radio&function=stationlist">Station List</a>';
		if($_POST['post_form'] == 'true' && $_POST['stationimport'] == 'true')
		{
			include(INCLUDE_PATH.'dataImport.php');
		
			$radioMsg = ImportFile("station");
			$template -> assign_block_vars("radio_msg", array(
				"RADIO_MSG" => $radioMsg));

		}
		else
		{
			$template -> assign_block_vars("station_import", array());
		}
	}
	/******************************************************/
	/*  City Import(from file)
	/******************************************************/
	elseif($_GET['function'] == 'stationcityimport')
	{
		$nav .= '&nbsp;&gt;&nbsp;<a href="index.php?action=radio&function=stationlist">Station List</a>';
		if($_POST['post_form'] == 'true' && $_POST['stationcityimport'] == 'true')
		{
			include(INCLUDE_PATH.'dataImport.php');
		
			$radioMsg = ImportFile("stationcity");
			$template -> assign_block_vars("radio_msg", array(
				"RADIO_MSG" => $radioMsg));

		}
		else
		{
			$template -> assign_block_vars("station_city_import", array());
		}
	}
	/******************************************************/
	/*  Station Del(Deactivate)
	/******************************************************/
	elseif($_GET['function'] == 'stationdel')
	{
		$nav .= '&nbsp;&gt;&nbsp;<a href="index.php?action=radio&function=stationlist">Station List</a>';
		if($_GET['station_id'] == '')
		{
			$template -> assign_block_vars("page_error",array());
			$template -> assign_block_vars("page_error.error_msg", array(
				"ERROR_MSG" => "No station provided.  Please try again."));
		}
		else
		{
			$stationObj = new StationObj();
			$stationObj->set_station_id($_GET['station_id']);
			$stationMsg = $stationObj->delStation();
			$template -> assign_block_vars("radio_msg", array(
				"RADIO_MSG" => $stationMsg));
		}
	}
	/******************************************************/
	/*  City Del(Deactivate)
	/******************************************************/
	elseif($_GET['function'] == 'stationcitydel')
	{
		$nav .= '&nbsp;&gt;&nbsp;<a href="index.php?action=radio&function=stationlist">Station List</a>';
		$nav .= '&nbsp;&gt;&nbsp;<a href="index.php?action=radio&function=stationview&station_id='.$_GET['station_id'].'">Station View</a>';
		if($_GET['city_name'] == '')
		{
			$template -> assign_block_vars("page_error",array());
			$template -> assign_block_vars("page_error.error_msg", array(
				"ERROR_MSG" => "No city provided.  Please try again."));
		}
		else
		{
			$stationCityObj = new StationCityObj();
			$stationCityObj->set_city_name($_GET['city_name']);
			$stationCityObj->set_city_st($_GET['city_st']);
			$stationCityObj->set_station_id($_GET['station_id']);
			$stationCityObj->set_action("remove");
			$station_cityMsg = $stationCityObj->updateCityPermission();
			$template -> assign_block_vars("radio_msg", array(
				"RADIO_MSG" => $station_cityMsg));
		}
	}
/**********************************************************/
/*--------------------------------------------------------*/
/*  Chart Admin Pages
/*--------------------------------------------------------*/
/**********************************************************/

	/******************************************************/
	/*  Chart List Page
	/******************************************************/
	elseif($_GET['function'] == 'chartlist')
	{
		$nav .= '&nbsp;&gt;&nbsp;<a href="index.php?action=radio&function=chartlist">Chart List</a>';
		$chartObj = new ChartObj();
		$chartlist = $chartObj -> listChart();
		$template -> assign_block_vars("chart_list", array());
		if(count($chartlist) > 0)
		{
			foreach($chartlist as $key => $value)
			{
				$template -> assign_block_vars("chart_list.chart", array(
					"CHART_ID" => $value->get_chart_id(),
					"CHART_NAME" => $value->get_chart_name()." - ".$value->get_chart_spin_imp()));
			}
		}
	}
	/******************************************************/
	/*  Chart View/Edit Page
	/******************************************************/
	elseif($_GET['function'] == 'chartview' || $_GET['function'] == 'chartedit' || $_GET['function'] == 'chartadd')
	{
		$nav .= '&nbsp;&gt;&nbsp;<a href="index.php?action=radio&function=chartlist">Chart List</a>';
		// Add/Update Chart Info in DB
		if($_POST['post_form'] == 'true' && ($_POST['chartadd'] == 'true' || $_POST['chart_id'] != ''))
		{
			$chartObj = new ChartObj();
			$chartObj->set_chart_id($_POST['chart_id']);
			$chartObj->set_chart_name($_POST['chart_name']);
			$chartObj->set_chart_spin_imp($_POST['chart_spin_imp']);
			$radioMsg = $chartObj->updateChart();
			
			$template -> assign_block_vars("radio_msg", array(
				"RADIO_MSG" => $radioMsg));
		}
		else
		{
			//  Display form to add a chart
			if($_GET['function'] == 'chartadd')
			{
				$template -> assign_block_vars("chart_view", array(
					"DISABLED" => " DISABLED"));
				$template -> assign_block_vars("chart_view.edit", array());
				$template -> assign_block_vars("chart_view.add", array());
			}
			elseif($_GET['chart_id'] == '' && $_POST['chart_id'] == '')
			{
				header("Location: index.php?action=chart&function=chartlist");
			}
			else
			{	
				// Edit or View chart
				$chartObj = new ChartObj();
				$chartObj->set_chart_id($_GET['chart_id']);
				$chartObj->getChart();
				if($chartObj->get_chart_name() == '')
				{
					$template -> assign_block_vars("page_error",array());
					$template -> assign_block_vars("page_error.error_msg", array(
						"ERROR_MSG" => "No chart found with the provided id.  Please try again."));
				}
				else
				{
					$template -> assign_block_vars("chart_view", array(
						"CHART_ID" => $chartObj->get_chart_id(),
						"CHART_NAME" => $chartObj->get_chart_name(),
						"CHART_SPIN_IMP" => $chartObj->get_chart_spin_imp(),
						"CHART_SI_SELECT_".$chartObj->get_chart_spin_imp() => " CHECKED"));
						
					$stationChartObj = new StationChartObj();
					$stationChartObj->set_chart_id($chartObj->get_chart_id());
					$stationChartList = $stationChartObj->listStationChart();
					foreach($stationChartList AS $key => $value)
					{
						$stationObj = new StationObj();
						$stationObj->set_station_id($value->get_station_id());
						$stationObj->getStation();
						$template -> assign_block_vars("chart_view.station", array(
							"STATION_ID" => $stationObj->get_station_id(),
							"STATION_LETTERS" => $stationObj->get_station_letters(),
							"STATION_CITY" => $stationObj->get_station_city(),
							"STATION_STATE" => $stationObj->get_station_state(),
							"STATION_COUNTRY" => $stationObj->get_station_country()));
					}

					if($_GET['function'] == 'chartedit') 
					{
						// Displays the Edit chart form
						$template -> assign_block_vars("chart_view.edit", array());
						$nav .= '&nbsp;&gt;&nbsp;<a href="index.php?action=radio&function=chartview&chart_id='.$_GET['chart_id'].'">Chart View</a>';
					}
					else
					{
						// Displays the chart view
						$template -> assign_block_vars("chart_view.view", array());
					}
				}
			}
		}
	}
	/******************************************************/
	/*  Chart Del(Deactivate)
	/******************************************************/
	elseif($_GET['function'] == 'chartdel')
	{
		$nav .= '&nbsp;&gt;&nbsp;<a href="index.php?action=radio&function=chartlist">Chart List</a>';
		if($_GET['chart_id'] == '')
		{
			$template -> assign_block_vars("page_error",array());
			$template -> assign_block_vars("page_error.error_msg", array(
				"ERROR_MSG" => "No chart provided.  Please try again."));
		}
		else
		{
			$chartObj = new ChartObj();
			$chartObj->set_chart_id($_GET['chart_id']);
			$chartMsg = $chartObj->delChart();
			$template -> assign_block_vars("radio_msg", array(
				"RADIO_MSG" => $chartMsg));
		}
	}
/**********************************************************/
/*--------------------------------------------------------*/
/*  Promoter Admin Pages
/*--------------------------------------------------------*/
/**********************************************************/

	/******************************************************/
	/*  Promoter List Page
	/******************************************************/
	elseif($_GET['function'] == 'promoterlist')
	{
		$nav .= '&nbsp;&gt;&nbsp;<a href="index.php?action=radio&function=promoterlist">Promoter List</a>';
		$promoterObj = new PromoterObj();
		$promoterlist = $promoterObj -> listPromoter();
		$template -> assign_block_vars("promoter_list", array());
		if(count($promoterlist) > 0)
		{
			foreach($promoterlist as $key => $value)
			{
				$template -> assign_block_vars("promoter_list.promoter", array(
					"PROMOTER_ID" => $value->get_promoter_id(),
					"PROMOTER_NAME" => $value->get_promoter_name()));
			}
		}
	}
	/******************************************************/
	/*  Promoter View/Edit Page
	/******************************************************/
	elseif($_GET['function'] == 'promoterview' || $_GET['function'] == 'promoteredit' || $_GET['function'] == 'promoteradd')
	{
		$nav .= '&nbsp;&gt;&nbsp;<a href="index.php?action=radio&function=promoterlist">Promoter List</a>';
		// Add/Update Promoter Info in DB
		if($_POST['post_form'] == 'true' && ($_POST['promoteradd'] == 'true' || $_POST['promoter_id'] != ''))
		{
			$promoterObj = new PromoterObj();
			$promoterObj->set_promoter_id($_POST['promoter_id']);
			$promoterObj->set_promoter_name($_POST['promoter_name']);
			$radioMsg = $promoterObj->updatePromoter();
			
			$template -> assign_block_vars("radio_msg", array(
				"RADIO_MSG" => $radioMsg));
		}
		else
		{
			//  Display form to add a promoter
			if($_GET['function'] == 'promoteradd')
			{
				$template -> assign_block_vars("promoter_view", array(
					"DISABLED" => " DISABLED"));
				$template -> assign_block_vars("promoter_view.edit", array());
				$template -> assign_block_vars("promoter_view.add", array());
			}
			elseif($_GET['promoter_id'] == '' && $_POST['promoter_id'] == '')
			{
				header("Location: index.php?action=promoter&function=promoterlist");
			}
			else
			{	
				// Edit or View promoter
				$promoterObj = new PromoterObj();
				$promoterObj->set_promoter_id($_GET['promoter_id']);
				$promoterObj->getPromoter();
				if($promoterObj->get_promoter_name() == '')
				{
					$template -> assign_block_vars("page_error",array());
					$template -> assign_block_vars("page_error.error_msg", array(
						"ERROR_MSG" => "No promoter found with the provided id.  Please try again."));
				}
				else
				{
					$template -> assign_block_vars("promoter_view", array(
						"PROMOTER_ID" => $promoterObj->get_promoter_id(),
						"PROMOTER_NAME" => $promoterObj->get_promoter_name()));
						
					$stationPromoterObj = new StationPromoterObj();
					$stationPromoterObj->set_promoter_id($promoterObj->get_promoter_id());
					$stationPromoterList = $stationPromoterObj->listStationPromoter();
					foreach($stationPromoterList AS $key => $value)
					{
						$stationObj = new StationObj();
						$stationObj->set_station_id($value->get_station_id());
						$stationObj->getStation();
						$template -> assign_block_vars("promoter_view.station", array(
							"STATION_ID" => $stationObj->get_station_id(),
							"STATION_LETTERS" => $stationObj->get_station_letters(),
							"STATION_CITY" => $stationObj->get_station_city(),
							"STATION_STATE" => $stationObj->get_station_state(),
							"STATION_COUNTRY" => $stationObj->get_station_country()));
					}

					if($_GET['function'] == 'promoteredit') 
					{
						// Displays the Edit promoter form
						$template -> assign_block_vars("promoter_view.edit", array());
						$nav .= '&nbsp;&gt;&nbsp;<a href="index.php?action=radio&function=promoterview&promoter_id='.$_GET['promoter_id'].'">Promoter View</a>';
					}
					else
					{
						// Displays the promoter view
						$template -> assign_block_vars("promoter_view.view", array());
					}
				}
			}
		}
	}
	/******************************************************/
	/*  Promoter Del(Deactivate)
	/******************************************************/
	elseif($_GET['function'] == 'promoterdel')
	{
		$nav .= '&nbsp;&gt;&nbsp;<a href="index.php?action=radio&function=promoterlist">Promoter List</a>';
		if($_GET['promoter_id'] == '')
		{
			$template -> assign_block_vars("page_error",array());
			$template -> assign_block_vars("page_error.error_msg", array(
				"ERROR_MSG" => "No promoter provided.  Please try again."));
		}
		else
		{
			$promoterObj = new PromoterObj();
			$promoterObj->set_promoter_id($_GET['promoter_id']);
			$promoterMsg = $promoterObj->delPromoter();
			$template -> assign_block_vars("radio_msg", array(
				"RADIO_MSG" => $promoterMsg));
		}
	}

	$template -> assign_var_from_handle('RADIO_ADMIN_PAGE', 'radioadminpage');
}
else
{
	$template -> assign_block_vars("page_error",array());
	$template -> assign_block_vars("page_error.permission", array());
}
?>