drupal-civicrm/sites/all/modules/civicrm/CRM/Contribute/Page/DashBoard.php

134 lines
4.6 KiB
PHP
Raw Permalink Normal View History

2018-01-14 15:10:16 +02:00
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
/**
* Page for displaying list of Payment-Instrument.
*/
class CRM_Contribute_Page_DashBoard extends CRM_Core_Page {
/**
* Heart of the viewing process.
*
* The runner gets all the meta data for the contact and calls the appropriate type of page to view.
*/
public function preProcess() {
CRM_Utils_System::setTitle(ts('CiviContribute'));
$status = array('Valid', 'Cancelled');
$prefixes = array('start', 'month', 'year');
$startDate = NULL;
$startToDate = $monthToDate = $yearToDate = array();
//get contribution dates.
$dates = CRM_Contribute_BAO_Contribution::getContributionDates();
foreach (array(
'now',
'yearDate',
'monthDate',
) as $date) {
$$date = $dates[$date];
}
// fiscal years end date
$yearNow = date('Ymd', strtotime('+1 year -1 day', strtotime($yearDate)));
foreach ($prefixes as $prefix) {
$aName = $prefix . 'ToDate';
$dName = $prefix . 'Date';
if ($prefix == 'year') {
$now = $yearNow;
}
// appending end date i.e $now with time
// to also calculate records of end date till mid-night
$nowWithTime = $now . '235959';
foreach ($status as $s) {
${$aName}[$s] = CRM_Contribute_BAO_Contribution::getTotalAmountAndCount($s, $$dName, $nowWithTime);
${$aName}[$s]['url'] = CRM_Utils_System::url('civicrm/contribute/search',
"reset=1&force=1&status=1&start={$$dName}&end=$now&test=0"
);
}
$this->assign($aName, $$aName);
}
//for contribution tabular View
$buildTabularView = CRM_Utils_Array::value('showtable', $_GET, FALSE);
$this->assign('buildTabularView', $buildTabularView);
if ($buildTabularView) {
return;
}
// Check for admin permission to see if we should include the Manage Contribution Pages action link
$isAdmin = 0;
if (CRM_Core_Permission::check('administer CiviCRM')) {
$isAdmin = 1;
}
$this->assign('isAdmin', $isAdmin);
}
/**
* the main function that is called when the page loads,
* it decides the which action has to be taken for the page.
*
* @return null
*/
public function run() {
$this->preProcess();
$controller = new CRM_Core_Controller_Simple('CRM_Contribute_Form_Search',
ts('Contributions'), NULL
);
$controller->setEmbedded(TRUE);
$controller->set('limit', 10);
$controller->set('force', 1);
$controller->set('context', 'dashboard');
$controller->process();
$controller->run();
$chartForm = new CRM_Core_Controller_Simple('CRM_Contribute_Form_ContributionCharts',
ts('Contributions Charts'), NULL
);
$chartForm->setEmbedded(TRUE);
$chartForm->process();
$chartForm->run();
CRM_Core_Resources::singleton()
->addScriptFile('civicrm', 'templates/CRM/Contribute/Page/DashBoard.js', 1, 'html-header');
return parent::run();
}
}