<?php

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

/**
* @package Admin
*/
class Signup_6_Finish extends SignupView
{
    var $permission     = '';

    function preHeaders()
    {
        if (trim($this->settings->get('Signup Completion URL')) != "") {
            $pass = ($_REQUEST['pass'] == 1)? 1 : 0;
            NE_Lib::redirectPage($this->settings->get('Signup Completion URL').'?succes='.$pass);
        }
        $this->initialize();
    }
    function dispatch()
    {
        $tPass=1;
        if ($_REQUEST['pass']==0) $tPass=0;
        if(!$this->settings->get('Signup Completion URL')){
            $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->tpl->assign("STATUS_TITLE",$strTitle);
            $this->tpl->assign("STATUS_TEXT",$strDisplay);
            $this->tpl->parse("SIGNUP_6_FINISH", "signup_6_finish");
            $this->tpl->FastPrint("SIGNUP_6_FINISH");
    
            $this->tpl->FastPrint("FOOTER");
        }
    }
}

?>
