From 37c782867562c457651ab5949de59a850f6d3348 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 22 May 2013 17:38:44 -0500 Subject: [PATCH] Remove giftaid CRM-9794 ---------------------------------------- * CRM-9794: http://issues.civicrm.org/jira/browse/CRM-9794 --- .../civicrm_giftaid/CustomGroupData.xml | 427 ------------------ .../GiftAid/Form/Task/AddToGiftAid.php | 162 ------- .../Report/Form/Contribute/GiftAid.php | 176 -------- .../GiftAid/Utils/Contribution.php | 264 ----------- .../civicrm_giftaid/GiftAid/Utils/GiftAid.php | 325 ------------- .../civicrm_giftaid/GiftAid/Utils/Hook.php | 109 ----- tools/drupal/modules/civicrm_giftaid/README | 8 - .../civicrm_giftaid/civicrm_giftaid.admin.inc | 30 -- .../civicrm_giftaid/civicrm_giftaid.info | 7 - .../civicrm_giftaid/civicrm_giftaid.install | 6 - .../civicrm_giftaid/civicrm_giftaid.module | 229 ---------- .../GiftAid/Form/Task/AddToGiftAid.tpl | 151 ------- .../Report/Form/Contribute/GiftAid.tpl | 27 -- .../civicrm_giftaid/tests/DeclarationTest.php | 113 ----- .../civicrm_giftaid_alpha/CustomGroupData.xml | 80 ---- .../civicrm_giftaid_alpha.info | 8 - .../civicrm_giftaid_alpha.module | 180 -------- 17 files changed, 2302 deletions(-) delete mode 100644 tools/drupal/modules/civicrm_giftaid/CustomGroupData.xml delete mode 100644 tools/drupal/modules/civicrm_giftaid/GiftAid/Form/Task/AddToGiftAid.php delete mode 100644 tools/drupal/modules/civicrm_giftaid/GiftAid/Report/Form/Contribute/GiftAid.php delete mode 100644 tools/drupal/modules/civicrm_giftaid/GiftAid/Utils/Contribution.php delete mode 100644 tools/drupal/modules/civicrm_giftaid/GiftAid/Utils/GiftAid.php delete mode 100644 tools/drupal/modules/civicrm_giftaid/GiftAid/Utils/Hook.php delete mode 100644 tools/drupal/modules/civicrm_giftaid/README delete mode 100644 tools/drupal/modules/civicrm_giftaid/civicrm_giftaid.admin.inc delete mode 100755 tools/drupal/modules/civicrm_giftaid/civicrm_giftaid.info delete mode 100644 tools/drupal/modules/civicrm_giftaid/civicrm_giftaid.install delete mode 100644 tools/drupal/modules/civicrm_giftaid/civicrm_giftaid.module delete mode 100644 tools/drupal/modules/civicrm_giftaid/templates/GiftAid/Form/Task/AddToGiftAid.tpl delete mode 100644 tools/drupal/modules/civicrm_giftaid/templates/GiftAid/Report/Form/Contribute/GiftAid.tpl delete mode 100644 tools/drupal/modules/civicrm_giftaid/tests/DeclarationTest.php delete mode 100644 tools/drupal/modules/civicrm_giftaid_alpha/CustomGroupData.xml delete mode 100755 tools/drupal/modules/civicrm_giftaid_alpha/civicrm_giftaid_alpha.info delete mode 100644 tools/drupal/modules/civicrm_giftaid_alpha/civicrm_giftaid_alpha.module diff --git a/tools/drupal/modules/civicrm_giftaid/CustomGroupData.xml b/tools/drupal/modules/civicrm_giftaid/CustomGroupData.xml deleted file mode 100644 index 9d0a482f02..0000000000 --- a/tools/drupal/modules/civicrm_giftaid/CustomGroupData.xml +++ /dev/null @@ -1,427 +0,0 @@ - - - - - - Gift_Aid_Declaration - Gift Aid Declaration - Individual - - 0 - - - 1 - 1 - civicrm_value_gift_aid_declaration - 1 - 0 - 2010-10-03 02:28:19 - - - Gift_Aid - Gift Aid - Contribution - - 1 - Stores the values that are submitted in the Gift Aid Report - - 2 - 1 - civicrm_value_gift_aid_submission - 0 - 0 - 2010-10-03 02:32:44 - - - - - Eligible_for_Gift_Aid - - Boolean - Radio - 1 - 0 - 0 - 1 - 1 - 0 - 255 - 60 - 4 - eligible_for_gift_aid - Gift_Aid_Declaration - - - Start_Date - - Date - Select Date - 1 - 0 - 0 - 2 - 1 - 0 - 255 - dd-mm-yy - 60 - 4 - start_date - Gift_Aid_Declaration - - - End_Date - - Date - Select Date - 0 - 0 - 0 - 3 - 1 - 0 - 255 - dd-mm-yy - 60 - 4 - end_date - Gift_Aid_Declaration - - - Reason_Ended - - String - Radio - 0 - 0 - 0 - 5 - 1 - 0 - 32 - 60 - 4 - reason_ended - reason_ended - Gift_Aid_Declaration - - - Source - - String - Text - 0 - 0 - 0 - 6 - 1 - 0 - 32 - 60 - 4 - source - Gift_Aid_Declaration - - - Notes - - Memo - TextArea - 0 - 0 - 0 - 7 - rows=4, cols=60 - 1 - 0 - 255 - 60 - 4 - notes - Gift_Aid_Declaration - - - Eligible_for_Gift_Aid - - Boolean - Radio - 1 - 0 - 0 - 1 - 1 - 0 - 255 - 60 - 4 - eligible_for_gift_aid - Gift_Aid - - - Contributor_Name - - String - Text - 0 - 1 - 0 - 2 - 1 - 1 - 255 - 60 - 4 - name - Gift_Aid - - - Address - - Memo - TextArea - 0 - 1 - 0 - 4 - rows=4, cols=60 - 1 - 1 - 255 - 60 - 4 - address - Gift_Aid - - - Post_Code - - String - Text - 0 - 1 - 0 - 6 - 1 - 1 - 16 - 60 - 4 - post_code - Gift_Aid - - - Amount - - Money - Text - 0 - 1 - 1 - 7 - 1 - 1 - 255 - 60 - 4 - amount - Gift_Aid - - - Gift_Aid_Amount - - Money - Text - 0 - 1 - 1 - 8 - 1 - 1 - 255 - 60 - 4 - gift_aid_amount - Gift_Aid - - - - - reason_ended - - 1 - - - - - - Contact Declined - Contact_Declined - 0 - 2 - 0 - 0 - 1 - reason_ended - - - - HMRC Declined - HMRC_Declined - 0 - 1 - 0 - 0 - 1 - reason_ended - - - - - 1 - Contribution,Individual,Contact - Gift Aid - 0 - 0 - 0 - 0 - 2 - Gift_Aid - 2010-10-03 14:54:18 - 0 - - - - - custom.civicrm_value_gift_aid_submission.eligible_for_gift_aid - 1 - 0 - 1 - 1 - <p>By selecting 'Yes' above you are confirming that -<ol> -<li>you are a UK taxpayer and</li> -<li>the amount of income and/or capital gains tax you pay is at least as much as we will reclaim on your donations in this tax year.</li> -</ol> -<p><b>About Gift Aid</b><p> -<p>Gift Aid increases the value of donations to charities by allowing them to reclaim basic rate tax on your gift. We would like to reclaim gift aid on your behalf. We can only reclaim Gift Aid if you are a UK taxpayer. Please confirm that you are a eligible for gift aid above. <a href="http://www.hmrc.gov.uk/individuals/giving/gift-aid.htm">More about Gift Aid</a>.</p> - User and User Admin Only - 0 - 0 - - Contribution - Gift_Aid - - - first_name - 1 - 0 - 1 - 2 - - User and User Admin Only - 0 - 0 - - Individual - Gift_Aid - - - last_name - 1 - 0 - 1 - 3 - - User and User Admin Only - 0 - 0 - - Individual - Gift_Aid - - - street_address - 1 - 0 - 1 - 4 - - User and User Admin Only - 0 - 0 - - Contact - Gift_Aid - - - supplemental_address_1 - 1 - 0 - 0 - 5 - - User and User Admin Only - 0 - 0 - - Contact - Gift_Aid - - - supplemental_address_2 - 1 - 0 - 0 - 6 - - User and User Admin Only - 0 - 0 - - Contact - Gift_Aid - - - city - 1 - 0 - 0 - 7 - - User and User Admin Only - 0 - 0 - - Contact - Gift_Aid - - - state_province - 1 - 0 - 0 - 8 - - User and User Admin Only - 0 - 0 - - Contact - Gift_Aid - - - postal_code - 1 - 0 - 1 - 9 - - User and User Admin Only - 0 - 0 - - Contact - Gift_Aid - - - diff --git a/tools/drupal/modules/civicrm_giftaid/GiftAid/Form/Task/AddToGiftAid.php b/tools/drupal/modules/civicrm_giftaid/GiftAid/Form/Task/AddToGiftAid.php deleted file mode 100644 index f987165312..0000000000 --- a/tools/drupal/modules/civicrm_giftaid/GiftAid/Form/Task/AddToGiftAid.php +++ /dev/null @@ -1,162 +0,0 @@ -_contributionIds); - $this->assign('selectedContributions', $total); - $this->assign('totalAddedContributions', count($added)); - $this->assign('alreadyAddedContributions', count($alreadyAdded)); - $this->assign('notValidContributions', count($notValid)); - - // get details of contribution that will be added to this batch. - $contributionsAddedRows = array(); - $contributionsAddedRows = GiftAid_Utils_Contribution::getContributionDetails($added); - $this->assign('contributionsAddedRows', $contributionsAddedRows); - - // get details of contribution thatare already added to this batch. - $contributionsAlreadyAddedRows = array(); - $contributionsAlreadyAddedRows = GiftAid_Utils_Contribution::getContributionDetails($alreadyAdded); - $this->assign('contributionsAlreadyAddedRows', $contributionsAlreadyAddedRows); - } - - /** - * Build the form - * - * @access public - * - * @return void - */ - function buildQuickForm() { - $attributes = CRM_Core_DAO::getAttribute('CRM_Batch_DAO_Batch'); - - $this->add('text', 'title', - ts('Batch Label'), - $attributes['label'], TRUE - ); - - $this->addRule('title', ts('Label already exists in Database.'), - 'objectExists', array('CRM_Batch_DAO_Batch', $this->_id, 'label') - ); - - $this->add('textarea', 'description', ts('Description:') . ' ', - $attributes['description'] - ); - - $defaults = array('label' => ts('Gift Aid Batch %1 (%2)'), - '%1' => date('d-m-Y'), - '%2' => date('H:i:s'), - ); - $this->setDefaults($defaults); - - $this->addDefaultButtons(ts('Add to batch')); - } - - /** - * process the form after the input has been submitted and validated - * - * @access public - * - * @return None - */ - public function postProcess() { - - $params = $this->controller->exportValues(); - $batchParams = array(); - $batchParams['label'] = $params['title']; - $batchParams['name'] = CRM_Utils_String::titleToVar($params['title'], 63); - $batchParams['description'] = $params['description']; - $batchParams['batch_type'] = "Gift Aid"; - - $session = &CRM_Core_Session::singleton(); - $batchParams['created_id'] = $session->get('userID'); - $batchParams['created_date'] = date("YmdHis"); - - require_once 'CRM/Core/Transaction.php'; - $transaction = new CRM_Core_Transaction(); - - require_once 'CRM/Core/BAO/Batch.php'; - $createdBatch = CRM_Batch_BAO_Batch::create($batchParams); - $batchID = $createdBatch->id; - $batchLabel = $batchParams['label']; - - require_once 'GiftAid/Utils/Contribution.php'; - list($total, $added, $notAdded) = GiftAid_Utils_Contribution::addContributionToBatch($this->_contributionIds, $batchID); - - if ($added <= 0) { - // rollback since there were no contributions added, and we might not want to keep an empty batch - $transaction->rollback(); - $status = ts('Could not create batch "%1", as there were no valid contribution(s) to be added.', - array(1 => $batchLabel) - ); - } - else { - $status = array(ts('Added Contribution(s) to %1', array(1 => $batchLabel)), - ts('Total Selected Contribution(s): %1', array(1 => $total)), - ); - if ($added) { - $status[] = ts('Total Contribution(s) added to batch: %1', array(1 => $added)); - } - if ($notAdded) { - $status[] = ts('Total Contribution(s) already in batch or not valid: %1', array(1 => $notAdded)); - } - $status = implode('
', $status); - } - $transaction->commit(); - CRM_Core_Session::setStatus($status); - } - //end of function -} - diff --git a/tools/drupal/modules/civicrm_giftaid/GiftAid/Report/Form/Contribute/GiftAid.php b/tools/drupal/modules/civicrm_giftaid/GiftAid/Report/Form/Contribute/GiftAid.php deleted file mode 100644 index d99350aa75..0000000000 --- a/tools/drupal/modules/civicrm_giftaid/GiftAid/Report/Form/Contribute/GiftAid.php +++ /dev/null @@ -1,176 +0,0 @@ -_columns = array('civicrm_entity_batch' => - array('dao' => 'CRM_Batch_DAO_EntityBatch', - 'filters' => - array( - 'batch_id' => - array('title' => 'Batch', - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => GiftAid_Utils_Contribution::getBatchIdTitle('id desc'), - ), - ), - ), - 'civicrm_contribution' => - array('dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => - array( - 'contribution_id' => - array( - 'name' => 'id', - 'no_display' => TRUE, - 'required' => TRUE, - ), - ), - ), - ); - - parent::__construct(); - - // set defaults - if (is_array($this->_columns['civicrm_value_gift_aid_submission'])) { - foreach ($this->_columns['civicrm_value_gift_aid_submission']['fields'] as $field => $values) { - $this->_columns['civicrm_value_gift_aid_submission']['fields'][$field]['default'] = TRUE; - } - } - } - - function select() { - $select = array(); - - $this->_columnHeaders = array(); - foreach ($this->_columns as $tableName => $table) { - if (array_key_exists('fields', $table)) { - foreach ($table['fields'] as $fieldName => $field) { - if (CRM_Utils_Array::value('required', $field) || - CRM_Utils_Array::value($fieldName, $this->_params['fields']) - ) { - if ($tableName == 'civicrm_address') { - $this->_addressField = TRUE; - } - elseif ($tableName == 'civicrm_email') { - $this->_emailField = TRUE; - } - - // only include statistics columns if set - if (CRM_Utils_Array::value('statistics', $field)) { - foreach ($field['statistics'] as $stat => $label) { - switch (strtolower($stat)) { - case 'sum': - $select[] = "SUM({$field['dbAlias']}) as {$tableName}_{$fieldName}_{$stat}"; - $this->_columnHeaders["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label; - $this->_columnHeaders["{$tableName}_{$fieldName}_{$stat}"]['type'] = $field['type']; - $this->_statFields[] = "{$tableName}_{$fieldName}_{$stat}"; - break; - - case 'count': - $select[] = "COUNT({$field['dbAlias']}) as {$tableName}_{$fieldName}_{$stat}"; - $this->_columnHeaders["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label; - $this->_statFields[] = "{$tableName}_{$fieldName}_{$stat}"; - break; - - case 'avg': - $select[] = "ROUND(AVG({$field['dbAlias']}),2) as {$tableName}_{$fieldName}_{$stat}"; - $this->_columnHeaders["{$tableName}_{$fieldName}_{$stat}"]['type'] = $field['type']; - $this->_columnHeaders["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label; - $this->_statFields[] = "{$tableName}_{$fieldName}_{$stat}"; - break; - } - } - } - else { - $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title']; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); - } - } - } - } - } - - $this->_select = "SELECT " . implode(', ', $select) . " "; - } - - function from() { - $this->_from = " -FROM civicrm_entity_batch {$this->_aliases['civicrm_entity_batch']} -INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']} - ON {$this->_aliases['civicrm_entity_batch']}.entity_table = 'civicrm_contribution' AND - {$this->_aliases['civicrm_entity_batch']}.entity_id = {$this->_aliases['civicrm_contribution']}.id"; - } - - function where() { - parent::where(); - - if (empty($this->_where)) { - $this->_where = "WHERE value_gift_aid_submission_civireport.amount IS NOT NULL"; - } - else { - $this->_where .= " AND value_gift_aid_submission_civireport.amount IS NOT NULL"; - } - } - - function statistics(&$rows) { - $statistics = parent::statistics($rows); - - $select = " - SELECT SUM( value_gift_aid_submission_civireport.amount ) as amount, - SUM( value_gift_aid_submission_civireport.gift_aid_amount ) as giftaid_amount"; - $sql = "{$select} {$this->_from} {$this->_where}"; - $dao = CRM_Core_DAO::executeQuery($sql); - - if ($dao->fetch()) { - $statistics['counts']['amount'] = array('value' => $dao->amount, - 'title' => 'Total Amount', - 'type' => CRM_Utils_Type::T_MONEY, - ); - $statistics['counts']['giftaid'] = array('value' => $dao->giftaid_amount, - 'title' => 'Total Gift Aid Amount', - 'type' => CRM_Utils_Type::T_MONEY, - ); - } - return $statistics; - } - - function postProcess() { - parent::postProcess(); - } -} - diff --git a/tools/drupal/modules/civicrm_giftaid/GiftAid/Utils/Contribution.php b/tools/drupal/modules/civicrm_giftaid/GiftAid/Utils/Contribution.php deleted file mode 100644 index 8068105bd6..0000000000 --- a/tools/drupal/modules/civicrm_giftaid/GiftAid/Utils/Contribution.php +++ /dev/null @@ -1,264 +0,0 @@ -entity_table = 'civicrm_contribution'; - $batchContribution->entity_id = $contributionID; - - // check if the selected contribution id already in a batch - // if not, add to batchContribution else keep the count of contributions that are not added - - if ($batchContribution->find(TRUE)) { - $contributionsNotAdded[] = $contributionID; - continue; - } - - // get additional info - // get contribution details from Contribution using contribution id - $params = array('id' => $contributionID); - CRM_Contribute_BAO_Contribution::retrieve($params, $contribution, $ids); - $contactId = $contribution['contact_id']; - - // check if contribution is valid for gift aid - if (GiftAid_Utils_GiftAid::isEligibleForGiftAid($contactId, $contribution['receive_date'], $contributionID)) { - $batchContribution->batch_id = $batchID; - $batchContribution->save(); - - // get display name - $displayName = CRM_Contact_BAO_Contact::displayName($contactId); - - // get Address & Postal Code from Address - $params = array('contact_id' => $contactId, - 'is_primary' => 1, - ); - $address = CRM_Core_BAO_Address::getValues($params); - $address = $address[1]; - //adds all address lines to the report - $fullFormatedAddress = CRM_Utils_Address::format($address);; - - // get gift aid amount - $giftAidAmount = self::_calculateGiftAidAmt($contribution['total_amount']); - - // FIXME: check if there is customTable method - $query = " -INSERT INTO civicrm_value_gift_aid_submission -(entity_id, eligible_for_gift_aid, name, address, post_code, amount, gift_aid_amount) -VALUES - ( %1, 1, %2, %3, %4, %5, %6 ) -ON DUPLICATE KEY UPDATE -name = %2, -address = %3, -post_code = %4, -amount = %5, -gift_aid_amount = %6 -"; - $sqlParams = array(1 => array($contributionID, 'Integer'), - 2 => array($displayName, 'String'), - 3 => array($fullFormatedAddress, 'String'), - 4 => array($address['postal_code'], 'String'), - 5 => array($contribution['total_amount'], 'Money'), - 6 => array($giftAidAmount, 'Money'), - ); - CRM_Core_DAO::executeQuery($query, $sqlParams); - - $contributionsAdded[] = $contributionID; - } - else { - $contributionsNotAdded[] = $contributionID; - } - } - - if (!empty($contributionsAdded)) { - // if there is any extra work required to be done for contributions that are batched, - // should be done via hook - GiftAid_Utils_Hook::batchContributions($batchID, $contributionsAdded); - } - - return array(count($contributionIDs), - count($contributionsAdded), - count($contributionsNotAdded), - ); - } - - - /* - this function calculate the gift aid amount - formula used is: (basic rate of year*contributed amount)/(100-basic rate of year) - */ - function _calculateGiftAidAmt($contributionAmount) { - $basicRate = variable_get('giftaid_value'); - return (($contributionAmount * $basicRate) / 100); - //$basicRate = 20; - //return (( $basicRate * $contributionAmount ) / ( 100- $basicRate )); - } - - /* - * this function check contribution is valid for giftaid or not: - * 1 - if contribution_id already inserted in batch_contribution - * 2 - if contributions are not valid for gift aid - */ - - - static - function _validateContributionToBatch(&$contributionIDs) { - $contributionsAdded = array(); - $contributionsAlreadyAdded = array(); - $contributionsNotValid = array(); - - require_once "GiftAid/Utils/GiftAid.php"; - require_once "CRM/Core/DAO/EntityBatch.php"; - require_once "CRM/Contribute/BAO/Contribution.php"; - - foreach ($contributionIDs as $contributionID) { - $batchContribution = &new CRM_Batch_DAO_EntityBatch(); - $batchContribution->entity_table = 'civicrm_contribution'; - $batchContribution->entity_id = $contributionID; - - // check if the selected contribution id already in a batch - // if not, increment $numContributionsAdded else keep the count of contributions that are already added - if (!$batchContribution->find(TRUE)) { - // get contact_id, & contribution receive date from Contribution using contribution id - $params = array('id' => $contributionID); - CRM_Contribute_BAO_Contribution::retrieve($params, $defaults, $ids); - - // check if contribution is not valid for gift aid, increment $numContributionsNotValid - if (GiftAid_Utils_GiftAid::isEligibleForGiftAid($defaults['contact_id'], $defaults['receive_date'], $contributionID)) { - $contributionsAdded[] = $contributionID; - } - else { - $contributionsNotValid[] = $contributionID; - } - } - else { - $contributionsAlreadyAdded[] = $contributionID; - } - } - - return array(count($contributionIDs), - $contributionsAdded, - $contributionsAlreadyAdded, - $contributionsNotValid, - ); - } - - /* - * this function returns the array of batchID & title - */ - - - static - function getBatchIdTitle($orderBy = 'id') { - $query = "SELECT * FROM civicrm_batch ORDER BY " . $orderBy; - $dao = &CRM_Core_DAO::executeQuery($query); - - $result = array(); - while ($dao->fetch()) { - $result[$dao->id] = $dao->id . " - " . $dao->label; - } - return $result; - } - - /* - * this function returns the array of contribution - * @param array $contributionIDs an array of contribution ids - * @return array $result an array of contributions - */ - - - static - function getContributionDetails($contributionIds) { - - if (empty($contributionIds)) { - return; - } - $query = " SELECT contribution.id, contact.id contact_id, contact.display_name, contribution.total_amount, contribution_type.name, - contribution.source, contribution.receive_date, batch.label FROM civicrm_contribution contribution - LEFT JOIN civicrm_contact contact ON ( contribution.contact_id = contact.id ) - LEFT JOIN civicrm_contribution_type contribution_type ON ( contribution_type.id = contribution.contribution_type_id ) - LEFT JOIN civicrm_entity_batch entity_batch ON ( entity_batch.entity_id = contribution.id ) - LEFT JOIN civicrm_batch batch ON ( batch.id = entity_batch.batch_id ) - WHERE contribution.id IN (" . implode(',', $contributionIds) . ")"; - - $dao = CRM_Core_DAO::executeQuery($query); - $result = array(); - while ($dao->fetch()) { - $result[$dao->id]['contact_id'] = $dao->contact_id; - $result[$dao->id]['display_name'] = $dao->display_name; - $result[$dao->id]['total_amount'] = $dao->total_amount; - $result[$dao->id]['financial_account'] = $dao->name; - $result[$dao->id]['source'] = $dao->source; - $result[$dao->id]['receive_date'] = $dao->receive_date; - $result[$dao->id]['batch'] = $dao->label; - } - - return $result; - } -} - diff --git a/tools/drupal/modules/civicrm_giftaid/GiftAid/Utils/GiftAid.php b/tools/drupal/modules/civicrm_giftaid/GiftAid/Utils/GiftAid.php deleted file mode 100644 index ca24f1e06a..0000000000 --- a/tools/drupal/modules/civicrm_giftaid/GiftAid/Utils/GiftAid.php +++ /dev/null @@ -1,325 +0,0 @@ - 1, pick latest end_date - $currentDeclaration = array(); - $sql = " - SELECT id, eligible_for_gift_aid, start_date, end_date, reason_ended, source, notes - FROM civicrm_value_gift_aid_declaration - WHERE entity_id = %1 AND start_date <= %2 AND (end_date > %2 OR end_date IS NULL) {$charityClause} - ORDER BY end_date DESC"; - $sqlParams = array(1 => array($contactID, 'Integer'), - 2 => array(CRM_Utils_Date::isoToMysql($date), 'Timestamp'), - ); - // allow query to be modified via hook - GiftAid_Utils_Hook::alterDeclarationQuery($sql, $sqlParams); - - $dao = CRM_Core_DAO::executeQuery($sql, $sqlParams); - if ($dao->fetch()) { - $currentDeclaration['id'] = $dao->id; - $currentDeclaration['eligible_for_gift_aid'] = $dao->eligible_for_gift_aid; - $currentDeclaration['start_date'] = $dao->start_date; - $currentDeclaration['end_date'] = $dao->end_date; - $currentDeclaration['reason_ended'] = $dao->reason_ended; - $currentDeclaration['source'] = $dao->source; - $currentDeclaration['notes'] = $dao->notes; - } - //CRM_Core_Error::debug('currentDeclaration', $currentDeclaration); - return $currentDeclaration; - } - - static - function isEligibleForGiftAid($contactID, $date = NULL, $contributionID = NULL) { - $charity = NULL; - if ($contributionID && - CRM_Core_DAO::checkFieldExists('civicrm_value_gift_aid_submission', 'charity') - ) { - $charity = CRM_Core_DAO::singleValueQuery('SELECT charity FROM civicrm_value_gift_aid_submission WHERE entity_id = %1', - array(1 => array($contributionID, 'Integer')) - ); - } - - $declaration = self::getDeclaration($contactID, $date, $charity); - if (isset($declaration['eligible_for_gift_aid'])) { - $isEligible = ($declaration['eligible_for_gift_aid'] == 1); - } - - // hook can alter the eligibility if needed - GiftAid_Utils_Hook::giftAidEligible($isEligible, $contactID, $date, $contributionID); - - return $isEligible; - } - - /** - * Create / update Gift Aid declaration records on Individual when - * "Eligible for Gift Aid" field on Contribution is updated. - * See http://wiki.civicrm.org/confluence/display/CRM/Gift+aid+implementation - * - * TODO change arguments to single $param array - * - * @param array $params - fields to store in declaration: - * - entity_id: the Individual for whom we will create/update declaration - * - eligible_for_gift_aid: 1 for positive declaration, 0 for negative - * - start_date: start date of declaration (in ISO date format) - * - end_date: end date of declaration (in ISO date format) - * - * @return array TODO - * @access public - * @static - */ - static - function setDeclaration($params) { - static $charityColumnExists = NULL; - - if (!CRM_Utils_Array::value('entity_id', $params)) { - return (array( - 'is_error' => 1, - 'error_message' => 'entity_id is required', - )); - } - $charity = CRM_Utils_Array::value('charity', $params); - - // Retrieve existing declarations for this user. - $currentDeclaration = GiftAid_Utils_GiftAid::getDeclaration($params['entity_id'], - $params['start_date'], - $charity - ); - - $charityClause = ''; - if ($charityColumnExists === NULL) { - $charityColumnExists = CRM_Core_DAO::checkFieldExists('civicrm_value_gift_aid_declaration', 'charity'); - } - if ($charityColumnExists) { - $charityClause = $charity ? " AND charity='{$charity}'" : " AND ( charity IS NULL OR charity = '' )"; - } - - // Get future declarations: start_date in future, end_date in future or null - // - if > 1, pick earliest start_date - $futureDeclaration = array(); - $sql = " - SELECT id, eligible_for_gift_aid, start_date, end_date - FROM civicrm_value_gift_aid_declaration - WHERE entity_id = %1 AND start_date > %2 AND (end_date > %2 OR end_date IS NULL) {$charityClause} - ORDER BY start_date"; - $dao = CRM_Core_DAO::executeQuery($sql, array( - 1 => array($params['entity_id'], 'Integer'), - 2 => array(CRM_Utils_Date::isoToMysql($params['start_date']), 'Timestamp'), - )); - if ($dao->fetch()) { - $futureDeclaration['id'] = $dao->id; - $futureDeclaration['eligible_for_gift_aid'] = $dao->eligible_for_gift_aid; - $futureDeclaration['start_date'] = $dao->start_date; - $futureDeclaration['end_date'] = $dao->end_date; - } - #CRM_Core_Error::debug('futureDeclaration', $futureDeclaration); - - $specifiedEndTimestamp = NULL; - if (CRM_Utils_Array::value('end_date', $params)) { - $specifiedEndTimestamp = strtotime(CRM_Utils_Array::value('end_date', $params)); - } - - // Calculate new_end_date for negative declaration - // - new_end_date = - // if end_date specified then (specified end_date) - // else (start_date of first future declaration if any, else null) - $futureTimestamp = NULL; - if (CRM_Utils_Array::value('start_date', $futureDeclaration)) { - $futureTimestamp = strtotime(CRM_Utils_Array::value('start_date', $futureDeclaration)); - } - - if ($specifiedEndTimestamp) { - $endTimestamp = $specifiedEndTimestamp; - } - elseif ($futureTimestamp) { - $endTimestamp = $futureTimestamp; - } - else { - $endTimestamp = NULL; - } - - if ($params['eligible_for_gift_aid'] == 1) { - - if (!$currentDeclaration) { - // There is no current declaration so create new. - GiftAid_Utils_GiftAid::_insertDeclaration($params, $endTimestamp); - } - elseif ($currentDeclaration['eligible_for_gift_aid'] == 1 && $endTimestamp) { - // - if current positive, extend its end_date to new_end_date. - $updateParams = array( - 'id' => $currentDeclaration['id'], - 'end_date' => date('YmdHis', $endTimestamp), - ); - GiftAid_Utils_GiftAid::_updateDeclaration($updateParams); - } - elseif ($currentDeclaration['eligible_for_gift_aid'] == 0) { - // - if current negative, set its end_date to now and create new ending new_end_date. - $updateParams = array( - 'id' => $currentDeclaration['id'], - 'end_date' => CRM_Utils_Date::isoToMysql($params['start_date']), - ); - GiftAid_Utils_GiftAid::_updateDeclaration($updateParams); - GiftAid_Utils_GiftAid::_insertDeclaration($params, $endTimestamp); - } - } - elseif ($params['eligible_for_gift_aid'] == 0) { - - if (!$currentDeclaration) { - // There is no current declaration so create new. - GiftAid_Utils_GiftAid::_insertDeclaration($params, $endTimestamp); - } - elseif ($currentDeclaration['eligible_for_gift_aid'] == 1) { - // - if current positive, set its end_date to now and create new ending new_end_date. - $updateParams = array( - 'id' => $currentDeclaration['id'], - 'end_date' => CRM_Utils_Date::isoToMysql($params['start_date']), - ); - GiftAid_Utils_GiftAid::_updateDeclaration($updateParams); - GiftAid_Utils_GiftAid::_insertDeclaration($params, $endTimestamp); - } - // - if current negative, leave as is. - } - - return array( - 'is_error' => 0, - // TODO 'inserted' => array(id => A, entity_id = B, ...), - // TODO 'updated' => array(id => A, entity_id = B, ...), - ); - } - - /* - * Private helper function for setDeclaration - * - update a declaration record. - */ - - - static - function _updateDeclaration($params) { - // Update (currently we only need to update end_date but can make generic) - // $params['end_date'] should by in date('YmdHis') format - $sql = " - UPDATE civicrm_value_gift_aid_declaration - SET end_date = %1 - WHERE id = %2"; - $dao = CRM_Core_DAO::executeQuery($sql, array( - 1 => array($params['end_date'], 'Timestamp'), - 2 => array($params['id'], 'Integer'), - )); - } - - /* - * Private helper function for setDeclaration - * - insert a declaration record. - */ - - - static - function _insertDeclaration($params, $endTimestamp) { - static $charityColumnExists = NULL; - $charityClause = ''; - if ($charityColumnExists === NULL) { - $charityColumnExists = CRM_Core_DAO::checkFieldExists('civicrm_value_gift_aid_declaration', 'charity'); - } - if (!CRM_Utils_Array::value('charity', $params)) { - $charityColumnExists = FALSE; - } - - if ($charityColumnExists) { - $charityCol = ', charity'; - $charityVal = ', %8'; - } - - // Insert - $sql = " - INSERT INTO civicrm_value_gift_aid_declaration (entity_id, eligible_for_gift_aid, start_date, end_date, reason_ended, source, notes {$charityCol}) - VALUES (%1, %2, %3, %4, %5, %6, %7 {$charityVal})"; - $queryParams = array( - 1 => array($params['entity_id'], 'Integer'), - 2 => array($params['eligible_for_gift_aid'], 'Integer'), - 3 => array(CRM_Utils_Date::isoToMysql($params['start_date']), 'Timestamp'), - 4 => array(($endTimestamp ? date('YmdHis', $endTimestamp) : ''), 'Timestamp'), - 5 => array(CRM_Utils_Array::value('reason_ended', $params, ''), 'String'), - 6 => array(CRM_Utils_Array::value('source', $params, ''), 'String'), - 7 => array(CRM_Utils_Array::value('notes', $params, ''), 'String'), - ); - if ($charityColumnExists) { - $queryParams[8] = array(CRM_Utils_Array::value('charity', $params, ''), 'String'); - } - - $dao = CRM_Core_DAO::executeQuery($sql, $queryParams); - } -} - diff --git a/tools/drupal/modules/civicrm_giftaid/GiftAid/Utils/Hook.php b/tools/drupal/modules/civicrm_giftaid/GiftAid/Utils/Hook.php deleted file mode 100644 index 00906c02de..0000000000 --- a/tools/drupal/modules/civicrm_giftaid/GiftAid/Utils/Hook.php +++ /dev/null @@ -1,109 +0,0 @@ -userHookClass - */ - static function singleton() { - if (self::$_singleton == NULL) { - $config = CRM_Core_Config::singleton(); - $class = $config->userHookClass; - require_once (str_replace('_', DIRECTORY_SEPARATOR, $config->userHookClass) . '.php'); - self::$_singleton = new $class(); - } - return self::$_singleton; - } - - abstract function invoke($numParams, - &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, - $fnSuffix - ); - - /** - * This hook allows filtering contributions for gift-aid - * - * @param bool $isEligible eligibilty already detected if getDeclaration() method. - * @param integer $contactID contact being checked - * @param date $date date gift-aid declaration was made on - * @param $contributionID contribution id if any being referred - * - * @access public - */ - static - function giftAidEligible(&$isEligible, $contactID, $date = NULL, $contributionID = NULL) { - return self::singleton()->invoke(4, $isEligible, $contactID, $date, $contributionID, self::$_nullObject, 'civicrm_giftAidEligible'); - } - - /** - * This hook allows doing any extra processing for contributions that are added to a batch. - * - * @param $contributionsAdded contribution ids that have been batched - * - * @access public - */ - static - function batchContributions($batchID, $contributionsAdded) { - return self::singleton()->invoke(2, $batchID, $contributionsAdded, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_batchContributions'); - } - - /** - * This hook allows altering getDeclaration() query - * - * @param string $query declaration query - * @param array $queryParams params required by query - * - * @access public - */ - static - function alterDeclarationQuery(&$query, &$queryParams) { - return self::singleton()->invoke(2, $query, $queryParams, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_alterDeclarationQuery'); - } -} - diff --git a/tools/drupal/modules/civicrm_giftaid/README b/tools/drupal/modules/civicrm_giftaid/README deleted file mode 100644 index 73238df981..0000000000 --- a/tools/drupal/modules/civicrm_giftaid/README +++ /dev/null @@ -1,8 +0,0 @@ -Gift Aid module for UK Charity - -Required: - -Drupal 7 -CiviCRM 4.1 - - diff --git a/tools/drupal/modules/civicrm_giftaid/civicrm_giftaid.admin.inc b/tools/drupal/modules/civicrm_giftaid/civicrm_giftaid.admin.inc deleted file mode 100644 index a484623172..0000000000 --- a/tools/drupal/modules/civicrm_giftaid/civicrm_giftaid.admin.inc +++ /dev/null @@ -1,30 +0,0 @@ - 'textfield', - '#title' => t('Basic Rate'), - '#default_value' => variable_get('giftaid_value'), - '#size' => 2, - '#maxlength' => 2, - '#description' => t('The basic rate for Gift Aid that system used.'), - '#required' => TRUE, - ); - - return system_settings_form($form); -} - -function giftaid_form_validate($form, &$form_state) { - $giftaid_value = $form_state['values']['giftaid_value']; - if (!is_numeric($giftaid_value)) { - form_set_error('giftaid_value', t('You must enter an integer for the basic rate.')); - } - elseif ($giftaid_value <= 0) { - form_set_error('giftaid_value', t('The basic rate must be positive.')); - } -} - diff --git a/tools/drupal/modules/civicrm_giftaid/civicrm_giftaid.info b/tools/drupal/modules/civicrm_giftaid/civicrm_giftaid.info deleted file mode 100755 index 4df3925db9..0000000000 --- a/tools/drupal/modules/civicrm_giftaid/civicrm_giftaid.info +++ /dev/null @@ -1,7 +0,0 @@ -name = CiviCRM GiftAid -description = Gift Aid Support for CiviCRM -version = 4.1 -dependencies[] = civicrm -package = CiviCRM -core = 7.x -php = 5.2 diff --git a/tools/drupal/modules/civicrm_giftaid/civicrm_giftaid.install b/tools/drupal/modules/civicrm_giftaid/civicrm_giftaid.install deleted file mode 100644 index 9bd6a26177..0000000000 --- a/tools/drupal/modules/civicrm_giftaid/civicrm_giftaid.install +++ /dev/null @@ -1,6 +0,0 @@ - 'Gift Aid Settings', - 'description' => 'Configure Gift Aid Basic Rate', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('giftaid_form'), - 'access arguments' => array('access administration pages'), - 'type' => MENU_NORMAL_ITEM, - 'file' => 'civicrm_giftaid.admin.inc', - ); - return $items; -} - -function civicrm_giftaid_civicrm_config(&$config) { - $template = &CRM_Core_Smarty::singleton(); - - $giftAidRoot = dirname(__FILE__); - - $giftAidDir = $giftAidRoot . DIRECTORY_SEPARATOR . 'templates'; - - if (is_array($template->template_dir)) { - array_unshift($template->template_dir, $giftAidDir); - } - else { - $template->template_dir = array($giftAidDir, $template->template_dir); - } - - // also fix php include path - $include_path = $giftAidRoot . PATH_SEPARATOR . get_include_path(); - set_include_path($include_path); -} - -function civicrm_giftaid_civicrm_searchTasks($objectType, &$tasks) { - if ($objectType == 'contribution') { - $tasks[CIVICRM_GIFTAID_TASKID] = array('title' => ts('Add to Gift Aid batch'), - 'class' => 'GiftAid_Form_Task_AddToGiftAid', - 'result' => FALSE, - ); - } -} - - -/* - * Implementation of hook_civicrm_custom - * Create / update Gift Aid declaration records on Individual when - * "Eligible for Gift Aid" field on Contribution is updated. - */ -function civicrm_giftaid_civicrm_custom($op, $groupID, $entityID, &$params) { - /* TODO && $op != 'edit' */ - - if ($op != 'create' - ) { - return; - } - - require_once 'CRM/Core/DAO.php'; - $tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $groupID, 'table_name', 'id'); - if ($tableName == 'civicrm_value_gift_aid_submission') { - // Iterate through $params to get new declaration value - $newStatus = NULL; - if (!is_array($params) || empty($params)) { - return; - } - - foreach ($params as $field) { - if ($field['column_name'] == 'eligible_for_gift_aid') { - $newStatus = $field['value']; - break; - } - } - - if (is_null($newStatus)) { - return; - } - - // Get contactID. - $sql = "SELECT contact_id, receive_date FROM civicrm_contribution WHERE id = %1"; - $dao = CRM_Core_DAO::executeQuery($sql, array(1 => array($entityID, 'Integer'))); - if ($dao->fetch()) { - $contactID = $dao->contact_id; - $contributionDate = $dao->receive_date; - } - - if ($contactID) { - require_once 'GiftAid/Utils/GiftAid.php'; - $params = array( - 'entity_id' => $contactID, - 'eligible_for_gift_aid' => $newStatus, - 'start_date' => $contributionDate, - ); - GiftAid_Utils_GiftAid::setDeclaration($params); - } - } -} - -/* - * Implementation of hook_civicrm_validate - * Validate set of Gift Aid declaration records on Individual, - * from multi-value custom field edit form: - * - check end > start, - * - check for overlaps between declarations. - */ -function civicrm_giftaid_civicrm_validate($formName, &$fields, &$files, &$form) { - $errors = array(); - - if ($formName == 'CRM_Contact_Form_CustomData') { - - $groupID = $form->getVar('_groupID'); - require_once 'CRM/Core/DAO.php'; - $tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $groupID, 'table_name', 'id'); - if ($tableName == 'civicrm_value_gift_aid_declaration') { - - // Assemble multi-value field values from custom_X_Y into - // array $declarations of sets of values as column_name => value - $sql = "SELECT id, column_name FROM civicrm_custom_field WHERE custom_group_id = %1"; - $dao = CRM_Core_DAO::executeQuery($sql, array(1 => array($groupID, 'Integer'))); - $columnNames = array(); - while ($dao->fetch()) { - $columnNames[$dao->id] = $dao->column_name; - } - - $declarations = array(); - foreach ($fields as $name => $value) { - if (preg_match('/^custom_(\d+)_(-?\d+)$/', $name, $matches)) { - $columnName = CRM_Utils_Array::value($matches[1], $columnNames); - if ($columnName) { - $declarations[$matches[2]][$columnName]['value'] = $value; - $declarations[$matches[2]][$columnName]['name'] = $name; - } - } - } - - require_once 'CRM/Utils/Date.php'; - // Iterate through each distinct pair of declarations, checking for overlap. - foreach ($declarations as $id1 => $values1) { - $start1 = CRM_Utils_Date::processDate($values1['start_date']['value']); - if ($values1['end_date']['value'] == '') { - $end1 = '25000101000000'; - } - else { - $end1 = CRM_Utils_Date::processDate($values1['end_date']['value']); - } - if ($values1['end_date']['value'] != '' && $start1 >= $end1) { - $errors[$values1['end_date']['name']] = 'End date must be later than start date.'; - continue; - } - $charity1 = NULL; - if (array_key_exists('charity', $values1)) { - $charity1 = CRM_Utils_Array::value('value', $values1['charity']); - } - foreach ($declarations as $id2 => $values2) { - $charity2 = NULL; - if (array_key_exists('charity', $values2)) { - $charity2 = CRM_Utils_Array::value('value', $values2['charity']); - } - if (($id2 <= $id1) || ($charity1 != $charity2)) { - continue; - } - $start2 = CRM_Utils_Date::processDate($values2['start_date']['value']); - if ($values2['end_date']['value'] == '') { - $end2 = '25000101000000'; - } - else { - $end2 = CRM_Utils_Date::processDate($values2['end_date']['value']); - } - - if ($start1 < $end2 && $end1 > $start2) { - $message = 'This declaration overlaps with the one from ' . $values2['start_date']['value']; - if ($values2['end_date']['value']) { - $message .= ' to ' . $values2['end_date']['value']; - } - $errors[$values1['start_date']['name']] = $message; - $message = 'This declaration overlaps with the one from ' . $values1['start_date']['value']; - if ($values1['end_date']['value']) { - $message .= ' to ' . $values1['end_date']['value']; - } - $errors[$values2['start_date']['name']] = $message; - } - } - } - } - } - if (!empty($errors)) { - return $errors; - } -} - diff --git a/tools/drupal/modules/civicrm_giftaid/templates/GiftAid/Form/Task/AddToGiftAid.tpl b/tools/drupal/modules/civicrm_giftaid/templates/GiftAid/Form/Task/AddToGiftAid.tpl deleted file mode 100644 index 6bd713bcc3..0000000000 --- a/tools/drupal/modules/civicrm_giftaid/templates/GiftAid/Form/Task/AddToGiftAid.tpl +++ /dev/null @@ -1,151 +0,0 @@ -{* - +--------------------------------------------------------------------+ - | CiviCRM version 4.1 | - +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2011 | - +--------------------------------------------------------------------+ - | 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 | - +--------------------------------------------------------------------+ -*} -
- -

