Import from SVN (r45945, r596)
[civicrm-core.git] / CRM / Financial / Page / FinancialBatch.php
1 <?php
2
3 /*
4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.3 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2013 |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
10 | |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
19 | |
20 | You should have received a copy of the GNU Affero General Public |
21 | License and the CiviCRM Licensing Exception along |
22 | with this program; if not, contact CiviCRM LLC |
23 | at info[AT]civicrm[DOT]org. If you have questions about the |
24 | GNU Affero General Public License or the licensing of CiviCRM, |
25 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
26 +--------------------------------------------------------------------+
27 */
28
29 /**
30 *
31 * @package CRM
32 * @copyright CiviCRM LLC (c) 2004-2013
33 * $Id$
34 *
35 */
36
37 /**
38 * Page for displaying list of financial types
39 */
40 class CRM_Financial_Page_FinancialBatch extends CRM_Core_Page_Basic {
41
42 /**
43 * The action links that we need to display for the browse screen
44 *
45 * @var array
46 * @static
47 */
48 static $_links = null;
49
50 /**
51 * Get BAO Name
52 *
53 * @return string classname of BAO.
54 */
55 function getBAOName() {
56 return 'CRM_Batch_BAO_Batch';
57 }
58
59 /**
60 * Get action Links
61 *
62 * @return array (reference) of action links
63 */
64 function &links() {
65 if (!(self::$_links)) {
66 self::$_links = array();
67 }
68 return self::$_links;
69 }
70
71 /**
72 * Run the page.
73 *
74 * This method is called after the page is created. It checks for the
75 * type of action and executes that action.
76 * Finally it calls the parent's run method.
77 *
78 * @return void
79 * @access public
80 *
81 */
82 function run() {
83 $context = CRM_Utils_Request::retrieve('context', 'String', $this);
84 $this->set("context", $context);
85 // assign vars to templates
86 $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, false, 0);
87 $action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'browse'); // default to 'browse'
88
89 // what action to take ?
90 if ($action &
91 (CRM_Core_Action::UPDATE |
92 CRM_Core_Action::ADD |
93 CRM_Core_Action::CLOSE |
94 CRM_Core_Action::REOPEN |
95 CRM_Core_Action::EXPORT)) {
96 $this->edit($action, $id) ;
97 }
98 // parent run
99 return parent::run();
100 }
101
102
103 /**
104 * Get name of edit form
105 *
106 * @return string classname of edit form.
107 */
108 function editForm() {
109 return 'CRM_Financial_Form_FinancialBatch';
110 }
111
112 /**
113 * Get edit form name
114 *
115 * @return string name of this page.
116 */
117 function editName() {
118 return 'Accounting Batch';
119 }
120
121 /**
122 * Get user context.
123 *
124 * Redirect to civicrm home page when clicked on cancel button
125 *
126 * @return string user context.
127 */
128 function userContext($mode = null) {
129 $context = $this->get("context");
130 if ($mode == CRM_Core_Action::UPDATE || ($mode = CRM_Core_Action::ADD & isset($context))) {
131 return "civicrm/financial/financialbatches";
132 }
133 return 'civicrm';
134 }
135
136 function userContextParams($mode = NULL) {
137 $context = $this->get("context");
138 if ($mode == CRM_Core_Action::UPDATE || ($mode = CRM_Core_Action::ADD & isset($context))) {
139 return "reset=1&batchStatus={$context}";
140 }
141 }
142
143 }