<?php
	
	if( !$this->network->id ) {
		$this->redirect('home');
	}
	if( !$this->user->is_logged ) {
		$this->redirect('home');
	}
	
	$db2->query('SELECT 1 FROM users WHERE iduser="'.$this->user->id.'" AND is_network_admin=1 LIMIT 1');
	if( 0 == $db2->num_rows() ) {
		$this->redirect('dashboard');
	}
	
	
	/*************************************************************************/
	// needed before proceeding
	require_once('_all-required-language.php');
	
	$this->load_langfile('global/global.php');	
	$this->load_langfile('inside/admin.php');

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

	/*************************************************************************/

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

	$D->optionactive_admin = 6;
	$D->tabsmenu_active = 2;
	
	if (!empty($D->codad)) {
		
		$r = $this->db2->query("SELECT * FROM my_ads_plans WHERE code='".$D->codad."' LIMIT 1");
		if ($o = $this->db2->fetch_object($r)) {
			$D->plan = $o;
		} else $this->redirect($C->SITE_URL.'admin/ads/plans');

		$this->load_template('admin_ads-plans-edit.php');
	
	} else {	
		
		$listsplans = $this->db2->fetch_all('SELECT * FROM my_ads_plans ORDER BY typeaction ASC');
		$D->htmlPlans = '';
		foreach ($listsplans as $oneplan) {
			$D->plan = $oneplan;
			$D->plan->name_plan = stripslashes($D->plan->name_plan);
			$D->htmlPlans .= $this->load_template('__admin-ads-one-plan.php', FALSE);
		}
		unset($listsplans, $oneplan);
			
		$this->load_template('admin_ads-plans.php');
	}
?>