First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
64
sites/all/modules/civicrm/CRM/Contribute/Page/AJAX.php
Normal file
64
sites/all/modules/civicrm/CRM/Contribute/Page/AJAX.php
Normal file
|
@ -0,0 +1,64 @@
|
|||
<?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
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class contains all the function that are called using AJAX (jQuery)
|
||||
*/
|
||||
class CRM_Contribute_Page_AJAX {
|
||||
/**
|
||||
* Get Soft credit to list in DT
|
||||
*/
|
||||
public static function getSoftContributionRows() {
|
||||
$requiredParameters = array(
|
||||
'cid' => 'Integer',
|
||||
'context' => 'String',
|
||||
);
|
||||
$optionalParameters = array(
|
||||
'entityID' => 'Integer',
|
||||
'isTest' => 'Integer',
|
||||
);
|
||||
|
||||
$params = CRM_Core_Page_AJAX::defaultSortAndPagerParams();
|
||||
$params += CRM_Core_Page_AJAX::validateParams($requiredParameters, $optionalParameters);
|
||||
|
||||
$softCreditList = CRM_Contribute_BAO_ContributionSoft::getSoftContributionSelector($params);
|
||||
|
||||
if (!empty($_GET['is_unit_test'])) {
|
||||
return $softCreditList;
|
||||
}
|
||||
|
||||
CRM_Utils_JSON::output($softCreditList);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,712 @@
|
|||
<?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
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a page for displaying Contribute Pages
|
||||
* Contribute Pages are pages that are used to display
|
||||
* contributions of different types. Pages consist
|
||||
* of many customizable sections which can be
|
||||
* accessed.
|
||||
*
|
||||
* This page provides a top level browse view
|
||||
* of all the contribution pages in the system.
|
||||
*
|
||||
*/
|
||||
class CRM_Contribute_Page_ContributionPage extends CRM_Core_Page {
|
||||
|
||||
/**
|
||||
* The action links that we need to display for the browse screen.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_actionLinks;
|
||||
private static $_contributionLinks;
|
||||
private static $_configureActionLinks;
|
||||
private static $_onlineContributionLinks;
|
||||
|
||||
/**
|
||||
* @var CRM_Utils_Pager
|
||||
*/
|
||||
protected $_pager = NULL;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_sortByCharacter;
|
||||
|
||||
/**
|
||||
* Get the action links for this page.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function &actionLinks() {
|
||||
// check if variable _actionsLinks is populated
|
||||
if (!isset(self::$_actionLinks)) {
|
||||
// helper variable for nicer formatting
|
||||
$deleteExtra = ts('Are you sure you want to delete this Contribution page?');
|
||||
$copyExtra = ts('Are you sure you want to make a copy of this Contribution page?');
|
||||
|
||||
self::$_actionLinks = array(
|
||||
CRM_Core_Action::COPY => array(
|
||||
'name' => ts('Make a Copy'),
|
||||
'url' => CRM_Utils_System::currentPath(),
|
||||
'qs' => 'action=copy&gid=%%id%%',
|
||||
'title' => ts('Make a Copy of CiviCRM Contribution Page'),
|
||||
'extra' => 'onclick = "return confirm(\'' . $copyExtra . '\');"',
|
||||
),
|
||||
CRM_Core_Action::DISABLE => array(
|
||||
'name' => ts('Disable'),
|
||||
'title' => ts('Disable'),
|
||||
'ref' => 'crm-enable-disable',
|
||||
),
|
||||
CRM_Core_Action::ENABLE => array(
|
||||
'name' => ts('Enable'),
|
||||
'ref' => 'crm-enable-disable',
|
||||
'title' => ts('Enable'),
|
||||
),
|
||||
CRM_Core_Action::DELETE => array(
|
||||
'name' => ts('Delete'),
|
||||
'url' => CRM_Utils_System::currentPath(),
|
||||
'qs' => 'action=delete&reset=1&id=%%id%%',
|
||||
'title' => ts('Delete Custom Field'),
|
||||
'extra' => 'onclick = "return confirm(\'' . $deleteExtra . '\');"',
|
||||
),
|
||||
);
|
||||
}
|
||||
return self::$_actionLinks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configure action links for this page.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function &configureActionLinks() {
|
||||
// check if variable _actionsLinks is populated
|
||||
if (!isset(self::$_configureActionLinks)) {
|
||||
$urlString = 'civicrm/admin/contribute/';
|
||||
$urlParams = 'reset=1&action=update&id=%%id%%';
|
||||
|
||||
self::$_configureActionLinks = array(
|
||||
CRM_Core_Action::ADD => array(
|
||||
'name' => ts('Title and Settings'),
|
||||
'title' => ts('Title and Settings'),
|
||||
'url' => $urlString . 'settings',
|
||||
'qs' => $urlParams,
|
||||
'uniqueName' => 'settings',
|
||||
),
|
||||
CRM_Core_Action::UPDATE => array(
|
||||
'name' => ts('Contribution Amounts'),
|
||||
'title' => ts('Contribution Amounts'),
|
||||
'url' => $urlString . 'amount',
|
||||
'qs' => $urlParams,
|
||||
'uniqueName' => 'amount',
|
||||
),
|
||||
CRM_Core_Action::VIEW => array(
|
||||
'name' => ts('Membership Settings'),
|
||||
'title' => ts('Membership Settings'),
|
||||
'url' => $urlString . 'membership',
|
||||
'qs' => $urlParams,
|
||||
'uniqueName' => 'membership',
|
||||
),
|
||||
CRM_Core_Action::EXPORT => array(
|
||||
'name' => ts('Thank-you and Receipting'),
|
||||
'title' => ts('Thank-you and Receipting'),
|
||||
'url' => $urlString . 'thankyou',
|
||||
'qs' => $urlParams,
|
||||
'uniqueName' => 'thankyou',
|
||||
),
|
||||
CRM_Core_Action::BASIC => array(
|
||||
'name' => ts('Tell a Friend'),
|
||||
'title' => ts('Tell a Friend'),
|
||||
'url' => $urlString . 'friend',
|
||||
'qs' => $urlParams,
|
||||
'uniqueName' => 'friend',
|
||||
),
|
||||
CRM_Core_Action::PROFILE => array(
|
||||
'name' => ts('Include Profiles'),
|
||||
'title' => ts('Include Profiles'),
|
||||
'url' => $urlString . 'custom',
|
||||
'qs' => $urlParams,
|
||||
'uniqueName' => 'custom',
|
||||
),
|
||||
CRM_Core_Action::MAP => array(
|
||||
'name' => ts('Contribution Widget'),
|
||||
'title' => ts('Contribution Widget'),
|
||||
'url' => $urlString . 'widget',
|
||||
'qs' => $urlParams,
|
||||
'uniqueName' => 'widget',
|
||||
),
|
||||
CRM_Core_Action::FOLLOWUP => array(
|
||||
'name' => ts('Premiums'),
|
||||
'title' => ts('Premiums'),
|
||||
'url' => $urlString . 'premium',
|
||||
'qs' => $urlParams,
|
||||
'uniqueName' => 'premium',
|
||||
),
|
||||
CRM_Core_Action::ADVANCED => array(
|
||||
'name' => ts('Personal Campaign Pages'),
|
||||
'title' => ts('Personal Campaign Pages'),
|
||||
'url' => $urlString . 'pcp',
|
||||
'qs' => $urlParams,
|
||||
'uniqueName' => 'pcp',
|
||||
),
|
||||
);
|
||||
$context = array(
|
||||
'urlString' => $urlString,
|
||||
'urlParams' => $urlParams,
|
||||
);
|
||||
CRM_Utils_Hook::tabset('civicrm/admin/contribute', self::$_configureActionLinks, $context);
|
||||
}
|
||||
|
||||
return self::$_configureActionLinks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the online contribution links.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function &onlineContributionLinks() {
|
||||
if (!isset(self::$_onlineContributionLinks)) {
|
||||
$urlString = 'civicrm/contribute/transact';
|
||||
$urlParams = 'reset=1&id=%%id%%';
|
||||
self::$_onlineContributionLinks = array(
|
||||
CRM_Core_Action::RENEW => array(
|
||||
'name' => ts('Live Page'),
|
||||
'title' => ts('Live Page'),
|
||||
'url' => $urlString,
|
||||
'qs' => $urlParams,
|
||||
'fe' => TRUE,
|
||||
'uniqueName' => 'live_page',
|
||||
),
|
||||
CRM_Core_Action::PREVIEW => array(
|
||||
'name' => ts('Test-drive'),
|
||||
'title' => ts('Test-drive'),
|
||||
'url' => $urlString,
|
||||
'qs' => $urlParams . '&action=preview',
|
||||
'uniqueName' => 'test_drive',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return self::$_onlineContributionLinks;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the page.
|
||||
*
|
||||
* This method is called after the page is created. It checks for the
|
||||
* type of action and executes that action.
|
||||
* Finally it calls the parent's run method.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function run() {
|
||||
// get the requested action
|
||||
$action = CRM_Utils_Request::retrieve('action', 'String',
|
||||
// default to 'browse'
|
||||
$this, FALSE, 'browse'
|
||||
);
|
||||
|
||||
// assign vars to templates
|
||||
$this->assign('action', $action);
|
||||
$id = CRM_Utils_Request::retrieve('id', 'Positive',
|
||||
$this, FALSE, 0
|
||||
);
|
||||
|
||||
// set breadcrumb to append to 2nd layer pages
|
||||
$breadCrumb = array(
|
||||
array(
|
||||
'title' => ts('Manage Contribution Pages'),
|
||||
'url' => CRM_Utils_System::url(CRM_Utils_System::currentPath(),
|
||||
'reset=1'
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// what action to take ?
|
||||
if ($action & CRM_Core_Action::ADD) {
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(),
|
||||
'action=browse&reset=1'
|
||||
));
|
||||
|
||||
$controller = new CRM_Contribute_Controller_ContributionPage(NULL, $action);
|
||||
CRM_Utils_System::setTitle(ts('Manage Contribution Page'));
|
||||
CRM_Utils_System::appendBreadCrumb($breadCrumb);
|
||||
return $controller->run();
|
||||
}
|
||||
elseif ($action & CRM_Core_Action::UPDATE) {
|
||||
$config = CRM_Core_Config::singleton();
|
||||
|
||||
// assign vars to templates
|
||||
$this->assign('id', $id);
|
||||
$this->assign('title', CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $id, 'title'));
|
||||
$this->assign('is_active', CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $id, 'is_active'));
|
||||
if (in_array('CiviMember', $config->enableComponents)) {
|
||||
$this->assign('CiviMember', TRUE);
|
||||
}
|
||||
}
|
||||
elseif ($action & CRM_Core_Action::COPY) {
|
||||
// @todo Unused local variable can be safely removed.
|
||||
// But are there any side effects of CRM_Core_Session::singleton() that we
|
||||
// need to preserve?
|
||||
$session = CRM_Core_Session::singleton();
|
||||
CRM_Core_Session::setStatus(ts('A copy of the contribution page has been created'), ts('Successfully Copied'), 'success');
|
||||
$this->copy();
|
||||
}
|
||||
elseif ($action & CRM_Core_Action::DELETE) {
|
||||
CRM_Utils_System::appendBreadCrumb($breadCrumb);
|
||||
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(),
|
||||
'reset=1&action=browse'
|
||||
));
|
||||
|
||||
$id = CRM_Utils_Request::retrieve('id', 'Positive',
|
||||
$this, FALSE, 0
|
||||
);
|
||||
$query = "
|
||||
SELECT ccp.title
|
||||
FROM civicrm_contribution_page ccp
|
||||
JOIN civicrm_pcp cp ON ccp.id = cp.page_id
|
||||
WHERE cp.page_id = {$id}
|
||||
AND cp.page_type = 'contribute'
|
||||
";
|
||||
|
||||
if ($pageTitle = CRM_Core_DAO::singleValueQuery($query)) {
|
||||
CRM_Core_Session::setStatus(ts('The \'%1\' cannot be deleted! You must Delete all Personal Campaign Page(s) related with this contribution page prior to deleting the page.', array(1 => $pageTitle)), ts('Deletion Error'), 'error');
|
||||
|
||||
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/contribute', 'reset=1'));
|
||||
}
|
||||
|
||||
$controller = new CRM_Core_Controller_Simple('CRM_Contribute_Form_ContributionPage_Delete',
|
||||
'Delete Contribution Page',
|
||||
CRM_Core_Action::DELETE
|
||||
);
|
||||
$controller->set('id', $id);
|
||||
$controller->process();
|
||||
return $controller->run();
|
||||
}
|
||||
else {
|
||||
// finally browse the contribution pages
|
||||
$this->browse();
|
||||
|
||||
CRM_Utils_System::setTitle(ts('Manage Contribution Pages'));
|
||||
}
|
||||
|
||||
return parent::run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a copy of a contribution page, including all the fields in the page.
|
||||
*/
|
||||
public function copy() {
|
||||
$gid = CRM_Utils_Request::retrieve('gid', 'Positive',
|
||||
$this, TRUE, 0, 'GET'
|
||||
);
|
||||
|
||||
CRM_Contribute_BAO_ContributionPage::copy($gid);
|
||||
|
||||
CRM_Utils_System::redirect(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Browse all contribution pages.
|
||||
*
|
||||
* @param mixed $action
|
||||
* Unused parameter.
|
||||
*/
|
||||
public function browse($action = NULL) {
|
||||
Civi::resources()->addStyleFile('civicrm', 'css/searchForm.css', 1, 'html-header');
|
||||
|
||||
$this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter',
|
||||
'String',
|
||||
$this
|
||||
);
|
||||
// @todo Unused local variable can be safely removed.
|
||||
// But are there any side effects of CRM_Utils_Request::retrieve() that we
|
||||
// need to preserve?
|
||||
$createdId = CRM_Utils_Request::retrieve('cid', 'Positive',
|
||||
$this, FALSE, 0
|
||||
);
|
||||
|
||||
if ($this->_sortByCharacter == 'all' ||
|
||||
!empty($_POST)
|
||||
) {
|
||||
$this->_sortByCharacter = '';
|
||||
$this->set('sortByCharacter', '');
|
||||
}
|
||||
|
||||
$this->search();
|
||||
|
||||
$params = array();
|
||||
|
||||
$whereClause = $this->whereClause($params, FALSE);
|
||||
$this->pagerAToZ($whereClause, $params);
|
||||
|
||||
$params = array();
|
||||
$whereClause = $this->whereClause($params, TRUE);
|
||||
$this->pager($whereClause, $params);
|
||||
|
||||
list($offset, $rowCount) = $this->_pager->getOffsetAndRowCount();
|
||||
|
||||
//check for delete CRM-4418
|
||||
$allowToDelete = CRM_Core_Permission::check('delete in CiviContribute');
|
||||
|
||||
$query = "
|
||||
SELECT id
|
||||
FROM civicrm_contribution_page
|
||||
WHERE $whereClause
|
||||
ORDER BY is_active desc, title asc
|
||||
LIMIT $offset, $rowCount";
|
||||
$contribPage = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Contribute_DAO_ContributionPage');
|
||||
$contribPageIds = array();
|
||||
while ($contribPage->fetch()) {
|
||||
$contribPageIds[$contribPage->id] = $contribPage->id;
|
||||
}
|
||||
//get all section info.
|
||||
$contriPageSectionInfo = CRM_Contribute_BAO_ContributionPage::getSectionInfo($contribPageIds);
|
||||
|
||||
$query = "
|
||||
SELECT *
|
||||
FROM civicrm_contribution_page
|
||||
WHERE $whereClause
|
||||
ORDER BY is_active desc, title asc
|
||||
LIMIT $offset, $rowCount";
|
||||
|
||||
$dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Contribute_DAO_ContributionPage');
|
||||
|
||||
//get all campaigns.
|
||||
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
|
||||
|
||||
//get configure actions links.
|
||||
$configureActionLinks = self::configureActionLinks();
|
||||
|
||||
while ($dao->fetch()) {
|
||||
$contribution[$dao->id] = array();
|
||||
CRM_Core_DAO::storeValues($dao, $contribution[$dao->id]);
|
||||
|
||||
// form all action links
|
||||
$action = array_sum(array_keys(self::actionLinks()));
|
||||
|
||||
//add configure actions links.
|
||||
$action += array_sum(array_keys($configureActionLinks));
|
||||
|
||||
//add online contribution links.
|
||||
$action += array_sum(array_keys(self::onlineContributionLinks()));
|
||||
|
||||
//add contribution search links.
|
||||
$action += array_sum(array_keys(self::contributionLinks()));
|
||||
|
||||
if ($dao->is_active) {
|
||||
$action -= (int) CRM_Core_Action::ENABLE;
|
||||
}
|
||||
else {
|
||||
$action -= (int) CRM_Core_Action::DISABLE;
|
||||
}
|
||||
|
||||
//CRM-4418
|
||||
if (!$allowToDelete) {
|
||||
$action -= (int) CRM_Core_Action::DELETE;
|
||||
}
|
||||
|
||||
//build the configure links.
|
||||
$sectionsInfo = CRM_Utils_Array::value($dao->id, $contriPageSectionInfo, array());
|
||||
$contribution[$dao->id]['configureActionLinks'] = CRM_Core_Action::formLink(self::formatConfigureLinks($sectionsInfo),
|
||||
$action,
|
||||
array('id' => $dao->id),
|
||||
ts('Configure'),
|
||||
TRUE,
|
||||
'contributionpage.configure.actions',
|
||||
'ContributionPage',
|
||||
$dao->id
|
||||
);
|
||||
|
||||
//build the contributions links.
|
||||
$contribution[$dao->id]['contributionLinks'] = CRM_Core_Action::formLink(self::contributionLinks(),
|
||||
$action,
|
||||
array('id' => $dao->id),
|
||||
ts('Contributions'),
|
||||
TRUE,
|
||||
'contributionpage.contributions.search',
|
||||
'ContributionPage',
|
||||
$dao->id
|
||||
);
|
||||
|
||||
//build the online contribution links.
|
||||
$contribution[$dao->id]['onlineContributionLinks'] = CRM_Core_Action::formLink(self::onlineContributionLinks(),
|
||||
$action,
|
||||
array('id' => $dao->id),
|
||||
ts('Links'),
|
||||
TRUE,
|
||||
'contributionpage.online.links',
|
||||
'ContributionPage',
|
||||
$dao->id
|
||||
);
|
||||
|
||||
//build the normal action links.
|
||||
$contribution[$dao->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(),
|
||||
$action,
|
||||
array('id' => $dao->id),
|
||||
ts('more'),
|
||||
TRUE,
|
||||
'contributionpage.action.links',
|
||||
'ContributionPage',
|
||||
$dao->id
|
||||
);
|
||||
|
||||
//show campaigns on selector.
|
||||
$contribution[$dao->id]['campaign'] = CRM_Utils_Array::value($dao->campaign_id, $allCampaigns);
|
||||
}
|
||||
|
||||
if (isset($contribution)) {
|
||||
$this->assign('rows', $contribution);
|
||||
}
|
||||
}
|
||||
|
||||
public function search() {
|
||||
if (isset($this->_action) & (CRM_Core_Action::ADD |
|
||||
CRM_Core_Action::UPDATE |
|
||||
CRM_Core_Action::DELETE
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
$form = new CRM_Core_Controller_Simple('CRM_Contribute_Form_SearchContribution',
|
||||
ts('Search Contribution'),
|
||||
CRM_Core_Action::ADD
|
||||
);
|
||||
$form->setEmbedded(TRUE);
|
||||
$form->setParent($this);
|
||||
$form->process();
|
||||
$form->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
* @param bool $sortBy
|
||||
*
|
||||
* @return int|string
|
||||
*/
|
||||
public function whereClause(&$params, $sortBy = TRUE) {
|
||||
// @todo Unused local variable can be safely removed.
|
||||
$values = $clauses = array();
|
||||
$title = $this->get('title');
|
||||
$createdId = $this->get('cid');
|
||||
|
||||
if ($createdId) {
|
||||
$clauses[] = "(created_id = {$createdId})";
|
||||
}
|
||||
|
||||
if ($title) {
|
||||
$clauses[] = "title LIKE %1";
|
||||
if (strpos($title, '%') !== FALSE) {
|
||||
$params[1] = array(trim($title), 'String', FALSE);
|
||||
}
|
||||
else {
|
||||
$params[1] = array(trim($title), 'String', TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
$value = $this->get('financial_type_id');
|
||||
$val = array();
|
||||
if ($value) {
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $k => $v) {
|
||||
if ($v) {
|
||||
$val[$k] = $k;
|
||||
}
|
||||
}
|
||||
$type = implode(',', $val);
|
||||
}
|
||||
// @todo Variable 'type' might not have been defined.
|
||||
$clauses[] = "financial_type_id IN ({$type})";
|
||||
}
|
||||
|
||||
if ($sortBy && $this->_sortByCharacter !== NULL) {
|
||||
$clauses[] = "title LIKE '" . strtolower(CRM_Core_DAO::escapeWildCardString($this->_sortByCharacter)) . "%'";
|
||||
}
|
||||
|
||||
$campaignIds = $this->getCampaignIds();
|
||||
if (count($campaignIds) >= 1) {
|
||||
$clauses[] = '( campaign_id IN ( ' . implode(' , ', $campaignIds) . ' ) )';
|
||||
}
|
||||
|
||||
if (empty($clauses)) {
|
||||
// Let template know if user has run a search or not
|
||||
$this->assign('isSearch', 0);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
$this->assign('isSearch', 1);
|
||||
}
|
||||
|
||||
return implode(' AND ', $clauses);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the campaign ids from the session.
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public function getCampaignIds() {
|
||||
// The unfiltered value from the session cannot be trusted, it needs to be
|
||||
// processed to get a clean array of positive integers.
|
||||
$ids = array();
|
||||
foreach ((array) $this->get('campaign_id') as $id) {
|
||||
if ((string) (int) $id === (string) $id && $id > 0) {
|
||||
$ids[] = $id;
|
||||
}
|
||||
}
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $whereClause
|
||||
* @param array $whereParams
|
||||
*/
|
||||
public function pager($whereClause, $whereParams) {
|
||||
|
||||
$params['status'] = ts('Contribution %%StatusMessage%%');
|
||||
$params['csvString'] = NULL;
|
||||
$params['buttonTop'] = 'PagerTopButton';
|
||||
$params['buttonBottom'] = 'PagerBottomButton';
|
||||
$params['rowCount'] = $this->get(CRM_Utils_Pager::PAGE_ROWCOUNT);
|
||||
if (!$params['rowCount']) {
|
||||
$params['rowCount'] = CRM_Utils_Pager::ROWCOUNT;
|
||||
}
|
||||
|
||||
$query = "
|
||||
SELECT count(id)
|
||||
FROM civicrm_contribution_page
|
||||
WHERE $whereClause";
|
||||
|
||||
$params['total'] = CRM_Core_DAO::singleValueQuery($query, $whereParams);
|
||||
|
||||
$this->_pager = new CRM_Utils_Pager($params);
|
||||
$this->assign_by_ref('pager', $this->_pager);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $whereClause
|
||||
* @param array $whereParams
|
||||
*/
|
||||
public function pagerAtoZ($whereClause, $whereParams) {
|
||||
|
||||
$query = "
|
||||
SELECT DISTINCT UPPER(LEFT(title, 1)) as sort_name
|
||||
FROM civicrm_contribution_page
|
||||
WHERE $whereClause
|
||||
ORDER BY UPPER(LEFT(title, 1))
|
||||
";
|
||||
$dao = CRM_Core_DAO::executeQuery($query, $whereParams);
|
||||
|
||||
$aToZBar = CRM_Utils_PagerAToZ::getAToZBar($dao, $this->_sortByCharacter, TRUE);
|
||||
$this->assign('aToZ', $aToZBar);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $sectionsInfo
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function formatConfigureLinks($sectionsInfo) {
|
||||
// build the formatted configure links.
|
||||
$formattedConfLinks = self::configureActionLinks();
|
||||
foreach ($formattedConfLinks as $act => & $link) {
|
||||
$sectionName = CRM_Utils_Array::value('uniqueName', $link);
|
||||
if (!$sectionName) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (empty($sectionsInfo[$sectionName])) {
|
||||
$classes = array();
|
||||
if (isset($link['class'])) {
|
||||
$classes = $link['class'];
|
||||
}
|
||||
$link['class'] = array_merge($classes, array('disabled'));
|
||||
}
|
||||
}
|
||||
|
||||
return $formattedConfLinks;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
<?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
|
||||
*/
|
||||
|
||||
/**
|
||||
* Main page for viewing Recurring Contributions.
|
||||
*/
|
||||
class CRM_Contribute_Page_ContributionRecur extends CRM_Core_Page {
|
||||
|
||||
static $_links = NULL;
|
||||
public $_permission = NULL;
|
||||
public $_contactId = NULL;
|
||||
|
||||
/**
|
||||
* View details of a recurring contribution.
|
||||
*/
|
||||
public function view() {
|
||||
$recur = new CRM_Contribute_DAO_ContributionRecur();
|
||||
$recur->id = $this->_id;
|
||||
if ($recur->find(TRUE)) {
|
||||
$values = array();
|
||||
CRM_Core_DAO::storeValues($recur, $values);
|
||||
// if there is a payment processor ID, get the name of the payment processor
|
||||
if (!empty($values['payment_processor_id'])) {
|
||||
$values['payment_processor'] = CRM_Core_DAO::getFieldValue(
|
||||
'CRM_Financial_DAO_PaymentProcessor',
|
||||
$values['payment_processor_id'],
|
||||
'name'
|
||||
);
|
||||
}
|
||||
$idFields = array('contribution_status_id', 'campaign_id');
|
||||
if (CRM_Contribute_BAO_ContributionRecur::supportsFinancialTypeChange($values['id'])) {
|
||||
$idFields[] = 'financial_type_id';
|
||||
}
|
||||
foreach ($idFields as $idField) {
|
||||
if (!empty($values[$idField])) {
|
||||
$values[substr($idField, 0, -3)] = CRM_Core_PseudoConstant::getLabel('CRM_Contribute_BAO_ContributionRecur', $idField, $values[$idField]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->assign('recur', $values);
|
||||
}
|
||||
}
|
||||
|
||||
public function preProcess() {
|
||||
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
|
||||
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'view');
|
||||
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
|
||||
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
|
||||
$this->assign('contactId', $this->_contactId);
|
||||
|
||||
// check logged in url permission
|
||||
CRM_Contact_Page_View::checkUserPermission($this);
|
||||
|
||||
$this->assign('action', $this->_action);
|
||||
|
||||
if ($this->_permission == CRM_Core_Permission::EDIT && !CRM_Core_Permission::check('edit contributions')) {
|
||||
// demote to view since user does not have edit contrib rights
|
||||
$this->_permission = CRM_Core_Permission::VIEW;
|
||||
$this->assign('permission', 'view');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
if ($this->_action & CRM_Core_Action::VIEW) {
|
||||
$this->view();
|
||||
}
|
||||
|
||||
return parent::run();
|
||||
}
|
||||
|
||||
}
|
133
sites/all/modules/civicrm/CRM/Contribute/Page/DashBoard.php
Normal file
133
sites/all/modules/civicrm/CRM/Contribute/Page/DashBoard.php
Normal file
|
@ -0,0 +1,133 @@
|
|||
<?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();
|
||||
}
|
||||
|
||||
}
|
194
sites/all/modules/civicrm/CRM/Contribute/Page/ManagePremiums.php
Normal file
194
sites/all/modules/civicrm/CRM/Contribute/Page/ManagePremiums.php
Normal file
|
@ -0,0 +1,194 @@
|
|||
<?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 Premiums.
|
||||
*/
|
||||
class CRM_Contribute_Page_ManagePremiums extends CRM_Core_Page_Basic {
|
||||
|
||||
public $useLivePageJS = TRUE;
|
||||
|
||||
/**
|
||||
* The action links that we need to display for the browse screen.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_links = NULL;
|
||||
|
||||
/**
|
||||
* Get BAO Name.
|
||||
*
|
||||
* @return string
|
||||
* Classname of BAO.
|
||||
*/
|
||||
public function getBAOName() {
|
||||
return 'CRM_Contribute_BAO_ManagePremiums';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get action Links.
|
||||
*
|
||||
* @return array
|
||||
* (reference) of action links
|
||||
*/
|
||||
public function &links() {
|
||||
if (!(self::$_links)) {
|
||||
self::$_links = array(
|
||||
CRM_Core_Action::UPDATE => array(
|
||||
'name' => ts('Edit'),
|
||||
'url' => 'civicrm/admin/contribute/managePremiums',
|
||||
'qs' => 'action=update&id=%%id%%&reset=1',
|
||||
'title' => ts('Edit Premium'),
|
||||
),
|
||||
CRM_Core_Action::PREVIEW => array(
|
||||
'name' => ts('Preview'),
|
||||
'url' => 'civicrm/admin/contribute/managePremiums',
|
||||
'qs' => 'action=preview&id=%%id%%',
|
||||
'title' => ts('Preview Premium'),
|
||||
),
|
||||
CRM_Core_Action::DISABLE => array(
|
||||
'name' => ts('Disable'),
|
||||
'ref' => 'crm-enable-disable',
|
||||
'title' => ts('Disable Premium'),
|
||||
),
|
||||
CRM_Core_Action::ENABLE => array(
|
||||
'name' => ts('Enable'),
|
||||
'ref' => 'crm-enable-disable',
|
||||
'title' => ts('Enable Premium'),
|
||||
),
|
||||
CRM_Core_Action::DELETE => array(
|
||||
'name' => ts('Delete'),
|
||||
'url' => 'civicrm/admin/contribute/managePremiums',
|
||||
'qs' => 'action=delete&id=%%id%%',
|
||||
'title' => ts('Delete Premium'),
|
||||
),
|
||||
);
|
||||
}
|
||||
return self::$_links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the page.
|
||||
*
|
||||
* This method is called after the page is created. It checks for the
|
||||
* type of action and executes that action.
|
||||
* Finally it calls the parent's run method.
|
||||
*/
|
||||
public function run() {
|
||||
$id = $this->getIdAndAction();
|
||||
|
||||
// what action to take ?
|
||||
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::PREVIEW)) {
|
||||
$this->edit($this->_action, $id, TRUE);
|
||||
}
|
||||
// finally browse the custom groups
|
||||
$this->browse();
|
||||
|
||||
// parent run
|
||||
return CRM_Core_Page::run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Browse all custom data groups.
|
||||
*/
|
||||
public function browse() {
|
||||
// get all custom groups sorted by weight
|
||||
$premiums = array();
|
||||
$dao = new CRM_Contribute_DAO_Product();
|
||||
$dao->orderBy('name');
|
||||
$dao->find();
|
||||
|
||||
while ($dao->fetch()) {
|
||||
$premiums[$dao->id] = array();
|
||||
CRM_Core_DAO::storeValues($dao, $premiums[$dao->id]);
|
||||
// form all action links
|
||||
$action = array_sum(array_keys($this->links()));
|
||||
|
||||
if ($dao->is_active) {
|
||||
$action -= CRM_Core_Action::ENABLE;
|
||||
}
|
||||
else {
|
||||
$action -= CRM_Core_Action::DISABLE;
|
||||
}
|
||||
|
||||
$premiums[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(),
|
||||
$action,
|
||||
array('id' => $dao->id),
|
||||
ts('more'),
|
||||
FALSE,
|
||||
'premium.manage.row',
|
||||
'Premium',
|
||||
$dao->id
|
||||
);
|
||||
//Financial Type
|
||||
if (!empty($dao->financial_type_id)) {
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
$premiums[$dao->id]['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $dao->financial_type_id, 'name');
|
||||
}
|
||||
}
|
||||
$this->assign('rows', $premiums);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name of edit form.
|
||||
*
|
||||
* @return string
|
||||
* Classname of edit form.
|
||||
*/
|
||||
public function editForm() {
|
||||
return 'CRM_Contribute_Form_ManagePremiums';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get edit form name.
|
||||
*
|
||||
* @return string
|
||||
* name of this page.
|
||||
*/
|
||||
public function editName() {
|
||||
return 'Manage Premiums';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user context.
|
||||
*
|
||||
* @param null $mode
|
||||
*
|
||||
* @return string
|
||||
* user context.
|
||||
*/
|
||||
public function userContext($mode = NULL) {
|
||||
return 'civicrm/admin/contribute/managePremiums';
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
<?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
|
||||
*/
|
||||
class CRM_Contribute_Page_PaymentInfo extends CRM_Core_Page {
|
||||
public function preProcess() {
|
||||
$this->_component = CRM_Utils_Request::retrieve('component', 'String', $this, TRUE);
|
||||
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
|
||||
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
|
||||
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this, TRUE);
|
||||
$this->_cid = CRM_Utils_Request::retrieve('cid', 'String', $this, TRUE);
|
||||
|
||||
$this->assign('cid', $this->_cid);
|
||||
$this->assign('id', $this->_id);
|
||||
$this->assign('context', $this->_context);
|
||||
$this->assign('component', $this->_component);
|
||||
if ($this->_component != 'event') {
|
||||
$this->assign('hideButtonLinks', TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
public function browse() {
|
||||
$getTrxnInfo = $this->_context == 'transaction' ? TRUE : FALSE;
|
||||
$paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_id, $this->_component, $getTrxnInfo, TRUE);
|
||||
if ($this->_context == 'payment_info') {
|
||||
$this->assign('paymentInfo', $paymentInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run page.
|
||||
*
|
||||
* This typically involves assigning the appropriate
|
||||
* smarty variable :)
|
||||
*
|
||||
* @return string
|
||||
* The content generated by running this page
|
||||
*/
|
||||
public function run() {
|
||||
$this->preProcess();
|
||||
if ($this->_action) {
|
||||
$this->browse();
|
||||
}
|
||||
|
||||
return parent::run();
|
||||
}
|
||||
|
||||
}
|
224
sites/all/modules/civicrm/CRM/Contribute/Page/Premium.php
Normal file
224
sites/all/modules/civicrm/CRM/Contribute/Page/Premium.php
Normal file
|
@ -0,0 +1,224 @@
|
|||
<?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 Premiums.
|
||||
*/
|
||||
class CRM_Contribute_Page_Premium extends CRM_Core_Page_Basic {
|
||||
|
||||
/**
|
||||
* The action links that we need to display for the browse screen.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_links = NULL;
|
||||
|
||||
/**
|
||||
* Get BAO Name.
|
||||
*
|
||||
* @return string
|
||||
* Classname of BAO.
|
||||
*/
|
||||
public function getBAOName() {
|
||||
return 'CRM_Contribute_BAO_Premium';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get action Links.
|
||||
*
|
||||
* @return array
|
||||
* (reference) of action links
|
||||
*/
|
||||
public function &links() {
|
||||
if (!(self::$_links)) {
|
||||
// helper variable for nicer formatting
|
||||
$deleteExtra = ts('Are you sure you want to remove this product form this page?');
|
||||
|
||||
self::$_links = array(
|
||||
CRM_Core_Action::UPDATE => array(
|
||||
'name' => ts('Edit'),
|
||||
'url' => 'civicrm/admin/contribute/addProductToPage',
|
||||
'qs' => 'action=update&id=%%id%%&pid=%%pid%%&reset=1',
|
||||
'title' => ts('Edit Premium'),
|
||||
),
|
||||
CRM_Core_Action::PREVIEW => array(
|
||||
'name' => ts('Preview'),
|
||||
'url' => 'civicrm/admin/contribute/addProductToPage',
|
||||
'qs' => 'action=preview&id=%%id%%&pid=%%pid%%',
|
||||
'title' => ts('Preview Premium'),
|
||||
),
|
||||
CRM_Core_Action::DELETE => array(
|
||||
'name' => ts('Remove'),
|
||||
'url' => 'civicrm/admin/contribute/addProductToPage',
|
||||
'qs' => 'action=delete&id=%%id%%&pid=%%pid%%',
|
||||
'extra' => 'onclick = "if (confirm(\'' . $deleteExtra . '\') ) this.href+=\'&confirmed=1\'; else return false;"',
|
||||
'title' => ts('Disable Premium'),
|
||||
),
|
||||
);
|
||||
}
|
||||
return self::$_links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the page.
|
||||
*
|
||||
* This method is called after the page is created. It checks for the
|
||||
* type of action and executes that action.
|
||||
* Finally it calls the parent's run method.
|
||||
*/
|
||||
public function run() {
|
||||
// get the requested action
|
||||
$action = CRM_Utils_Request::retrieve('action', 'String',
|
||||
// default to 'browse'
|
||||
$this, FALSE, 'browse'
|
||||
);
|
||||
|
||||
// assign vars to templates
|
||||
$this->assign('action', $action);
|
||||
$id = CRM_Utils_Request::retrieve('id', 'Positive',
|
||||
$this, FALSE, 0
|
||||
);
|
||||
$this->assign('id', $id);
|
||||
|
||||
$this->edit($action, $id, FALSE, FALSE);
|
||||
|
||||
// this is special case where we need to call browse to list premium
|
||||
if ($action == CRM_Core_Action::UPDATE) {
|
||||
$this->browse();
|
||||
}
|
||||
|
||||
// parent run
|
||||
return parent::run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Browse function.
|
||||
*/
|
||||
public function browse() {
|
||||
// get all custom groups sorted by weight
|
||||
$premiums = array();
|
||||
$pageID = CRM_Utils_Request::retrieve('id', 'Positive',
|
||||
$this, FALSE, 0
|
||||
);
|
||||
$dao = new CRM_Contribute_DAO_Premium();
|
||||
$dao->entity_table = 'civicrm_contribution_page';
|
||||
$dao->entity_id = $pageID;
|
||||
$dao->find(TRUE);
|
||||
$premiumID = $dao->id;
|
||||
$this->assign('products', FALSE);
|
||||
$this->assign('id', $pageID);
|
||||
if (!$premiumID) {
|
||||
return;
|
||||
}
|
||||
|
||||
$dao = new CRM_Contribute_DAO_PremiumsProduct();
|
||||
$dao->premiums_id = $premiumID;
|
||||
$dao->orderBy('weight');
|
||||
$dao->find();
|
||||
|
||||
while ($dao->fetch()) {
|
||||
$productDAO = new CRM_Contribute_DAO_Product();
|
||||
$productDAO->id = $dao->product_id;
|
||||
$productDAO->is_active = 1;
|
||||
|
||||
if ($productDAO->find(TRUE)) {
|
||||
$premiums[$productDAO->id] = array();
|
||||
$premiums[$productDAO->id]['weight'] = $dao->weight;
|
||||
CRM_Core_DAO::storeValues($productDAO, $premiums[$productDAO->id]);
|
||||
|
||||
$action = array_sum(array_keys($this->links()));
|
||||
|
||||
$premiums[$dao->product_id]['action'] = CRM_Core_Action::formLink(self::links(), $action,
|
||||
array('id' => $pageID, 'pid' => $dao->id),
|
||||
ts('more'),
|
||||
FALSE,
|
||||
'premium.contributionpage.row',
|
||||
'Premium',
|
||||
$dao->id
|
||||
);
|
||||
//Financial Type
|
||||
if (!empty($dao->financial_type_id)) {
|
||||
$premiums[$productDAO->id]['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $dao->financial_type_id, 'name');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count(CRM_Contribute_PseudoConstant::products($pageID)) == 0) {
|
||||
$this->assign('products', FALSE);
|
||||
}
|
||||
else {
|
||||
$this->assign('products', TRUE);
|
||||
}
|
||||
|
||||
// Add order changing widget to selector
|
||||
$returnURL = CRM_Utils_System::url('civicrm/admin/contribute/premium', "reset=1&action=update&id={$pageID}");
|
||||
$filter = "premiums_id = {$premiumID}";
|
||||
CRM_Utils_Weight::addOrder($premiums, 'CRM_Contribute_DAO_PremiumsProduct',
|
||||
'id', $returnURL, $filter
|
||||
);
|
||||
$this->assign('rows', $premiums);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name of edit form.
|
||||
*
|
||||
* @return string
|
||||
* Classname of edit form.
|
||||
*/
|
||||
public function editForm() {
|
||||
return 'CRM_Contribute_Form_ContributionPage_Premium';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get edit form name.
|
||||
*
|
||||
* @return string
|
||||
* name of this page.
|
||||
*/
|
||||
public function editName() {
|
||||
return 'Configure Premiums';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user context.
|
||||
*
|
||||
* @param null $mode
|
||||
*
|
||||
* @return string
|
||||
* user context.
|
||||
*/
|
||||
public function userContext($mode = NULL) {
|
||||
return CRM_Utils_System::currentPath();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
<?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
|
||||
*/
|
||||
class CRM_Contribute_Page_SubscriptionStatus extends CRM_Core_Page {
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
$task = CRM_Utils_Request::retrieve('task', 'String');
|
||||
$result = CRM_Utils_Request::retrieve('result', 'Integer');
|
||||
|
||||
$this->assign('task', $task);
|
||||
$this->assign('result', $result);
|
||||
|
||||
if ($task == 'billing') {
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$tplParams = $session->get('resultParams');
|
||||
foreach ($tplParams as $key => $val) {
|
||||
$this->assign($key, $val);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::run();
|
||||
}
|
||||
|
||||
}
|
470
sites/all/modules/civicrm/CRM/Contribute/Page/Tab.php
Normal file
470
sites/all/modules/civicrm/CRM/Contribute/Page/Tab.php
Normal file
|
@ -0,0 +1,470 @@
|
|||
<?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
|
||||
*/
|
||||
class CRM_Contribute_Page_Tab extends CRM_Core_Page {
|
||||
|
||||
/**
|
||||
* The action links that we need to display for the browse screen.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_links = NULL;
|
||||
static $_recurLinks = NULL;
|
||||
public $_permission = NULL;
|
||||
public $_contactId = NULL;
|
||||
public $_crid = NULL;
|
||||
|
||||
/**
|
||||
* This method returns the links that are given for recur search row.
|
||||
* currently the links added for each row are:
|
||||
* - View
|
||||
* - Edit
|
||||
* - Cancel
|
||||
*
|
||||
* @param bool $recurID
|
||||
* @param string $context
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function &recurLinks($recurID = FALSE, $context = 'contribution') {
|
||||
if (!(self::$_links)) {
|
||||
self::$_links = array(
|
||||
CRM_Core_Action::VIEW => array(
|
||||
'name' => ts('View'),
|
||||
'title' => ts('View Recurring Payment'),
|
||||
'url' => 'civicrm/contact/view/contributionrecur',
|
||||
'qs' => "reset=1&id=%%crid%%&cid=%%cid%%&context={$context}",
|
||||
),
|
||||
CRM_Core_Action::UPDATE => array(
|
||||
'name' => ts('Edit'),
|
||||
'title' => ts('Edit Recurring Payment'),
|
||||
'url' => 'civicrm/contribute/updaterecur',
|
||||
'qs' => "reset=1&action=update&crid=%%crid%%&cid=%%cid%%&context={$context}",
|
||||
),
|
||||
CRM_Core_Action::DISABLE => array(
|
||||
'name' => ts('Cancel'),
|
||||
'title' => ts('Cancel'),
|
||||
'ref' => 'crm-enable-disable',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if ($recurID) {
|
||||
$links = self::$_links;
|
||||
$paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($recurID, 'recur', 'obj');
|
||||
if (is_object($paymentProcessorObj) && $paymentProcessorObj->supports('cancelRecurring')) {
|
||||
unset($links[CRM_Core_Action::DISABLE]['extra'], $links[CRM_Core_Action::DISABLE]['ref']);
|
||||
$links[CRM_Core_Action::DISABLE]['url'] = "civicrm/contribute/unsubscribe";
|
||||
$links[CRM_Core_Action::DISABLE]['qs'] = "reset=1&crid=%%crid%%&cid=%%cid%%&context={$context}";
|
||||
}
|
||||
|
||||
if (is_object($paymentProcessorObj) && $paymentProcessorObj->isSupported('updateSubscriptionBillingInfo')) {
|
||||
$links[CRM_Core_Action::RENEW] = array(
|
||||
'name' => ts('Change Billing Details'),
|
||||
'title' => ts('Change Billing Details'),
|
||||
'url' => 'civicrm/contribute/updatebilling',
|
||||
'qs' => "reset=1&crid=%%crid%%&cid=%%cid%%&context={$context}",
|
||||
);
|
||||
}
|
||||
return $links;
|
||||
}
|
||||
|
||||
return self::$_links;
|
||||
}
|
||||
// end function
|
||||
|
||||
/**
|
||||
* called when action is browse.
|
||||
*
|
||||
*/
|
||||
public function browse() {
|
||||
// add annual contribution
|
||||
$annual = array();
|
||||
list($annual['count'],
|
||||
$annual['amount'],
|
||||
$annual['avg']
|
||||
) = CRM_Contribute_BAO_Contribution::annual($this->_contactId);
|
||||
$this->assign('annual', $annual);
|
||||
|
||||
$controller = new CRM_Core_Controller_Simple(
|
||||
'CRM_Contribute_Form_Search',
|
||||
ts('Contributions'),
|
||||
$this->_action,
|
||||
FALSE, FALSE, TRUE
|
||||
);
|
||||
$controller->setEmbedded(TRUE);
|
||||
$controller->reset();
|
||||
$controller->set('cid', $this->_contactId);
|
||||
$controller->set('crid', $this->_crid);
|
||||
$controller->set('context', 'contribution');
|
||||
$controller->set('limit', 50);
|
||||
$controller->process();
|
||||
$controller->run();
|
||||
|
||||
// add recurring block
|
||||
$action = array_sum(array_keys($this->recurLinks()));
|
||||
$params = CRM_Contribute_BAO_ContributionRecur::getRecurContributions($this->_contactId);
|
||||
|
||||
if (!empty($params)) {
|
||||
foreach ($params as $ids => $recur) {
|
||||
$action = array_sum(array_keys($this->recurLinks($ids)));
|
||||
// no action allowed if it's not active
|
||||
$params[$ids]['is_active'] = ($recur['contribution_status_id'] != 3);
|
||||
|
||||
if ($params[$ids]['is_active']) {
|
||||
$details = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($params[$ids]['id'], 'recur');
|
||||
$hideUpdate = $details->membership_id & $details->auto_renew;
|
||||
|
||||
if ($hideUpdate) {
|
||||
$action -= CRM_Core_Action::UPDATE;
|
||||
}
|
||||
|
||||
$params[$ids]['action'] = CRM_Core_Action::formLink(self::recurLinks($ids), $action,
|
||||
array(
|
||||
'cid' => $this->_contactId,
|
||||
'crid' => $ids,
|
||||
'cxt' => 'contribution',
|
||||
),
|
||||
ts('more'),
|
||||
FALSE,
|
||||
'contribution.selector.recurring',
|
||||
'Contribution',
|
||||
$ids
|
||||
);
|
||||
}
|
||||
}
|
||||
// assign vars to templates
|
||||
$this->assign('action', $this->_action);
|
||||
$this->assign('recurRows', $params);
|
||||
$this->assign('recur', TRUE);
|
||||
}
|
||||
|
||||
//enable/disable soft credit records for test contribution
|
||||
$isTest = 0;
|
||||
if (CRM_Utils_Request::retrieve('isTest', 'Positive', $this)) {
|
||||
$isTest = 1;
|
||||
}
|
||||
$this->assign('isTest', $isTest);
|
||||
|
||||
$softCreditList = CRM_Contribute_BAO_ContributionSoft::getSoftContributionList($this->_contactId, NULL, $isTest);
|
||||
|
||||
if (!empty($softCreditList)) {
|
||||
$softCreditTotals = array();
|
||||
|
||||
list($softCreditTotals['amount'],
|
||||
$softCreditTotals['avg'],
|
||||
$softCreditTotals['currency'],
|
||||
$softCreditTotals['cancelAmount'] //to get cancel amount
|
||||
) = CRM_Contribute_BAO_ContributionSoft::getSoftContributionTotals($this->_contactId, $isTest);
|
||||
|
||||
$this->assign('softCredit', TRUE);
|
||||
$this->assign('softCreditRows', $softCreditList);
|
||||
$this->assign('softCreditTotals', $softCreditTotals);
|
||||
}
|
||||
|
||||
if ($this->_contactId) {
|
||||
$displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
|
||||
$this->assign('displayName', $displayName);
|
||||
$this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent('contribution', $this->_contactId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* called when action is view.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function view() {
|
||||
$controller = new CRM_Core_Controller_Simple(
|
||||
'CRM_Contribute_Form_ContributionView',
|
||||
ts('View Contribution'),
|
||||
$this->_action
|
||||
);
|
||||
$controller->setEmbedded(TRUE);
|
||||
$controller->set('id', $this->_id);
|
||||
$controller->set('cid', $this->_contactId);
|
||||
|
||||
return $controller->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* called when action is update or new.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function edit() {
|
||||
// set https for offline cc transaction
|
||||
$mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
|
||||
if ($mode == 'test' || $mode == 'live') {
|
||||
CRM_Utils_System::redirectToSSL();
|
||||
}
|
||||
|
||||
$controller = new CRM_Core_Controller_Simple(
|
||||
'CRM_Contribute_Form_Contribution',
|
||||
'Create Contribution',
|
||||
$this->_action
|
||||
);
|
||||
$controller->setEmbedded(TRUE);
|
||||
$controller->set('id', $this->_id);
|
||||
$controller->set('cid', $this->_contactId);
|
||||
|
||||
return $controller->run();
|
||||
}
|
||||
|
||||
public function preProcess() {
|
||||
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
|
||||
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
|
||||
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
|
||||
|
||||
if ($context == 'standalone') {
|
||||
$this->_action = CRM_Core_Action::ADD;
|
||||
}
|
||||
else {
|
||||
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, empty($this->_id));
|
||||
if (empty($this->_contactId)) {
|
||||
$this->_contactId = civicrm_api3('contribution', 'getvalue', array(
|
||||
'id' => $this->_id,
|
||||
'return' => 'contact_id',
|
||||
));
|
||||
}
|
||||
$this->assign('contactId', $this->_contactId);
|
||||
|
||||
// check logged in url permission
|
||||
CRM_Contact_Page_View::checkUserPermission($this);
|
||||
}
|
||||
$this->assign('action', $this->_action);
|
||||
|
||||
if ($this->_permission == CRM_Core_Permission::EDIT && !CRM_Core_Permission::check('edit contributions')) {
|
||||
// demote to view since user does not have edit contrib rights
|
||||
$this->_permission = CRM_Core_Permission::VIEW;
|
||||
$this->assign('permission', 'view');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
// check if we can process credit card contribs
|
||||
$this->assign('newCredit', CRM_Core_Config::isEnabledBackOfficeCreditCardPayments());
|
||||
|
||||
$this->setContext();
|
||||
|
||||
if ($this->_action & CRM_Core_Action::VIEW) {
|
||||
$this->view();
|
||||
}
|
||||
elseif ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::DELETE)) {
|
||||
$this->edit();
|
||||
}
|
||||
else {
|
||||
$this->browse();
|
||||
}
|
||||
|
||||
return parent::run();
|
||||
}
|
||||
|
||||
public function setContext() {
|
||||
$qfKey = CRM_Utils_Request::retrieve('key', 'String', $this);
|
||||
$context = CRM_Utils_Request::retrieve('context', 'String',
|
||||
$this, FALSE, 'search'
|
||||
);
|
||||
$compContext = CRM_Utils_Request::retrieve('compContext', 'String', $this);
|
||||
|
||||
$searchContext = CRM_Utils_Request::retrieve('searchContext', 'String', $this);
|
||||
|
||||
//swap the context.
|
||||
if ($context == 'search' && $compContext) {
|
||||
$context = $compContext;
|
||||
}
|
||||
else {
|
||||
$compContext = NULL;
|
||||
}
|
||||
|
||||
// make sure we dont get tricked with a bad key
|
||||
// so check format
|
||||
if (!CRM_Core_Key::valid($qfKey)) {
|
||||
$qfKey = NULL;
|
||||
}
|
||||
|
||||
$session = CRM_Core_Session::singleton();
|
||||
|
||||
switch ($context) {
|
||||
case 'user':
|
||||
$url = CRM_Utils_System::url('civicrm/user', 'reset=1');
|
||||
break;
|
||||
|
||||
case 'dashboard':
|
||||
$url = CRM_Utils_System::url('civicrm/contribute',
|
||||
'reset=1'
|
||||
);
|
||||
break;
|
||||
|
||||
case 'pledgeDashboard':
|
||||
$url = CRM_Utils_System::url('civicrm/pledge',
|
||||
'reset=1'
|
||||
);
|
||||
break;
|
||||
|
||||
case 'contribution':
|
||||
$url = CRM_Utils_System::url('civicrm/contact/view',
|
||||
"reset=1&force=1&cid={$this->_contactId}&selectedChild=contribute"
|
||||
);
|
||||
break;
|
||||
|
||||
case 'search':
|
||||
case 'advanced':
|
||||
$extraParams = "force=1";
|
||||
if ($qfKey) {
|
||||
$extraParams .= "&qfKey=$qfKey";
|
||||
}
|
||||
|
||||
$this->assign('searchKey', $qfKey);
|
||||
if ($context == 'advanced') {
|
||||
$url = CRM_Utils_System::url('civicrm/contact/search/advanced', $extraParams);
|
||||
}
|
||||
elseif ($searchContext) {
|
||||
$url = CRM_Utils_System::url("civicrm/$searchContext/search", $extraParams);
|
||||
}
|
||||
else {
|
||||
$url = CRM_Utils_System::url('civicrm/contribute/search', $extraParams);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'home':
|
||||
$url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
|
||||
break;
|
||||
|
||||
case 'activity':
|
||||
$url = CRM_Utils_System::url('civicrm/contact/view',
|
||||
"reset=1&force=1&cid={$this->_contactId}&selectedChild=activity"
|
||||
);
|
||||
break;
|
||||
|
||||
case 'member':
|
||||
case 'membership':
|
||||
$componentId = CRM_Utils_Request::retrieve('compId', 'Positive', $this);
|
||||
$componentAction = CRM_Utils_Request::retrieve('compAction', 'Integer', $this);
|
||||
|
||||
$context = 'membership';
|
||||
$searchKey = NULL;
|
||||
if ($compContext) {
|
||||
$context = 'search';
|
||||
if ($qfKey) {
|
||||
$searchKey = "&key=$qfKey";
|
||||
}
|
||||
$compContext = "&compContext={$compContext}";
|
||||
}
|
||||
if ($componentAction & CRM_Core_Action::VIEW) {
|
||||
$action = 'view';
|
||||
}
|
||||
else {
|
||||
$action = 'update';
|
||||
}
|
||||
$url = CRM_Utils_System::url('civicrm/contact/view/membership',
|
||||
"reset=1&action={$action}&id={$componentId}&cid={$this->_contactId}&context={$context}&selectedChild=member{$searchKey}{$compContext}"
|
||||
);
|
||||
break;
|
||||
|
||||
case 'participant':
|
||||
$componentId = CRM_Utils_Request::retrieve('compId', 'Positive', $this);
|
||||
$componentAction = CRM_Utils_Request::retrieve('compAction', 'Integer', $this);
|
||||
|
||||
$context = 'participant';
|
||||
$searchKey = NULL;
|
||||
if ($compContext) {
|
||||
$context = 'search';
|
||||
if ($qfKey) {
|
||||
$searchKey = "&key=$qfKey";
|
||||
}
|
||||
$compContext = "&compContext={$compContext}";
|
||||
}
|
||||
if ($componentAction == CRM_Core_Action::VIEW) {
|
||||
$action = 'view';
|
||||
}
|
||||
else {
|
||||
$action = 'update';
|
||||
}
|
||||
$url = CRM_Utils_System::url('civicrm/contact/view/participant',
|
||||
"reset=1&action={$action}&id={$componentId}&cid={$this->_contactId}&context={$context}&selectedChild=event{$searchKey}{$compContext}"
|
||||
);
|
||||
break;
|
||||
|
||||
case 'pledge':
|
||||
$url = CRM_Utils_System::url('civicrm/contact/view',
|
||||
"reset=1&force=1&cid={$this->_contactId}&selectedChild=pledge"
|
||||
);
|
||||
break;
|
||||
|
||||
case 'standalone':
|
||||
$url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
|
||||
break;
|
||||
|
||||
case 'fulltext':
|
||||
$keyName = '&qfKey';
|
||||
$urlParams = 'force=1';
|
||||
$urlString = 'civicrm/contact/search/custom';
|
||||
if ($this->_action == CRM_Core_Action::UPDATE) {
|
||||
if ($this->_contactId) {
|
||||
$urlParams .= '&cid=' . $this->_contactId;
|
||||
}
|
||||
$keyName = '&key';
|
||||
$urlParams .= '&context=fulltext&action=view';
|
||||
$urlString = 'civicrm/contact/view/contribution';
|
||||
}
|
||||
if ($qfKey) {
|
||||
$urlParams .= "$keyName=$qfKey";
|
||||
}
|
||||
$this->assign('searchKey', $qfKey);
|
||||
$url = CRM_Utils_System::url($urlString, $urlParams);
|
||||
break;
|
||||
|
||||
default:
|
||||
$cid = NULL;
|
||||
if ($this->_contactId) {
|
||||
$cid = '&cid=' . $this->_contactId;
|
||||
}
|
||||
$url = CRM_Utils_System::url('civicrm/contribute/search',
|
||||
'reset=1&force=1' . $cid
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$session->pushUserContext($url);
|
||||
}
|
||||
|
||||
}
|
151
sites/all/modules/civicrm/CRM/Contribute/Page/UserDashboard.php
Normal file
151
sites/all/modules/civicrm/CRM/Contribute/Page/UserDashboard.php
Normal file
|
@ -0,0 +1,151 @@
|
|||
<?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
|
||||
*/
|
||||
class CRM_Contribute_Page_UserDashboard extends CRM_Contact_Page_View_UserDashBoard {
|
||||
|
||||
/**
|
||||
* called when action is browse.
|
||||
*/
|
||||
public function listContribution() {
|
||||
$controller = new CRM_Core_Controller_Simple(
|
||||
'CRM_Contribute_Form_Search',
|
||||
ts('Contributions'),
|
||||
NULL,
|
||||
FALSE, FALSE, TRUE, FALSE
|
||||
);
|
||||
$controller->setEmbedded(TRUE);
|
||||
$controller->reset();
|
||||
$controller->set('limit', 12);
|
||||
$controller->set('cid', $this->_contactId);
|
||||
$controller->set('context', 'user');
|
||||
$controller->set('force', 1);
|
||||
$controller->process();
|
||||
$controller->run();
|
||||
|
||||
//add honor block
|
||||
$params = CRM_Contribute_BAO_Contribution::getHonorContacts($this->_contactId);
|
||||
|
||||
if (!empty($params)) {
|
||||
// assign vars to templates
|
||||
$this->assign('honorRows', $params);
|
||||
$this->assign('honor', TRUE);
|
||||
}
|
||||
|
||||
$recur = new CRM_Contribute_DAO_ContributionRecur();
|
||||
$recur->contact_id = $this->_contactId;
|
||||
$recur->is_test = 0;
|
||||
$recur->find();
|
||||
|
||||
$config = CRM_Core_Config::singleton();
|
||||
|
||||
$recurStatus = CRM_Contribute_PseudoConstant::contributionStatus();
|
||||
|
||||
$recurRow = array();
|
||||
$recurIDs = array();
|
||||
while ($recur->fetch()) {
|
||||
$mode = $recur->is_test ? 'test' : 'live';
|
||||
$paymentProcessor = CRM_Contribute_BAO_ContributionRecur::getPaymentProcessor($recur->id,
|
||||
$mode
|
||||
);
|
||||
if (!$paymentProcessor) {
|
||||
continue;
|
||||
}
|
||||
|
||||
require_once 'api/v3/utils.php';
|
||||
//@todo calling api functions directly is not supported
|
||||
_civicrm_api3_object_to_array($recur, $values);
|
||||
|
||||
$values['recur_status'] = $recurStatus[$values['contribution_status_id']];
|
||||
$recurRow[$values['id']] = $values;
|
||||
|
||||
$action = array_sum(array_keys(CRM_Contribute_Page_Tab::recurLinks($recur->id, 'dashboard')));
|
||||
|
||||
$details = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($recur->id, 'recur');
|
||||
$hideUpdate = $details->membership_id & $details->auto_renew;
|
||||
|
||||
if ($hideUpdate) {
|
||||
$action -= CRM_Core_Action::UPDATE;
|
||||
}
|
||||
|
||||
$recurRow[$values['id']]['action'] = CRM_Core_Action::formLink(CRM_Contribute_Page_Tab::recurLinks($recur->id, 'dashboard'),
|
||||
$action, array(
|
||||
'cid' => $this->_contactId,
|
||||
'crid' => $values['id'],
|
||||
'cxt' => 'contribution',
|
||||
),
|
||||
ts('more'),
|
||||
FALSE,
|
||||
'contribution.dashboard.recurring',
|
||||
'Contribution',
|
||||
$values['id']
|
||||
);
|
||||
|
||||
$recurIDs[] = $values['id'];
|
||||
|
||||
//reset $paymentObject for checking other paymenet processor
|
||||
//recurring url
|
||||
$paymentObject = NULL;
|
||||
}
|
||||
if (is_array($recurIDs) && !empty($recurIDs)) {
|
||||
$getCount = CRM_Contribute_BAO_ContributionRecur::getCount($recurIDs);
|
||||
foreach ($getCount as $key => $val) {
|
||||
$recurRow[$key]['completed'] = $val;
|
||||
$recurRow[$key]['link'] = CRM_Utils_System::url('civicrm/contribute/search',
|
||||
"reset=1&force=1&recur=$key"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->assign('recurRows', $recurRow);
|
||||
if (!empty($recurRow)) {
|
||||
$this->assign('recur', TRUE);
|
||||
}
|
||||
else {
|
||||
$this->assign('recur', FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* the main function that is called when the page
|
||||
* loads, it decides the which action has to be taken for the page.
|
||||
*/
|
||||
public function run() {
|
||||
$invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
|
||||
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
|
||||
$defaultInvoicePage = CRM_Utils_Array::value('default_invoice_page', $invoiceSettings);
|
||||
$this->assign('invoicing', $invoicing);
|
||||
$this->assign('defaultInvoicePage', $defaultInvoicePage);
|
||||
parent::preProcess();
|
||||
$this->listContribution();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue