Merge pull request #16674 from alexymik/patch-2
[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 * @return array
48 * (reference) of action links
49 */
50 public function &links() {
51 if (!(self::$_links)) {
52 self::$_links = [
53 'view' => [
54 'name' => ts('View'),
55 'url' => 'civicrm/contact/view/contribution',
56 'qs' => 'reset=1&id=%%contid%%&cid=%%cid%%&action=view&context=contribution&selectedChild=contribute',
57 'title' => ts('View Contribution'),
58 ],
59 'remove' => [
60 'name' => ts('Remove'),
61 'title' => ts('Remove Transaction'),
62 'extra' => 'onclick = "assignRemove( %%id%%,\'' . 'remove' . '\' );"',
63 ],
64 ];
65 }
66 return self::$_links;
67 }
68
69 /**
70 * Run the page.
71 *
72 * This method is called after the page is created. It checks for the
73 * type of action and executes that action.
74 * Finally it calls the parent's run method.
75 */
76 public function run() {
77 // get the requested action
78 // default to 'browse'
79 $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
80
81 // assign vars to templates
82 $this->assign('action', $action);
83
84 self::$_entityID = CRM_Utils_Request::retrieve('bid', 'Positive');
85 $statusID = NULL;
86 if (isset(self::$_entityID)) {
87 $statusID = CRM_Core_DAO::getFieldValue('CRM_Batch_BAO_Batch', self::$_entityID, 'status_id');
88 }
89 $breadCrumb
90 = [
91 [
92 'title' => ts('Accounting Batches'),
93 'url' => CRM_Utils_System::url('civicrm/financial/financialbatches',
94 "reset=1&batchStatus=$statusID"),
95 ],
96 ];
97
98 CRM_Utils_System::appendBreadCrumb($breadCrumb);
99 $this->edit($action, self::$_entityID);
100 return parent::run();
101 }
102
103 /**
104 * Get name of edit form.
105 *
106 * @return string
107 * Classname of edit form.
108 */
109 public function editForm() {
110 return 'CRM_Financial_Form_BatchTransaction';
111 }
112
113 /**
114 * Get edit form name.
115 *
116 * @return string
117 * name of this page.
118 */
119 public function editName() {
120 return 'Batch';
121 }
122
123 /**
124 * Get user context.
125 *
126 * @param null $mode
127 *
128 * @return string
129 * user context.
130 */
131 public function userContext($mode = NULL) {
132 return 'civicrm/batchtransaction';
133 }
134
135 }