<?php
QUnit_Global::includeClass('QUnit_UI_TemplatePage');

class Affiliate_Scripts_Views_AccountSignup extends QUnit_UI_TemplatePage
{
    
    function Affiliate_Scripts_Views_AccountSignup() {
    }
            
    function process() {
        QUnit_Global::includeClass('QUnit_Countries');
        QUnit_Global::includeClass('QCore_Bl_Accounts');
        QUnit_Global::includeClass('QUnit_Messager');
        QUnit_Global::includeClass('QCore_Settings');
        QUnit_Global::includeClass('Affiliate_Scripts_Bl_AccountAddNew');
                
        if($_POST['commited'] == 'yes')
        {
            $signupAccount = QUnit_Global::newObj('Affiliate_Scripts_Bl_AccountAddNew');
            
            if($signupAccount->process() == false) {
                QUnit_Messager::setErrorMessage(L_G_CHECKFAILED);
            } else {
                QUnit_Messager::setOkMessage(L_G_SUCCESS);
                //$signup->redirect($signup->settings['Aff_affpostsignupurl']);
            }
        
        }

        $this->assign('settings', $this->getSettings());
        $this->assign('model', $this);
        $this->addContent('acct_signup');
    }
    
    function getSettings() {
        $settings = QCore_Settings::getAccountSettings(SETTINGTYPE_ACCOUNT, $_REQUEST['aid']);
        $settings = array_merge($settings, QCore_Settings::getGlobalSettings());
        return $settings;
    }
    
    function getFieldRow($code, $caption) {
        $settings = $this->getSettings();
        if($settings['Glob_acct_signup_'.$code] == "1") {
            if($settings['Glob_acct_signup_'.$code.'_mandatory'] === "true") {
                $caption = "<b>$caption</b>";
                $mandatSign = "*";
            } else {
                $mandatSign = "";
            }        
            return "<tr>\n" .
                "<td class=dir_form>$caption</td>\n" .
                "<td><input type=text name=$code size=44 value=".$_POST[$code].">$mandatSign</td>" .
                "</tr>";             
        }
    }
    
}
?>
