<?php

require_once 'modules/admin/views/SignupView.php';

/**
* @package Admin
*/
class Signup_0_ShowPackages extends SignupView
{
    function dispatch()
    {
        $this->initialize();
        $this->templateInit();

        if ($this->clienttype == 0 && $this->package == 0) {
             $_SESSION['AllowStep0']=true;
        }

        if (!isset($this->currency)) {
            $this->currency = '';
        }

        $this->tpl->assign("CLIENTTYPE",$this->clienttype);
        $this->tpl->assign("CURRENCY",$this->currency);
        $this->tpl->assign("DOMAIN",$this->domain);
        $this->tpl->assign("COUPONCODE",$this->couponcode);

        if ($this->package > 0) {
            $this->tpl->assign("INPUTNAME","package");
            $this->tpl->assign("INPUTVALUE",$this->package);
            $this->tpl->parse("FORM_INPUTS", "form_hidden_inputs");
        }

        if ($this->clienttype == 0 && $this->package == 0) {
            //First Time through step 0
            require_once 'modules/admin/models/PackageTypeGateway.php';
            $packageTypes = PackageTypeGateway::getDefaultPackageTypes();
            $plancount = $packageTypes->getNumItems();

            //might change to >1 in the event that I want to automatically forward to the next section
            if ($plancount > 0) {
                $this->showProgress($this->lang('Select hosting type.'),25);
            }

            $count=0;
            $row = 0;

            //Loop through all the packagetypes
            while($packageType = $packageTypes->fetch()) {
                $row++;
                $this->tpl->assign("SUBMITFUNCTION","SubmitStepZero");
                $this->tpl->assign("SIZEOFBOX","115");
                $this->tpl->assign("WIDTHOFBOX","326");
                $this->tpl->assign("INPUTNAME","clienttype");
                $this->tpl->assign("INPUTVALUE", $packageType->getId());
                $this->tpl->assign("SIGNUPBLOCKDESCRIPTION",$packageType->getName());
                $this->tpl->assign("SIGNUPBLOCKCONTENT",$packageType->getDescription());
                $this->tpl->parse("BOXSUBMIT", "boxsubmit");
                $this->tpl->parse("TD_STEP0", ".td_step0");
                if (++$count == 2 || $row == $plancount) { //if true add tr
                    $this->tpl->parse("TR_STEP0", ".tr_step0");
                    $this->tpl->clear_dynamic("td_step0");
                    $count = 0;
                }
            }//end while loop

            $this->tpl->parse("TABLES_STEP0", "tables_step0");
        }

        $this->tpl->parse("FORMSTEP0", "formstep0");
        $this->tpl->FastPrint("FORMSTEP0");

        $this->tpl->FastPrint("FOOTER");
    }
}

?>
