/** * Heart of the viewing process. The runner gets all the meta data for * the contact and calls the appropriate type of page to view. * * @return void * @access 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); }
/** * Get the contributions links. * * @return array */ public function &contributionLinks() { if (!isset(self::$_contributionLinks)) { //get contribution dates. $dates = CRM_Contribute_BAO_Contribution::getContributionDates(); $now = $dates['now']; $yearDate = $dates['yearDate']; $monthDate = $dates['monthDate']; $yearNow = $yearDate + 10000; $urlString = 'civicrm/contribute/search'; $urlParams = 'reset=1&pid=%%id%%&force=1&test=0'; self::$_contributionLinks = array(CRM_Core_Action::DETACH => array('name' => ts('Current Month-To-Date'), 'title' => ts('Current Month-To-Date'), 'url' => $urlString, 'qs' => "{$urlParams}&start={$monthDate}&end={$now}", 'uniqueName' => 'current_month_to_date'), CRM_Core_Action::REVERT => array('name' => ts('Fiscal Year-To-Date'), 'title' => ts('Fiscal Year-To-Date'), 'url' => $urlString, 'qs' => "{$urlParams}&start={$yearDate}&end={$yearNow}", 'uniqueName' => 'fiscal_year_to_date'), CRM_Core_Action::BROWSE => array('name' => ts('Cumulative'), 'title' => ts('Cumulative'), 'url' => $urlString, 'qs' => "{$urlParams}&start=&end={$now}", 'uniqueName' => 'cumulative')); } return self::$_contributionLinks; }