Merge pull request #24115 from kcristiano/5.52-token
[civicrm-core.git] / CRM / Financial / Page / BatchTransaction.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17
18
19 /**
20 * Page for displaying list of financial batches
21 */
22 class CRM_Financial_Page_BatchTransaction extends CRM_Core_Page_Basic {
23 /**
24 * The action links that we need to display for the browse screen.
25 *
26 * @var array
27 */
28 public static $_links = NULL;
29 public static $_entityID;
30
31 public static $_columnHeader = NULL;
32 public static $_returnvalues = NULL;
33
34 /**
35 * Get BAO Name.
36 *
37 * @return string
38 * Classname of BAO.
39 */
40 public function getBAOName() {
41 return 'CRM_Batch_BAO_Batch';
42 }
43
44 /**
45 * Get action Links.
46 *
47 * @todo:
48 * While this function only references static self::$_links, we can't make
49 * the function static because we need to match CRM_Core_Page_Basic. Possibly
50 * the intent was caching, but there's nothing very time-consuming in here
51 * that needs it so do we even need $_links? The variable is public - a quick
52 * look doesn't seem like it's used on its own, but it's hard to fully check
53 * that.
54 *
55 * @return array
56 * (reference) of action links
57 */
58 public function &links() {
59 if (!(self::$_links)) {
60 self::$_links = [
61 'view' => [
62 'name' => ts('View'),
63 'url' => 'civicrm/contact/view/contribution',
64 'qs' => 'reset=1&id=%%contid%%&cid=%%cid%%&action=view&context=contribution&selectedChild=contribute',
65 'title' => ts('View Contribution'),
66 ],
67 'remove' => [
68 'name' => ts('Remove'),
69 'title' => ts('Remove Transaction'),
70 'extra' => 'onclick = "assignRemove( %%id%%,\'' . 'remove' . '\' );"',
71 ],
72 ];
73 }
74 return self::$_links;
75 }
76
77 /**
78 * Run the page.
79 *
80 * This method is called after the page is created. It checks for the
81 * type of action and executes that action.
82 * Finally it calls the parent's run method.
83 */
84 public function run() {
85 // get the requested action
86 // default to 'browse'
87 $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
88
89 // assign vars to templates
90 $this->assign('action', $action);
91
92 self::$_entityID = CRM_Utils_Request::retrieve('bid', 'Positive');
93 $statusID = NULL;
94 if (isset(self::$_entityID)) {
95 $statusID = CRM_Core_DAO::getFieldValue('CRM_Batch_BAO_Batch', self::$_entityID, 'status_id');
96 }
97 $breadCrumb
98 = [
99 [
100 'title' => ts('Accounting Batches'),
101 'url' => CRM_Utils_System::url('civicrm/financial/financialbatches',
102 "reset=1&batchStatus=$statusID"),
103 ],
104 ];
105
106 CRM_Utils_System::appendBreadCrumb($breadCrumb);
107 $this->edit($action, self::$_entityID);
108 return parent::run();
109 }
110
111 /**
112 * Get name of edit form.
113 *
114 * @return string
115 * Classname of edit form.
116 */
117 public function editForm() {
118 return 'CRM_Financial_Form_BatchTransaction';
119 }
120
121 /**
122 * Get edit form name.
123 *
124 * @return string
125 * name of this page.
126 */
127 public function editName() {
128 return 'Batch';
129 }
130
131 /**
132 * Get user context.
133 *
134 * @param null $mode
135 *
136 * @return string
137 * user context.
138 */
139 public function userContext($mode = NULL) {
140 return 'civicrm/batchtransaction';
141 }
142
143 }