{ts}Add To Gift Aid{/ts}

-
-

{ts}Use this form to submit Gift Aid contributions. Note that this action is irreversible, i.e. you cannot take contributions out of a batch once they have been added.{/ts}

-
- - - - -
- - - -
{$form.title.label}{$form.title.html}
{$form.description.label}{$form.description.html}
-
-

{ts}Summary{/ts}

- - - - - - {if $totalAddedContributions} - - {else} - - {/if} - - - {if $alreadyAddedContributions} - - {else} - - {/if} - - - - -
-
- Number of selected contributions: {$selectedContributions} -
-
-
-
-
- Number of contributions that will be added to this batch: {$totalAddedContributions} -
-
- - - - - - - - - - - {foreach from=$contributionsAddedRows item=row} - - - - - - - - {/foreach} -
{ts}Name{/ts}{ts}Amount{/ts}{ts}Type{/ts}{ts}Source{/ts}{ts}Recieved{/ts}
{$row.display_name}{$row.total_amount}{$row.financial_account}{$row.source}{$row.receive_date}
-
-
-
-
- Number of selected contributions: {$totalAddedContributions} -
-
-
-
- Number of contributions already in a batch: {$alreadyAddedContributions} -
-
- - - - - - - - - - - - {foreach from=$contributionsAlreadyAddedRows item=row} - - - - - - - - - {/foreach} -
{ts}Name{/ts}{ts}Amount{/ts}{ts}Type{/ts}{ts}Source{/ts}{ts}Recieved{/ts}{ts}Batch{/ts}
{$row.display_name}{$row.total_amount}{$row.financial_account}{$row.source}{$row.receive_date}{$row.batch}
-
-
-
-
- Number of contributions already in a batch: {$alreadyAddedContributions} -
-
-
- Number of contributions not valid for gift aid: {$notValidContributions} -
-
-

