~katiekitty/+junk/solidstate

« back to all changes in this revision

Viewing changes to solidstate/branches/v0.4/manager/pages/.svn/text-base/ExecuteOrderPage.class.php.svn-base

  • Committer: root
  • Date: 2010-01-13 07:44:31 UTC
  • Revision ID: root@ds3-vamp.cs-monitor.cz.cc-20100113074431-kt8ceoeznpjg22x7
Reviving the project

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * ExecuteOrderPage.class.php
 
4
 *
 
5
 * This file contains the definition for the Execute Order Page class
 
6
 *
 
7
 * @package Pages
 
8
 * @author John Diamond <jdiamond@solid-state.org>
 
9
 * @copyright John Diamond <jdiamond@solid-state.org>
 
10
 * @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
 
11
 */
 
12
 
 
13
// Include the parent class
 
14
require_once BASE_PATH . "solidworks/Page.class.php";
 
15
 
 
16
// OrderDBO class
 
17
require_once BASE_PATH . "DBO/OrderDBO.class.php";
 
18
 
 
19
/**
 
20
 * ExecuteOrderPage
 
21
 *
 
22
 * Display an order.
 
23
 *
 
24
 * @package Pages
 
25
 * @author John Diamond <jdiamond@solid-state.org>
 
26
 */
 
27
class ExecuteOrderPage extends Page
 
28
{
 
29
  /**
 
30
   * @var OrderDBO The order
 
31
   */
 
32
  var $orderDBO = null;
 
33
 
 
34
  /**
 
35
   * Action
 
36
   *
 
37
   * Actions handled by this page:
 
38
   *   browse_accounts_action (form)
 
39
   *
 
40
   * @param string $action_name Action
 
41
   */
 
42
  function action( $action_name )
 
43
  {
 
44
    switch( $action_name )
 
45
      {
 
46
      case "execute_order":
 
47
        if( isset( $this->session['execute_order']['cancel'] ) )
 
48
          {
 
49
            $this->cancel();
 
50
          }
 
51
        elseif( isset( $this->session['execute_order']['continue'] ) )
 
52
          {
 
53
            $this->execute();
 
54
          }
 
55
        break;
 
56
 
 
57
      default:
 
58
        // No matching action, refer to base class
 
59
        parent::action( $action_name );
 
60
      }
 
61
  }
 
62
 
 
63
  /**
 
64
   * Cancel
 
65
   */
 
66
  function cancel()
 
67
  {
 
68
    $this->goto( "view_order", null, sprintf( "id=%d", $this->orderDBO->getID() ) );
 
69
  }
 
70
 
 
71
  /**
 
72
   * Execute the Order
 
73
   */
 
74
  function execute()
 
75
  {
 
76
    // Execute the order
 
77
    switch( $this->orderDBO->getAccountType() )
 
78
      {
 
79
      case "New Account":
 
80
        if( !$this->orderDBO->executeNewAccount( $this->session['execute_order']['type'],
 
81
                                                 $this->session['execute_order']['status'],
 
82
                                                 $this->session['execute_order']['billingstatus'],
 
83
                                                 $this->session['execute_order']['billingday'] ) )
 
84
          {
 
85
            fatal_error( "ExecuteOrderPage::execut()", 
 
86
                         "Failed to execute Order.  ID=" . $this->orderDBO->getID() );
 
87
          }
 
88
        break;
 
89
 
 
90
      case "Existing Account":
 
91
        if( !$this->orderDBO->execute() )
 
92
          {
 
93
            fatal_error( "ExecuteOrderPage::execut()", 
 
94
                         "Failed to execute Order.  ID=" . $this->orderDBO->getID() );
 
95
          }
 
96
        break;
 
97
 
 
98
      default:
 
99
        fatal_error( "ExecuteOrderPage::execute()",
 
100
                     "Failed to execute order: invalid account type." );
 
101
      }
 
102
        
 
103
    // Jump to the view account page
 
104
    $this->goto( "accounts_view_account", 
 
105
                 null, 
 
106
                 sprintf( "id=%d", $this->orderDBO->getAccountID() ) );
 
107
  }
 
108
 
 
109
  /**
 
110
   * Initialize the Execute Order Page
 
111
   */
 
112
  function init()
 
113
  {
 
114
    $this->orderDBO =& $this->session['orderdbo'];
 
115
    if( isset( $_GET['id'] ) )
 
116
      {
 
117
        // Retrieve the Order from the database
 
118
        $this->orderDBO = load_OrderDBO( intval( $_GET['id'] ) );
 
119
      }
 
120
 
 
121
    if( !isset( $this->orderDBO ) )
 
122
      {
 
123
        // Could not find the Order
 
124
        fatal_error( "ExecuteOrderPage::init()", 
 
125
                     "Could not load Order.  ID = " . $_GET['id'] );
 
126
      }
 
127
 
 
128
    // Set Nav vars
 
129
    $this->setNavVar( "order_id", $this->orderDBO->getID() );
 
130
 
 
131
    // Go ahead and execute if this is an existing customer
 
132
    if( $this->orderDBO->getAccountType() == "Existing Account" )
 
133
      {
 
134
        $this->execute();
 
135
      }
 
136
  }
 
137
 
 
138
  /**
 
139
   * Populate the Order Item's Table
 
140
   *
 
141
   * @return array An array of all OrderItemDBO's for this Order
 
142
   */
 
143
  function populateItemTable()
 
144
  {
 
145
    return $this->orderDBO->getAcceptedItems();
 
146
  }
 
147
}
 
148
?>
 
 
b'\\ No newline at end of file'