commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / CRM / Pledge / Page / DashBoard.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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-2015
32 * $Id$
33 *
34 */
35
36 /**
37 * This is page is for Pledge Dashboard
38 */
39 class CRM_Pledge_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 */
47 public function preProcess() {
48 CRM_Utils_System::setTitle(ts('CiviPledge'));
49
50 $startToDate = array();
51 $yearToDate = array();
52 $monthToDate = array();
53 $previousToDate = array();
54
55 $prefixes = array('start', 'month', 'year', 'previous');
56 $status = array('Completed', 'Cancelled', 'Pending', 'In Progress', 'Overdue');
57
58 // cumulative (since inception) - prefix = 'start'
59 $startDate = NULL;
60 $startDateEnd = NULL;
61
62 // current year - prefix = 'year'
63 $config = CRM_Core_Config::singleton();
64 $yearDate = $config->fiscalYearStart;
65 $year = array('Y' => date('Y'));
66 $this->assign('curYear', $year['Y']);
67 $yearDate = array_merge($year, $yearDate);
68 $yearDate = CRM_Utils_Date::format($yearDate);
69 $yearDate = $yearDate . '000000';
70 $yearDateEnd = $year['Y'] . '1231235959';
71
72 // current month - prefix = 'month'
73 $currentMonth = date("F Y", mktime(0, 0, 0, date("m"), 01, date("Y")));
74 $this->assign('currentMonthYear', $currentMonth);
75 $monthDate = date('Ym') . '01000000';
76 $monthDateEnd = CRM_Utils_Date::customFormat(date("Y-m-t", mktime(0, 0, 0, date("m"), 01, date("Y"))), '%Y%m%d') . '235959';
77
78 // previous month - prefix = 'previous'
79 $previousDate = CRM_Utils_Date::customFormat(date("Y-m-d", mktime(0, 0, 0, date("m") - 1, 01, date("Y"))), '%Y%m%d') . '000000';
80 $previousDateEnd = CRM_Utils_Date::customFormat(date("Y-m-t", mktime(0, 0, 0, date("m") - 1, 01, date("Y"))), '%Y%m%d') . '235959';
81 $previousMonth = date("F Y", mktime(0, 0, 0, date("m") - 1, 01, date("Y")));
82 $this->assign('previousMonthYear', $previousMonth);
83
84 foreach ($prefixes as $prefix) {
85 $aName = $prefix . 'ToDate';
86 $startName = $prefix . 'Date';
87 $endName = $prefix . 'DateEnd';
88 foreach ($status as $s) {
89 ${$aName}[str_replace(" ", "", $s)] = CRM_Pledge_BAO_Pledge::getTotalAmountAndCount($s, $$startName, $$endName);
90 }
91 $this->assign($aName, $$aName);
92 }
93 }
94
95 /**
96 * the main function that is called when the page loads,
97 * it decides the which action has to be taken for the page.
98 *
99 * @return null
100 */
101 public function run() {
102 $this->preProcess();
103
104 $controller = new CRM_Core_Controller_Simple('CRM_Pledge_Form_Search',
105 ts('Pledge'),
106 NULL
107 );
108 $controller->setEmbedded(TRUE);
109 $controller->reset();
110 $controller->set('limit', 10);
111 $controller->set('force', 1);
112 $controller->set('context', 'dashboard');
113 $controller->process();
114 $controller->run();
115
116 return parent::run();
117 }
118
119 }