Construct and display the AddPoints view
authorMichael Tänzer <neo@nhng.de>
Mon, 26 Apr 2010 18:57:27 +0000 (20:57 +0200)
committerMichael Tänzer <neo@nhng.de>
Mon, 26 Apr 2010 18:57:27 +0000 (20:57 +0200)
* define input form (draft)
* create the view and make it display the form
* add a link to the view in the topNav

Signed-off-by: Michael Tänzer <neo@nhng.de>
manager/application/controllers/AddPointsController.php
manager/application/views/scripts/add-points/index.phtml [new file with mode: 0644]
manager/library/actions/ActionAddPoints.php [new file with mode: 0644]

index 89ade78..ff66f0b 100644 (file)
@@ -12,6 +12,44 @@ class AddPointsController extends Zend_Controller_Action
     
     public function indexAction()
     {
-        /* TODO */
+        $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;
     }
 }
diff --git a/manager/application/views/scripts/add-points/index.phtml b/manager/application/views/scripts/add-points/index.phtml
new file mode 100644 (file)
index 0000000..b627b78
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+/**
+ * @author Michael Tänzer
+ */
+?>
+
+<h1><?php print I18n::_('Add Assurance Points to your Account') ?></h1>
+
+<h2><?php print I18n::_('Get Points by Automated Assurance') ?></h2>
+<p><?php print I18n::_('Assign the points by doing an automated assurance '.
+    'which looks just like a normal assurance done by a real person.') ?></p>
+<p><?php print I18n::_('If you enter more than 35 points they will be split '.
+    'into multiple assurances. You can do zero point assurances.') ?></p>
+<?php print $this->assurance_form ?>
diff --git a/manager/library/actions/ActionAddPoints.php b/manager/library/actions/ActionAddPoints.php
new file mode 100644 (file)
index 0000000..ef71b2f
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+
+require_once (FWACTIONS_PATH . '/FWAction.php');
+
+class AddPoints extends FWAction {
+       /**
+        * get a list of required permissions that are needed to access this action
+        * @return array
+        */
+       public static function getRequiredPermissions() {
+               return array();
+       }
+
+       /**
+        * get a role that is required for accessing that action
+        * @return string
+        */
+       public static function getRequiredRole() {
+               return 'User';
+       }
+
+       /**
+        * sort order for top navigation
+        * @return integer
+        */
+       public static function getTopNavPrio() {
+               return 50;
+       }
+
+       /**
+        * controller to invoke
+        * @return string
+        */
+       public static function getController() {
+               return 'add-points';
+       }
+
+       /**
+        * action to invoke
+        * @return string
+        */
+       public static function getAction() {
+               return 'index';
+       }
+
+       /**
+        * get text for menu, caller is responsible for translating
+        * @return string
+        */
+       public static function getMenuText() {
+               return 'Add Points';
+       }
+}