<?php

class Wizard extends PhonalisaRecord
{
    public $step;
    public $agreeTOC = 0;
    public $agreePrivacy = 0;

    public static function myAttributes()
    {
        return array(
            'step' => 'step',
            "agreeTOC" => "agreeTOC",
            'agreePrivacy' => 'agreePrivacy'
        );
    }

    public static function model($className = __CLASS__)
    {
        return parent::model($className);
    }

    public function rules()
    {
        return array(
            array(
                'step, agreeTOC, agreePrivacy',  'safe'
            ),
        );
    }

    public function getStep() {

        if ($this->step == NULL) { // case of new model!
            return 0; // return first step
        }

        return (int)$this->step;
    }
    
    public function setStep($step)
    {
        $this->step = $step;
    }
    
    public function incrementStep()
    {
        $nextStep = $this->step + 1;
        $this->setStep($nextStep);
        $this->save();
    }
    
    public function decrementStep()
    {
        $previosStep = $this->getStep() - 1;
        if ($previosStep < 0) {
            $this->setStep(0);
        } else {
            $this->setStep($previosStep);
        }
    }
    
    public function attributeLabels()
    {
        return array(
            'agreeTOC' => __('WIZARD_AGREE'),
            'agreePrivacy' => __('WIZARD_AGREE_PRIVACY')
        );
    }
        
        
}
