BatchTransaction.php 4.44 KB
Newer Older
totten's avatar
totten committed
1 2 3
<?php
/*
  +--------------------------------------------------------------------+
totten's avatar
totten committed
4
  | CiviCRM version 5                                                  |
totten's avatar
totten committed
5
  +--------------------------------------------------------------------+
Seamus Lee's avatar
Seamus Lee committed
6
  | Copyright CiviCRM LLC (c) 2004-2019                                |
totten's avatar
totten committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | CiviCRM is free software; you can copy, modify, and distribute it  |
  | under the terms of the GNU Affero General Public License           |
  | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
  |                                                                    |
  | CiviCRM is distributed in the hope that it will be useful, but     |
  | WITHOUT ANY WARRANTY; without even the implied warranty of         |
  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
  | See the GNU Affero General Public License for more details.        |
  |                                                                    |
  | You should have received a copy of the GNU Affero General Public   |
  | License and the CiviCRM Licensing Exception along                  |
  | with this program; if not, contact CiviCRM LLC                     |
  | at info[AT]civicrm[DOT]org. If you have questions about the        |
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
26
 */
totten's avatar
totten committed
27 28 29 30

/**
 *
 * @package CRM
Seamus Lee's avatar
Seamus Lee committed
31
 * @copyright CiviCRM LLC (c) 2004-2019
totten's avatar
totten committed
32 33 34 35 36 37 38 39
 */


/**
 * Page for displaying list of financial batches
 */
class CRM_Financial_Page_BatchTransaction extends CRM_Core_Page_Basic {
  /**
40
   * The action links that we need to display for the browse screen.
totten's avatar
totten committed
41 42 43
   *
   * @var array
   */
44 45
  public static $_links = NULL;
  public static $_entityID;
totten's avatar
totten committed
46

47 48
  public static $_columnHeader = NULL;
  public static $_returnvalues = NULL;
totten's avatar
totten committed
49

totten's avatar
totten committed
50
  /**
51
   * Get BAO Name.
totten's avatar
totten committed
52
   *
53 54
   * @return string
   *   Classname of BAO.
totten's avatar
totten committed
55
   */
56
  public function getBAOName() {
totten's avatar
totten committed
57 58 59 60
    return 'CRM_Batch_BAO_Batch';
  }

  /**
61
   * Get action Links.
totten's avatar
totten committed
62
   *
63 64
   * @return array
   *   (reference) of action links
totten's avatar
totten committed
65
   */
66
  public function &links() {
totten's avatar
totten committed
67
    if (!(self::$_links)) {
68 69
      self::$_links = [
        'view' => [
totten's avatar
totten committed
70 71 72
          'name' => ts('View'),
          'url' => 'civicrm/contact/view/contribution',
          'qs' => 'reset=1&id=%%contid%%&cid=%%cid%%&action=view&context=contribution&selectedChild=contribute',
totten's avatar
totten committed
73
          'title' => ts('View Contribution'),
74 75
        ],
        'remove' => [
totten's avatar
totten committed
76
          'name' => ts('Remove'),
totten's avatar
totten committed
77 78
          'title' => ts('Remove Transaction'),
          'extra' => 'onclick = "assignRemove( %%id%%,\'' . 'remove' . '\' );"',
79 80
        ],
      ];
totten's avatar
totten committed
81 82 83 84 85 86 87 88 89 90 91
    }
    return self::$_links;
  }

  /**
   * Run the page.
   *
   * This method is called after the page is created. It checks for the
   * type of action and executes that action.
   * Finally it calls the parent's run method.
   */
92
  public function run() {
totten's avatar
totten committed
93
    // get the requested action
94 95
    // default to 'browse'
    $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
96

totten's avatar
totten committed
97 98
    // assign vars to templates
    $this->assign('action', $action);
99

totten's avatar
totten committed
100
    self::$_entityID = CRM_Utils_Request::retrieve('bid', 'Positive');
101
    $statusID = NULL;
totten's avatar
totten committed
102 103 104
    if (isset(self::$_entityID)) {
      $statusID = CRM_Core_DAO::getFieldValue('CRM_Batch_BAO_Batch', self::$_entityID, 'status_id');
    }
Web Access's avatar
Web Access committed
105
    $breadCrumb
106 107
      = [
        [
totten's avatar
totten committed
108 109 110
          'title' => ts('Accounting Batches'),
          'url' => CRM_Utils_System::url('civicrm/financial/financialbatches',
            "reset=1&batchStatus=$statusID"),
111 112
        ],
      ];
totten's avatar
totten committed
113 114 115 116 117 118 119

    CRM_Utils_System::appendBreadCrumb($breadCrumb);
    $this->edit($action, self::$_entityID);
    return parent::run();
  }

  /**
120
   * Get name of edit form.
totten's avatar
totten committed
121
   *
122 123
   * @return string
   *   Classname of edit form.
totten's avatar
totten committed
124
   */
125
  public function editForm() {
totten's avatar
totten committed
126 127 128 129
    return 'CRM_Financial_Form_BatchTransaction';
  }

  /**
130
   * Get edit form name.
totten's avatar
totten committed
131
   *
132 133
   * @return string
   *   name of this page.
totten's avatar
totten committed
134
   */
135
  public function editName() {
totten's avatar
totten committed
136 137 138 139 140 141
    return 'Batch';
  }

  /**
   * Get user context.
   *
Eileen McNaughton's avatar
Eileen McNaughton committed
142 143
   * @param null $mode
   *
144 145
   * @return string
   *   user context.
totten's avatar
totten committed
146
   */
totten's avatar
totten committed
147
  public function userContext($mode = NULL) {
totten's avatar
totten committed
148 149
    return 'civicrm/batchtransaction';
  }
150

totten's avatar
totten committed
151
}