3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * This page is for the Pledge Dashboard.
21 class CRM_Pledge_Page_DashBoard
extends CRM_Core_Page
{
24 * Heart of the viewing process.
26 * The runner gets all the meta data for the contact and calls the appropriate type of page to view.
28 public function preProcess() {
29 CRM_Utils_System
::setTitle(ts('CiviPledge'));
36 $prefixes = ['start', 'month', 'year', 'previous'];
37 $status = ['Completed', 'Cancelled', 'Pending', 'In Progress', 'Overdue'];
39 // cumulative (since inception) - prefix = 'start'
43 // current year - prefix = 'year'
44 $yearDate = \Civi
::settings()->get('fiscalYearStart');
45 $year = ['Y' => date('Y')];
46 $this->assign('curYear', $year['Y']);
47 $yearDate = array_merge($year, $yearDate);
48 $yearDate = CRM_Utils_Date
::format($yearDate);
49 $yearDate = $yearDate . '000000';
50 $yearDateEnd = $year['Y'] . '1231235959';
52 // current month - prefix = 'month'
53 $currentMonth = date("F Y", mktime(0, 0, 0, date("m"), 01, date("Y")));
54 $this->assign('currentMonthYear', $currentMonth);
55 $monthDate = date('Ym') . '01000000';
56 $monthDateEnd = CRM_Utils_Date
::customFormat(date("Y-m-t", mktime(0, 0, 0, date("m"), 01, date("Y"))), '%Y%m%d') . '235959';
58 // previous month - prefix = 'previous'
59 $previousDate = CRM_Utils_Date
::customFormat(date("Y-m-d", mktime(0, 0, 0, date("m") - 1, 01, date("Y"))), '%Y%m%d') . '000000';
60 $previousDateEnd = CRM_Utils_Date
::customFormat(date("Y-m-t", mktime(0, 0, 0, date("m") - 1, 01, date("Y"))), '%Y%m%d') . '235959';
61 $previousMonth = date("F Y", mktime(0, 0, 0, date("m") - 1, 01, date("Y")));
62 $this->assign('previousMonthYear', $previousMonth);
64 foreach ($prefixes as $prefix) {
65 $aName = $prefix . 'ToDate';
66 $startName = $prefix . 'Date';
67 $endName = $prefix . 'DateEnd';
68 foreach ($status as $s) {
69 $
{$aName}[str_replace(" ", "", $s)] = CRM_Pledge_BAO_Pledge
::getTotalAmountAndCount($s, $
$startName, $
$endName);
71 $this->assign($aName, $
$aName);
76 * The main function that is called when the page loads.
78 * it decides which action has to be taken for the page.
82 public function run() {
85 $controller = new CRM_Core_Controller_Simple('CRM_Pledge_Form_Search',
89 $controller->setEmbedded(TRUE);
91 $controller->set('limit', 10);
92 $controller->set('force', 1);
93 $controller->set('context', 'dashboard');
94 $controller->process();