<?php
	if( !$this->user->is_logged ) {
		$this->redirect('home');
	}
	
	
	/*************************************************************************/
	// needed before proceeding
	require_once('_all-required-language.php');
	
	$this->load_langfile('global/global.php');	
	$this->load_langfile('inside/dashboard.php');

	/*************************************************************************/
	
	
	require_once('_all-required-dashboard.php');
	

	/*************************************************************************/
	
	$D->codad = '';
	if ($this->param('a')) $D->codad = $this->param('a');

	if (empty($D->codad)) {
		$this->redirect($C->SITE_URL.'dashboard/myads');
	} else {
		$r = $this->db2->query("SELECT * FROM my_ads WHERE status<>2 AND status_admin=0 AND iduser=".$this->user->id." AND code='".$D->codad."' LIMIT 1");
		
		if (!$obj = $this->db2->fetch_object($r)) $this->redirect($C->SITE_URL.'dashboard/myads');
		else $D->ad = $obj;

		$D->ad->headline = stripslashes($D->ad->headline);
		$D->ad->descriptionline1 = stripslashes($D->ad->descriptionline1);
		$D->ad->descriptionline2 = stripslashes($D->ad->descriptionline2);
		
		$D->htmlPlans1 = ''; // by impressions
		$D->htmlPlans2 = ''; // by clics
		
		$plans1 = $this->db2->fetch_all("SELECT * FROM my_ads_plans WHERE typeaction=1");
		foreach ($plans1 as $oneplan1) {
			$D->p = $oneplan1;
			$D->htmlPlans1 .= $this->load_template('__ads-one-plan-activate.php',FALSE);
		}
		unset($plans1, $oneplan1);

		$plans2 = $this->db2->fetch_all("SELECT * FROM my_ads_plans WHERE typeaction=2");
		foreach ($plans2 as $oneplan2) {
			$D->p = $oneplan2;
			$D->htmlPlans2 .= $this->load_template('__ads-one-plan-activate.php',FALSE);
		}
		unset($plans2, $oneplan2);
		
	}
	/*************************************************************************/

	$D->optionactive = 13;

	$this->load_template('dashboard-myads-activate.php');

?>