<?php

require_once 'modules/admin/views/SignupView.php';
require_once 'newedge/classes/NE_PluginCollection.php';

/**
* @package Admin
*/
class Signup_6_Finish extends SignupView
{
    function dispatch()
    {
        $tPass=1;
        if ($_REQUEST['pass']==0) $tPass=0;
     if(!$this->settings->get('Signup Completion URL')){
        $this->initialize();
        $this->templateInit();

        if ($tPass == 1) {
            $strDisplay = $this->settings->get('Signup Completion Template');
            $strDisplay = str_replace('&quot;','"',$strDisplay);
            $strDisplay = str_replace('&#039;','\'',$strDisplay);
            $strTitle = $this->lang("Your order has completed successfully");
            // Setup Affiliate Plugins
            $plugins = new NE_PluginCollection('affiliates', $this->user);
            while ($plugin = $plugins->getNext()) {
                if (@$this->settings->get("plugin_".$plugin->getInternalName()."_Enabled") == 1 && isset($_SESSION['affiliate'])) {
                    $params = array();
                    $affiliateVariables = $plugin->getVariables();
                    foreach ($affiliateVariables as $key => $var) {
                        $settingname = "plugin_".$plugin->getInternalName()."_".$key;
                        $params = array_merge($params,array( $key => $this->settings->get($settingname) ));
                    }
                    $params = array_merge($params, $_SESSION['affiliate']);
                    $strDisplay .= $plugin->getImage($params);
                    unset($_SESSION['affiliate']);
                    break;
                }
            }
        } else {
            //enter text that payment was rejected
            $strDisplay = $this->settings->get('Signup Rejection Template');
            $strDisplay = str_replace('&quot;','"',$strDisplay);
            $strDisplay = str_replace('&#039;','\'',$strDisplay);
            $strTitle = $this->lang("Your order was rejected");
        }
        $strDisplay = str_replace("[COMPANYNAME]", $this->settings->get("Company Name"), $strDisplay);
        $strDisplay = str_replace("[SUPPORTEMAIL]", $this->settings->get("Support E-mail"), $strDisplay);
        $strDisplay = str_replace("[CLIENTAPPLICATIONURL]", NE_Lib::getSoftwareURL(), $strDisplay);
        $strDisplay = str_replace("[COMPANYURL]", $this->settings->get("Company URL"), $strDisplay);

        $this->showProgress($this->lang('Order Complete'),100);
        $this->tpl->assign("SIZEOFBOX","40");
        $this->tpl->assign("WIDTHOFBOX","570");
        $this->tpl->assign("SIGNUPBLOCKDESCRIPTION",$strTitle);
        $this->tpl->assign("SIGNUPBLOCKCONTENT",$strDisplay);
        $this->tpl->assign("SIGNUPBLOCKRIGHTTEXT","");
        $this->tpl->parse("BOXNOSUBMIT", "boxnosubmit");
        $this->tpl->FastPrint("BOXNOSUBMIT");

        $this->tpl->FastPrint("FOOTER");
    } else {
    		NE_Lib::redirectPage($this->settings->get('Signup Completion URL').'?succes='.$tPass);
    }
    }
}

?>
