summaryrefslogtreecommitdiff
path: root/manager/application/controllers/AddPointsController.php
blob: ff66f0bde7bb2e804c86716fa0eafe13b4cccf8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
 * @author Michael Tänzer
 */

class AddPointsController extends Zend_Controller_Action
{
    public function init()
    {
        /* Initialize action controller here */
    }
    
    public function indexAction()
    {
        $this->view->assurance_form = $this->getAssuranceForm();
        $this->render('index');
    }
    
    public function assuranceAction()
    {
        /* Validate form */
        if (!$this->getRequest()->isPost()) {
            return $this->_forward('index');
        }
        
        $form = $this->getAssuranceForm();
        if (!$form->isValid($_POST)) {
            $this->view->assurance_form = $form;
            return $this->render('index');
        }
        
        
        /* Form is valid -> get values and process them */
        $values = $form->getValues();
    }
    
    protected function getAssuranceForm()
    {
        $form = new Zend_Form();
        $form->setAction('/add-points/assurance')->setMethod('post');
        
        $quantity = new Zend_Form_Element_Text('quantity');
        $quantity->setRequired(true)
                ->setLabel(I18n::_('Number of Points'))
                ->addFilter(new Zend_Filter_Int())
                ->addValidator(new Zend_Validate_Between(0, 100));
        $form->addElement($quantity);
        
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel(I18n::_('Assure Me'));
        $form->addElement($submit);
        
        return $form;
    }
}