Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
e7112fa7 | 6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
e7112fa7 | 31 | * @copyright CiviCRM LLC (c) 2004-2015 |
6a488035 TO |
32 | * $Id$ |
33 | * | |
34 | */ | |
35 | ||
36 | /** | |
37 | * Page for displaying list of Payment-Instrument | |
38 | */ | |
39 | class CRM_Contribute_Page_DashBoard extends CRM_Core_Page { | |
40 | ||
41 | /** | |
42 | * Heart of the viewing process. The runner gets all the meta data for | |
43 | * the contact and calls the appropriate type of page to view. | |
44 | * | |
45 | * @return void | |
6a488035 | 46 | */ |
00be9182 | 47 | public function preProcess() { |
6a488035 TO |
48 | CRM_Utils_System::setTitle(ts('CiviContribute')); |
49 | ||
353ffa53 TO |
50 | $status = array('Valid', 'Cancelled'); |
51 | $prefixes = array('start', 'month', 'year'); | |
52 | $startDate = NULL; | |
6a488035 TO |
53 | $startToDate = $monthToDate = $yearToDate = array(); |
54 | ||
55 | //get contribution dates. | |
56 | $dates = CRM_Contribute_BAO_Contribution::getContributionDates(); | |
57 | foreach (array( | |
353ffa53 TO |
58 | 'now', |
59 | 'yearDate', | |
28a04ea9 | 60 | 'monthDate', |
353ffa53 | 61 | ) as $date) { |
6a488035 TO |
62 | $$date = $dates[$date]; |
63 | } | |
acff69f0 PJ |
64 | // fiscal years end date |
65 | $yearNow = date('Ymd', strtotime('+1 year -1 day', strtotime($yearDate))); | |
66 | ||
6a488035 TO |
67 | foreach ($prefixes as $prefix) { |
68 | $aName = $prefix . 'ToDate'; | |
69 | $dName = $prefix . 'Date'; | |
70 | ||
71 | if ($prefix == 'year') { | |
72 | $now = $yearNow; | |
73 | } | |
74 | ||
106f4f2d PJ |
75 | // appending end date i.e $now with time |
76 | // to also calculate records of end date till mid-night | |
77 | $nowWithTime = $now . '235959'; | |
78 | ||
6a488035 | 79 | foreach ($status as $s) { |
106f4f2d | 80 | ${$aName}[$s] = CRM_Contribute_BAO_Contribution::getTotalAmountAndCount($s, $$dName, $nowWithTime); |
6a488035 TO |
81 | ${$aName}[$s]['url'] = CRM_Utils_System::url('civicrm/contribute/search', |
82 | "reset=1&force=1&status=1&start={$$dName}&end=$now&test=0" | |
83 | ); | |
84 | } | |
85 | ||
86 | $this->assign($aName, $$aName); | |
87 | } | |
88 | ||
89 | //for contribution tabular View | |
90 | $buildTabularView = CRM_Utils_Array::value('showtable', $_GET, FALSE); | |
91 | $this->assign('buildTabularView', $buildTabularView); | |
92 | if ($buildTabularView) { | |
93 | return; | |
94 | } | |
95 | ||
96 | // Check for admin permission to see if we should include the Manage Contribution Pages action link | |
97 | $isAdmin = 0; | |
98 | if (CRM_Core_Permission::check('administer CiviCRM')) { | |
99 | $isAdmin = 1; | |
100 | } | |
101 | $this->assign('isAdmin', $isAdmin); | |
102 | } | |
103 | ||
104 | /** | |
dc195289 | 105 | * the main function that is called when the page loads, |
6a488035 TO |
106 | * it decides the which action has to be taken for the page. |
107 | * | |
76e7a76c | 108 | * @return null |
6a488035 | 109 | */ |
00be9182 | 110 | public function run() { |
6a488035 TO |
111 | $this->preProcess(); |
112 | ||
113 | $controller = new CRM_Core_Controller_Simple('CRM_Contribute_Form_Search', | |
114 | ts('Contributions'), NULL | |
115 | ); | |
116 | $controller->setEmbedded(TRUE); | |
117 | ||
118 | $controller->set('limit', 10); | |
119 | $controller->set('force', 1); | |
120 | $controller->set('context', 'dashboard'); | |
121 | $controller->process(); | |
122 | $controller->run(); | |
123 | $chartForm = new CRM_Core_Controller_Simple('CRM_Contribute_Form_ContributionCharts', | |
124 | ts('Contributions Charts'), NULL | |
125 | ); | |
126 | ||
127 | $chartForm->setEmbedded(TRUE); | |
128 | $chartForm->process(); | |
129 | $chartForm->run(); | |
353ffa53 TO |
130 | CRM_Core_Resources::singleton() |
131 | ->addScriptFile('civicrm', 'templates/CRM/Contribute/Page/DashBoard.js', 1, 'html-header'); | |
6a488035 TO |
132 | |
133 | return parent::run(); | |
134 | } | |
96025800 | 135 | |
6a488035 | 136 | } |