<?php  
   session_start();
    if (!isset($_SESSION['initiated']))
    { 
        session_regenerate_id(true);
        $_SESSION['initiated'] = true;
        //echo "regene" . session_id();
    }
?>
  
<!DOCTYPE html>
<html>
<head> 
<?php
//include_once "vgd_logic.php";
include_once $_SERVER["DOCUMENT_ROOT"] . "/payment/payment_shared.php";
include_once $_SERVER["DOCUMENT_ROOT"] . "/editor/editor_shared.php";
include_once $_SERVER["DOCUMENT_ROOT"] . "/vgd_shared.php";
include_once $_SERVER["DOCUMENT_ROOT"] . "/vgd_logic.php";
include_once $_SERVER["DOCUMENT_ROOT"] . "/language.php";
include_once $_SERVER["DOCUMENT_ROOT"] . "/emailer.php";
include_once $_SERVER["DOCUMENT_ROOT"] . "/panel/panel_shared.php";

PutCookie();
$endoffree = test_input($_GET["endoffree"]);
$norights = test_input($_GET["norights"]);
$nordicmojo = test_input($_GET["nordicmojo"]);

$hndl = test_input($_GET["hndl"]); 
$id = test_input($_GET["id"]); 
$rmv  = test_input($_GET["rmv"]); 
$cart = test_input($_GET["cart"]);
$checkout = test_input($_GET["checkout"]);
$paypal = test_input($_GET["paypal"]);
$cnt = test_input(strtoupper($_GET["cnt"]));
$filter = test_input($_GET["filter"]);
$quiz = test_input($_GET["quiz"]);

SetFilter($filter);

$header = AddHeader(lan_pricingtitle, false, "/header2.html");
echo $header;
//nop menu HandleEdugaMenu2($_SESSION['loginname'], $_SERVER['DOCUMENT_ROOT'] . '/menu_edugametion_2025.html', "megamenu", "", '');
?>
<style>

body{

<?php    
//    echo "background-image: url('" . CDN . "img/pricing_bckvs4b.jpg');"; 
//    echo "background-image: url('" . CDN . "img/sections_back_top3.jpg');"; 
//      echo "background-image: url('" . CDN . "img/homeimage3b.jpg');"; //2,3
    
//    echo "background-image: url('img/pricing_bckvs4.jpg');"; 
//#5fc5ed;
?>
    background-color: #fff;
    background-size: 100%;
    background-repeat: no-repeat;
    background-height:640px;
        
}
</style>
<?php     
//HandleMenu($_SESSION['fname'], 'menu2_new.html', "megamenu" );
SaveStats($_SESSION["user_id"], "pricing_new", "open", $_SERVER['HTTP_REFERER']);
//include_once "vgd_logic.php";


if ($_SESSION['user_country'] == "")  
{
    $_SESSION['user_country'] = GetCountry($_SERVER['REMOTE_ADDR']);
}    
if ($_SESSION['user_country'] != "")
{
    SetCountry($_SESSION['user_country']);
}    
$currency = $_SESSION['CURRENCY_NAME'];
$currency_symbol = $_SESSION['CURRENCY_SYMBOL'];

function AddCountryIcon($countrycode)
{
    echo "<a href='/payment/pricing.php?cnt=" . $countrycode . "'>";
    echo "<img src='../img/flags/" . strtolower($countrycode) . ".svg' alt='" . $country . "' width='16' height='12' >";
    echo "</a>";
}

if (($cnt != ''))// && (IsSite('METROSITE')))
    SetCountry($cnt); 

if (($_SESSION['user_id'] == 2) || ($_SESSION['loginname'] == 'jhuhtakallio@gmail.com'))
{
    echo "For Juha only: " . $_SESSION['user_id'] . " : " . $_SESSION['user_country'] ." : " . $_SESSION['CURRENCY_NAME'];
    AddCountryIcon('FI');
    AddCountryIcon('IN');
    AddCountryIcon('US');
    AddCountryIcon('GB');
    AddCountryIcon('ID');
    AddCountryIcon('VN');
    AddCountryIcon('MY');
    AddCountryIcon('PH');
    AddCountryIcon('DE');
    AddCountryIcon('SE');
    AddCountryIcon('CA');
    AddCountryIcon('SA'); 
    AddCountryIcon('SG'); 
    echo "<br>Cart " . print_r($_SESSION['cart']);
}
$partner = test_input($_GET["partner"]);
if ($partner != "") 
{
    SetPartner($partner);
}
$onecourse = test_input($_GET["onecourse"]); 
if ($onecourse != '')
{
    CreateCartArray("," . $onecourse . ",");
}
$hndl = test_input($_GET["hndl"]); 
if ($hndl != '')
{
    ProcessCartForCourse($hndl);    
}
$rmv  = test_input($_GET["rmv"]); 
if ($rmv != '')
{
//    echo "removing " . $rmv;
    RemoveCourseFromCart($rmv);     
//    echo var_dump($_SESSION['cart']);
} 
if ($quiz != '') 
{
    SaveStats($_SESSION['user_id'], "pricing", $quiz, '', true);
} 
 
