Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
7e9e8871 | 4 | | CiviCRM version 4.7 | |
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 | */ |
33 | ||
34 | /** | |
cc28438b | 35 | * This page is for the Pledge Dashboard. |
6a488035 TO |
36 | */ |
37 | class CRM_Pledge_Page_DashBoard extends CRM_Core_Page { | |
38 | ||
39 | /** | |
cc28438b | 40 | * Heart of the viewing process: The runner gets all the meta data for |
6a488035 | 41 | * the contact and calls the appropriate type of page to view. |
6a488035 | 42 | */ |
00be9182 | 43 | public function preProcess() { |
6a488035 TO |
44 | CRM_Utils_System::setTitle(ts('CiviPledge')); |
45 | ||
353ffa53 TO |
46 | $startToDate = array(); |
47 | $yearToDate = array(); | |
48 | $monthToDate = array(); | |
6a488035 TO |
49 | $previousToDate = array(); |
50 | ||
51 | $prefixes = array('start', 'month', 'year', 'previous'); | |
52 | $status = array('Completed', 'Cancelled', 'Pending', 'In Progress', 'Overdue'); | |
53 | ||
54 | // cumulative (since inception) - prefix = 'start' | |
55 | $startDate = NULL; | |
56 | $startDateEnd = NULL; | |
57 | ||
58 | // current year - prefix = 'year' | |
353ffa53 | 59 | $config = CRM_Core_Config::singleton(); |
6a488035 | 60 | $yearDate = $config->fiscalYearStart; |
353ffa53 | 61 | $year = array('Y' => date('Y')); |
6a488035 | 62 | $this->assign('curYear', $year['Y']); |
353ffa53 TO |
63 | $yearDate = array_merge($year, $yearDate); |
64 | $yearDate = CRM_Utils_Date::format($yearDate); | |
65 | $yearDate = $yearDate . '000000'; | |
6a488035 TO |
66 | $yearDateEnd = $year['Y'] . '1231235959'; |
67 | ||
68 | // current month - prefix = 'month' | |
69 | $currentMonth = date("F Y", mktime(0, 0, 0, date("m"), 01, date("Y"))); | |
70 | $this->assign('currentMonthYear', $currentMonth); | |
71 | $monthDate = date('Ym') . '01000000'; | |
72 | $monthDateEnd = CRM_Utils_Date::customFormat(date("Y-m-t", mktime(0, 0, 0, date("m"), 01, date("Y"))), '%Y%m%d') . '235959'; | |
73 | ||
74 | // previous month - prefix = 'previous' | |
353ffa53 | 75 | $previousDate = CRM_Utils_Date::customFormat(date("Y-m-d", mktime(0, 0, 0, date("m") - 1, 01, date("Y"))), '%Y%m%d') . '000000'; |
6a488035 | 76 | $previousDateEnd = CRM_Utils_Date::customFormat(date("Y-m-t", mktime(0, 0, 0, date("m") - 1, 01, date("Y"))), '%Y%m%d') . '235959'; |
353ffa53 | 77 | $previousMonth = date("F Y", mktime(0, 0, 0, date("m") - 1, 01, date("Y"))); |
6a488035 TO |
78 | $this->assign('previousMonthYear', $previousMonth); |
79 | ||
6a488035 | 80 | foreach ($prefixes as $prefix) { |
353ffa53 | 81 | $aName = $prefix . 'ToDate'; |
6a488035 | 82 | $startName = $prefix . 'Date'; |
353ffa53 | 83 | $endName = $prefix . 'DateEnd'; |
6a488035 TO |
84 | foreach ($status as $s) { |
85 | ${$aName}[str_replace(" ", "", $s)] = CRM_Pledge_BAO_Pledge::getTotalAmountAndCount($s, $$startName, $$endName); | |
86 | } | |
87 | $this->assign($aName, $$aName); | |
88 | } | |
89 | } | |
90 | ||
91 | /** | |
dc195289 | 92 | * the main function that is called when the page loads, |
cc28438b | 93 | * it decides which action has to be taken for the page. |
6a488035 | 94 | * |
76e7a76c | 95 | * @return null |
6a488035 | 96 | */ |
00be9182 | 97 | public function run() { |
6a488035 TO |
98 | $this->preProcess(); |
99 | ||
100 | $controller = new CRM_Core_Controller_Simple('CRM_Pledge_Form_Search', | |
101 | ts('Pledge'), | |
102 | NULL | |
103 | ); | |
104 | $controller->setEmbedded(TRUE); | |
105 | $controller->reset(); | |
106 | $controller->set('limit', 10); | |
107 | $controller->set('force', 1); | |
108 | $controller->set('context', 'dashboard'); | |
109 | $controller->process(); | |
110 | $controller->run(); | |
111 | ||
112 | return parent::run(); | |
113 | } | |
96025800 | 114 | |
6a488035 | 115 | } |