{ts}Use this form to submit Gift Aid contributions. Note that this action is irreversible, i.e. you cannot take contributions out of a batch once they have been added.{/ts}

- -{$form.buttons.html} - -
-{literal} - -{/literal} \ No newline at end of file diff --git a/tools/drupal/modules/civicrm_giftaid/templates/GiftAid/Report/Form/Contribute/GiftAid.tpl b/tools/drupal/modules/civicrm_giftaid/templates/GiftAid/Report/Form/Contribute/GiftAid.tpl deleted file mode 100644 index 2fb849ddee..0000000000 --- a/tools/drupal/modules/civicrm_giftaid/templates/GiftAid/Report/Form/Contribute/GiftAid.tpl +++ /dev/null @@ -1,27 +0,0 @@ -{* - +--------------------------------------------------------------------+ - | CiviCRM version 4.1 | - +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2011 | - +--------------------------------------------------------------------+ - | 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 | - +--------------------------------------------------------------------+ -*} - -{include file="CRM/Report/Form.tpl"} \ No newline at end of file diff --git a/tools/drupal/modules/civicrm_giftaid/tests/DeclarationTest.php b/tools/drupal/modules/civicrm_giftaid/tests/DeclarationTest.php deleted file mode 100644 index b9679d1154..0000000000 --- a/tools/drupal/modules/civicrm_giftaid/tests/DeclarationTest.php +++ /dev/null @@ -1,113 +0,0 @@ - cid, eligible, start-date, end-date - array('ip' => array(1, 1, '2010-01-01', NULL), - // output - 'op' => array(array(1, 1, '2010-01-01 00:00:00', '2013-01-01 00:00:00')), - ), - // 01-jun-10 user makes contrib, says yes - // input - array('ip' => array(1, 1, '2010-06-01', NULL), - // output - 'op' => array(array(1, 1, '2010-01-01 00:00:00', '2013-06-01 00:00:00')), - ), - // 01-jan-11 user makes contrib, says no - // input - array('ip' => array(1, 0, '2011-01-11', NULL), - // output row1 - 'op' => array(array(1, 1, '2010-01-01 00:00:00', '2011-01-11 00:00:00'), - array(1, 0, '2011-01-11 00:00:00', NULL), - // output row2 - ), - ), - // 01-jun-11 user makes contrib, says no - // input - array('ip' => array(1, 0, '2011-06-11', NULL), - // output row1 - 'op' => array(array(1, 1, '2010-01-01 00:00:00', '2011-01-11 00:00:00'), - array(1, 0, '2011-01-11 00:00:00', NULL), - // output row2 - ), - ), - // 01-jan-12 user sets up monthly regular contrib, says yes - // input - array('ip' => array(1, 1, '2012-01-01', NULL), - // output row1 - 'op' => array(array(1, 1, '2010-01-01 00:00:00', '2011-01-11 00:00:00'), - array(1, 0, '2011-01-11 00:00:00', '2012-01-01 00:00:00'), - array(1, 1, '2012-01-01 00:00:00', '2015-01-01 00:00:00'), - // output row2 - ), - ), - ); - } - - /** - * @dataProvider dataProvider - */ - public function testDeclarations($input, $output) { - $count = 0; - $params = $tableRows = array(); - $declarationFields = array('entity_id', 'eligible_for_gift_aid', 'start_date', 'end_date'); - foreach ($declarationFields as $field) { - $params[$field] = $input[$count]; - $count++; - } - - $result = GiftAid_Utils_GiftAid::setDeclaration($params); - - $sql = "select * from civicrm_value_gift_aid_declaration"; - $dao = &CRM_Core_DAO::executeQuery($sql); - - $count = 0; - while ($dao->fetch()) { - foreach ($declarationFields as $field) { - $tableRows[$count][] = $dao->$field; - } - $count++; - } - - $this->assertEquals($output, $tableRows, 'In line ' . __LINE__); - } -} - diff --git a/tools/drupal/modules/civicrm_giftaid_alpha/CustomGroupData.xml b/tools/drupal/modules/civicrm_giftaid_alpha/CustomGroupData.xml deleted file mode 100644 index dcd09ed97b..0000000000 --- a/tools/drupal/modules/civicrm_giftaid_alpha/CustomGroupData.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - Gift_Aid_Declaration - Gift Aid Declaration - Individual - - 0 - - - 1 - 1 - civicrm_value_gift_aid_declaration - 1 - 0 - 2010-10-03 02:28:19 - - - Gift_Aid - Gift Aid - Contribution - - 1 - Stores the values that are submitted in the Gift Aid Report - - 2 - 1 - civicrm_value_gift_aid_submission - 0 - 0 - 2010-10-03 02:32:44 - - - - - name_of_charity - - String - Text - 0 - 0 - 0 - 1 - 0 - 8 - 32 - 60 - 4 - charity - Gift_Aid_Declaration - - - name_of_charity - - String - Text - 0 - 0 - 0 - 1 - 0 - 7 - 32 - 60 - 4 - charity - Gift_Aid - - - - - Gift Aid - 0 - 1 - 1 - - - diff --git a/tools/drupal/modules/civicrm_giftaid_alpha/civicrm_giftaid_alpha.info b/tools/drupal/modules/civicrm_giftaid_alpha/civicrm_giftaid_alpha.info deleted file mode 100755 index a03cbaf5ea..0000000000 --- a/tools/drupal/modules/civicrm_giftaid_alpha/civicrm_giftaid_alpha.info +++ /dev/null @@ -1,8 +0,0 @@ -name = CiviCRM GiftAid Alpha -description = Additional features for Gift Aid for Alpha -version = 3.4 -dependencies[] = civicrm -dependencies[] = civicrm_giftaid -package = CiviCRM -core = 6.x -php = 5.2 diff --git a/tools/drupal/modules/civicrm_giftaid_alpha/civicrm_giftaid_alpha.module b/tools/drupal/modules/civicrm_giftaid_alpha/civicrm_giftaid_alpha.module deleted file mode 100644 index a14c995a12..0000000000 --- a/tools/drupal/modules/civicrm_giftaid_alpha/civicrm_giftaid_alpha.module +++ /dev/null @@ -1,180 +0,0 @@ - $session->get('userID'), - 'financial_account_id' => $contributionTypeId, - 'receive_date' => date('YmdHis'), - 'total_amount' => $totalAmount, - 'invoice_id' => md5(uniqid(rand(), TRUE)), - 'currency' => $config->defaultCurrency, - 'source' => ts('Gift aid batch'), - 'contribution_status_id' => $contributionStatusId, - ); - $pendingContribution = &CRM_Contribute_BAO_Contribution::add($contribParams, CRM_Core_DAO::$_nullArray); - - // and add to the batch - $batchID - $batchContribution = new CRM_Batch_DAO_EntityBatch(); - $batchContribution->entity_table = 'civicrm_contribution'; - $batchContribution->entity_id = $pendingContribution->id; - $batchContribution->batch_id = $batchID; - $batchContribution->save(); -} - -function civicrm_giftaid_civicrm_giftAidEligible(&$isEligible, $contactID, $date, $contributionID) { - if ($isEligible && - $contactID && - $contributionID && - CIVICRM_GIFTAID_CHARITY_DECLARATION_CF_NAME && - CIVICRM_GIFTAID_CHARITY_SUBMISSION_CF_NAME - ) { - - // ************* Support for multiple charities **************** // - // Note there is no point processing further if $isEligible is false, which is based on declaration date - - $cgID = _civicrm_giftaid_getCustomGroupID('Gift_Aid'); - if (!$cgID) { - return; - } - - $charity = NULL; - if ($contributionID && - CRM_Core_DAO::checkFieldExists('civicrm_value_gift_aid_submission', 'charity') - ) { - $charity = CRM_Core_DAO::singleValueQuery('SELECT charity FROM civicrm_value_gift_aid_submission WHERE entity_id = %1', - array(1 => array($contributionID, 'Integer')) - ); - } - - // do a declaration fetch again, in order to get the declaration id - $declaration = GiftAid_Utils_GiftAid::getDeclaration($contactID, $date, $charity); - - // now use declaration id to fetch charity - $sql = "SELECT " . CIVICRM_GIFTAID_CHARITY_DECLARATION_CF_NAME . " as charity -FROM civicrm_value_gift_aid_declaration -WHERE id = %1"; - $declaredCharity = CRM_Core_DAO::singleValueQuery($sql, array(1 => array($declaration['id'], 'Integer'))); - - // if declaration has charity set AND donation doesn't have same charity specified, - // set the eligibility to false - if ($declaredCharity) { - require_once 'CRM/Dedupe/Finder.php'; - require_once 'CRM/Core/BAO/CustomGroup.php'; - $infoGroupTree = CRM_Core_BAO_CustomGroup::getTree('Contribution', - CRM_Core_DAO::$_nullObject, - $contributionID, - $cgID - ); - $infoGroupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($infoGroupTree, 1, CRM_Core_DAO::$_nullObject); - - foreach ($infoGroupTree as $gId => $groupTree) { - foreach ($groupTree['fields'] as $fId => $fieldTree) { - if ($fieldTree['column_name'] == CIVICRM_GIFTAID_CHARITY_SUBMISSION_CF_NAME && - $declaredCharity != $fieldTree['element_value'] - ) { - $isEligible = FALSE; - break; - } - } - } - } - } - - if ($isEligible && $contributionID && - CIVICRM_GIFTAID_NOT_ELIGIBLE_CONTRIBUTION_TYPES - ) { - - // ******** Contribution types automatically set as not eligable for gift aid ********** // - - // get financial account. - $query = "SELECT financial_account.name -FROM civicrm_contribution contribution -INNER JOIN civicrm_financial_account financial_account ON ( contribution.financial_account_id = financial_account.id ) -WHERE contribution.id = %1"; - - $params = array(1 => array($contributionID, 'Integer')); - $contributionType = CRM_Core_DAO::singleValueQuery($query, $params); - $notEligibleContributionTypes = explode(',', CIVICRM_GIFTAID_NOT_ELIGIBLE_CONTRIBUTION_TYPES); - foreach ($notEligibleContributionTypes as & $type) { - $type = trim($type); - } - - $isEligible = in_array($contributionType, $notEligibleContributionTypes) ? FALSE : $isEligible; - } -} - -function _civicrm_giftaid_getCustomGroupID($customGroupName) { - require_once 'CRM/Utils/Type.php'; - $customGroupName = CRM_Utils_Type::escape($customGroupName, 'String'); - return CRM_Core_DAO::getFieldValue("CRM_Core_DAO_CustomGroup", $customGroupName, 'id', 'name'); -} - -- 2.25.1