//SetCountry('PL');
$hid = test_input($_GET['hid']);
$show = test_input($_GET['show']);
$tosub = test_input($_GET['tosub']);
$notrial = test_input($_GET['notrial']);
if ($notrial == '1')
{
    ShowResultBanner(COLOR_ATTENTION, "Your trial is over");
}
$noaccess = test_input($_GET['noaccess']);
/*if ($noaccess == '1')
{
    ShowResultBanner(COLOR_ATTENTION, "<h4>Please subscribe to continue your studies!</h4>");
}*/

if (($tosub != '') && ($_SESSION['user_id'] != "") && ($_SESSION['plan'] == 2) && (CountMyCourses() < COURSES_PLAN_DIPLOMA))
{ 
    echo "Activating...";
    $conn = CreateConnection("vgd");
    $result = CreateEnrolment($conn, $tosub, $_SESSION['user_id'], $_SESSION['school'], true);
    ShowResultBanner(COLOR_SUCCESS, $result);
    CacheAccess($conn);
    CloseConnection($conn);
    echo "<script language=\"javascript\" type=\"text/javascript\">";
    echo "window.location=\"/index.php#courses\";";
    echo "</script>";
}


if ($_SESSION['user_id'] == "")
{
        if ((isset($hid)) && ($hid != "")) //login info is in the link sent in the email 
        {
            //die("Died HEre:" . $user_id . " HID:" . $hid . ":". $completed . $uncompleted . "<br><br><br><br><br><br><br>");
            //die ("USer found...". $_SESSION['user_id'] . $_SESSION['user'] ." - ". $_SESSION['cookies']);
            $conn = CreateConnection("vgd");
            $result = DoHIDLogin($conn, $hid);
            echo "<script language=\"javascript\" type=\"text/javascript\">";
            echo "window.location=\"pricing.php\";";
            echo "</script>"; 
            
        }
}

if ($_SERVER['REQUEST_METHOD'] == "POST")   
{   
    echo  "<br><br><br><br><br>posting";
    $payment_option = test_input($_POST['payment_option']);
    if ($payment_option != '')
    {
        echo  "<br><br><br><br><br>posting payment option";
        if (payment_option == 'card')
            $_SESSION['sub'] = 3;
        if (payment_option == 'paypal')
            $_SESSION['sub'] = 2;
        if (payment_option == 'razorpay')
            $_SESSION['sub'] = 1;
    } 
    else
    {
        $cartbtn = test_input($_POST['cartbtn']);
    //    $cartdiscount  = strtoupper(test_input($_POST['cart_discount']));
        $cartdiscount = strtoupper(test_input($_POST['cart_discount_button']));
    //    $cartdiscount3 = strtoupper(test_input($_POST['cart_discount_input']));
        //echo "Posting happening..." . $cartdiscount . " - " . $cartdiscount2  . " - " . $cartdiscount3;

        if ($cartbtn != '')
            $hndl = $cartbtn;

        if ($cartdiscount != '')
        {
            SetPartner($cartdiscount, false);
    //        SetCartDiscount($cartdiscount, false);
        }
    }    
}
?>

</head>
<body class="index-page">
<script>
  fbq('track', 'ViewContent');
</script>

<?php     
    
