Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
232624b1 | 4 | | CiviCRM version 4.4 | |
6a488035 TO |
5 | +--------------------------------------------------------------------+ |
6 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
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 | +--------------------------------------------------------------------+ | |
26 | */ | |
27 | ||
28 | /** | |
29 | * | |
30 | * @package CRM | |
31 | * @copyright CiviCRM LLC (c) 2004-2013 | |
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 | |
46 | * @access public | |
47 | * | |
48 | */ | |
49 | function preProcess() { | |
50 | CRM_Utils_System::setTitle(ts('CiviContribute')); | |
51 | ||
52 | $status = array('Valid', 'Cancelled'); | |
53 | $prefixes = array('start', 'month', 'year'); | |
54 | $startDate = NULL; | |
55 | $startToDate = $monthToDate = $yearToDate = array(); | |
56 | ||
57 | //get contribution dates. | |
58 | $dates = CRM_Contribute_BAO_Contribution::getContributionDates(); | |
59 | foreach (array( | |
60 | 'now', 'yearDate', 'monthDate') as $date) { | |
61 | $$date = $dates[$date]; | |
62 | } | |
acff69f0 PJ |
63 | // fiscal years end date |
64 | $yearNow = date('Ymd', strtotime('+1 year -1 day', strtotime($yearDate))); | |
65 | ||
6a488035 TO |
66 | foreach ($prefixes as $prefix) { |
67 | $aName = $prefix . 'ToDate'; | |
68 | $dName = $prefix . 'Date'; | |
69 | ||
70 | if ($prefix == 'year') { | |
71 | $now = $yearNow; | |
72 | } | |
73 | ||
106f4f2d PJ |
74 | // appending end date i.e $now with time |
75 | // to also calculate records of end date till mid-night | |
76 | $nowWithTime = $now . '235959'; | |
77 | ||
6a488035 | 78 | foreach ($status as $s) { |
106f4f2d | 79 | ${$aName}[$s] = CRM_Contribute_BAO_Contribution::getTotalAmountAndCount($s, $$dName, $nowWithTime); |
6a488035 TO |
80 | ${$aName}[$s]['url'] = CRM_Utils_System::url('civicrm/contribute/search', |
81 | "reset=1&force=1&status=1&start={$$dName}&end=$now&test=0" | |
82 | ); | |
83 | } | |
84 | ||
85 | $this->assign($aName, $$aName); | |
86 | } | |
87 | ||
88 | //for contribution tabular View | |
89 | $buildTabularView = CRM_Utils_Array::value('showtable', $_GET, FALSE); | |
90 | $this->assign('buildTabularView', $buildTabularView); | |
91 | if ($buildTabularView) { | |
92 | return; | |
93 | } | |
94 | ||
95 | // Check for admin permission to see if we should include the Manage Contribution Pages action link | |
96 | $isAdmin = 0; | |
97 | if (CRM_Core_Permission::check('administer CiviCRM')) { | |
98 | $isAdmin = 1; | |
99 | } | |
100 | $this->assign('isAdmin', $isAdmin); | |
101 | } | |
102 | ||
103 | /** | |
104 | * This function is the main function that is called when the page loads, | |
105 | * it decides the which action has to be taken for the page. | |
106 | * | |
107 | * return null | |
108 | * @access public | |
109 | */ | |
110 | function run() { | |
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(); | |
4265dd23 | 130 | CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Contribute/Page/DashBoard.js'); |
6a488035 TO |
131 | |
132 | return parent::run(); | |
133 | } | |
134 | } | |
135 |