<?php
@session_start();
function getSelectedMenuStyle($var, $val, $class, $active_class) {
	$str = '';
	if(isset($_REQUEST[$var]) && $_REQUEST[$var] == $val) {
		$str .= ' '.$class.'  '.$active_class;
	}
	else {
		$str .= ' '.$class;
	}
	return $str;
}

$optres['js'][] = $path . "assets/js/moment.min.js";
$optres['css'][] = $path . "assets/css/daterangepicker.css";
$optres['js'][] = $path . "assets/js/daterangepicker.js";
$optres['css'][] = $module_css_path . "amodules/stats/css/stats.css";
$optres['js'][] = $path . "amodules/stats/js/stats.js";

if(!isset($_REQUEST['stats_step'])) {
	$_REQUEST['stats_step'] = "my_stats_overview";
}

if(isset($_SESSION['member_id']) && $_SESSION['member_id']>0) {
	$member_id = $_SESSION['member_id'];
	$stats_overview_link = "account/my_stats.html?stats_step=my_stats_overview";
	$stats_logos_link = "account/my_stats.html?stats_step=my_stats_logos";
	$stats_banners_link = "account/my_stats.html?stats_step=my_stats_banners";
	$myaccount_link = "account/my_account.html";
}
?>


<?php
$exclude_menu_for = array(
	'pop-country-statistic',
	'pop-ip'
);
?>
<article class="article cyprus">
    <header>
        <h1>Statistics</h1>
    </header>
    <div class="article-body cyprus">
        <?php

        if(isset($_REQUEST['stats_step']) && !in_array($_REQUEST['stats_step'], $exclude_menu_for)) {
            $overview_class = $_REQUEST['stats_step'] == "my_stats_overview" ? "active" : "";
            $logos_class = $_REQUEST['stats_step'] == "my_stats_logos" ? "active" : "";
            $banners_class = $_REQUEST['stats_step'] == "my_stats_banners" ? "active" : "";

            if($_REQUEST['stats_step'] == "my_stats_analitics") {
                $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'adv';
                switch($type) {
                    case "adv":
                        $logos_class = "active";
                        break;
                    case "ban":
                        $banners_class = "active";
                        break;
                }
            }

            ?>
            <nav id="account-menu" class="navbar navbar-default navbar-static-top" role="navigation">
                <div class="container-fluid no-padding">
                    <div class="navbar-header">
                        <a class="navbar-brand" href="account/my_stats.html"><i class="fa fa-bar-chart"></i></a>
                        <button id="alu" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-menu">
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
                    </div>
                    <div class="collapse navbar-collapse out" id="navbar-menu">
                        <ul class="nav navbar-nav navbar-left no-margin">
                            <li class="<?=$overview_class;?>"><a href="<?php echo $stats_overview_link; ?>">Overview</a></li>
                            <li class="<?=$logos_class;?>"><a href="<?php echo $stats_logos_link; ?>">My Logos</a></li>
                            <li class="<?=$banners_class;?>"><a href="<?php echo $stats_banners_link; ?>">My Banners</a></li>
                            <li><a href="<?php echo $myaccount_link; ?>">My Account</a></li>
                        </ul>
                    </div>
                </div>
            </nav>
            <?php
        }
        ?>

        <?php
        // Get the modules prefix
        $dot_include = "";
        $mod_include_pref	= "amodules/";
        if(!is_dir($mod_include_pref)) {
            $mod_include_pref = "../" . $mod_include_pref;
            $dot_include = "../" . $dot_include;
            if(!is_dir($mod_include_pref)) {
                $mod_include_pref = "../" . $mod_include_pref;
                $dot_include = "../" . $dot_include;
                if(!is_dir($mod_include_pref)) {
                    $mod_include_pref = "../" . $mod_include_pref;
                    $dot_include = "../" . $dot_include;
                }
            }
        }



        if(isset($_REQUEST['stats_step'])) {
            $stats_step = $_REQUEST['stats_step'];
            $included_step = $mod_include_pref."stats/".$stats_step.".php";
            //echo $included_step;
            include_once($included_step);
        }
        else {
            $included_step = $mod_include_pref."stats/"."my_stats_overview.php";
            //echo "First time: " . $included_step;
            include_once($included_step);
        }
        ?>
    </div>
</article>
