From 6c65142573b50c6e1e56a2b82f45f99f2629a483 Mon Sep 17 00:00:00 2001 From: Jon Goldberg Date: Tue, 13 Aug 2019 14:06:08 -0400 Subject: [PATCH] display batch export date on contribution forms --- batchexportperm.php | 43 +++++++++++++------ js/exportDate.js | 3 ++ .../CRM/Batchexportperm/Form/BatchDetails.tpl | 16 +++++++ 3 files changed, 50 insertions(+), 12 deletions(-) create mode 100644 js/exportDate.js create mode 100644 templates/CRM/Batchexportperm/Form/BatchDetails.tpl diff --git a/batchexportperm.php b/batchexportperm.php index 51fb01b..72861d5 100644 --- a/batchexportperm.php +++ b/batchexportperm.php @@ -1,7 +1,7 @@ [$contributionId, 'Integer']]; - $dao = CRM_Core_DAO::executeQuery($query, $params); - - if ($dao->N === 0 || CRM_Core_Permission::check('edit exported contributions')) { - return TRUE; - } - return FALSE; + $date = CRM_Core_DAO::singleValueQuery($query, $params); + return CRM_Utils_Date::customFormat($date); } /** @@ -278,8 +292,13 @@ function batchexportperm_civicrm_post($op, $objectName, $objectId, &$objectRef) * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_buildForm */ function batchexportperm_civicrm_buildForm($formName, $form) { - if (in_array($formName, ['CRM_Contribute_Form_ContributionView', 'CRM_Contribute_Form_Contribution']) && - !empty($form->_id)) { - $temp = $form->_id; - $temp2 = } + if ($formName == 'CRM_Contribute_Form_ContributionView' || + $formName == 'CRM_Contribute_Form_Contribution' && !empty($form->_id)) { + // ContributionView doesn't pass the ID in the form object? Really? + $contributionId = $form->_id ?? CRM_Utils_Request::retrieve('id', 'Positive'); + $exportDate = _getExportData($contributionId); + $form->assign('exportDate', $exportDate); + CRM_Core_Region::instance('page-body')->add(['template' => "CRM/Batchexportperm/Form/BatchDetails.tpl"]); + CRM_Core_Resources::singleton()->addScriptFile('org.agbu.batchexportperm', 'js/exportDate.js'); + } } diff --git a/js/exportDate.js b/js/exportDate.js new file mode 100644 index 0000000..5636991 --- /dev/null +++ b/js/exportDate.js @@ -0,0 +1,3 @@ +CRM.$(function ($) { + $('#export-details-accordion').insertBefore('.crm-submit-buttons:last'); +}); diff --git a/templates/CRM/Batchexportperm/Form/BatchDetails.tpl b/templates/CRM/Batchexportperm/Form/BatchDetails.tpl new file mode 100644 index 0000000..7b8a412 --- /dev/null +++ b/templates/CRM/Batchexportperm/Form/BatchDetails.tpl @@ -0,0 +1,16 @@ + +
+
+ {ts}Export Details{/ts} +
+
+ + + + + +
Export Date{$exportDate}
+
+
+ +