<?php
$module_css_path = ($line_domain['theme'] != "" && $line_domain['theme'] != "default") ? ($path . ('assets/themes/' . $line_domain['theme'] . '/')) : $path;
// Hide sides
$cf_show_left_side = false;
$cf_show_right_side = false;
$member_id = isset($_SESSION['member_id']) ? intval($_SESSION['member_id']) : 0;

if($member_id > 0) {

    $_SESSION['requested_url'] = null;
    unset($_SESSION['requested_url']);

    $optres['css'][] = $module_css_path . 'amodules/jobsresumes/css/jobsresumes.css';
    $optres['js'][] = $path . 'amodules/jobsresumes/js/jobsresumes.js';

    $jr_route = "account/";

    $jr_steps = array(
        "dashboard" => array(
            "route" => "account/jobs/",
            "title" => "",
            "icon"  => "fa fa-dashboard",
            "steps" => array(
                "dashboard"
            )
        ),

        "my_jobs" => array(
            "route" => "account/jobs/",
            "title" => "My Jobs",
            "icon"  => "",
            "steps" => array(
                "my_jobs",
                "job"
            )
        ),
        "my_resume" => array(
            "route" => "account/resume/",
            "title" => "My Resume",
            "icon"  => "",
            "steps" => array(
                "my_resume",
                "resume"
            )
        ),
        /*"search_jobs" => array(
            "title" => "Search Jobs",
            "icon"  => "",
            "steps" => array(
                "search_jobs"
            )
        ),
        "search_resumes" => array(
            "title" => "Search Resumes",
            "icon"  => "",
            "steps" => array(
                "search_resumes"
            )
        ),*/
    );

    $_REQUEST['jobs_step'] = 'dashboard';
    if (isset($_REQUEST['jobs_url'])) {
        $jobs_url = str_replace(".html", "", $_REQUEST['jobs_url']);
        $jobs_url = str_replace("-", "_", $jobs_url);

        foreach ($jr_steps as $j_step => $j_data) {
            if (in_array($jobs_url, $j_data['steps'])) $_REQUEST['jobs_step'] = $j_step;
        }

    }

    ?>
    <article class="article cyprus">
        <header>
            <h1>Jobs & Resume</h1>
            <!--[/SocialShareButtons/]-->
        </header>
        <div class="article-body cyprus">
            <nav id="account-menu" class="navbar navbar-default navbar-static-top" role="navigation">
                <div class="container-fluid no-padding">
                    <div class="navbar-header">
                        <div class="navbar-brand visible-xs-block">MENU</div>
                        <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" id="navbar-menu">
                        <ul class="nav navbar-nav navbar-left no-margin">

                            <?php
                            foreach($jr_steps as $j_step=>$j_data) {
                                $j_menu_class = '';
                                $j_menu_link = $j_data['route'] . str_replace('_', '-', $j_step) . '.html';
                                $j_menu_icon = ($j_data['icon'] != "") ? '<i class="'.$j_data['icon'].'"></i> ' : '';
                                if($_REQUEST['jobs_step'] == $j_step) $j_menu_class = "active";
                                ?>
                                <li class="<?= $j_menu_class; ?>">
                                    <a href="<?php print $j_menu_link; ?>"><?=$j_menu_icon;?><label><?=$j_data['title'];?></label></a>
                                </li>
                                <?php
                            }
                            ?>
                        </ul>
                    </div>
                </div>
            </nav>

            <?php
            if($_REQUEST['jobs_step'] != 'dashboard') {
                ?>
                <div class="alert alert-warning">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    <p><i class="fa fa-warning"></i> Please be aware that any information posted here will be available
                        to the public and it will be crawled by search engines (eg. Google, Yahoo, Bing).</p>
                </div>

                <?php
            }

            $mod_include_pref = dirname(__FILE__) . "/";

            $jr_url = $jr_route;

            if(isset($_REQUEST['jobs_url']) && trim($_REQUEST['jobs_url']) != "") {
                $jobs_step = str_replace('.html', '', $_REQUEST['jobs_url']);
                $jobs_step = str_replace('-', '_', $jobs_step);
                $included_step = $mod_include_pref.$jobs_step.".php";
                //echo $included_step;
                include_once($included_step);
            }
            else {
                $included_step = $mod_include_pref.'dasboard.php';
                //echo $included_step;
                include_once($included_step);
            }
            ?>
        </div>
    </article>
    <?php
}
else {
    $_SESSION['requested_url'] = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

    $account_url = "login";
    $mod_include_pref = dirname(__FILE__) . "/../account/";

    if (file_exists($mod_include_pref . $account_url . '.php')) {
        //echo "<br>" . $mod_include_pref . $account_url . '.php';
        require_once($mod_include_pref . $account_url . '.php');
    }
}