if (IsPaymentAvailableCountry() == false)
{
    echo "<br><h2 align='center'>Please contact us for volume purchases</h2>";
    echo "<h5 align='center'>Currently purchasing is available only for <a href='/promo/forcompanies.php'>Companies</a> and <a href='/promo/forinstitutes.php'>Institutes</a> in your country.</h5>";
    echo "<br>";
    HandleEdugaMenu2($_SESSION['loginname'], $_SERVER['DOCUMENT_ROOT'] . '/menu_edugametion_2025.html', "megamenu", "");
    AddContactUs($_SERVER["DOCUMENT_ROOT"] . "/promo/get_quote.html");
}
else
{
//    var_dump($_SESSION['cart']);
//    var_dump($_SESSION['cart_courses']);
    if ($hndl != '')
    {
//        echo "here " . $hndl;
        $_SESSION['cart_courses'] = [];
        ProcessCartForCourse($hndl);
//        HandleEdugaMenu($_SESSION['loginname'], $_SERVER["DOCUMENT_ROOT"] . '/menu_edugametion.html', "megamenu", "", $educator);
//        CreateCartListing(false, $hndl);
    }
    else
    if ($rmv != '')
    {
        RemoveCourseFromCart($rmv);
//        CreateCartListing();    
    }

/*
if ($_SERVER["REQUEST_METHOD"] == "POST") 
{
//    echo "POST";
    //from page parameters
    $name = test_input($_POST["name"]);
    $email = test_input($_POST["email"]);
    $subject = test_input($_POST["subject"]);
    $message = test_input($_POST["message"]);
    
//    echo $name;
//    echo $email;
//    echo $subject;
//    echo $message;
    CreateEMailSendgrid(SITEEMAIL, "Contact request from " . $email, "Name: " . $name . "<br>Email: " . $email . "<br>Subject: " . $subject. "<br>Message: ". $message, "Name: " . $name . " Email: " . $email . " Subject: " . $subject. " Message: ". $message);

}
*/ 
    
/*    if ($show == 'for_businesses')
    { 
        $file = file_get_contents($_SERVER["DOCUMENT_ROOT"] . '/payment/plans_businesses.html');
        $file = str_replace('xxxCDNxxx', CDN, $file);
        $file = str_replace('xxxSITENAMExxx', SITENAME, $file);
        $file = str_replace_first('xxxWELCOMETOxxx', xxxGREATGAMESxxx, $file);
        $file = str_replace_first('xxxTAGLINExxx', lan_tagline, $file);                
        $file = str_replace_first('COLOR_GRADIENTDARKER', COLOR_GRADIENTDARKER, $file); 
        $file = str_replace_first('COLOR_GRADIENTDARK', COLOR_GRADIENTDARK, $file); 
        echo $file;
        AddOurPartners($_SERVER['DOCUMENT_ROOT'] . '/promo/ourpartners.html');
        AddOfferQuiz();
        AddTestimonials4();   
    }    
    else*/  
    {   
        
        echo "<div class='container' style='max-width:100%;color:white;background-image: linear-gradient(" . COLOR_GRADIENTDARK . "," . COLOR_GRADIENTDARKER . ");border-radius:0px;padding:0px;'>";

        if ($_SESSION['user_country'] == 'FI')    
            AddECTSInfo($_SERVER["DOCUMENT_ROOT"] . '/promo/ECTSInfo2025.html'); //tässä filessä samoja tageja niin toimii se näinkin!
//            CreateCourseGrid4("/payment/pricing.php", $filter, false);
        else  
        {
              
            AddSubscriptionPlans2025($_SESSION['plan'], false, $hndl, $_SERVER["DOCUMENT_ROOT"] . '/payment/pricing.html', $endoffree, $noaccess); 
//            AddSubscriptionPlans2025($_SESSION['plan'], false, $hndl, $_SERVER["DOCUMENT_ROOT"] . '/payment/pricing2025_soon.html', $endoffree); 
            
//            AddSubscriptionPlans($_SESSION['plan'], false, $hndl); 
            
//            if ($_SESSION['user_id'] == "")
//                AddOfferQuiz($_SERVER['DOCUMENT_ROOT'] .  '/payment/offerquiz2024.html');
            
            
//            AddPromoSection('promo_whatyouget3.html');
            //AddPromoSection('promo_testimonials20253.html', true);
//            AddPromoSection('promo_educators.html', $showbutton);

            
            
//            $header = "<h1 align='center'>COURSES INCLUDED</h1>";
            //$header = $header . "<h4 align='center'>Price is set accordingly</h4>";
//            if (CheckIsTrialOver())
//                $header = $header . "<h3 align='center' style='color:orange'>Your trial is over!</h3>";

//            CreateCourseGrid4("/payment/pricing.php", $filter, true, $header, false);
//            echo "<br>";
//            echo "current cart:" . var_dump($_SESSION['cart']) . "<br>";
        } 

        

//        AddPreviousStudents("courseprevious2.html", false);
//        AddOfferQuiz();
//        AddCourseHow(); 
//        AddCourseCertificate();              
//        AddCourseTable();
//        AddJuha("aboutjuha_short.html");
//        AddJoin("coursejoin2.html");
//        echo CreateWhy();
/*        echo "<br>";
        echo "<div class='container' style='background-color: #ffffff'>";
        echo "<h6 align='center'  style='color:black;'>" . xxxDEALSAVAILxxx . "</h6>";
        echo "</div>";*/
        AddPricingFaq($_SERVER["DOCUMENT_ROOT"] . "/payment/pricing_faq_2025.html");  

//        if (($_SESSION['member'] < 1) && IsSuperOfferCountry())//($_SESSION['user_country'] != 'IN'))
//            AddSuperSpecialOffer();
//        AddCourseAbout();
//        AddJoin();
        echo "</div>";
    }
}
//  <a href="#" id="scroll-top" class="scroll-top d-flex align-items-center justify-content-center"><i class="bi bi-arrow-up-short"></i></a>
?>

  <!-- Preloader -->
  <div id="preloader"></div>
 
</body>

<?php
    $footer = CreateFooter("pricing.php", $_SERVER["DOCUMENT_ROOT"] . "/footer2.html");
    echo $footer;
?>

</html>

