]> git.mxchange.org Git - shipsimu.git/blobdiff - application/ship-simu/main/commands/web/class_WebShipsimuRefillCommand.php
Copyright updated, menu class added for 'home'
[shipsimu.git] / application / ship-simu / main / commands / web / class_WebShipsimuRefillCommand.php
index fb7bd40c8e71a3d88bf94ad467573bbdf7b64fa5..9bf663fc28c7c34aba933555f011be5ca209bbd3 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, this is free software
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Ship-Simu Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
@@ -59,10 +59,17 @@ class WebShipsimuRefillCommand extends BaseCommand implements Commandable {
         * @param       $requestInstance        An instance of a class with an Requestable interface
         * @param       $responseInstance       An instance of a class with an Responseable interface
         * @return      void
-        * @todo        We should add something like payment discovery here (where to withdraw, e.g. external API)
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
-               // Unfinished method
+               // Get template instance
+               $templateInstance = $responseInstance->getTemplateInstance();
+
+               // Set amount and type as variables
+               $templateInstance->assignVariable('refill_done', $requestInstance->getRequestElement('type'));
+               $templateInstance->assignVariable('amount'     , $requestInstance->getRequestElement('amount'));
+
+               // This method does currently redirect if all goes right
+               $responseInstance->redirectToConfiguredUrl('refill_page_done');
        }
 
        /**
@@ -91,11 +98,17 @@ class WebShipsimuRefillCommand extends BaseCommand implements Commandable {
                // Verify refill request
                $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('refill_request_validator_filter'));
 
+               // Construct config entry for wether automatic payment from API or waiting for approval
+               $paymentTypeConfig = sprintf("refill_request_%s_payment_type", $requestInstance->getRequestElement('type'));
+
                // Prepare a filter based on the requested type we shall refill
-               $filterName = sprintf("refill_request_%s_book_filter", $requestInstance->getRequestElement('type'));
+               $filterName = sprintf("refill_request_%s_%s_book_filter",
+                       $requestInstance->getRequestElement('type'),
+                       $this->getConfigInstance()->readConfig($paymentTypeConfig)
+               );
 
                // Now, try to load that filter
-               $controllerInstance->addPostFilter(ObjectFactory::createObjectByConfiguredName($filterName));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName($filterName));
        }
 }