while ($dao->fetch()) {
$groupIDs[] = $dao->id;
- if (($dao->saved_search_id || $dao->children || $dao->parents) &&
- $dao->cache_date == NULL
- ) {
- CRM_Contact_BAO_GroupContactCache::load($dao);
+ if (($dao->saved_search_id || $dao->children || $dao->parents)) {
+ if ($dao->cache_date == NULL) {
+ CRM_Contact_BAO_GroupContactCache::load($dao);
+ }
$groupContactCacheClause = " UNION SELECT contact_id FROM civicrm_group_contact_cache WHERE group_id IN (" . implode(', ', $groupIDs) . ")";
}
return Civi::$statics[__CLASS__]['permissioned_groups'][$userCacheKey];
}
+ if ($allGroups == NULL) {
+ $allGroups = CRM_Contact_BAO_Contact::buildOptions('group_id', NULL, ['onlyActive' => FALSE]);
+ }
+
$acls = CRM_ACL_BAO_Cache::build($contactID);
$ids = array();
'source_contact_name',
'assignee_contact_id',
'target_contact_id',
- 'target_contact_name',
'assignee_contact_name',
'status_id',
'subject',
'subject' => 'subject',
'campaign_id' => 'campaign_id',
'assignee_contact_name' => 'assignee_contact_name',
- 'target_contact_name' => 'target_contact_name',
'source_contact_id' => 'source_contact_id',
'source_contact_name' => 'source_contact_name',
'case_id' => 'case_id',
$activities[$id] = array();
$isBulkActivity = (!$bulkActivityTypeID || ($bulkActivityTypeID === $activity['activity_type_id']));
-
+ $activities[$id]['target_contact_counter'] = count($activity['target_contact_id']);
+ if ($activities[$id]['target_contact_counter']) {
+ try {
+ $activities[$id]['target_contact_name'][$activity['target_contact_id'][0]] = civicrm_api3('Contact', 'getvalue', ['id' => $activity['target_contact_id'][0], 'return' => 'sort_name']);
+ }
+ catch (CiviCRM_API3_Exception $e) {
+ // Really they should have names but a fatal here feels wrong.
+ $activities[$id]['target_contact_name'] = '';
+ }
+ }
foreach ($mappingParams as $apiKey => $expectedName) {
if (in_array($apiKey, array('assignee_contact_name', 'target_contact_name'))) {
$activities[$id][$expectedName] = CRM_Utils_Array::value($apiKey, $activity, array());
- if ($apiKey == 'target_contact_name' && count($activity['target_contact_name'])) {
- $activities[$id]['target_contact_counter'] = count($activity['target_contact_name']);
- }
if ($isBulkActivity) {
$activities[$id]['recipients'] = ts('(%1 recipients)', array(1 => count($activity['target_contact_name'])));
$priorActivities[$index][$dao->activityID]['name'] = $dao->name;
$priorActivities[$index][$dao->activityID]['date'] = $dao->date;
}
- $dao->free();
}
}
return $priorActivities[$index];
$result = self::deleteActivity($activityParams);
}
- $activityContactOther->free();
}
- $activityContact->free();
$transaction->commit();
return $result;
return FALSE;
}
+ /**
+ * @return array
+ */
+ public static function getEntityRefFilters() {
+ return [
+ ['key' => 'activity_type_id', 'value' => ts('Activity Type')],
+ ['key' => 'status_id', 'value' => ts('Activity Status')],
+ ];
+ }
+
}
'type' => 'text',
'label' => ts('Subject'),
'attributes' => CRM_Core_DAO::getAttribute('CRM_Activity_DAO_Activity',
- 'subject'
+ 'activity_subject'
),
),
'duration' => array(
// form should be frozen for view mode
$this->freeze();
- $buttons = array();
- $buttons[] = array(
- 'type' => 'cancel',
- 'name' => ts('Done'),
- );
- $this->addButtons($buttons);
+ $this->addButtons([
+ [
+ 'type' => 'cancel',
+ 'name' => ts('Done'),
+ ],
+ ]);
}
else {
- $message = array(
- 'completed' => ts('Are you sure? This is a COMPLETED activity with the DATE in the FUTURE. Click Cancel to change the date / status. Otherwise, click OK to save.'),
- 'scheduled' => ts('Are you sure? This is a SCHEDULED activity with the DATE in the PAST. Click Cancel to change the date / status. Otherwise, click OK to save.'),
- );
- $js = array('onclick' => "return activityStatus(" . json_encode($message) . ");");
- $this->addButtons(array(
- array(
+ $this->addButtons([
+ [
'type' => 'upload',
'name' => ts('Save'),
- 'js' => $js,
'isDefault' => TRUE,
- ),
- array(
+ 'submitOnce' => TRUE,
+ ],
+ [
'type' => 'cancel',
'name' => ts('Cancel'),
- ),
- ));
+ ],
+ ]);
}
if ($this->_activityTypeFile) {
$this->_actionButtonName = $this->getButtonName('next', 'action');
$this->_done = FALSE;
- $this->defaults = array();
$this->loadStandardSearchOptionsFromUrl();
}
}
- // Added for membership search
-
- $signupType = CRM_Utils_Request::retrieve('signupType', 'Positive');
-
- if ($signupType) {
- $this->_formValues['activity_role'] = 1;
- $this->_defaults['activity_role'] = 1;
- $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name');
-
- $renew = CRM_Utils_Array::key('Membership Renewal', $activityTypes);
- $signup = CRM_Utils_Array::key('Membership Signup', $activityTypes);
-
- switch ($signupType) {
- case 3: // signups and renewals
- $this->_formValues['activity_type_id'][$renew] = 1;
- $this->_defaults['activity_type_id'][$renew] = 1;
- case 1: // signups only
- $this->_formValues['activity_type_id'][$signup] = 1;
- $this->_defaults['activity_type_id'][$signup] = 1;
- break;
-
- case 2: // renewals only
- $this->_formValues['activity_type_id'][$renew] = 1;
- $this->_defaults['activity_type_id'][$renew] = 1;
- break;
- }
- }
-
$dateLow = CRM_Utils_Request::retrieve('dateLow', 'String');
if ($dateLow) {
$mainActivity->save();
$mainActivityId = $mainActivity->id;
CRM_Activity_BAO_Activity::logActivityAction($mainActivity);
- $mainActivity->free();
// Mark previous activity as deleted. If it was a non-case activity
// then just change the subject.
}
$otherActivity->save();
- $caseActivity->free();
}
- $otherActivity->free();
$targetContacts = array();
if (!empty($params['targetContactIds'])) {
$params['mainActivityId'] = $mainActivityId;
CRM_Activity_BAO_Activity::copyExtendedActivityData($params);
CRM_Utils_Hook::post('create', 'CaseActivity', $caseActivity->id, $caseActivity);
- $caseActivity->free();
return (array('error_msg' => $error_msg, 'newId' => $mainActivity->id));
}
$activityId = NULL,
$key = NULL,
$compContext = NULL) {
- static $activityActTypes = NULL;
- //CRM-14277 added addtitional param to handle activity search
+
+ //CRM-14277 added additional param to handle activity search
$extraParams = "&searchContext=activity";
$extraParams .= ($key) ? "&key={$key}" : NULL;
$showView = TRUE;
$showUpdate = $showDelete = FALSE;
$qsUpdate = NULL;
+ $url = NULL;
+ $qsView = NULL;
- if (!$activityActTypes) {
- $activeActTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name', TRUE);
- }
- $activityTypeName = CRM_Utils_Array::value($activityTypeId, $activeActTypes);
+ $activityTypeName = CRM_Core_PseudoConstant::getName('CRM_Activity_BAO_Activity', 'activity_type_id', $activityTypeId);
// CRM-7607
// Lets allow to have normal operation for only activity types.
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
- // Get all activity types
- $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name', TRUE);
+ $bulkActivityTypeID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Bulk Email');
while ($result->fetch()) {
$row = array();
if ($row['activity_is_test']) {
$row['activity_type'] = $row['activity_type'] . " (test)";
}
- $bulkActivityTypeID = CRM_Utils_Array::key('Bulk Email', $activityTypes);
$row['mailingId'] = '';
if (
$accessCiviMail &&
$this->add('text', 'SpaceY', ts('Vertical Spacing'), array('size' => 8, 'maxlength' => 8) + $disabled, $required);
$this->add('text', 'lPadding', ts('Left Padding'), array('size' => 8, 'maxlength' => 8), $required);
$this->add('text', 'tPadding', ts('Top Padding'), array('size' => 8, 'maxlength' => 8), $required);
- $this->add('text', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Core_BAO_LabelFormat', 'weight'), TRUE);
+ $this->add('number', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Core_BAO_LabelFormat', 'weight'), TRUE);
$this->addRule('label', ts('Name already exists in Database.'), 'objectExists', array(
'CRM_Core_BAO_LabelFormat',
);
}
- $this->add('text',
+ $this->add('number',
'weight',
ts('Order'),
CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'weight'),
$this->add('checkbox', 'is_active', ts('Active?'));
$this->add('checkbox', 'is_counted', ts('Counted?'));
- $this->add('text', 'weight', ts('Order'), $attributes['weight'], TRUE);
+ $this->add('number', 'weight', ts('Order'), $attributes['weight'], TRUE);
$this->addSelect('visibility_id', array('label' => ts('Visibility'), 'required' => TRUE));
$this->add('text', 'margin_right', ts('Right Margin'), array('size' => 8, 'maxlength' => 8), TRUE);
$this->add('text', 'margin_top', ts('Top Margin'), array('size' => 8, 'maxlength' => 8), TRUE);
$this->add('text', 'margin_bottom', ts('Bottom Margin'), array('size' => 8, 'maxlength' => 8), TRUE);
- $this->add('text', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Core_BAO_PdfFormat', 'weight'), TRUE);
+ $this->add('number', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Core_BAO_PdfFormat', 'weight'), TRUE);
$this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array(
'CRM_Core_BAO_PdfFormat',
$options = civicrm_api3('Setting', 'getoptions', [
'field' => $setting,
])['values'];
+ if ($props['html_type'] === 'Select' && isset($props['is_required']) && $props['is_required'] === FALSE && !isset($options[''])) {
+ // If the spec specifies the field is not required add a null option.
+ // Why not if empty($props['is_required']) - basically this has been added to the spec & might not be set to TRUE
+ // when it is true.
+ $options = ['' => ts('None')] + $options;
+ }
}
if ($props['type'] === 'Boolean') {
$options = [$props['title'] => $props['name']];
}
/**
- * Get the list of local extensions and format them as a table with
+ * Get the list of remote extensions and format them as a table with
* status and action data.
*
* @param array $localExtensionRows
// build list of available downloads
$remoteExtensionRows = array();
+ $compat = CRM_Extension_System::getCompatibilityInfo();
+
foreach ($remoteExtensions as $info) {
+ if (!empty($compat[$info->key]['obsolete'])) {
+ continue;
+ }
$row = (array) $info;
$row['id'] = $info->key;
$action = CRM_Core_Action::UPDATE;
$activityParams = array('source_record_id' => $values['id'], 'activity_type_id' => $aid);
$exportActivity = CRM_Activity_BAO_Activity::retrieve($activityParams, $val);
$fid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_EntityFile', $exportActivity->id, 'file_id', 'entity_id');
- $tokens = array_merge(array('eid' => $exportActivity->id, 'fid' => $fid), $tokens);
+ $fileHash = CRM_Core_BAO_File::generateFileHash($exportActivity->id, $fid);
+ $tokens = array_merge(array('eid' => $exportActivity->id, 'fid' => $fid, 'fcs' => $fileHash), $tokens);
}
$values['action'] = CRM_Core_Action::formLink(
$newLinks,
'download' => array(
'name' => ts('Download'),
'url' => 'civicrm/file',
- 'qs' => 'reset=1&id=%%fid%%&eid=%%eid%%',
+ 'qs' => 'reset=1&id=%%fid%%&eid=%%eid%%&fcs=%%fcs%%',
'title' => ts('Download Batch'),
),
);
$dao->entity_id = $entityId;
$dao->group_type = 'Include';
$dao->save();
- $dao->free();
}
}
if ($connectedCampaignId || ($isCampaignEnabled && $hasAccessCampaign)) {
$showAddCampaign = TRUE;
$campaign = $form->addEntityRef('campaign_id', ts('Campaign'), [
- 'entity' => 'campaign',
+ 'entity' => 'Campaign',
'create' => TRUE,
+ 'select' => ['minimumInputLength' => 0],
]);
//lets freeze when user does not has access or campaign is disabled.
if (!$isCampaignEnabled || !$hasAccessCampaign) {
$form->assign('campaignInfo', $campaignInfo);
}
+ /**
+ * @return array
+ */
+ public static function getEntityRefFilters() {
+ return [
+ ['key' => 'campaign_type_id', 'value' => ts('Campaign Type')],
+ ['key' => 'status_id', 'value' => ts('Status')],
+ [
+ 'key' => 'start_date',
+ 'value' => ts('Start Date'),
+ 'options' => [
+ ['key' => '{">":"now"}', 'value' => ts('Upcoming')],
+ [
+ 'key' => '{"BETWEEN":["now - 3 month","now"]}',
+ 'value' => ts('Past 3 Months'),
+ ],
+ [
+ 'key' => '{"BETWEEN":["now - 6 month","now"]}',
+ 'value' => ts('Past 6 Months'),
+ ],
+ [
+ 'key' => '{"BETWEEN":["now - 1 year","now"]}',
+ 'value' => ts('Past Year'),
+ ],
+ ],
+ ],
+ [
+ 'key' => 'end_date',
+ 'value' => ts('End Date'),
+ 'options' => [
+ ['key' => '{">":"now"}', 'value' => ts('In the future')],
+ ['key' => '{"<":"now"}', 'value' => ts('In the past')],
+ ['key' => '{"IS NULL":"1"}', 'value' => ts('Not set')],
+ ],
+ ],
+ ];
+ }
+
/**
* Links to create new campaigns from entityRef widget
*
* @return array|bool
*/
- public static function entityRefCreateLinks() {
+ public static function getEntityRefCreateLinks() {
if (CRM_Core_Permission::check([['administer CiviCampaign', 'manage campaign']])) {
return [
[
);
$voterDetails[$contact->contactId]['contact_type'] = $image;
}
- $contact->free();
}
return $voterDetails;
$this->add('wysiwyg', 'instructions', ts('Introduction'), $attributes['instructions']);
$this->addEntityRef('campaign_id', ts('Campaign'), [
- 'entity' => 'campaign',
+ 'entity' => 'Campaign',
'create' => TRUE,
+ 'select' => ['minimumInputLength' => 0],
]);
$customContactProfiles = CRM_Core_BAO_UFGroup::getProfiles(array('Individual'));
$this->addSelect('activity_type_id', array('option_url' => 'civicrm/admin/campaign/surveyType'), TRUE);
$this->addEntityRef('campaign_id', ts('Campaign'), [
- 'entity' => 'campaign',
+ 'entity' => 'Campaign',
'create' => TRUE,
+ 'select' => ['minimumInputLength' => 0],
]);
// script / instructions
);
// weight
- $this->add('text', "option_weight[$i]", ts('Order'),
+ $this->add('number', "option_weight[$i]", ts('Order'),
$optionAttributes['weight']
);
) {
$this->freeze(array('label', 'is_active'));
}
- $this->add('text', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'weight'), TRUE);
+ $this->add('number', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'weight'), TRUE);
$this->assign('id', $this->_id);
}
//really this should use Activity BAO& not be here but refactoring will have to be later
//actually the whole ajax call could be done as an api ajax call & post hook would be sorted
CRM_Utils_Hook::post('edit', 'Activity', $activity->id, $activity);
- $activity->free();
return $activityId;
}
$cacheKey = "civicrm search {$this->_key}";
Civi::service('prevnext')->deleteItem(NULL, $cacheKey, 'civicrm_contact');
- $sql = $this->_query->searchQuery(0, 0, $sort,
+ $sql = $this->_query->getSearchSQL(0, 0, $sort,
FALSE, FALSE,
FALSE, FALSE,
- TRUE, $this->_campaignWhereClause,
+ $this->_campaignWhereClause,
NULL,
$this->_campaignFromClause
);
list($select, $from) = explode(' FROM ', $sql);
$selectSQL = "
- SELECT '$cacheKey', contact_a.id, contact_a.display_name
+ SELECT %1, contact_a.id, contact_a.display_name
FROM {$from}
";
try {
- Civi::service('prevnext')->fillWithSql($cacheKey, $selectSQL);
+ Civi::service('prevnext')->fillWithSql($cacheKey, $selectSQL, [1 => [$cacheKey, 'String']]);
}
catch (CRM_Core_Exception $e) {
// Heavy handed, no? Seems like this merits an explanation.
$caseCount = CRM_Core_DAO::singleValueQuery('SELECT FOUND_ROWS()');
$activityTypes = CRM_Case_PseudoConstant::caseActivityType(FALSE, TRUE);
- $activityStatuses = CRM_Core_PseudoConstant::activityStatus();
$url = CRM_Utils_System::url("civicrm/case/activity",
"reset=1&cid={$contactID}&caseid={$caseID}", FALSE, NULL, FALSE
$caseActivities = array();
while ($dao->fetch()) {
- $caseActivity = array();
$caseActivityId = $dao->id;
$allowView = self::checkPermission($caseActivityId, 'view', $dao->activity_type_id, $userID);
}
}
- //Activity Status
- $caseActivities[$caseActivityId]['status_id'] = $activityStatuses[$dao->status];
+ // Activity Status Label for Case activities list
+ $caseActivities[$caseActivityId]['status_id'] = CRM_Core_PseudoConstant::getLabel('CRM_Activity_BAO_Activity', 'activity_status_id', $dao->status);
// FIXME: Why are we not using CRM_Core_Action for these links? This is too much manual work and likely to get out-of-sync with core markup.
$url = "";
return array();
}
- $linkActType = array_search('Link Cases',
- CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name')
- );
+ $linkActType = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Link Cases');
if (!$linkActType) {
return array();
}
return $mainCaseIds;
}
- $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name');
- $activityStatuses = CRM_Core_PseudoConstant::activityStatus('name');
+ $activityTypes = CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'validate');
+ $completedActivityStatus = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Completed');
$activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
}
}
- $mainCase->free();
-
$mainCaseIds[] = $mainCaseId;
//insert record for case contact.
$otherCaseContact = new CRM_Case_DAO_CaseContact();
if (!$mainCaseContact->find(TRUE)) {
$mainCaseContact->save();
}
- $mainCaseContact->free();
}
- $otherCaseContact->free();
}
elseif (!$otherContactId) {
$otherContactId = $mainContactId;
// insert log of all activities
CRM_Activity_BAO_Activity::logActivityAction($mainActivity);
- $otherActivity->free();
- $mainActivity->free();
$copiedActivityIds[] = $otherActivityId;
//create case activity record.
$mainCaseActivity->case_id = $mainCaseId;
$mainCaseActivity->activity_id = $mainActivityId;
$mainCaseActivity->save();
- $mainCaseActivity->free();
//migrate source activity.
$otherSourceActivity = new CRM_Activity_DAO_ActivityContact();
if (!$mainActivitySource->find(TRUE)) {
$mainActivitySource->save();
}
- $mainActivitySource->free();
}
- $otherSourceActivity->free();
//migrate target activities.
$otherTargetActivity = new CRM_Activity_DAO_ActivityContact();
if (!$mainActivityTarget->find(TRUE)) {
$mainActivityTarget->save();
}
- $mainActivityTarget->free();
}
- $otherTargetActivity->free();
//migrate assignee activities.
$otherAssigneeActivity = new CRM_Activity_DAO_ActivityContact();
if (!$mainAssigneeActivity->find(TRUE)) {
$mainAssigneeActivity->save();
}
- $mainAssigneeActivity->free();
}
- $otherAssigneeActivity->free();
// copy custom fields and attachments
$aparams = array(
if (!$mainRelationship->find(TRUE)) {
$mainRelationship->save();
}
- $mainRelationship->free();
//get the other relationship ids to update end date.
if ($updateOtherRel) {
$otherRelationshipIds[$otherRelationship->id] = $otherRelationship->id;
}
}
- $otherRelationship->free();
//update other relationships end dates
if (!empty($otherRelationshipIds)) {
}
}
- //Create merge activity record. Source for merge activity is the logged in user's contact ID ($currentUserId).
+ // Create merge activity record. Source for merge activity is the logged in user's contact ID ($currentUserId).
$activityParams = array(
'subject' => $mergeActSubject,
'details' => $mergeActSubjectDetails,
- 'status_id' => array_search('Completed', $activityStatuses),
+ 'status_id' => $completedActivityStatus,
'activity_type_id' => $mergeActType,
'source_contact_id' => $currentUserId,
'activity_date_time' => date('YmdHis'),
if (!$mergeActivityId) {
continue;
}
- $mergeActivity->free();
//connect merge activity to case.
$mergeCaseAct = array(
//do further only when operation is granted.
if ($allow) {
- $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name');
-
- //get the activity type name.
- $actTypeName = CRM_Utils_Array::value($actTypeId, $activityTypes);
+ $actTypeName = CRM_Core_PseudoConstant::getName('CRM_Activity_BAO_Activity', 'activity_type_id', $actTypeId);
//do not allow multiple copy / edit action.
$singletonNames = array(
if (!$newRelationship->find(TRUE)) {
$newRelationship->save();
}
- $newRelationship->free();
// store relationship type of newly created relationship
$relationshipTypes[] = $caseRelationships->relationship_type_id;
return "$name <$address>";
}
+ /**
+ * @return array
+ */
+ public static function getEntityRefFilters() {
+ $filters = [
+ [
+ 'key' => 'case_id.case_type_id',
+ 'value' => ts('Case Type'),
+ 'entity' => 'Case',
+ ],
+ [
+ 'key' => 'case_id.status_id',
+ 'value' => ts('Case Status'),
+ 'entity' => 'Case',
+ ],
+ ];
+ foreach (CRM_Contact_BAO_Contact::getEntityRefFilters() as $filter) {
+ $filter += ['entity' => 'Contact'];
+ $filter['key'] = 'contact_id.' . $filter['key'];
+ $filters[] = $filter;
+ }
+ return $filters;
+ }
+
}
$this->_crmDir = 'Case';
$this->assign('context', $this->_context);
- $result = parent::preProcess();
+ parent::preProcess();
$scheduleStatusId = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Scheduled');
$this->assign('scheduleStatusId', $scheduleStatusId);
unset($caseParams['subject'], $caseParams['details'],
$caseParams['status_id'], $caseParams['custom']
);
- $case = CRM_Case_BAO_Case::create($caseParams);
+ CRM_Case_BAO_Case::create($caseParams);
// create case activity record
$caseParams = array(
'activity_id' => $vval['actId'],
CRM_Case_BAO_Case::processCaseActivity($caseParams);
}
- // Insert civicrm_log record for the activity (e.g. store the
- // created / edited by contact id and date for the activity)
- // Note - civicrm_log is already created by CRM_Activity_BAO_Activity::create()
-
// send copy to selected contacts.
$mailStatus = '';
$mailToContacts = array();
//CRM-5695
//check for notification settings for assignee contacts
$selectedContacts = array('contact_check');
- $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
- $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
if (Civi::settings()->get('activity_assignee_notification')) {
$selectedContacts[] = 'assignee_contact_id';
}
'type' => 'upload',
'name' => ts('Save'),
'isDefault' => TRUE,
+ 'submitOnce' => TRUE,
),
array(
'type' => 'upload',
'name' => ts('Save and New'),
'subName' => 'new',
+ 'submitOnce' => TRUE,
),
array(
'type' => 'cancel',
$this->addEntityRef(
'assign_to',
ts('Assign to'),
- array('entity' => 'case'),
+ array('entity' => 'Case'),
TRUE
);
$this->_actionButtonName = $this->getButtonName('next', 'action');
$this->_done = FALSE;
- $this->defaults = array();
$this->loadStandardSearchOptionsFromUrl();
$this->loadFormValues();
if (!$isCaseManager) {
$result[$relationshipTypeID] = $relationshipTypeName;
}
- elseif ($relationshipTypeXML->manager) {
+ elseif ($relationshipTypeXML->manager == 1) {
return $relationshipTypeID;
}
}
$contact->copyValues($updateParams);
$contact->save();
+ CRM_Core_BAO_Log::register($contact->id, 'civicrm_contact', $contact->id);
CRM_Utils_Hook::post('update', $contact->contact_type, $contact->id, $contact);
) {
// if profile was used, and had any subtype, we obtain it from there
//CRM-13596 - add to existing contact types, rather than overwriting
- $data_contact_sub_type_arr = CRM_Utils_Array::explodePadded($data['contact_sub_type']);
- if (!in_array($params['contact_sub_type_hidden'], $data_contact_sub_type_arr)) {
- //CRM-20517 - make sure contact_sub_type gets the correct delimiters
- $data['contact_sub_type'] = trim($data['contact_sub_type'], CRM_Core_DAO::VALUE_SEPARATOR);
- $data['contact_sub_type'] = CRM_Core_DAO::VALUE_SEPARATOR . $data['contact_sub_type'] . CRM_Utils_Array::implodePadded($params['contact_sub_type_hidden']);
+ if (empty($data['contact_sub_type'])) {
+ // If we don't have a contact ID the $data['contact_sub_type'] will not be defined...
+ $data['contact_sub_type'] = CRM_Utils_Array::implodePadded($params['contact_sub_type_hidden']);
+ }
+ else {
+ $data_contact_sub_type_arr = CRM_Utils_Array::explodePadded($data['contact_sub_type']);
+ if (!in_array($params['contact_sub_type_hidden'], $data_contact_sub_type_arr)) {
+ //CRM-20517 - make sure contact_sub_type gets the correct delimiters
+ $data['contact_sub_type'] = trim($data['contact_sub_type'], CRM_Core_DAO::VALUE_SEPARATOR);
+ $data['contact_sub_type'] = CRM_Core_DAO::VALUE_SEPARATOR . $data['contact_sub_type'] . CRM_Utils_Array::implodePadded($params['contact_sub_type_hidden']);
+ }
}
}
}
/**
- * Checks permission to create new contacts from entityRef widget
+ * @param array $appendProfiles
+ * Name of profile(s) to append to each link.
*
- * Note: other components must return an array of links from this function,
- * but Contacts are given special treatment - the links are in javascript already.
- *
- * @return bool
+ * @return array
+ */
+ public static function getEntityRefCreateLinks($appendProfiles = []) {
+ // You'd think that "create contacts" would be the permission to check,
+ // But new contact popups are profile forms and those use their own permissions.
+ if (!CRM_Core_Permission::check([['profile create', 'profile listings and forms']])) {
+ return FALSE;
+ }
+ $profiles = [];
+ foreach (CRM_Contact_BAO_ContactType::basicTypes() as $contactType) {
+ $profiles[] = 'new_' . strtolower($contactType);
+ }
+ $retrieved = civicrm_api3('uf_group', 'get', [
+ 'name' => ['IN' => array_merge($profiles, (array) $appendProfiles)],
+ 'is_active' => 1,
+ ]);
+ $links = $append = [];
+ if (!empty($retrieved['values'])) {
+ $icons = [
+ 'individual' => 'fa-user',
+ 'organization' => 'fa-building',
+ 'household' => 'fa-home',
+ ];
+ foreach ($retrieved['values'] as $id => $profile) {
+ if (in_array($profile['name'], $profiles)) {
+ $links[] = array(
+ 'label' => $profile['title'],
+ 'url' => CRM_Utils_System::url('civicrm/profile/create', "reset=1&context=dialog&gid=$id",
+ NULL, NULL, FALSE, FALSE, TRUE),
+ 'type' => ucfirst(str_replace('new_', '', $profile['name'])),
+ 'icon' => CRM_Utils_Array::value(str_replace('new_', '', $profile['name']), $icons),
+ );
+ }
+ else {
+ $append[] = $id;
+ }
+ }
+ foreach ($append as $id) {
+ foreach ($links as &$link) {
+ $link['url'] .= ",$id";
+ }
+ }
+ }
+ return $links;
+ }
+
+ /**
+ * @return array
*/
- public static function entityRefCreateLinks() {
- return CRM_Core_Permission::check([['edit all contacts', 'add contacts']]);
+ public static function getEntityRefFilters() {
+ return [
+ ['key' => 'contact_type', 'value' => ts('Contact Type')],
+ ['key' => 'group', 'value' => ts('Group'), 'entity' => 'GroupContact'],
+ ['key' => 'tag', 'value' => ts('Tag'), 'entity' => 'EntityTag'],
+ ['key' => 'state_province', 'value' => ts('State/Province'), 'entity' => 'Address'],
+ ['key' => 'country', 'value' => ts('Country'), 'entity' => 'Address'],
+ ['key' => 'gender_id', 'value' => ts('Gender'), 'condition' => ['contact_type' => 'Individual']],
+ ['key' => 'is_deceased', 'value' => ts('Deceased'), 'condition' => ['contact_type' => 'Individual']],
+ ['key' => 'contact_id', 'value' => ts('Contact ID'), 'type' => 'text'],
+ ['key' => 'external_identifier', 'value' => ts('External ID'), 'type' => 'text'],
+ ['key' => 'source', 'value' => ts('Contact Source'), 'type' => 'text'],
+ ];
}
}
$check = self::generateChecksum($contactID, $inputTS, $inputLF);
- if ($check != $inputCheck) {
+ if (!hash_equals($check, $inputCheck)) {
return FALSE;
}
//create/update saved search record.
$savedSearch = new CRM_Contact_BAO_SavedSearch();
$savedSearch->id = $ssId;
- $savedSearch->form_values = serialize($params['form_values']);
+ $savedSearch->form_values = serialize(CRM_Contact_BAO_Query::convertFormValues($params['form_values']));
$savedSearch->mapping_id = $mappingId;
$savedSearch->search_custom_id = CRM_Utils_Array::value('search_custom_id', $params);
$savedSearch->save();
}
$values[$object->id]['group_type'] = implode(', ', $types);
}
- $values[$object->id]['action'] = CRM_Core_Action::formLink($newLinks,
- $action,
- array(
- 'id' => $object->id,
- 'ssid' => $object->saved_search_id,
- ),
- ts('more'),
- FALSE,
- 'group.selector.row',
- 'Group',
- $object->id
- );
+ if ($action) {
+ $values[$object->id]['action'] = CRM_Core_Action::formLink($newLinks,
+ $action,
+ array(
+ 'id' => $object->id,
+ 'ssid' => $object->saved_search_id,
+ ),
+ ts('more'),
+ FALSE,
+ 'group.selector.row',
+ 'Group',
+ $object->id
+ );
+ }
// If group has children, add class for link to view children
$values[$object->id]['is_parent'] = FALSE;
* @return array|bool
*/
public static function buildOptions($fieldName, $context = NULL, $props = array()) {
- $params = array();
- $options = CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context);
+ $options = CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $props, $context);
// Sort group list by hierarchy
// TODO: This will only work when api.entity is "group_contact". What about others?
public $_pseudoConstantsSelect = array();
+ public $_groupUniqueKey = NULL;
+ public $_groupKeys = [];
+
/**
* Class constructor which also does all the work.
*
// check for both id and contact_id
if ($this->_params[$id][0] == 'id' || $this->_params[$id][0] == 'contact_id') {
$this->_where[0][] = self::buildClause("contact_a.id", $this->_params[$id][1], $this->_params[$id][2]);
+ $field = CRM_Utils_Array::value('id', $this->_fields);
+ list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue(
+ 'CRM_Contact_BAO_Contact',
+ "contact_a.id",
+ $this->_params[$id][2],
+ $this->_params[$id][1]
+ );
+ $this->_qill[0][] = ts("%1 %2 %3", [
+ 1 => $field['title'],
+ 2 => $qillop,
+ 3 => $qillVal
+ ]);
}
else {
$this->whereClauseSingle($this->_params[$id], $apiEntity);
$smartGroupIDs[] = $id;
}
else {
- $regularGroupIDs[] = $id;
+ $regularGroupIDs[] = trim($id);
}
}
if (count($regularGroupIDs) > 1) {
$op = strpos($op, 'IN') ? $op : ($op == '!=') ? 'NOT IN' : 'IN';
}
- $groupIds = implode(',', (array) $regularGroupIDs);
+ $groupIds = CRM_Utils_Type::validate(
+ implode(',', (array) $regularGroupIDs),
+ 'CommaSeparatedIntegers'
+ );
$gcTable = "`civicrm_group_contact-" . uniqid() . "`";
$joinClause = array("contact_a.id = {$gcTable}.contact_id");
//CRM-19589: contact(s) removed from a Smart Group, resides in civicrm_group_contact table
$groupContactCacheClause = '';
if (count($smartGroupIDs) || empty($value)) {
- $gccTableAlias = "civicrm_group_contact_cache";
+ $this->_groupUniqueKey = uniqid();
+ $this->_groupKeys[] = $this->_groupUniqueKey;
+ $gccTableAlias = "civicrm_group_contact_cache_{$this->_groupUniqueKey}";
$groupContactCacheClause = $this->addGroupContactCache($smartGroupIDs, $gccTableAlias, "contact_a", $op);
if (!empty($groupContactCacheClause)) {
if ($isNotOp) {
$groupIds = implode(',', (array) $smartGroupIDs);
- $gcTable = "civicrm_group_contact";
+ $gcTable = "civicrm_group_contact_{$this->_groupUniqueKey}";
$joinClause = array("contact_a.id = {$gcTable}.contact_id");
$this->_tables[$gcTable] = $this->_whereTables[$gcTable] = " LEFT JOIN civicrm_group_contact {$gcTable} ON (" . implode(' AND ', $joinClause) . ")";
if (strpos($op, 'IN') !== FALSE) {
}
}
+ public function getGroupCacheTableKeys() {
+ return $this->_groupKeys;
+ }
+
/**
* Function translates selection of group type into a list of groups.
* @param $value
$op = "LIKE";
$value = "%{$value}%";
+ $escapedValue = CRM_Utils_Type::escape("%{$value}%", 'String');
$useAllTagTypes = $this->getWhereValues('all_tag_types', $grouping);
$tagTypesText = $this->getWhereValues('tag_types_text', $grouping);
- $etTable = "`civicrm_entity_tag-" . $value . "`";
- $tTable = "`civicrm_tag-" . $value . "`";
+ $etTable = "`civicrm_entity_tag-" . uniqid() . "`";
+ $tTable = "`civicrm_tag-" . uniqid() . "`";
if ($useAllTagTypes[2]) {
$this->_tables[$etTable] = $this->_whereTables[$etTable]
LEFT JOIN civicrm_tag {$tTable} ON ( {$etTable}.tag_id = {$tTable}.id )";
// search tag in cases
- $etCaseTable = "`civicrm_entity_case_tag-" . $value . "`";
- $tCaseTable = "`civicrm_case_tag-" . $value . "`";
+ $etCaseTable = "`civicrm_entity_case_tag-" . uniqid() . "`";
+ $tCaseTable = "`civicrm_case_tag-" . uniqid() . "`";
$this->_tables[$etCaseTable] = $this->_whereTables[$etCaseTable]
= " LEFT JOIN civicrm_case_contact ON civicrm_case_contact.contact_id = contact_a.id
LEFT JOIN civicrm_case
LEFT JOIN civicrm_entity_tag {$etCaseTable} ON ( {$etCaseTable}.entity_table = 'civicrm_case' AND {$etCaseTable}.entity_id = civicrm_case.id )
LEFT JOIN civicrm_tag {$tCaseTable} ON ( {$etCaseTable}.tag_id = {$tCaseTable}.id )";
// search tag in activities
- $etActTable = "`civicrm_entity_act_tag-" . $value . "`";
- $tActTable = "`civicrm_act_tag-" . $value . "`";
+ $etActTable = "`civicrm_entity_act_tag-" . uniqid() . "`";
+ $tActTable = "`civicrm_act_tag-" . uniqid() . "`";
$activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
LEFT JOIN civicrm_entity_tag as {$etActTable} ON ( {$etActTable}.entity_table = 'civicrm_activity' AND {$etActTable}.entity_id = civicrm_activity.id )
LEFT JOIN civicrm_tag {$tActTable} ON ( {$etActTable}.tag_id = {$tActTable}.id )";
- $this->_where[$grouping][] = "({$tTable}.name $op '" . $value . "' OR {$tCaseTable}.name $op '" . $value . "' OR {$tActTable}.name $op '" . $value . "')";
+ $this->_where[$grouping][] = "({$tTable}.name $op '" . $escapedValue . "' OR {$tCaseTable}.name $op '" . $escapedValue . "' OR {$tActTable}.name $op '" . $escapedValue . "')";
$this->_qill[$grouping][] = ts('Tag %1 %2', array(1 => $tagTypesText[2], 2 => $op)) . ' ' . $value;
}
else {
- $etTable = "`civicrm_entity_tag-" . $value . "`";
- $tTable = "`civicrm_tag-" . $value . "`";
+ $etTable = "`civicrm_entity_tag-" . uniqid() . "`";
+ $tTable = "`civicrm_tag-" . uniqid() . "`";
$this->_tables[$etTable] = $this->_whereTables[$etTable] = " LEFT JOIN civicrm_entity_tag {$etTable} ON ( {$etTable}.entity_id = contact_a.id AND
{$etTable}.entity_table = 'civicrm_contact' )
LEFT JOIN civicrm_tag {$tTable} ON ( {$etTable}.tag_id = {$tTable}.id ) ";
if (count($value) > 1) {
$this->_useDistinct = TRUE;
}
- $value = implode(',', (array) $value);
}
+ // implode array, then remove all spaces and validate CommaSeparatedIntegers
+ $value = CRM_Utils_Type::validate(
+ str_replace(' ', '', implode(',', (array) $value)),
+ 'CommaSeparatedIntegers'
+ );
+
$useAllTagTypes = $this->getWhereValues('all_tag_types', $grouping);
$tagTypesText = $this->getWhereValues('tag_types_text', $grouping);
- $etTable = "`civicrm_entity_tag-" . $value . "`";
+ $etTable = "`civicrm_entity_tag-" . uniqid() . "`";
if ($useAllTagTypes[2]) {
$this->_tables[$etTable] = $this->_whereTables[$etTable]
= " LEFT JOIN civicrm_entity_tag {$etTable} ON ( {$etTable}.entity_id = contact_a.id AND {$etTable}.entity_table = 'civicrm_contact') ";
// search tag in cases
- $etCaseTable = "`civicrm_entity_case_tag-" . $value . "`";
+ $etCaseTable = "`civicrm_entity_case_tag-" . uniqid() . "`";
$activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
AND civicrm_case.is_deleted = 0 )
LEFT JOIN civicrm_entity_tag {$etCaseTable} ON ( {$etCaseTable}.entity_table = 'civicrm_case' AND {$etCaseTable}.entity_id = civicrm_case.id ) ";
// search tag in activities
- $etActTable = "`civicrm_entity_act_tag-" . $value . "`";
+ $etActTable = "`civicrm_entity_act_tag-" . uniqid() . "`";
$this->_tables[$etActTable] = $this->_whereTables[$etActTable]
= " LEFT JOIN civicrm_activity_contact
ON ( civicrm_activity_contact.contact_id = contact_a.id AND civicrm_activity_contact.record_type_id = {$targetID} )
$additionalFromClause = NULL, $skipOrderAndLimit = FALSE
) {
- if ($includeContactIds) {
- $this->_includeContactIds = TRUE;
- $this->_whereClause = $this->whereClause();
- }
-
- $onlyDeleted = in_array(array('deleted_contacts', '=', '1', '0', '0'), $this->_params);
-
- // if we’re explicitly looking for a certain contact’s contribs, events, etc.
- // and that contact happens to be deleted, set $onlyDeleted to true
- foreach ($this->_params as $values) {
- $name = CRM_Utils_Array::value(0, $values);
- $op = CRM_Utils_Array::value(1, $values);
- $value = CRM_Utils_Array::value(2, $values);
- if ($name == 'contact_id' and $op == '=') {
- if (CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $value, 'is_deleted')) {
- $onlyDeleted = TRUE;
- }
- break;
- }
- }
-
- // building the query string
- $groupBy = $groupByCols = NULL;
- if (!$count) {
- if (isset($this->_groupByComponentClause)) {
- $groupBy = $this->_groupByComponentClause;
- $groupByCols = preg_replace('/^GROUP BY /', '', trim($this->_groupByComponentClause));
- $groupByCols = explode(', ', $groupByCols);
- }
- elseif ($this->_useGroupBy) {
- $groupByCols = array('contact_a.id');
- }
- }
- if ($this->_mode & CRM_Contact_BAO_Query::MODE_ACTIVITY && (!$count)) {
- $groupByCols = array('civicrm_activity.id');
- }
-
- $order = $orderBy = $limit = '';
- if (!$count) {
- list($order, $additionalFromClause) = $this->prepareOrderBy($sort, $sortByChar, $sortOrder, $additionalFromClause);
-
- if ($rowCount > 0 && $offset >= 0) {
- $offset = CRM_Utils_Type::escape($offset, 'Int');
- $rowCount = CRM_Utils_Type::escape($rowCount, 'Int');
- $limit = " LIMIT $offset, $rowCount ";
- }
- }
- // Two cases where we are disabling FGB (FULL_GROUP_BY_MODE):
- // 1. Expecting the search query to return all the first single letter characters of contacts ONLY, but when FGB is enabled
- // MySQL expect the columns present in GROUP BY, must be present in SELECT clause and that results into error, needless to have other columns.
- // 2. When GROUP BY columns are present then disable FGB otherwise it demands to add ORDER BY columns in GROUP BY and eventually in SELECT
- // clause. This will impact the search query output.
- $disableFullGroupByMode = ($sortByChar || !empty($groupByCols));
-
- if ($disableFullGroupByMode) {
- CRM_Core_DAO::disableFullGroupByMode();
- }
-
- // CRM-15231
- $this->_sort = $sort;
-
- //CRM-15967
- $this->includePseudoFieldsJoin($sort);
-
- list($select, $from, $where, $having) = $this->query($count, $sortByChar, $groupContacts, $onlyDeleted);
-
- if (!empty($groupByCols)) {
- $groupBy = " GROUP BY " . implode(', ', $groupByCols);
- }
-
- if ($additionalWhereClause) {
- $where = $where . ' AND ' . $additionalWhereClause;
- }
-
- //additional from clause should be w/ proper joins.
- if ($additionalFromClause) {
- $from .= "\n" . $additionalFromClause;
- }
-
- // if we are doing a transform, do it here
- // use the $from, $where and $having to get the contact ID
- if ($this->_displayRelationshipType) {
- $this->filterRelatedContacts($from, $where, $having);
- }
-
- if ($skipOrderAndLimit) {
- $query = "$select $from $where $having $groupBy";
- }
- else {
- $query = "$select $from $where $having $groupBy $order $limit";
- }
+ $query = $this->getSearchSQL($offset, $rowCount, $sort, $count, $includeContactIds, $sortByChar, $groupContacts, $additionalWhereClause, $sortOrder, $additionalFromClause, $skipOrderAndLimit);
if ($returnQuery) {
return $query;
$dao = CRM_Core_DAO::executeQuery($query);
- if ($disableFullGroupByMode) {
- CRM_Core_DAO::reenableFullGroupByMode();
- }
+ // We can always call this - it will only re-enable if it was originally enabled.
+ CRM_Core_DAO::reenableFullGroupByMode();
if ($groupContacts) {
$ids = array();
$select .= sprintf(", (%s) AS _wgt", $this->createSqlCase('contact_a.id', $cids));
$where .= sprintf(' AND contact_a.id IN (%s)', implode(',', $cids));
$order = 'ORDER BY _wgt';
- $groupBy = '';
+ $groupBy = $this->_useGroupBy ? ' GROUP BY contact_a.id' : '';
$limit = '';
$query = "$select $from $where $groupBy $order $limit";
*
* @return array
*/
- public function &summaryContribution($context = NULL) {
+ public function summaryContribution($context = NULL) {
list($innerselect, $from, $where, $having) = $this->query(TRUE);
-
- // hack $select
- $select = "
-SELECT COUNT( conts.total_amount ) as total_count,
- SUM( conts.total_amount ) as total_amount,
- AVG( conts.total_amount ) as total_avg,
- conts.currency as currency";
if ($this->_permissionWhereClause) {
$where .= " AND " . $this->_permissionWhereClause;
}
$where .= " AND contact_a.is_deleted = 0 ";
}
- $query = $this->appendFinancialTypeWhereAndFromToQueryStrings($where, $from);
-
- // make sure contribution is completed - CRM-4989
- $completedWhere = $where . " AND civicrm_contribution.contribution_status_id = 1 ";
-
- $summary = array();
- $summary['total'] = array();
- $summary['total']['count'] = $summary['total']['amount'] = $summary['total']['avg'] = "n/a";
- $innerQuery = "SELECT civicrm_contribution.total_amount, COUNT(civicrm_contribution.total_amount) as civicrm_contribution_total_amount_count,
- civicrm_contribution.currency $from $completedWhere";
- $query = "$select FROM (
- $innerQuery GROUP BY civicrm_contribution.id
- ) as conts
- GROUP BY currency";
-
- $dao = CRM_Core_DAO::executeQuery($query);
-
- $summary['total']['count'] = 0;
- $summary['total']['amount'] = $summary['total']['avg'] = array();
- while ($dao->fetch()) {
- $summary['total']['count'] += $dao->total_count;
- $summary['total']['amount'][] = CRM_Utils_Money::format($dao->total_amount, $dao->currency);
- $summary['total']['avg'][] = CRM_Utils_Money::format($dao->total_avg, $dao->currency);
- }
-
- $orderBy = 'ORDER BY civicrm_contribution_total_amount_count DESC';
- $groupBy = 'GROUP BY currency, civicrm_contribution.total_amount';
- $modeSQL = "$select, SUBSTRING_INDEX(GROUP_CONCAT(conts.total_amount
- ORDER BY conts.civicrm_contribution_total_amount_count DESC SEPARATOR ';'), ';', 1) as amount,
- MAX(conts.civicrm_contribution_total_amount_count) as civicrm_contribution_total_amount_count
- FROM ($innerQuery
- $groupBy $orderBy) as conts
- GROUP BY currency";
-
- $summary['total']['mode'] = CRM_Contribute_BAO_Contribution::computeStats('mode', $modeSQL);
+ $this->appendFinancialTypeWhereAndFromToQueryStrings($where, $from);
- $medianSQL = "{$from} {$completedWhere}";
- $summary['total']['median'] = CRM_Contribute_BAO_Contribution::computeStats('median', $medianSQL, 'civicrm_contribution');
- $summary['total']['currencyCount'] = count($summary['total']['median']);
+ $summary = ['total' => []];
+ $this->addBasicStatsToSummary($summary, $where, $from);
- if (!empty($summary['total']['amount'])) {
- $summary['total']['amount'] = implode(', ', $summary['total']['amount']);
- $summary['total']['avg'] = implode(', ', $summary['total']['avg']);
- $summary['total']['mode'] = implode(', ', $summary['total']['mode']);
- $summary['total']['median'] = implode(', ', $summary['total']['median']);
- }
- else {
- $summary['total']['amount'] = $summary['total']['avg'] = $summary['total']['median'] = 0;
- }
-
- // soft credit summary
if (CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled()) {
- $softCreditWhere = "{$completedWhere} AND civicrm_contribution_soft.id IS NOT NULL";
- $query = "
- $select FROM (
- SELECT civicrm_contribution_soft.amount as total_amount, civicrm_contribution_soft.currency $from $softCreditWhere
- GROUP BY civicrm_contribution_soft.id
- ) as conts
- GROUP BY currency";
- $dao = CRM_Core_DAO::executeQuery($query);
- $summary['soft_credit']['count'] = 0;
- $summary['soft_credit']['amount'] = $summary['soft_credit']['avg'] = array();
- while ($dao->fetch()) {
- $summary['soft_credit']['count'] += $dao->total_count;
- $summary['soft_credit']['amount'][] = CRM_Utils_Money::format($dao->total_amount, $dao->currency);
- $summary['soft_credit']['avg'][] = CRM_Utils_Money::format($dao->total_avg, $dao->currency);
- }
- if (!empty($summary['soft_credit']['amount'])) {
- $summary['soft_credit']['amount'] = implode(', ', $summary['soft_credit']['amount']);
- $summary['soft_credit']['avg'] = implode(', ', $summary['soft_credit']['avg']);
- }
- else {
- $summary['soft_credit']['amount'] = $summary['soft_credit']['avg'] = 0;
- }
- }
-
- // hack $select
- //@todo - this could be one query using the IF in mysql - eg
- // SELECT sum(total_completed), sum(count_completed), sum(count_cancelled), sum(total_cancelled) FROM (
- // SELECT civicrm_contribution.total_amount, civicrm_contribution.currency ,
- // IF(civicrm_contribution.contribution_status_id = 1, 1, 0 ) as count_completed,
- // IF(civicrm_contribution.contribution_status_id = 1, total_amount, 0 ) as total_completed,
- // IF(civicrm_contribution.cancel_date IS NOT NULL = 1, 1, 0 ) as count_cancelled,
- // IF(civicrm_contribution.cancel_date IS NOT NULL = 1, total_amount, 0 ) as total_cancelled
- // FROM civicrm_contact contact_a
- // LEFT JOIN civicrm_contribution ON civicrm_contribution.contact_id = contact_a.id
- // WHERE ( ... where clause....
- // AND (civicrm_contribution.cancel_date IS NOT NULL OR civicrm_contribution.contribution_status_id = 1)
- // ) as conts
-
- $select = "
-SELECT COUNT( conts.total_amount ) as cancel_count,
- SUM( conts.total_amount ) as cancel_amount,
- AVG( conts.total_amount ) as cancel_avg,
- conts.currency as currency";
-
- $where .= " AND civicrm_contribution.cancel_date IS NOT NULL ";
- if ($context == 'search') {
- $where .= " AND contact_a.is_deleted = 0 ";
+ $this->addBasicSoftCreditStatsToStats($summary, $where, $from);
}
- $query = "$select FROM (
- SELECT civicrm_contribution.total_amount, civicrm_contribution.currency $from $where
- GROUP BY civicrm_contribution.id
- ) as conts
- GROUP BY currency";
-
- $dao = CRM_Core_DAO::executeQuery($query);
-
- if ($dao->N <= 1) {
- if ($dao->fetch()) {
- $summary['cancel']['count'] = $dao->cancel_count;
- $summary['cancel']['amount'] = CRM_Utils_Money::format($dao->cancel_amount, $dao->currency);
- $summary['cancel']['avg'] = CRM_Utils_Money::format($dao->cancel_avg, $dao->currency);
- }
- }
- else {
- $summary['cancel']['count'] = 0;
- $summary['cancel']['amount'] = $summary['cancel']['avg'] = array();
- while ($dao->fetch()) {
- $summary['cancel']['count'] += $dao->cancel_count;
- $summary['cancel']['amount'][] = CRM_Utils_Money::format($dao->cancel_amount, $dao->currency);
- $summary['cancel']['avg'][] = CRM_Utils_Money::format($dao->cancel_avg, $dao->currency);
- }
- $summary['cancel']['amount'] = implode(', ', $summary['cancel']['amount']);
- $summary['cancel']['avg'] = implode(', ', $summary['cancel']['avg']);
- }
+ $this->addBasicCancelStatsToSummary($summary, $where, $from);
return $summary;
}
* list(string $orderByClause, string $additionalFromClause).
*/
protected function prepareOrderBy($sort, $sortByChar, $sortOrder, $additionalFromClause) {
- $order = NULL;
- $orderByArray = array();
- $config = CRM_Core_Config::singleton();
- if ($config->includeOrderByClause ||
+ $orderByArray = [];
+ $orderBy = '';
+
+ if (CRM_Core_Config::singleton()->includeOrderByClause ||
isset($this->_distinctComponentClause)
) {
if ($sort) {
$orderBy = str_replace('sort_name', 'contact_a.sort_name', $orderBy);
}
- $order = " ORDER BY $orderBy";
-
if ($sortOrder) {
- $order .= " $sortOrder";
+ $orderBy .= " $sortOrder";
}
// always add contact_a.id to the ORDER clause
// so the order is deterministic
- if (strpos('contact_a.id', $order) === FALSE) {
- $order .= ", contact_a.id";
+ if (strpos('contact_a.id', $orderBy) === FALSE) {
+ $orderBy .= ", contact_a.id";
}
}
}
$orderByArray = array("UPPER(LEFT(contact_a.sort_name, 1)) asc");
}
else {
- $order = " ORDER BY contact_a.sort_name ASC, contact_a.id";
+ $orderBy = " contact_a.sort_name ASC, contact_a.id";
}
}
- if (!$order && empty($orderByArray)) {
- return array($order, $additionalFromClause);
+ if (!$orderBy && empty($orderByArray)) {
+ return [NULL, $additionalFromClause];
}
// Remove this here & add it at the end for simplicity.
- $order = trim(str_replace('ORDER BY', '', $order));
+ $order = trim($orderBy);
// hack for order clause
if (!empty($orderByArray)) {
return $select;
}
+ /**
+ * Add basic statistics to the summary.
+ *
+ * @param array $summary
+ * @param string $where
+ * @param string $from
+ *
+ * @return array
+ */
+ protected function addBasicStatsToSummary(&$summary, $where, $from) {
+ $summary['total']['count'] = 0;
+ $summary['total']['amount'] = $summary['total']['avg'] = [];
+
+ $query = "
+ SELECT COUNT( conts.total_amount ) as total_count,
+ SUM( conts.total_amount ) as total_amount,
+ AVG( conts.total_amount ) as total_avg,
+ conts.currency as currency
+ FROM (
+ SELECT civicrm_contribution.total_amount, COUNT(civicrm_contribution.total_amount) as civicrm_contribution_total_amount_count,
+ civicrm_contribution.currency
+ $from
+ $where AND civicrm_contribution.contribution_status_id = 1
+ GROUP BY civicrm_contribution.id
+ ) as conts
+ GROUP BY currency";
+
+ $dao = CRM_Core_DAO::executeQuery($query);
+
+ while ($dao->fetch()) {
+ $summary['total']['count'] += $dao->total_count;
+ $summary['total']['amount'][] = CRM_Utils_Money::format($dao->total_amount, $dao->currency);
+ $summary['total']['avg'][] = CRM_Utils_Money::format($dao->total_avg, $dao->currency);
+ }
+
+ if (!empty($summary['total']['amount'])) {
+ $summary['total']['amount'] = implode(', ', $summary['total']['amount']);
+ $summary['total']['avg'] = implode(', ', $summary['total']['avg']);
+ }
+ else {
+ $summary['total']['amount'] = $summary['total']['avg'] = 0;
+ }
+ return $summary;
+ }
+
+ /**
+ * Add basic soft credit statistics to summary array.
+ *
+ * @param array $summary
+ * @param string $where
+ * @param string $from
+ */
+ protected function addBasicSoftCreditStatsToStats(&$summary, $where, $from) {
+ $query = "
+ SELECT COUNT( conts.total_amount ) as total_count,
+ SUM( conts.total_amount ) as total_amount,
+ AVG( conts.total_amount ) as total_avg,
+ conts.currency as currency
+ FROM (
+ SELECT civicrm_contribution_soft.amount as total_amount, civicrm_contribution_soft.currency
+ $from
+ $where AND civicrm_contribution.contribution_status_id = 1 AND civicrm_contribution_soft.id IS NOT NULL
+ GROUP BY civicrm_contribution_soft.id
+ ) as conts
+ GROUP BY currency";
+
+ $dao = CRM_Core_DAO::executeQuery($query);
+ $summary['soft_credit']['count'] = 0;
+ $summary['soft_credit']['amount'] = $summary['soft_credit']['avg'] = [];
+ while ($dao->fetch()) {
+ $summary['soft_credit']['count'] += $dao->total_count;
+ $summary['soft_credit']['amount'][] = CRM_Utils_Money::format($dao->total_amount, $dao->currency);
+ $summary['soft_credit']['avg'][] = CRM_Utils_Money::format($dao->total_avg, $dao->currency);
+ }
+ if (!empty($summary['soft_credit']['amount'])) {
+ $summary['soft_credit']['amount'] = implode(', ', $summary['soft_credit']['amount']);
+ $summary['soft_credit']['avg'] = implode(', ', $summary['soft_credit']['avg']);
+ }
+ else {
+ $summary['soft_credit']['amount'] = $summary['soft_credit']['avg'] = 0;
+ }
+ }
+
+ /**
+ * Add basic stats about cancelled contributions to the summary.
+ *
+ * @param array $summary
+ * @param string $where
+ * @param string $from
+ */
+ protected function addBasicCancelStatsToSummary(&$summary, $where, $from) {
+ $query = "
+ SELECT COUNT( conts.total_amount ) as cancel_count,
+ SUM( conts.total_amount ) as cancel_amount,
+ AVG( conts.total_amount ) as cancel_avg,
+ conts.currency as currency
+ FROM (
+ SELECT civicrm_contribution.total_amount, civicrm_contribution.currency
+ $from
+ $where AND civicrm_contribution.cancel_date IS NOT NULL
+ GROUP BY civicrm_contribution.id
+ ) as conts
+ GROUP BY currency";
+
+ $dao = CRM_Core_DAO::executeQuery($query);
+
+ if ($dao->N <= 1) {
+ if ($dao->fetch()) {
+ $summary['cancel']['count'] = $dao->cancel_count;
+ $summary['cancel']['amount'] = CRM_Utils_Money::format($dao->cancel_amount, $dao->currency);
+ $summary['cancel']['avg'] = CRM_Utils_Money::format($dao->cancel_avg, $dao->currency);
+ }
+ }
+ else {
+ $summary['cancel']['count'] = 0;
+ $summary['cancel']['amount'] = $summary['cancel']['avg'] = [];
+ while ($dao->fetch()) {
+ $summary['cancel']['count'] += $dao->cancel_count;
+ $summary['cancel']['amount'][] = CRM_Utils_Money::format($dao->cancel_amount, $dao->currency);
+ $summary['cancel']['avg'][] = CRM_Utils_Money::format($dao->cancel_avg, $dao->currency);
+ }
+ $summary['cancel']['amount'] = implode(', ', $summary['cancel']['amount']);
+ $summary['cancel']['avg'] = implode(', ', $summary['cancel']['avg']);
+ }
+ }
+
+ /**
+ * /**
+ * Create the sql query for an contact search.
+ *
+ * @param int $offset
+ * The offset for the query.
+ * @param int $rowCount
+ * The number of rows to return.
+ * @param string|CRM_Utils_Sort $sort
+ * The order by string.
+ * @param bool $count
+ * Is this a count only query ?.
+ * @param bool $includeContactIds
+ * Should we include contact ids?.
+ * @param bool $sortByChar
+ * If true returns the distinct array of first characters for search results.
+ * @param bool $groupContacts
+ * If true, return only the contact ids.
+ * @param string $additionalWhereClause
+ * If the caller wants to further restrict the search (used for components).
+ * @param null $sortOrder
+ * @param string $additionalFromClause
+ * Should be clause with proper joins, effective to reduce where clause load.
+ *
+ * @param bool $skipOrderAndLimit
+ * @return string
+ */
+ public function getSearchSQL(
+ $offset = 0, $rowCount = 0, $sort = NULL,
+ $count = FALSE, $includeContactIds = FALSE,
+ $sortByChar = FALSE, $groupContacts = FALSE,
+ $additionalWhereClause = NULL, $sortOrder = NULL,
+ $additionalFromClause = NULL, $skipOrderAndLimit = FALSE) {
+ if ($includeContactIds) {
+ $this->_includeContactIds = TRUE;
+ $this->_whereClause = $this->whereClause();
+ }
+
+ $onlyDeleted = in_array([
+ 'deleted_contacts',
+ '=',
+ '1',
+ '0',
+ '0'
+ ], $this->_params);
+
+ // if we’re explicitly looking for a certain contact’s contribs, events, etc.
+ // and that contact happens to be deleted, set $onlyDeleted to true
+ foreach ($this->_params as $values) {
+ $name = CRM_Utils_Array::value(0, $values);
+ $op = CRM_Utils_Array::value(1, $values);
+ $value = CRM_Utils_Array::value(2, $values);
+ if ($name == 'contact_id' and $op == '=') {
+ if (CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $value, 'is_deleted')) {
+ $onlyDeleted = TRUE;
+ }
+ break;
+ }
+ }
+
+ // building the query string
+ $groupBy = $groupByCols = NULL;
+ if (!$count) {
+ if (isset($this->_groupByComponentClause)) {
+ $groupByCols = preg_replace('/^GROUP BY /', '', trim($this->_groupByComponentClause));
+ $groupByCols = explode(', ', $groupByCols);
+ }
+ elseif ($this->_useGroupBy) {
+ $groupByCols = ['contact_a.id'];
+ }
+ }
+ if ($this->_mode & CRM_Contact_BAO_Query::MODE_ACTIVITY && (!$count)) {
+ $groupByCols = ['civicrm_activity.id'];
+ }
+ if (!empty($groupByCols)) {
+ $groupBy = " GROUP BY " . implode(', ', $groupByCols);
+ }
+
+ $order = $orderBy = $limit = '';
+ if (!$count) {
+ list($order, $additionalFromClause) = $this->prepareOrderBy($sort, $sortByChar, $sortOrder, $additionalFromClause);
+
+ if ($rowCount > 0 && $offset >= 0) {
+ $offset = CRM_Utils_Type::escape($offset, 'Int');
+ $rowCount = CRM_Utils_Type::escape($rowCount, 'Int');
+ $limit = " LIMIT $offset, $rowCount ";
+ }
+ }
+ // Two cases where we are disabling FGB (FULL_GROUP_BY_MODE):
+ // 1. Expecting the search query to return all the first single letter characters of contacts ONLY, but when FGB is enabled
+ // MySQL expect the columns present in GROUP BY, must be present in SELECT clause and that results into error, needless to have other columns.
+ // 2. When GROUP BY columns are present then disable FGB otherwise it demands to add ORDER BY columns in GROUP BY and eventually in SELECT
+ // clause. This will impact the search query output.
+ $disableFullGroupByMode = ($sortByChar || !empty($groupBy) || $groupContacts);
+
+ if ($disableFullGroupByMode) {
+ CRM_Core_DAO::disableFullGroupByMode();
+ }
+
+ // CRM-15231
+ $this->_sort = $sort;
+
+ //CRM-15967
+ $this->includePseudoFieldsJoin($sort);
+
+ list($select, $from, $where, $having) = $this->query($count, $sortByChar, $groupContacts, $onlyDeleted);
+
+ if ($additionalWhereClause) {
+ $where = $where . ' AND ' . $additionalWhereClause;
+ }
+
+ //additional from clause should be w/ proper joins.
+ if ($additionalFromClause) {
+ $from .= "\n" . $additionalFromClause;
+ }
+
+ // if we are doing a transform, do it here
+ // use the $from, $where and $having to get the contact ID
+ if ($this->_displayRelationshipType) {
+ $this->filterRelatedContacts($from, $where, $having);
+ }
+
+ if ($skipOrderAndLimit) {
+ $query = "$select $from $where $having $groupBy";
+ }
+ else {
+ $query = "$select $from $where $having $groupBy $order $limit";
+ }
+ return $query;
+ }
+
}
*
* @return CRM_Contact_BAO_Relationship
*/
- public static function add(&$params, $ids = array(), $contactId = NULL) {
- $relationshipId = CRM_Utils_Array::value('relationship', $ids, CRM_Utils_Array::value('id', $params));
+ public static function add($params, $ids = array(), $contactId = NULL) {
+ $params['id'] = CRM_Utils_Array::value('relationship', $ids, CRM_Utils_Array::value('id', $params));
$hook = 'create';
- if ($relationshipId) {
+ if ($params['id']) {
$hook = 'edit';
}
//@todo hook are called from create and add - remove one
- CRM_Utils_Hook::pre($hook, 'Relationship', $relationshipId, $params);
+ CRM_Utils_Hook::pre($hook, 'Relationship', $params['id'], $params);
$relationshipTypes = CRM_Utils_Array::value('relationship_type_id', $params);
if ($type == 6) {
CRM_Contact_BAO_Household::updatePrimaryContact($params['contact_id_b'], $params['contact_id_a']);
}
- if (!empty($relationshipId) && self::isCurrentEmployerNeedingToBeCleared($params, $relationshipId, $type)) {
+ if (!empty($params['id']) && self::isCurrentEmployerNeedingToBeCleared($params, $params['id'], $type)) {
CRM_Contact_BAO_Contact_Utils::clearCurrentEmployer($params['contact_id_a']);
}
$relationship = new CRM_Contact_BAO_Relationship();
$relationship->contact_id_b = $params['contact_id_b'];
$relationship->contact_id_a = $params['contact_id_a'];
$relationship->relationship_type_id = $type;
- $relationship->id = $relationshipId;
+ $relationship->id = $params['id'];
$dateFields = array('end_date', 'start_date');
$relationship->$defaultField = $params[$defaultField];
}
}
- elseif (!$relationshipId) {
+ elseif (empty($params['id'])) {
$relationship->$defaultField = $defaultValue;
}
}
$form->addElement('checkbox', "address[$blockId][use_shared_address]", NULL, ts('Use another contact\'s address'));
// Override the default profile links to add address form
- $profileLinks = CRM_Contact_BAO_Contact::entityRefCreateLinks() ? CRM_Core_BAO_UFGroup::getCreateLinks('', 'shared_address') : FALSE;
+ $profileLinks = CRM_Contact_BAO_Contact::getEntityRefCreateLinks('shared_address');
$form->addEntityRef("address[$blockId][master_contact_id]", ts('Share With'), array('create' => $profileLinks));
}
}
CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues);
- $this->_formValues = $this->_params = CRM_Contact_BAO_Query::convertFormValues($this->_formValues, 0, FALSE, NULL, $this->entityReferenceFields);
+ $this->_params = CRM_Contact_BAO_Query::convertFormValues($this->_formValues, 0, FALSE, NULL, $this->entityReferenceFields);
$this->_returnProperties = &$this->returnProperties();
parent::postProcess();
}
$ssId = $this->get('ssID');
$hiddenSmartParams = array(
'group_type' => array('2' => 1),
- 'form_values' => $this->get('formValues'),
+ // queryParams have been preprocessed esp WRT any entity reference fields - see +
+ // https://github.com/civicrm/civicrm-core/pull/13250
+ 'form_values' => $this->get('queryParams'),
'saved_search_id' => $ssId,
'search_custom_id' => $this->get('customSearchID'),
'search_context' => $this->get('context'),
public function __construct() {
parent::__construct();
- $check = CRM_Core_Permission::check('access Contact Dashboard');
-
- if (!$check) {
+ if (!CRM_Core_Permission::check('access Contact Dashboard')) {
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/dashboard', 'reset=1'));
}
$this->_contactId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
-
- $session = CRM_Core_Session::singleton();
- $userID = $session->get('userID');
+ $userID = CRM_Core_Session::singleton()->getLoggedInContactID();
$userChecksum = $this->getUserChecksum();
$validUser = FALSE;
*/
public function buildUserDashBoard() {
//build component selectors
- $dashboardElements = array();
- $config = CRM_Core_Config::singleton();
+ $dashboardElements = [];
- $this->_userOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
+ $dashboardOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'user_dashboard_options'
);
continue;
}
- if (!empty($this->_userOptions[$name]) &&
+ if (!empty($dashboardOptions[$name]) &&
(CRM_Core_Permission::access($component->name) ||
CRM_Core_Permission::check($elem['perm'][0])
)
}
// CRM-16512 - Hide related contact table if user lacks permission to view self
- if (!empty($this->_userOptions['Permissioned Orgs']) && CRM_Core_Permission::check('view my contact')) {
+ if (!empty($dashboardOptions['Permissioned Orgs']) && CRM_Core_Permission::check('view my contact')) {
$dashboardElements[] = array(
'class' => 'crm-dashboard-permissionedOrgs',
'templatePath' => 'CRM/Contact/Page/View/RelationshipSelector.tpl',
}
- if (!empty($this->_userOptions['PCP'])) {
+ if (!empty($dashboardOptions['PCP'])) {
$dashboardElements[] = array(
'class' => 'crm-dashboard-pcp',
'templatePath' => 'CRM/Contribute/Page/PcpUserDashboard.tpl',
$this->assign('pcpInfo', $pcpInfo);
}
- if (!empty($this->_userOptions['Assigned Activities']) && empty($this->_isChecksumUser)) {
+ if (!empty($dashboardOptions['Assigned Activities']) && empty($this->_isChecksumUser)) {
// Assigned Activities section
$dashboardElements[] = array(
'class' => 'crm-dashboard-assignedActivities',
$this->assign('dashboardElements', $dashboardElements);
// return true when 'Invoices / Credit Notes' checkbox is checked
- $this->assign('invoices', $this->_userOptions['Invoices / Credit Notes']);
+ $this->assign('invoices', $dashboardOptions['Invoices / Credit Notes']);
- if (!empty($this->_userOptions['Groups'])) {
+ if (!empty($dashboardOptions['Groups'])) {
$this->assign('showGroup', TRUE);
//build group selector
$gContact = new CRM_Contact_Page_View_UserDashBoard_GroupContact();
// the other alternative of running the FULL query will just be incredibly inefficient
// and slow things down way too much on large data sets / complex queries
- $selectSQL = "SELECT DISTINCT '$cacheKey', contact_a.id, contact_a.sort_name";
+ $selectSQL = "SELECT DISTINCT %1, contact_a.id, contact_a.sort_name";
- $sql = str_replace(array("SELECT contact_a.id as contact_id", "SELECT contact_a.id as id"), $selectSQL, $sql);
+ $sql = str_ireplace(array("SELECT contact_a.id as contact_id", "SELECT contact_a.id as id"), $selectSQL, $sql);
try {
- Civi::service('prevnext')->fillWithSql($cacheKey, $sql);
+ Civi::service('prevnext')->fillWithSql($cacheKey, $sql, [1 => [$cacheKey, 'String']]);
}
catch (CRM_Core_Exception $e) {
if ($coreSearch) {
}
}
- //if contribution is created with cancelled or refunded status, add credit note id
- if (!empty($params['contribution_status_id'])) {
- $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
-
- if (($params['contribution_status_id'] == array_search('Refunded', $contributionStatus)
- || $params['contribution_status_id'] == array_search('Cancelled', $contributionStatus))
- ) {
- if (empty($params['creditnote_id']) || $params['creditnote_id'] == "null") {
- $params['creditnote_id'] = self::createCreditNoteId();
- }
- }
- }
-
$transaction = new CRM_Core_Transaction();
try {
return self::$_exportableFields;
}
+ /**
+ * @inheritDoc
+ */
+ public function addSelectWhereClause() {
+ $whereClauses = parent::addSelectWhereClause();
+ if ($whereClauses !== []) {
+ // In this case permisssions have been applied & we assume the
+ // financialaclreport is applying these
+ // https://github.com/JMAConsulting/biz.jmaconsulting.financialaclreport/blob/master/financialaclreport.php#L107
+ return $whereClauses;
+ }
+
+ if (!CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) {
+ return $whereClauses;
+ }
+ $types = CRM_Financial_BAO_FinancialType::getAllEnabledAvailableFinancialTypes();
+ if (empty($types)) {
+ $whereClauses['financial_type_id'] = 'IN (0)';
+ }
+ else {
+ $whereClauses['financial_type_id'] = [
+ 'IN (' . implode(',', array_keys($types)) . ')'
+ ];
+ }
+ return $whereClauses;
+ }
+
/**
* @param null $status
* @param null $startDate
*
* @return mixed
*/
- public static function getPaymentInfo($id, $component, $getTrxnInfo = FALSE, $usingLineTotal = FALSE) {
+ public static function getPaymentInfo($id, $component = 'contribution', $getTrxnInfo = FALSE, $usingLineTotal = FALSE) {
+ // @todo deprecate passing in component - always call with contribution.
if ($component == 'event') {
- $entity = 'participant';
- $entityTable = 'civicrm_participant';
$contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantPayment', $id, 'contribution_id', 'participant_id');
if (!$contributionId) {
}
}
elseif ($component == 'membership') {
- $entity = $component;
- $entityTable = 'civicrm_membership';
$contributionId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipPayment', $id, 'contribution_id', 'membership_id');
}
else {
$contributionId = $id;
- $entity = 'contribution';
- $entityTable = 'civicrm_contribution';
}
$total = CRM_Core_BAO_FinancialTrxn::getBalanceTrxnAmt($contributionId);
$total = $total['total_amount'];
}
- $paymentBalance = CRM_Core_BAO_FinancialTrxn::getPartialPaymentWithType($id, $entity, FALSE, $total);
+ $paymentBalance = CRM_Contribute_BAO_Contribution::getContributionBalance($contributionId, $total);
+
$contribution = civicrm_api3('Contribution', 'getsingle', array('id' => $contributionId, 'return' => array('currency', 'is_pay_later', 'contribution_status_id', 'financial_type_id')));
$info['payLater'] = $contribution['is_pay_later'];
* @return float
*/
public static function getContributionBalance($contributionId, $contributionTotal = NULL) {
-
if ($contributionTotal === NULL) {
$contributionTotal = CRM_Price_BAO_LineItem::getLineTotal($contributionId);
}
- $statusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed');
- $refundStatusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Refunded');
- $sqlFtTotalAmt = "
-SELECT SUM(ft.total_amount)
-FROM civicrm_financial_trxn ft
- INNER JOIN civicrm_entity_financial_trxn eft ON (ft.id = eft.financial_trxn_id AND eft.entity_table = 'civicrm_contribution' AND eft.entity_id = {$contributionId})
-WHERE ft.is_payment = 1
- AND ft.status_id IN ({$statusId}, {$refundStatusId})
-";
-
- $ftTotalAmt = CRM_Core_DAO::singleValueQuery($sqlFtTotalAmt);
- if (!$ftTotalAmt) {
- $ftTotalAmt = 0;
- }
- $currency = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'currency');
- return CRM_Utils_Money::subtractCurrencies($contributionTotal, $ftTotalAmt, $currency);
+ return CRM_Utils_Money::subtractCurrencies(
+ $contributionTotal,
+ CRM_Core_BAO_FinancialTrxn::getTotalPayments($contributionId, TRUE) ?: 0,
+ CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'currency')
+ );
}
/**
/**
* Compute the stats values
*
+ * @deprecated
+ *
* @param string $stat either 'mode' or 'median'
* @param string $sql
* @param string $alias of civicrm_contribution
* @return array|null
*/
public static function computeStats($stat, $sql, $alias = NULL) {
- $mode = $median = array();
- switch ($stat) {
- case 'mode':
- $modeDAO = CRM_Core_DAO::executeQuery($sql);
- while ($modeDAO->fetch()) {
- if ($modeDAO->civicrm_contribution_total_amount_count > 1) {
- $mode[] = CRM_Utils_Money::format($modeDAO->amount, $modeDAO->currency);
- }
- else {
- $mode[] = 'N/A';
- }
- }
- return $mode;
-
- case 'median':
- $currencies = CRM_Core_OptionGroup::values('currencies_enabled');
- foreach ($currencies as $currency => $val) {
- $midValue = 0;
- $where = "AND {$alias}.currency = '{$currency}'";
- $rowCount = CRM_Core_DAO::singleValueQuery("SELECT count(*) as count {$sql} {$where}");
-
- $even = FALSE;
- $offset = 1;
- $medianRow = floor($rowCount / 2);
- if ($rowCount % 2 == 0 && !empty($medianRow)) {
- $even = TRUE;
- $offset++;
- $medianRow--;
- }
-
- $medianValue = "SELECT {$alias}.total_amount as median
- {$sql} {$where}
- ORDER BY median LIMIT {$medianRow},{$offset}";
- $medianValDAO = CRM_Core_DAO::executeQuery($medianValue);
- while ($medianValDAO->fetch()) {
- if ($even) {
- $midValue = $midValue + $medianValDAO->median;
- }
- else {
- $median[] = CRM_Utils_Money::format($medianValDAO->median, $currency);
- }
- }
- if ($even) {
- $midValue = $midValue / 2;
- $median[] = CRM_Utils_Money::format($midValue, $currency);
- }
- }
- return $median;
-
- default:
- return NULL;
- }
+ CRM_Core_Error::deprecatedFunctionWarning('computeStats is now deprecated');
+ return [];
}
/**
public static function createCreditNoteId() {
$prefixValue = Civi::settings()->get('contribution_invoice_settings');
- $creditNoteNum = CRM_Core_DAO::singleValueQuery("SELECT count(creditnote_id) as creditnote_number FROM civicrm_contribution");
+ $creditNoteNum = CRM_Core_DAO::singleValueQuery("SELECT count(creditnote_id) as creditnote_number FROM civicrm_contribution WHERE creditnote_id IS NOT NULL");
$creditNoteId = NULL;
do {
$balanceTrxnParams['from_financial_account_id'] = $fromFinancialAccountId;
$balanceTrxnParams['total_amount'] = $params['total_amount'];
$balanceTrxnParams['contribution_id'] = $params['contribution_id'];
- $balanceTrxnParams['trxn_date'] = !empty($params['contribution_receive_date']) ? $params['contribution_receive_date'] : date('YmdHis');
+ $balanceTrxnParams['trxn_date'] = CRM_Utils_Array::value('trxn_date', $params, CRM_Utils_Array::value('contribution_receive_date', $params, date('YmdHis')));
$balanceTrxnParams['fee_amount'] = CRM_Utils_Array::value('fee_amount', $params);
$balanceTrxnParams['net_amount'] = CRM_Utils_Array::value('total_amount', $params);
$balanceTrxnParams['currency'] = $contribution['currency'];
}
$startDate = "$year$monthDay";
$endDate = "$nextYear$monthDay";
- $financialTypes = [];
- CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes);
- // this is a clumsy way of saying never return anything
- // @todo improve!
- $liWhere = " AND i.financial_type_id IN (0)";
- if (!empty($financialTypes)) {
- $liWhere = " AND i.financial_type_id NOT IN (" . implode(',', array_keys($financialTypes)) . ")";
- }
+
$whereClauses = [
- 'b.contact_id IN (' . $contactIDs . ')',
- 'b.contribution_status_id = ' . (int) CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'),
- 'b.is_test = 0',
- 'b.receive_date >= ' . $startDate,
- 'b.receive_date < ' . $endDate,
+ 'contact_id' => 'IN (' . $contactIDs . ')',
+ 'is_test' => ' = 0',
+ 'receive_date' => ['>=' . $startDate, '< ' . $endDate],
];
- CRM_Financial_BAO_FinancialType::buildPermissionedClause($whereClauses, NULL, 'b');
+ $havingClause = 'contribution_status_id = ' . (int) CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed');
+ CRM_Financial_BAO_FinancialType::addACLClausesToWhereClauses($whereClauses);
+
+ $clauses = [];
+ foreach ($whereClauses as $key => $clause) {
+ $clauses[] = 'b.' . $key . " " . implode(' AND b.' . $key, (array) $clause);
+ }
+ $whereClauseString = implode(' AND ', $clauses);
+
+ // See https://github.com/civicrm/civicrm-core/pull/13512 for discussion of how
+ // this group by + having on contribution_status_id improves performance
$query = "
SELECT COUNT(*) as count,
SUM(total_amount) as amount,
AVG(total_amount) as average,
currency
FROM civicrm_contribution b
- LEFT JOIN civicrm_line_item i ON i.contribution_id = b.id AND i.entity_table = 'civicrm_contribution' $liWhere
- WHERE " . implode(' AND ', $whereClauses) . "
- GROUP BY currency
+ WHERE " . $whereClauseString . "
+ GROUP BY currency, contribution_status_id
+ HAVING $havingClause
";
return $query;
}
/**
* Returns array with statuses that are considered to make a recurring
- * contribution inacteve.
+ * contribution inactive.
*
* @return array
*/
$quoteValue = "\"$value\"";
}
- $strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
-
$recurrringFields = CRM_Contribute_BAO_ContributionRecur::getRecurringFields();
unset($recurrringFields['contribution_recur_payment_made']);
foreach ($recurrringFields as $dateField => $dateFieldTitle) {
return;
case 'contribution_note':
- $value = $strtolower(CRM_Core_DAO::escapeString($value));
+ $value = CRM_Core_DAO::escapeString($value);
if ($wildcard) {
$value = "%$value%";
$op = 'LIKE';
}
- // LOWER roughly translates to 'hurt my database without deriving any benefit' See CRM-19811.
- $wc = ($op != 'LIKE') ? "LOWER(civicrm_note.note)" : "civicrm_note.note";
- $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($wc, $op, $value, "String");
+ $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause('civicrm_note.note', $op, $value, "String");
$query->_qill[$grouping][] = ts('Contribution Note %1 %2', array(1 => $op, 2 => $quoteValue));
$query->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = $query->_whereTables['contribution_note'] = 1;
return;
*
* Generated from xml/schema/CRM/Contribute/ContributionRecur.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:d3bbedd50918aaf27f7177cceb6593b4)
+ * (GenCodeChecksum:1eb0ecd4aadee175dadb66464c06dd25)
*/
/**
public $id;
/**
- * Foreign key to civicrm_contact.id .
+ * Foreign key to civicrm_contact.id.
*
* @var int unsigned
*/
'contact_id' => [
'name' => 'contact_id',
'type' => CRM_Utils_Type::T_INT,
- 'title' => ts('Contact ID'),
- 'description' => ts('Foreign key to civicrm_contact.id .'),
+ 'title' => ts('Contact'),
+ 'description' => ts('Foreign key to civicrm_contact.id.'),
'required' => TRUE,
'table_name' => 'civicrm_contribution_recur',
'entity' => 'ContributionRecur',
'bao' => 'CRM_Contribute_BAO_ContributionRecur',
'localizable' => 0,
'FKClassName' => 'CRM_Contact_DAO_Contact',
+ 'html' => [
+ 'type' => 'EntityRef',
+ ],
],
'amount' => [
'name' => 'amount',
'start_date' => [
'name' => 'start_date',
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
- 'title' => ts('Recurring Contribution Started Date'),
+ 'title' => ts('Start Date'),
'description' => ts('The date the first scheduled recurring contribution occurs.'),
'required' => TRUE,
'table_name' => 'civicrm_contribution_recur',
'localizable' => 0,
'html' => [
'type' => 'Select Date',
- 'formatType' => 'activityDate',
+ 'formatType' => 'activityDateTime',
],
],
'create_date' => [
'name' => 'create_date',
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
- 'title' => ts('Recurring Contribution Created Date'),
+ 'title' => ts('Created Date'),
'description' => ts('When this recurring contribution record was created.'),
'required' => TRUE,
'table_name' => 'civicrm_contribution_recur',
'localizable' => 0,
'html' => [
'type' => 'Select Date',
- 'formatType' => 'activityDate',
+ 'formatType' => 'activityDateTime',
],
],
'modified_date' => [
'name' => 'modified_date',
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
- 'title' => ts('Recurring Contribution Modified Date'),
+ 'title' => ts('Modified Date'),
'description' => ts('Last updated date for this record. mostly the last time a payment was received'),
'table_name' => 'civicrm_contribution_recur',
'entity' => 'ContributionRecur',
'localizable' => 0,
'html' => [
'type' => 'Select Date',
- 'formatType' => 'activityDate',
+ 'formatType' => 'activityDateTime',
],
],
'cancel_date' => [
'name' => 'cancel_date',
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
- 'title' => ts('Recurring Contribution Cancel Date'),
+ 'title' => ts('Cancel Date'),
'description' => ts('Date this recurring contribution was cancelled by contributor- if we can get access to it'),
'table_name' => 'civicrm_contribution_recur',
'entity' => 'ContributionRecur',
'entity' => 'ContributionRecur',
'bao' => 'CRM_Contribute_BAO_ContributionRecur',
'localizable' => 0,
+ 'html' => [
+ 'type' => 'Text',
+ ],
],
'payment_token_id' => [
'name' => 'payment_token_id',
'entity' => 'ContributionRecur',
'bao' => 'CRM_Contribute_BAO_ContributionRecur',
'localizable' => 0,
+ 'html' => [
+ 'type' => 'Text',
+ ],
],
'invoice_id' => [
'name' => 'invoice_id',
'entity' => 'ContributionRecur',
'bao' => 'CRM_Contribute_BAO_ContributionRecur',
'localizable' => 0,
+ 'html' => [
+ 'type' => 'Text',
+ ],
],
'contribution_status_id' => [
'name' => 'contribution_status_id',
'type' => CRM_Utils_Type::T_INT,
- 'title' => ts('Recurring Contribution Status'),
+ 'title' => ts('Status'),
'import' => TRUE,
'where' => 'civicrm_contribution_recur.contribution_status_id',
'headerPattern' => '',
'entity' => 'ContributionRecur',
'bao' => 'CRM_Contribute_BAO_ContributionRecur',
'localizable' => 0,
+ 'html' => [
+ 'type' => 'Select',
+ ],
'pseudoconstant' => [
'optionGroupName' => 'contribution_status',
'optionEditPath' => 'civicrm/admin/options/contribution_status',
'cycle_day' => [
'name' => 'cycle_day',
'type' => CRM_Utils_Type::T_INT,
- 'title' => ts('Number of Cycle Day'),
+ 'title' => ts('Cycle Day'),
'description' => ts('Day in the period when the payment should be charged e.g. 1st of month, 15th etc.'),
'required' => TRUE,
'default' => '1',
'bao' => 'CRM_Contribute_BAO_ContributionRecur',
'localizable' => 0,
'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
+ 'html' => [
+ 'type' => 'Select',
+ ],
],
'financial_type_id' => [
'name' => 'financial_type_id',
'bao' => 'CRM_Contribute_BAO_ContributionRecur',
'localizable' => 0,
'FKClassName' => 'CRM_Financial_DAO_FinancialType',
+ 'html' => [
+ 'type' => 'Select',
+ ],
'pseudoconstant' => [
'table' => 'civicrm_financial_type',
'keyColumn' => 'id',
'bao' => 'CRM_Contribute_BAO_ContributionRecur',
'localizable' => 0,
'FKClassName' => 'CRM_Campaign_DAO_Campaign',
+ 'html' => [
+ 'type' => 'Select',
+ ],
'pseudoconstant' => [
'table' => 'civicrm_campaign',
'keyColumn' => 'id',
$statusMsg = ts('The payment record has been processed.');
// send email
if (!empty($result) && !empty($this->_params['is_email_receipt'])) {
- $this->_params['contact_id'] = $this->_contactId;
- $this->_params['contribution_id'] = $this->_contributionId;
-
- $sendReceipt = $this->emailReceipt($this->_params);
- if ($sendReceipt) {
+ $sendResult = civicrm_api3('Payment', 'sendconfirmation', ['id' => $result->id])['values'][$result->id];
+ if ($sendResult['is_sent']) {
$statusMsg .= ' ' . ts('A receipt has been emailed to the contributor.');
}
}
}
}
- /**
- * Function to send email receipt.
- *
- * @param array $params
- *
- * @return bool
- */
- public function emailReceipt(&$params) {
- $templateEngine = CRM_Core_Smarty::singleton();
- // email receipt sending
- list($contributorDisplayName, $contributorEmail, $doNotMail) = CRM_Contact_BAO_Contact::getContactDetails($params['contact_id']);
- if (!$contributorEmail || $doNotMail) {
- return FALSE;
- }
- $templateEngine->assign('contactDisplayName', $contributorDisplayName);
- // send message template
- if ($this->_component == 'event') {
-
- // fetch event information from participant ID using API
- $eventId = civicrm_api3('Participant', 'getvalue', array(
- 'return' => "event_id",
- 'id' => $this->_id,
- ));
- $event = civicrm_api3('Event', 'getsingle', array('id' => $eventId));
-
- $templateEngine->assign('event', $event);
- $templateEngine->assign('isShowLocation', $event['is_show_location']);
- if (CRM_Utils_Array::value('is_show_location', $event) == 1) {
- $locationParams = array(
- 'entity_id' => $eventId,
- 'entity_table' => 'civicrm_event',
- );
- $location = CRM_Core_BAO_Location::getValues($locationParams, TRUE);
- $templateEngine->assign('location', $location);
- }
- }
-
- // assign payment info here
- $paymentConfig['confirm_email_text'] = CRM_Utils_Array::value('confirm_email_text', $params);
- $templateEngine->assign('paymentConfig', $paymentConfig);
-
- $templateEngine->assign('totalAmount', $this->_amtTotal);
-
- $isRefund = ($this->_paymentType == 'refund') ? TRUE : FALSE;
- $templateEngine->assign('isRefund', $isRefund);
- if ($isRefund) {
- $templateEngine->assign('totalPaid', $this->_amtPaid);
- $templateEngine->assign('refundAmount', $params['total_amount']);
- }
- else {
- $balance = $this->_amtTotal - ($this->_amtPaid + $params['total_amount']);
- $paymentsComplete = ($balance == 0) ? 1 : 0;
- $templateEngine->assign('amountOwed', $balance);
- $templateEngine->assign('paymentAmount', $params['total_amount']);
- $templateEngine->assign('paymentsComplete', $paymentsComplete);
- }
-
- // assign trxn details
- $templateEngine->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $params));
- $templateEngine->assign('receive_date', CRM_Utils_Array::value('trxn_date', $params));
- $templateEngine->assign('paidBy', CRM_Core_PseudoConstant::getLabel(
- 'CRM_Contribute_BAO_Contribution',
- 'payment_instrument_id',
- $params['payment_instrument_id']
- ));
- $templateEngine->assign('checkNumber', CRM_Utils_Array::value('check_number', $params));
-
- $sendTemplateParams = array(
- 'groupName' => 'msg_tpl_workflow_contribution',
- 'valueName' => 'payment_or_refund_notification',
- 'contactId' => $params['contact_id'],
- 'PDFFilename' => ts('notification') . '.pdf',
- );
-
- $sendTemplateParams['from'] = $params['from_email_address'];
- $sendTemplateParams['toName'] = $contributorDisplayName;
- $sendTemplateParams['toEmail'] = $contributorEmail;
-
- list($mailSent) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
- return $mailSent;
- }
-
/**
* Wrapper for unit testing the post process submit function.
*
}
// add various dates
- $this->addField('receive_date', array('entity' => 'contribution'), FALSE, FALSE);
+ $this->addField('receive_date', array('entity' => 'contribution'), !$this->_mode, FALSE);
$this->addField('receipt_date', array('entity' => 'contribution'), FALSE, FALSE);
$this->addField('cancel_date', array('entity' => 'contribution', 'label' => ts('Cancelled / Refunded Date')), FALSE, FALSE);
*
* @param array $params
* @param int $financialTypeID
- * @param bool $pending
* @param array $paymentProcessorOutcome
* @param string $receiptDate
* @param int $recurringContributionID
* @return array
*/
public static function getContributionParams(
- $params, $financialTypeID, $pending,
+ $params, $financialTypeID,
$paymentProcessorOutcome, $receiptDate, $recurringContributionID) {
$contributionParams = array(
'financial_type_id' => $financialTypeID,
'receipt_date' => $receiptDate,
);
}
- if (!$pending && $paymentProcessorOutcome) {
- $contributionParams += array(
- 'fee_amount' => CRM_Utils_Array::value('fee_amount', $paymentProcessorOutcome),
- 'net_amount' => CRM_Utils_Array::value('net_amount', $paymentProcessorOutcome, $params['amount']),
- 'trxn_id' => $paymentProcessorOutcome['trxn_id'],
- 'receipt_date' => $receiptDate,
- // also add financial_trxn details as part of fix for CRM-4724
- 'trxn_result_code' => CRM_Utils_Array::value('trxn_result_code', $paymentProcessorOutcome),
- );
- }
if ($recurringContributionID) {
$contributionParams['contribution_recur_id'] = $recurringContributionID;
}
- $contributionParams['contribution_status_id'] = $pending ? 2 : 1;
+ $contributionParams['contribution_status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending');
if (isset($contributionParams['invoice_id'])) {
$contributionParams['id'] = CRM_Core_DAO::getFieldValue(
'CRM_Contribute_DAO_Contribution',
if (isset($params['amount'])) {
$contributionParams = array_merge(self::getContributionParams(
- $params, $financialType->id, TRUE,
+ $params, $financialType->id,
$result, $receiptDate,
$recurringContributionID), $contributionParams
);
* Build the form object.
*/
public function buildQuickForm() {
-
$this->addButtons(array(
array(
'type' => 'cancel',
$this->_actionButtonName = $this->getButtonName('next', 'action');
$this->_done = FALSE;
- // @todo - is this an error - $this->_defaults is used.
- $this->defaults = array();
$this->loadStandardSearchOptionsFromUrl();
$params = array();
$whereClause = $this->whereClause($params, FALSE);
- $this->pagerAToZ($whereClause, $params);
-
+ $config = CRM_Core_Config::singleton();
+ if ($config->includeAlphabeticalPager) {
+ $this->pagerAToZ($whereClause, $params);
+ }
$params = array();
$whereClause = $this->whereClause($params, TRUE);
$this->pager($whereClause, $params);
* 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();
+ $rows = civicrm_api3('Contribution', 'get', [
+ 'options' => ['limit' => 12],
+ 'sequential' => 1,
+ 'contact_id' => $this->_contactId,
+ 'return' => [
+ 'total_amount',
+ 'contribution_recur_id',
+ 'financial_type',
+ 'receive_date',
+ 'receipt_date',
+ 'contribution_status',
+ 'currency',
+ 'amount_level',
+ 'contact_id,',
+ 'contribution_source',
+ ],
+ ])['values'];
+
+ foreach ($rows as $index => $row) {
+ // This is required for tpl logic. We should move away from hard-code this to adding an array of actions to the row
+ // which the tpl can iterate through - this should allow us to cope with competing attempts to add new buttons
+ // and allow extensions to assign new ones through the pageRun hook
+ $row[0]['contribution_status_name'] = CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $row['contribution_status_id']);;
+ }
+
+ $this->assign('contribute_rows', $rows);
+ $this->assign('contributionSummary', ['total_amount' => civicrm_api3('Contribution', 'getcount', ['contact_id' => $this->_contactId])]);
//add honor block
$params = CRM_Contribute_BAO_Contribution::getHonorContacts($this->_contactId);
$recur->is_test = 0;
$recur->find();
- $config = CRM_Core_Config::singleton();
-
$recurStatus = CRM_Contribute_PseudoConstant::contributionStatus();
$recurRow = array();
$streetAddress = trim($streetAddress);
}
+ // If street number is too large, we cannot store it.
+ if ($parseFields['street_number'] > CRM_Utils_Type::INT_MAX) {
+ return $emptyParseFields;
+ }
+
// suffix might be like 1/2
$matches = array();
if (preg_match('/^\d\/\d/', $streetAddress, $matches)) {
*
* @return object
* The data if present in cache, else null
+ * @deprecated
*/
public static function &getItem($group, $path, $componentID = NULL) {
+ if (($adapter = CRM_Utils_Constant::value('CIVICRM_BAO_CACHE_ADAPTER')) !== NULL) {
+ $value = $adapter::getItem($group, $path, $componentID);
+ return $value;
+ }
+
if (self::$_cache === NULL) {
self::$_cache = array();
}
*
* @return object
* The data if present in cache, else null
+ * @deprecated
*/
public static function &getItems($group, $componentID = NULL) {
+ if (($adapter = CRM_Utils_Constant::value('CIVICRM_BAO_CACHE_ADAPTER')) !== NULL) {
+ return $adapter::getItems($group, $componentID);
+ }
+
if (self::$_cache === NULL) {
self::$_cache = array();
}
* (required) The path under which this item is stored.
* @param int $componentID
* The optional component ID (so componenets can share the same name space).
+ * @deprecated
*/
public static function setItem(&$data, $group, $path, $componentID = NULL) {
+ if (($adapter = CRM_Utils_Constant::value('CIVICRM_BAO_CACHE_ADAPTER')) !== NULL) {
+ return $adapter::setItem($data, $group, $path, $componentID);
+ }
+
if (self::$_cache === NULL) {
self::$_cache = array();
}
* @param string $path
* Path of the item that needs to be deleted.
* @param bool $clearAll clear all caches
+ * @deprecated
*/
public static function deleteGroup($group = NULL, $path = NULL, $clearAll = TRUE) {
- $table = self::getTableName();
- $where = self::whereCache($group, $path, NULL);
- CRM_Core_DAO::executeQuery("DELETE FROM $table WHERE $where");
+ if (($adapter = CRM_Utils_Constant::value('CIVICRM_BAO_CACHE_ADAPTER')) !== NULL) {
+ return $adapter::deleteGroup($group, $path);
+ }
+ else {
+ $table = self::getTableName();
+ $where = self::whereCache($group, $path, NULL);
+ CRM_Core_DAO::executeQuery("DELETE FROM $table WHERE $where");
+ }
if ($clearAll) {
// also reset ACL Cache
--- /dev/null
+<?php
+
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 5 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2019 |
+ +--------------------------------------------------------------------+
+ | 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 |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ * Class CRM_Core_BAO_Cache_Psr16
+ *
+ * This optional adapter to help phase-out CRM_Core_BAO_Cache.
+ *
+ * In effect, it changes the default behavior of legacy cache-consumers
+ * (CRM_Core_BAO_Cache) so that they store in the best-available tier
+ * (Reds/Memcache or SQL or array) rather than being hard-coded to SQL.
+ *
+ * It basically just calls "CRM_Utils_Cache::create()" for each $group and
+ * maps the getItem/setItem to get()/set().
+ */
+class CRM_Core_BAO_Cache_Psr16 {
+
+ /**
+ * Original BAO behavior did not do expiration. PSR-16 providers have
+ * diverse defaults. To provide some consistency, we'll pick a long(ish)
+ * TTL for everything that goes through the adapter.
+ */
+ const TTL = 86400;
+
+ /**
+ * @param string $group
+ * @return CRM_Utils_Cache_Interface
+ */
+ protected static function getGroup($group) {
+ if (!isset(Civi::$statics[__CLASS__][$group])) {
+ if (!in_array($group, self::getLegacyGroups())) {
+ Civi::log()
+ ->warning('Unrecognized BAO cache group ({group}). This should work generally, but data may not be flushed in some edge-cases. Consider migrating explicitly to PSR-16.', [
+ 'group' => $group,
+ ]);
+ }
+
+ $cache = CRM_Utils_Cache::create([
+ 'name' => "bao_$group",
+ 'type' => array('*memory*', 'SqlGroup', 'ArrayCache'),
+ // We're replacing CRM_Core_BAO_Cache, which traditionally used a front-cache
+ // that was not aware of TTLs. So it seems more consistent/performant to
+ // use 'fast' here.
+ 'withArray' => 'fast',
+ ]);
+ Civi::$statics[__CLASS__][$group] = $cache;
+ }
+ return Civi::$statics[__CLASS__][$group];
+ }
+
+ /**
+ * Retrieve an item from the DB cache.
+ *
+ * @param string $group
+ * (required) The group name of the item.
+ * @param string $path
+ * (required) The path under which this item is stored.
+ * @param int $componentID
+ * The optional component ID (so componenets can share the same name space).
+ *
+ * @return object
+ * The data if present in cache, else null
+ */
+ public static function getItem($group, $path, $componentID = NULL) {
+ // TODO: Generate a general deprecation notice.
+ if ($componentID) {
+ Civi::log()
+ ->warning('getItem({group},{path},...) uses unsupported componentID. Consider migrating explicitly to PSR-16.', [
+ 'group' => $group,
+ 'path' => $path,
+ ]);
+ }
+ return self::getGroup($group)->get(CRM_Core_BAO_Cache::cleanKey($path));
+ }
+
+ /**
+ * Retrieve all items in a group.
+ *
+ * @param string $group
+ * (required) The group name of the item.
+ * @param int $componentID
+ * The optional component ID (so componenets can share the same name space).
+ *
+ * @throws CRM_Core_Exception
+ */
+ public static function &getItems($group, $componentID = NULL) {
+ // Based on grepping universe, this function is not currently used.
+ // Moreover, it's hard to implement in PSR-16. (We'd have to extend the
+ // interface.) Let's wait and see if anyone actually needs this...
+ throw new \CRM_Core_Exception('Not implemented: CRM_Core_BAO_Cache_Psr16::getItems');
+ }
+
+ /**
+ * Store an item in the DB cache.
+ *
+ * @param object $data
+ * (required) A reference to the data that will be serialized and stored.
+ * @param string $group
+ * (required) The group name of the item.
+ * @param string $path
+ * (required) The path under which this item is stored.
+ * @param int $componentID
+ * The optional component ID (so componenets can share the same name space).
+ */
+ public static function setItem(&$data, $group, $path, $componentID = NULL) {
+ // TODO: Generate a general deprecation notice.
+
+ if ($componentID) {
+ Civi::log()
+ ->warning('setItem({group},{path},...) uses unsupported componentID. Consider migrating explicitly to PSR-16.', [
+ 'group' => $group,
+ 'path' => $path,
+ ]);
+ }
+ self::getGroup($group)
+ ->set(CRM_Core_BAO_Cache::cleanKey($path), $data, self::TTL);
+ }
+
+ /**
+ * Delete all the cache elements that belong to a group OR delete the entire cache if group is not specified.
+ *
+ * @param string $group
+ * The group name of the entries to be deleted.
+ * @param string $path
+ * Path of the item that needs to be deleted.
+ */
+ public static function deleteGroup($group = NULL, $path = NULL) {
+ // FIXME: Generate a general deprecation notice.
+
+ if ($path) {
+ self::getGroup($group)->delete(CRM_Core_BAO_Cache::cleanKey($path));
+ }
+ else {
+ self::getGroup($group)->clear();
+ }
+ }
+
+ /**
+ * Cleanup any caches that we've mapped.
+ *
+ * Traditional SQL-backed caches are cleared as a matter of course during a
+ * system flush (by way of "TRUNCATE TABLE civicrm_cache"). This provides
+ * a spot where the adapter can
+ */
+ public static function clearDBCache() {
+ foreach (self::getLegacyGroups() as $groupName) {
+ $group = self::getGroup($groupName);
+ $group->clear();
+ }
+ }
+
+ /**
+ * Get a list of known cache-groups
+ *
+ * @return array
+ */
+ public static function getLegacyGroups() {
+ return [
+ // Core
+ 'CiviCRM Search PrevNextCache',
+ 'contact fields',
+ 'navigation',
+ 'contact groups',
+ 'custom data',
+
+ // Universe
+ 'dashboard', // be.chiro.civi.atomfeeds
+ 'lineitem-editor', // biz.jmaconsulting.lineitemedit
+ 'HRCore_Info', // civihr/uk.co.compucorp.civicrm.hrcore
+ 'CiviCRM setting Spec', // nz.co.fuzion.entitysetting
+ 'descendant groups for an org', // org.civicrm.multisite
+ ];
+ }
+
+}
else {
// FIXME: This won't work with customFieldOptions hook
$attributes += array(
- 'entity' => 'option_value',
+ 'entity' => 'OptionValue',
'placeholder' => $placeholder,
'multiple' => $search,
'api' => array(
'entity_id',
'file_id'
);
- list($path) = CRM_Core_BAO_File::path($fileID, $entityId, NULL, NULL);
+ list($path) = CRM_Core_BAO_File::path($fileID, $entityId);
+ $fileHash = CRM_Core_BAO_File::generateFileHash($entityId, $fileID);
$url = CRM_Utils_System::url('civicrm/file',
- "reset=1&id=$fileID&eid=$contactID",
+ "reset=1&id=$fileID&eid=$entityId&fcs=$fileHash",
$absolute, NULL, TRUE, TRUE
);
$result['file_url'] = CRM_Utils_File::getFileURL($path, $fileType, $url);
$fileID,
'uri'
);
+ $fileHash = CRM_Core_BAO_File::generateFileHash($contactID, $fileID);
$url = CRM_Utils_System::url('civicrm/file',
- "reset=1&id=$fileID&eid=$contactID",
+ "reset=1&id=$fileID&eid=$contactID&fcs=$fileHash",
$absolute, NULL, TRUE, TRUE
);
$result['file_url'] = CRM_Utils_File::getFileURL($uri, $fileType, $url);
if ($fileDAO->find(TRUE)) {
$entityIDName = "{$table}_entity_id";
+ $fileHash = CRM_Core_BAO_File::generateFileHash($dao->$entityIDName, $fileDAO->id);
$customValue['id'] = $dao->$idName;
$customValue['data'] = $fileDAO->uri;
$customValue['fid'] = $fileDAO->id;
- $customValue['fileURL'] = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileDAO->id}&eid={$dao->$entityIDName}");
+ $customValue['fileURL'] = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileDAO->id}&eid={$dao->$entityIDName}&fcs=$fileHash");
$customValue['displayURL'] = NULL;
$deleteExtra = ts('Are you sure you want to delete attached file.');
$deleteURL = array(
CRM_Core_Action::DELETE => array(
'name' => ts('Delete Attached File'),
'url' => 'civicrm/file',
- 'qs' => 'reset=1&id=%%id%%&eid=%%eid%%&fid=%%fid%%&action=delete',
+ 'qs' => 'reset=1&id=%%id%%&eid=%%eid%%&fid=%%fid%%&action=delete&fcs=%%fcs%%',
'extra' => 'onclick = "if (confirm( \'' . $deleteExtra
. '\' ) ) this.href+=\'&confirmed=1\'; else return false;"',
),
'id' => $fileDAO->id,
'eid' => $dao->$entityIDName,
'fid' => $fieldID,
+ 'fcs' => $fileHash,
),
ts('more'),
FALSE,
);
$customValue['imageURL'] = str_replace('persist/contribute', 'custom', $config->imageUploadURL) .
$fileDAO->uri;
- list($path) = CRM_Core_BAO_File::path($fileDAO->id, $entityId, NULL, NULL);
+ list($path) = CRM_Core_BAO_File::path($fileDAO->id, $entityId);
if ($path && file_exists($path)) {
list($imageWidth, $imageHeight) = getimagesize($path);
list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
default:
break;
}
- if (strtolower($value) === "null") {
+ if ($value === 'null') {
// when unsetting a value to null, we don't need to validate the type
// https://projectllr.atlassian.net/browse/VGQBMP-20
$set[$field['column_name']] = $value;
/**
* @param int $fileID
* @param int $entityID
- * @param null $entityTable
*
* @return array
*/
- public static function path($fileID, $entityID, $entityTable = NULL) {
+ public static function path($fileID, $entityID) {
$entityFileDAO = new CRM_Core_DAO_EntityFile();
- if ($entityTable) {
- $entityFileDAO->entity_table = $entityTable;
- }
$entityFileDAO->entity_id = $entityID;
$entityFileDAO->file_id = $fileID;
$dao = CRM_Core_DAO::executeQuery($sql, $params);
$results = array();
while ($dao->fetch()) {
+ $fileHash = self::generateFileHash($dao->entity_id, $dao->cfID);
$result['fileID'] = $dao->cfID;
$result['entityID'] = $dao->cefID;
$result['mime_type'] = $dao->mime_type;
$result['description'] = $dao->description;
$result['cleanName'] = CRM_Utils_File::cleanFileName($dao->uri);
$result['fullPath'] = $config->customFileUploadDir . DIRECTORY_SEPARATOR . $dao->uri;
- $result['url'] = CRM_Utils_System::url('civicrm/file', "reset=1&id={$dao->cfID}&eid={$dao->entity_id}");
+ $result['url'] = CRM_Utils_System::url('civicrm/file', "reset=1&id={$dao->cfID}&eid={$dao->entity_id}&fcs={$fileHash}");
$result['href'] = "<a href=\"{$result['url']}\">{$result['cleanName']}</a>";
$result['tag'] = CRM_Core_BAO_EntityTag::getTag($dao->cfID, 'civicrm_file');
$result['icon'] = CRM_Utils_File::getIconFromMimeType($dao->mime_type);
return NULL;
}
+ /**
+ * Generates an access-token for downloading a specific file.
+ *
+ * @param int $entityId entity id the file is attached to
+ * @param int $fileId file ID
+ * @return string
+ */
+ public static function generateFileHash($entityId = NULL, $fileId = NULL, $genTs = NULL, $life = NULL) {
+ // Use multiple (but stable) inputs for hash information.
+ $siteKey = CRM_Utils_Constant::value('CIVICRM_SITE_KEY');
+ if (!$siteKey) {
+ throw new \CRM_Core_Exception("Cannot generate file access token. Please set CIVICRM_SITE_KEY.");
+ }
+
+ if (!$genTs) {
+ $genTs = time();
+ }
+ if (!$life) {
+ $days = Civi::settings()->get('checksum_timeout');
+ $life = 24 * $days;
+ }
+ // Trim 8 chars off the string, make it slightly easier to find
+ // but reveals less information from the hash.
+ $cs = hash_hmac('sha256', "entity={$entityId}&file={$fileId}&life={$life}", $siteKey);
+ return "{$cs}_{$genTs}_{$life}";
+ }
+
+ /**
+ * Validate a file access token.
+ *
+ * @param string $hash
+ * @param int $entityId Entity Id the file is attached to
+ * @param int $fileId File Id
+ * @return bool
+ */
+ public static function validateFileHash($hash, $entityId, $fileId) {
+ $input = CRM_Utils_System::explode('_', $hash, 3);
+ $inputTs = CRM_Utils_Array::value(1, $input);
+ $inputLF = CRM_Utils_Array::value(2, $input);
+ $testHash = CRM_Core_BAO_File::generateFileHash($entityId, $fileId, $inputTs, $inputLF);
+ if (hash_equals($testHash, $hash)) {
+ $now = time();
+ if ($inputTs + ($inputLF * 60 * 60) >= $now) {
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+ }
+ return FALSE;
+ }
+
}
}
/**
- * get partial payment amount and type of it.
+ * get partial payment amount.
+ *
+ * @deprecated
+ *
+ * This function basically calls CRM_Contribute_BAO_Contribution::getContributionBalance
+ * - just do that. If need be we could have a fn to get the contribution id but
+ * chances are the calling functions already know it anyway.
*
* @param int $entityId
* @param string $entityName
- * @param bool $returnType
* @param int $lineItemTotal
*
- * @return array|int|NULL|string
- * [payment type => amount]
- * payment type: 'amount_owed' or 'refund_due'
+ * @return array
*/
- public static function getPartialPaymentWithType($entityId, $entityName = 'participant', $returnType = TRUE, $lineItemTotal = NULL) {
+ public static function getPartialPaymentWithType($entityId, $entityName = 'participant', $lineItemTotal = NULL) {
$value = NULL;
if (empty($entityName)) {
return $value;
}
+ // @todo - deprecate passing in entity & type - just figure out contribution id FIRST
if ($entityName == 'participant') {
$contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $entityId, 'contribution_id', 'participant_id');
}
if ($contributionId && $financialTypeId) {
- $value = CRM_Contribute_BAO_Contribution::getContributionBalance($contributionId, $lineItemTotal);
-
- $paymentVal = $value;
- if ($returnType) {
- $value = array();
- if ($paymentVal < 0) {
- $value['refund_due'] = $paymentVal;
- }
- elseif ($paymentVal > 0) {
- $value['amount_owed'] = $paymentVal;
- }
+ $paymentVal = CRM_Contribute_BAO_Contribution::getContributionBalance($contributionId, $lineItemTotal);
+ $value = [];
+ if ($paymentVal < 0) {
+ $value['refund_due'] = $paymentVal;
+ }
+ elseif ($paymentVal > 0) {
+ $value['amount_owed'] = $paymentVal;
}
}
return $value;
}
/**
- * @param int $contributionId
+ * @param int $contributionID
+ * @param bool $includeRefund
*
* @return string
*/
- public static function getTotalPayments($contributionId) {
- $statusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed');
+ public static function getTotalPayments($contributionID, $includeRefund = FALSE) {
+ $statusIDs = [CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed')];
+
+ if ($includeRefund) {
+ $statusIDs[] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Refunded');
+ }
$sql = "SELECT SUM(ft.total_amount) FROM civicrm_financial_trxn ft
INNER JOIN civicrm_entity_financial_trxn eft ON (eft.financial_trxn_id = ft.id AND eft.entity_table = 'civicrm_contribution')
- WHERE eft.entity_id = %1 AND ft.is_payment = 1 AND ft.status_id = %2";
-
- $params = array(
- 1 => array($contributionId, 'Integer'),
- 2 => array($statusId, 'Integer'),
- );
+ WHERE eft.entity_id = %1 AND ft.is_payment = 1 AND ft.status_id IN (%2) ";
- return CRM_Core_DAO::singleValueQuery($sql, $params);
+ return CRM_Core_DAO::singleValueQuery($sql, [
+ 1 => [$contributionID, 'Integer'],
+ 2 => [implode(',', $statusIDs), 'CommaSeparatedIntegers'],
+ ]);
}
/**
$details = $query->searchQuery(0, 0, NULL, FALSE, FALSE,
FALSE, FALSE, FALSE, $additionalWhereClause);
- if (!$details->fetch()) {
- return;
+ while ($details->fetch()) {
+ if (!$details) {
+ return;
+ }
}
$query->convertToPseudoNames($details);
$config = CRM_Core_Config::singleton();
}
}
- /**
- * @param array|string $profiles - name of profile(s) to create links for
- * @param array $appendProfiles
- * Name of profile(s) to append to each link.
- *
- * @return array
- */
- public static function getCreateLinks($profiles = '', $appendProfiles = array()) {
- // Default to contact profiles
- if (!$profiles) {
- $profiles = array('new_individual', 'new_organization', 'new_household');
- }
- $profiles = (array) $profiles;
- $toGet = array_merge($profiles, (array) $appendProfiles);
- $retrieved = civicrm_api3('uf_group', 'get', array(
- 'name' => array('IN' => $toGet),
- 'is_active' => 1,
- ));
- $links = $append = array();
- if (!empty($retrieved['values'])) {
- $icons = [
- 'individual' => 'fa-user',
- 'organization' => 'fa-building',
- 'household' => 'fa-home',
- ];
- foreach ($retrieved['values'] as $id => $profile) {
- if (in_array($profile['name'], $profiles)) {
- $links[] = array(
- 'label' => $profile['title'],
- 'url' => CRM_Utils_System::url('civicrm/profile/create', "reset=1&context=dialog&gid=$id",
- NULL, NULL, FALSE, FALSE, TRUE),
- 'type' => ucfirst(str_replace('new_', '', $profile['name'])),
- 'icon' => CRM_Utils_Array::value(str_replace('new_', '', $profile['name']), $icons),
- );
- }
- else {
- $append[] = $id;
- }
- }
- foreach ($append as $id) {
- foreach ($links as &$link) {
- $link['url'] .= ",$id";
- }
- }
- }
- return $links;
- }
-
/**
* Retrieve groups of profiles.
*
CRM_Core_DAO::executeQuery($query);
}
+ if ($adapter = CRM_Utils_Constant::value('CIVICRM_BAO_CACHE_ADAPTER')) {
+ return $adapter::clearDBCache();
+ }
+
// also delete all the import and export temp tables
self::clearTempTables();
}
}
}
+ /**
+ * @return array
+ */
+ public static function getEntityRefFilters() {
+ return [];
+ }
+
/**
* Get exportable fields with pseudoconstants rendered as an extra field.
*
* @return bool
*/
public static function isCoreTable($tableName) {
- return FALSE !== array_search($tableName, self::tables());
+ return array_key_exists($tableName, self::tables());
}
/**
*
* Generated from xml/schema/CRM/Core/Note.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:b61ee312769a75c8c8de8acb23094844)
+ * (GenCodeChecksum:daafebd13390de67d82735263e9fa886)
*/
/**
'entity' => 'Note',
'bao' => 'CRM_Core_BAO_Note',
'localizable' => 0,
+ 'html' => [
+ 'type' => 'Select',
+ ],
'pseudoconstant' => [
'optionGroupName' => 'note_privacy',
'optionEditPath' => 'civicrm/admin/options/note_privacy',
public function addButtons($params) {
$prevnext = $spacing = array();
foreach ($params as $button) {
+ if (!empty($button['submitOnce'])) {
+ $button['js']['onclick'] = "return submitOnce(this,'{$this->_name}','" . ts('Processing') . "');";
+ }
+
$attrs = array('class' => 'crm-form-submit') + (array) CRM_Utils_Array::value('js', $button);
if (!empty($button['class'])) {
if ($action & (CRM_Core_Action::VIEW + CRM_Core_Action::BROWSE + CRM_Core_Action::BASIC + CRM_Core_Action::ADVANCED + CRM_Core_Action::PREVIEW)) {
return 'get';
}
+ if ($action & (CRM_Core_Action::DELETE)) {
+ return 'delete';
+ }
// If you get this exception try adding more cases above.
throw new Exception("Cannot determine api action for " . get_class($this) . '.' . 'CRM_Core_Action "' . CRM_Core_Action::description($action) . '" not recognized.');
}
* @param array $props
* Mix of html and widget properties, including:.
* - select - params to give to select2 widget
- * - entity - defaults to contact
+ * - entity - defaults to Contact
* - create - can the user create a new entity on-the-fly?
* Set to TRUE if entity is contact and you want the default profiles,
- * or pass in your own set of links. @see CRM_Core_BAO_UFGroup::getCreateLinks for format
+ * or pass in your own set of links. @see CRM_Campaign_BAO_Campaign::getEntityRefCreateLinks for format
* note that permissions are checked automatically
* - api - array of settings for the getlist api wrapper
* note that it accepts a 'params' setting which will be passed to the underlying api
* @return HTML_QuickForm_Element
*/
public function addEntityRef($name, $label = '', $props = array(), $required = FALSE) {
- require_once "api/api.php";
- $config = CRM_Core_Config::singleton();
// Default properties
$props['api'] = CRM_Utils_Array::value('api', $props, array());
- $props['entity'] = _civicrm_api_get_entity_name_from_camel(CRM_Utils_Array::value('entity', $props, 'contact'));
+ $props['entity'] = CRM_Utils_String::convertStringToCamel(CRM_Utils_Array::value('entity', $props, 'Contact'));
$props['class'] = ltrim(CRM_Utils_Array::value('class', $props, '') . ' crm-form-entityref');
- if (isset($props['create']) && $props['create'] === TRUE) {
- require_once "api/v3/utils.php";
- $baoClass = _civicrm_api3_get_BAO($props['entity']);
- $props['create'] = $baoClass && is_callable([$baoClass, 'entityRefCreateLinks']) ? $baoClass::entityRefCreateLinks() : FALSE;
- }
if (array_key_exists('create', $props) && empty($props['create'])) {
unset($props['create']);
}
$this->assign('entityTable', CRM_Core_DAO_AllCoreTables::getTableForClass(CRM_Core_DAO_AllCoreTables::getFullName($this->getDefaultEntity())));
$this->addCustomDataToForm();
$this->addFormButtons();
+
+ if ($this->isViewContext()) {
+ $this->freeze();
+ }
}
/**
* Add relevant buttons to the form.
*/
protected function addFormButtons() {
- if ($this->_action & CRM_Core_Action::VIEW || $this->_action & CRM_Core_Action::PREVIEW) {
+ if ($this->isViewContext() || $this->_action & CRM_Core_Action::PREVIEW) {
$this->addButtons(array(
array(
'type' => 'cancel',
$this->addButtons(array(
array(
'type' => 'next',
- 'name' => $this->_action & CRM_Core_Action::DELETE ? ts('Delete') : ts('Save'),
+ 'name' => $this->isDeleteContext() ? ts('Delete') : ts('Save'),
'isDefault' => TRUE,
),
array(
*/
protected function getEntityDefaults() {
$defaults = [];
- if ($this->_action != CRM_Core_Action::DELETE &&
+ if (!$this->isDeleteContext() &&
$this->getEntityId()
) {
$params = ['id' => $this->getEntityId()];
$baoName = $this->_BAOName;
$baoName::retrieve($params, $defaults);
}
- foreach ($this->entityFields as $fieldSpec) {
+ foreach ($this->entityFields as &$fieldSpec) {
$value = CRM_Utils_Request::retrieveValue($fieldSpec['name'], $this->getValidationTypeForField($fieldSpec['name']));
if ($value !== FALSE && $value !== NULL) {
$defaults[$fieldSpec['name']] = $value;
}
+ if (CRM_Utils_Array::value('formatter', $fieldSpec) == 'crmMoney') {
+ if (!empty($defaults['currency'])) {
+ $fieldSpec['formatterParam'] = $defaults['currency'];
+ }
+ }
}
+ // Assign again as we may have modified above
+ $this->assign('entityFields', $this->entityFields);
return $defaults;
}
return ($this->_action & CRM_Core_Action::DELETE);
}
+ /**
+ * Is the form being used in the context of a view.
+ *
+ * @return bool
+ */
+ protected function isViewContext() {
+ return ($this->_action & CRM_Core_Action::VIEW);
+ }
+
protected function setEntityFieldsMetadata() {
foreach ($this->entityFields as $field => &$props) {
if (!empty($props['not-auto-addable'])) {
// We can't load this field using metadata
continue;
}
+ if ($field != 'id' && $this->isDeleteContext()) {
+ // Delete forms don't generally present any fields to edit
+ continue;
+ }
// Resolve action.
if (empty($props['action'])) {
$props['action'] = $this->getApiAction();
$params = $field->getAttribute('data-api-params');
$params = $params ? json_decode($params, TRUE) : array();
$result = civicrm_api3($entity, 'getlist', array('id' => $val) + $params);
+ // Purify label output of entityreference fields
+ if (!empty($result['values'])) {
+ foreach ($result['values'] as &$res) {
+ if (!empty($res['label'])) {
+ $res['label'] = CRM_Utils_String::purifyHTML($res['label']);
+ }
+ }
+ }
if ($field->isFrozen()) {
// Prevent js from treating frozen entityRef as a "live" field
$field->removeAttribute('class');
foreach (explode(',', $val) as $item) {
$match = CRM_Utils_Array::findInTree($item, $params['data']);
if (isset($match['text']) && strlen($match['text'])) {
- $display[] = $match['text'];
+ $display[] = CRM_Utils_String::purifyHTML($match['text']);
}
}
$el['html'] = implode('; ', $display) . '<input type="hidden" value="' . $field->getValue() . '" name="' . $field->getAttribute('name') . '">';
* @param HTML_QuickForm_element $field
*/
public function renderFrozenEntityRef(&$el, $field) {
- $entity = strtolower($field->getAttribute('data-api-entity'));
+ $entity = $field->getAttribute('data-api-entity');
$vals = json_decode($field->getAttribute('data-entity-value'), TRUE);
$display = array();
// Custom fields of type contactRef store their data in a slightly different format
- if ($field->getAttribute('data-crm-custom') && $entity == 'contact') {
+ if ($field->getAttribute('data-crm-custom') && $entity == 'Contact') {
$vals = array(array('id' => $vals['id'], 'label' => $vals['text']));
}
foreach ($vals as $val) {
// Format contact as link
- if ($entity == 'contact' && CRM_Contact_BAO_Contact_Permission::allow($val['id'], CRM_Core_Permission::VIEW)) {
+ if ($entity == 'Contact' && CRM_Contact_BAO_Contact_Permission::allow($val['id'], CRM_Core_Permission::VIEW)) {
$url = CRM_Utils_System::url("civicrm/contact/view", array('reset' => 1, 'cid' => $val['id']));
- $val['label'] = '<a class="view-' . $entity . ' no-popup" href="' . $url . '" title="' . ts('View Contact') . '">' . $val['label'] . '</a>';
+ $val['label'] = '<a class="view-contact no-popup" href="' . $url . '" title="' . ts('View Contact') . '">' . CRM_Utils_String::purifyHTML($val['label']) . '</a>';
}
$display[] = $val['label'];
}
* Build form elements based on the above metadata.
*/
public function buildQuickForm() {
- CRM_Core_Resources::singleton()
- ->addScriptFile('civicrm', 'js/crm.insert-shortcode.js');
-
$components = CRM_Utils_Array::collect('label', $this->components);
$data = CRM_Utils_Array::collect('select', $this->components);
$tagset[$tagsetItem]['tagsetElementName'] = $tagsetElementName;
$form->addEntityRef("{$tagsetElementName}[{$parentId}]", $parentNameItem, array(
- 'entity' => 'tag',
+ 'entity' => 'Tag',
'multiple' => TRUE,
'create' => !$skipTagCreate,
'api' => array('params' => array('parent_id' => $parentId)),
* Run page.
*/
public function run() {
- $fileName = CRM_Utils_Request::retrieve('filename', 'String', $this);
- $path = CRM_Core_Config::singleton()->customFileUploadDir . $fileName;
- $mimeType = CRM_Utils_Request::retrieve('mime-type', 'String', $this);
$action = CRM_Utils_Request::retrieve('action', 'String', $this);
$download = CRM_Utils_Request::retrieve('download', 'Integer', $this, FALSE, 1);
$disposition = $download == 0 ? 'inline' : 'download';
- // if we are not providing essential parameter needed for file preview then
- if (empty($fileName) && empty($mimeType)) {
- $eid = CRM_Utils_Request::retrieve('eid', 'Positive', $this, TRUE);
- $fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, FALSE);
- $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
- $quest = CRM_Utils_Request::retrieve('quest', 'String', $this);
+ $entityId = CRM_Utils_Request::retrieve('eid', 'Positive', $this, FALSE); // Entity ID (e.g. Contact ID)
+ $fieldId = CRM_Utils_Request::retrieve('fid', 'Positive', $this, FALSE); // Field ID
+ $fileId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE); // File ID
+ $fileName = CRM_Utils_Request::retrieve('filename', 'String', $this, FALSE);
+ if (empty($fileName) && (empty($entityId) || empty($fileId))) {
+ CRM_Core_Error::statusBounce("Cannot access file: Must pass either \"Filename\" or the combination of \"Entity ID\" + \"File ID\"");
+ }
+
+ if (empty($fileName)) {
+ $hash = CRM_Utils_Request::retrieve('fcs', 'Alphanumeric', $this);
+ if (!CRM_Core_BAO_File::validateFileHash($hash, $entityId, $fileId)) {
+ CRM_Core_Error::statusBounce('URL for file is not valid');
+ }
- list($path, $mimeType) = CRM_Core_BAO_File::path($id, $eid, NULL, $quest);
+ list($path, $mimeType) = CRM_Core_BAO_File::path($fileId, $entityId);
+ }
+ else {
+ if (!CRM_Utils_File::isValidFileName($fileName)) {
+ throw new CRM_Core_Exception("Malformed filename");
+ }
+ $mimeType = '';
+ $path = CRM_Core_Config::singleton()->customFileUploadDir . $fileName;
}
+ $mimeType = CRM_Utils_Request::retrieveValue('mime-type', 'String', $mimeType, FALSE);
if (!$path) {
CRM_Core_Error::statusBounce('Could not retrieve the file');
if ($action & CRM_Core_Action::DELETE) {
if (CRM_Utils_Request::retrieve('confirmed', 'Boolean')) {
- CRM_Core_BAO_File::deleteFileReferences($id, $eid, $fid);
+ CRM_Core_BAO_File::deleteFileReferences($fileId, $entityId, $fieldId);
CRM_Core_Session::setStatus(ts('The attached file has been deleted.'), ts('Complete'), 'success');
$session = CRM_Core_Session::singleton();
}
$smarty->assign('params', $args);
+ $output = $smarty->fetch($file);
$extraoutput = '';
if ($smarty->template_exists($additionalTPLFile)) {
- //@todo hook has been put here as a conservative approach
- // but probably should always run. It doesn't run otherwise because of the exit
- CRM_Utils_Hook::pageRun($this);
$extraoutput .= trim($smarty->fetch($additionalTPLFile));
+ // Allow override param to replace default text e.g. {hlp id='foo' override=1}
+ if ($smarty->get_template_vars('override_help_text')) {
+ $output = '';
+ }
}
- exit($smarty->fetch($file) . $extraoutput);
+ exit($output . $extraoutput);
}
}
* @param string $sql
* A SQL query. The query *MUST* be a SELECT statement which yields
* the following columns (in order): cacheKey, entity_id1, data
+ * @param array $sqlParams
+ * An array of parameters to be used with $sql.
+ * Use the same interpolation format as CRM_Core_DAO (composeQuery/executeQuery).
+ * Ex: [1 => ['foo', 'String']]
* @return bool
+ * @see CRM_Core_DAO::composeQuery
*/
- public function fillWithSql($cacheKey, $sql);
+ public function fillWithSql($cacheKey, $sql, $sqlParams = []);
/**
* Store the contents of an array in the cache.
$this->prefix .= \CRM_Utils_Cache::DELIMITER . 'prevnext' . \CRM_Utils_Cache::DELIMITER;
}
- public function fillWithSql($cacheKey, $sql) {
- $dao = CRM_Core_DAO::executeQuery($sql, [], FALSE, NULL, FALSE, TRUE, TRUE);
+ public function fillWithSql($cacheKey, $sql, $sqlParams = []) {
+ $dao = CRM_Core_DAO::executeQuery($sql, $sqlParams, FALSE, NULL, FALSE, TRUE, TRUE);
if (is_a($dao, 'DB_Error')) {
throw new CRM_Core_Exception($dao->message);
}
* @param string $sql
* A SQL query. The query *MUST* be a SELECT statement which yields
* the following columns (in order): cacheKey, entity_id1, data
+ * @param array $sqlParams
+ * An array of parameters to be used with $sql.
+ * Use the same interpolation format as CRM_Core_DAO (composeQuery/executeQuery).
+ * Ex: [1 => ['foo', 'String']]
* @return bool
* @throws CRM_Core_Exception
+ * @see CRM_Core_DAO::composeQuery
*/
- public function fillWithSql($cacheKey, $sql) {
+ public function fillWithSql($cacheKey, $sql, $sqlParams = []) {
$insertSQL = "
INSERT INTO civicrm_prevnext_cache (cacheKey, entity_id1, data)
";
- $result = CRM_Core_DAO::executeQuery($insertSQL . $sql, [], FALSE, NULL, FALSE, TRUE, TRUE);
+ $result = CRM_Core_DAO::executeQuery($insertSQL . $sql, $sqlParams, FALSE, NULL, FALSE, TRUE, TRUE);
if (is_a($result, 'DB_Error')) {
throw new CRM_Core_Exception($result->message);
}
}
/**
- * DEPRECATED generic populate method.
+ * @deprecated generic populate method.
* All pseudoconstant functions that use this method are also @deprecated
*
* The static array $var is populated from the db
if (is_array($item)) {
$this->addSetting($item);
}
- elseif (substr($item, -2) == 'js') {
+ elseif (strpos($item, '.css')) {
+ $this->isFullyFormedUrl($item) ? $this->addStyleUrl($item, -100, $region) : $this->addStyleFile('civicrm', $item, -100, $region);
+ }
+ elseif ($this->isFullyFormedUrl($item)) {
+ $this->addScriptUrl($item, $jsWeight++, $region);
+ }
+ else {
// Don't bother looking for ts() calls in packages, there aren't any
$translate = (substr($item, 0, 3) == 'js/');
$this->addScriptFile('civicrm', $item, $jsWeight++, $region, $translate);
}
- else {
- $this->addStyleFile('civicrm', $item, -100, $region);
- }
}
-
- $tsLocale = CRM_Core_I18n::getLocale();
- // Dynamic localization script
- $this->addScriptUrl(CRM_Utils_System::url('civicrm/ajax/l10n-js/' . $tsLocale, array('r' => $this->getCacheCode())), $jsWeight++, $region);
-
// Add global settings
$settings = array(
'config' => array(
'moneyFormat' => json_encode(CRM_Utils_Money::format(1234.56)),
'contactSearch' => json_encode($config->includeEmailInName ? ts('Start typing a name or email...') : ts('Start typing a name...')),
'otherSearch' => json_encode(ts('Enter search term...')),
- 'entityRef' => array(
- 'contactCreate' => CRM_Core_BAO_UFGroup::getCreateLinks(),
- 'filters' => self::getEntityRefFilters(),
- ),
+ 'entityRef' => self::getEntityRefMetadata(),
'ajaxPopupsEnabled' => self::singleton()->ajaxPopupsEnabled,
'allowAlertAutodismissal' => (bool) Civi::settings()->get('allow_alert_autodismissal'),
'resourceCacheCode' => self::singleton()->getCacheCode(),
"js/crm.ajax.js",
"js/wysiwyg/crm.wysiwyg.js",
);
+
+ // Dynamic localization script
+ $items[] = $this->addCacheCode(
+ CRM_Utils_System::url('civicrm/ajax/l10n-js/' . CRM_Core_I18n::getLocale(),
+ ['cid' => CRM_Core_Session::getLoggedInContactID()], FALSE, NULL, FALSE)
+ );
+
// add wysiwyg editor
$editor = Civi::settings()->get('editor_id');
if ($editor == "CKEditor") {
/**
* Provide a list of available entityRef filters.
- * @todo: move component filters into their respective components (e.g. CiviEvent)
*
* @return array
*/
- public static function getEntityRefFilters() {
- $filters = array();
- $config = CRM_Core_Config::singleton();
-
- if (in_array('CiviEvent', $config->enableComponents)) {
- $filters['event'] = array(
- array('key' => 'event_type_id', 'value' => ts('Event Type')),
- array(
- 'key' => 'start_date',
- 'value' => ts('Start Date'),
- 'options' => array(
- array('key' => '{">":"now"}', 'value' => ts('Upcoming')),
- array(
- 'key' => '{"BETWEEN":["now - 3 month","now"]}',
- 'value' => ts('Past 3 Months'),
- ),
- array(
- 'key' => '{"BETWEEN":["now - 6 month","now"]}',
- 'value' => ts('Past 6 Months'),
- ),
- array(
- 'key' => '{"BETWEEN":["now - 1 year","now"]}',
- 'value' => ts('Past Year'),
- ),
- ),
- ),
- );
- }
-
- $filters['activity'] = array(
- array('key' => 'activity_type_id', 'value' => ts('Activity Type')),
- array('key' => 'status_id', 'value' => ts('Activity Status')),
- );
-
- $filters['contact'] = [
- ['key' => 'contact_type', 'value' => ts('Contact Type')],
- ['key' => 'group', 'value' => ts('Group'), 'entity' => 'group_contact'],
- ['key' => 'tag', 'value' => ts('Tag'), 'entity' => 'entity_tag'],
- ['key' => 'state_province', 'value' => ts('State/Province'), 'entity' => 'address'],
- ['key' => 'country', 'value' => ts('Country'), 'entity' => 'address'],
- ['key' => 'gender_id', 'value' => ts('Gender'), 'condition' => ['contact_type' => 'Individual']],
- ['key' => 'is_deceased', 'value' => ts('Deceased'), 'condition' => ['contact_type' => 'Individual']],
- ['key' => 'contact_id', 'value' => ts('Contact ID'), 'type' => 'text'],
- ['key' => 'external_identifier', 'value' => ts('External ID'), 'type' => 'text'],
- ['key' => 'source', 'value' => ts('Contact Source'), 'type' => 'text'],
+ public static function getEntityRefMetadata() {
+ $data = [
+ 'filters' => [],
+ 'links' => [],
];
+ $config = CRM_Core_Config::singleton();
- if (in_array('CiviCase', $config->enableComponents)) {
- $filters['case'] = array(
- array(
- 'key' => 'case_id.case_type_id',
- 'value' => ts('Case Type'),
- 'entity' => 'Case',
- ),
- array(
- 'key' => 'case_id.status_id',
- 'value' => ts('Case Status'),
- 'entity' => 'Case',
- ),
- );
- foreach ($filters['contact'] as $filter) {
- $filter += array('entity' => 'contact');
- $filter['key'] = 'contact_id.' . $filter['key'];
- $filters['case'][] = $filter;
+ $disabledComponents = [];
+ $dao = CRM_Core_DAO::executeQuery("SELECT name, namespace FROM civicrm_component");
+ while ($dao->fetch()) {
+ if (!in_array($dao->name, $config->enableComponents)) {
+ $disabledComponents[$dao->name] = $dao->namespace;
}
}
- if (in_array('CiviCampaign', $config->enableComponents)) {
- $filters['campaign'] = [
- ['key' => 'campaign_type_id', 'value' => ts('Campaign Type')],
- ['key' => 'status_id', 'value' => ts('Status')],
- [
- 'key' => 'start_date',
- 'value' => ts('Start Date'),
- 'options' => [
- ['key' => '{">":"now"}', 'value' => ts('Upcoming')],
- [
- 'key' => '{"BETWEEN":["now - 3 month","now"]}',
- 'value' => ts('Past 3 Months'),
- ],
- [
- 'key' => '{"BETWEEN":["now - 6 month","now"]}',
- 'value' => ts('Past 6 Months'),
- ],
- [
- 'key' => '{"BETWEEN":["now - 1 year","now"]}',
- 'value' => ts('Past Year'),
- ],
- ],
- ],
- [
- 'key' => 'end_date',
- 'value' => ts('End Date'),
- 'options' => [
- ['key' => '{">":"now"}', 'value' => ts('In the future')],
- ['key' => '{"<":"now"}', 'value' => ts('In the past')],
- ['key' => '{"IS NULL":"1"}', 'value' => ts('Not set')],
- ],
- ],
- ];
+ foreach (CRM_Core_DAO_AllCoreTables::daoToClass() as $entity => $daoName) {
+ // Skip DAOs of disabled components
+ foreach ($disabledComponents as $nameSpace) {
+ if (strpos($daoName, $nameSpace) === 0) {
+ continue 2;
+ }
+ }
+ $baoName = str_replace('_DAO_', '_BAO_', $daoName);
+ if (class_exists($baoName)) {
+ $filters = $baoName::getEntityRefFilters();
+ if ($filters) {
+ $data['filters'][$entity] = $filters;
+ }
+ if (is_callable([$baoName, 'getEntityRefCreateLinks'])) {
+ $createLinks = $baoName::getEntityRefCreateLinks();
+ if ($createLinks) {
+ $data['links'][$entity] = $createLinks;
+ }
+ }
+ }
}
- CRM_Utils_Hook::entityRefFilters($filters);
+ CRM_Utils_Hook::entityRefFilters($data['filters']);
- return $filters;
+ return $data;
}
/**
return $url . $operator . 'r=' . $this->cacheCode;
}
+ /**
+ * Checks if the given URL is fully-formed
+ *
+ * @param string $url
+ *
+ * @return bool
+ */
+ public static function isFullyFormedUrl($url) {
+ return (substr($url, 0, 4) === 'http') || (substr($url, 0, 1) === '/');
+ }
+
}
* the string, translated by gettext
*/
function smarty_block_htxt($params, $text, &$smarty) {
- $id = $params['id'];
- if ($id == $smarty->_tpl_vars['id']) {
+ if ($params['id'] == $smarty->_tpl_vars['id']) {
+ $smarty->assign('override_help_text', !empty($params['override']));
return $text;
}
else {
<page_callback>CRM_Activity_Form_Activity</page_callback>
<access_arguments>access CiviCRM</access_arguments>
<page_arguments>attachUpload=1</page_arguments>
- <path_arguments>action=add&context=standalone</path_arguments>
+ <path_arguments>action=add,context=standalone</path_arguments>
</item>
<item>
<path>civicrm/activity/view</path>
$entitySubType = $form->getEntitySubTypeId($subType);
}
- // when custom data is included in this page
- if (!empty($_POST['hidden_custom'])) {
- self::preProcess($form, $subName, $entitySubType, $groupCount, $entityName, $entityID);
- self::buildQuickForm($form);
- self::setDefaultValues($form);
+ if ($form->getAction() == CRM_Core_Action::VIEW) {
+ // Viewing custom data (Use with {include file="CRM/Custom/Page/CustomDataView.tpl"} in template)
+ $groupTree = CRM_Core_BAO_CustomGroup::getTree($entityName, NULL, $entityID, 0, $entitySubType);
+ CRM_Core_BAO_CustomGroup::buildCustomDataView($form, $groupTree, FALSE, NULL, NULL, NULL, $entityID);
+ }
+ else {
+ // Editing custom data (Use with {include file="CRM/common/customDataBlock.tpl"} in template)
+ if (!empty($_POST['hidden_custom'])) {
+ self::preProcess($form, $subName, $entitySubType, $groupCount, $entityName, $entityID);
+ self::buildQuickForm($form);
+ self::setDefaultValues($form);
+ }
}
// need to assign custom data type and subtype to the template
$form->assign('customDataType', $entityName);
);
// weight
- $this->add('text', "option_weight[$i]", ts('Order'),
+ $this->add('number', "option_weight[$i]", ts('Order'),
$optionAttributes['weight']
);
$this->add('wysiwyg', 'help_post', ts('Post-form Help'), $attributes['help_post']);
// weight
- $this->add('text', 'weight', ts('Order'), $attributes['weight'], TRUE);
+ $this->add('number', 'weight', ts('Order'), $attributes['weight'], TRUE);
$this->addRule('weight', ts('is a numeric field'), 'numeric');
// display style
$this->add('textarea', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'description'));
// weight
- $this->add('text', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'weight'), TRUE);
+ $this->add('number', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'weight'), TRUE);
$this->addRule('weight', ts('is a numeric field'), 'numeric');
// is active ?
// full matches, respectively)
$where = array();
$on = array("SUBSTR(t1.{$this->rule_field}, 1, {$this->rule_length}) = SUBSTR(t2.{$this->rule_field}, 1, {$this->rule_length})");
- $using = array($this->rule_field);
+ $entity = CRM_Core_DAO_AllCoreTables::getBriefName(CRM_Core_DAO_AllCoreTables::getClassForTable($this->rule_table));
+ $fields = civicrm_api3($entity, 'getfields', ['action' => 'create'])['values'];
+
+ $innerJoinClauses = [
+ "t1.{$this->rule_field} IS NOT NULL",
+ "t2.{$this->rule_field} IS NOT NULL",
+ "t1.{$this->rule_field} = t2.{$this->rule_field}"
+ ];
+ if ($fields[$this->rule_field]['type'] === CRM_Utils_Type::T_DATE) {
+ $innerJoinClauses[] = "t1.{$this->rule_field} > '1000-01-01'";
+ $innerJoinClauses[] = "t2.{$this->rule_field} > '1000-01-01'";
+ }
+ else {
+ $innerJoinClauses[] = "t1.{$this->rule_field} <> ''";
+ $innerJoinClauses[] = "t2.{$this->rule_field} <> ''";
+ }
switch ($this->rule_table) {
case 'civicrm_contact':
case 'civicrm_address':
$id = 'contact_id';
$on[] = 't1.location_type_id = t2.location_type_id';
- $using[] = 'location_type_id';
+ $innerJoinClauses[] = ['t1.location_type_id = t2.location_type_id'];
if ($this->params['civicrm_address']['location_type_id']) {
$locTypeId = CRM_Utils_Type::escape($this->params['civicrm_address']['location_type_id'], 'Integer', FALSE);
if ($locTypeId) {
if ($this->rule_length) {
$where[] = "SUBSTR(t1.{$this->rule_field}, 1, {$this->rule_length}) = SUBSTR('$str', 1, {$this->rule_length})";
$where[] = "t1.{$this->rule_field} IS NOT NULL";
- $where[] = "t1.{$this->rule_field} <> ''";
}
else {
$where[] = "t1.{$this->rule_field} = '$str'";
$from = "{$this->rule_table} t1 JOIN {$this->rule_table} t2 ON (" . implode(' AND ', $on) . ")";
}
else {
- $from = "{$this->rule_table} t1 JOIN {$this->rule_table} t2 USING (" . implode(', ', $using) . ")";
+ $from = "{$this->rule_table} t1 INNER JOIN {$this->rule_table} t2 ON (" . implode(' AND ', $innerJoinClauses) . ")";
}
}
// finish building WHERE, also limit the results if requested
if (!$this->params) {
$where[] = "t1.$id < t2.$id";
- $where[] = "t1.{$this->rule_field} IS NOT NULL";
- $where[] = "t1.{$this->rule_field} <> ''";
}
$query = "SELECT $select FROM $from WHERE " . implode(' AND ', $where);
if ($this->contactIds) {
*
* Generated from xml/schema/CRM/Dedupe/Exception.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:8be54351020230bbff872ebf033c811b)
+ * (GenCodeChecksum:1f39e9ee1f80da1b62c054f6ca4119c5)
*/
/**
'type' => CRM_Utils_Type::T_INT,
'title' => ts('First Dupe Contact ID'),
'description' => ts('FK to Contact ID'),
+ 'required' => TRUE,
'table_name' => 'civicrm_dedupe_exception',
'entity' => 'Exception',
'bao' => 'CRM_Dedupe_DAO_Exception',
'type' => CRM_Utils_Type::T_INT,
'title' => ts('Second Dupe Contact ID'),
'description' => ts('FK to Contact ID'),
+ 'required' => TRUE,
'table_name' => 'civicrm_dedupe_exception',
'entity' => 'Exception',
'bao' => 'CRM_Dedupe_DAO_Exception',
}
}
if ($name == 'rel_table_memberships') {
- $elements[] = array('checkbox', "operation[move_{$name}][add]", NULL, ts('add new'));
+ //Enable 'add new' checkbox if main contact does not contain any membership similar to duplicate contact.
+ $attributes = ['checked' => 'checked'];
+ $otherContactMemberships = CRM_Member_BAO_Membership::getAllContactMembership($otherId);
+ foreach ($otherContactMemberships as $membership) {
+ $mainMembership = CRM_Member_BAO_Membership::getContactMembership($mainId, $membership['membership_type_id'], FALSE);
+ if ($mainMembership) {
+ $attributes = [];
+ }
+ }
+ $elements[] = array('checkbox', "operation[move_{$name}][add]", NULL, ts('add new'), $attributes);
$migrationInfo["operation"]["move_{$name}"]['add'] = 1;
}
}
return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context);
}
+ /**
+ * @return array
+ */
+ public static function getEntityRefFilters() {
+ return [
+ ['key' => 'event_type_id', 'value' => ts('Event Type')],
+ [
+ 'key' => 'start_date',
+ 'value' => ts('Start Date'),
+ 'options' => [
+ ['key' => '{">":"now"}', 'value' => ts('Upcoming')],
+ [
+ 'key' => '{"BETWEEN":["now - 3 month","now"]}',
+ 'value' => ts('Past 3 Months'),
+ ],
+ [
+ 'key' => '{"BETWEEN":["now - 6 month","now"]}',
+ 'value' => ts('Past 6 Months'),
+ ],
+ [
+ 'key' => '{"BETWEEN":["now - 1 year","now"]}',
+ 'value' => ts('Past Year'),
+ ],
+ ],
+ ],
+ ];
+ }
+
}
$form->assign('dataURLEventFee', $dataURLEventFee);
$form->addEntityRef('event_id', ts('Event Name'), array(
- 'entity' => 'event',
+ 'entity' => 'Event',
'placeholder' => ts('- any -'),
'multiple' => 1,
'select' => array('minimumInputLength' => 0),
)
);
$form->addEntityRef('event_type_id', ts('Event Type'), array(
- 'entity' => 'option_value',
+ 'entity' => 'OptionValue',
'placeholder' => ts('- any -'),
'select' => array('minimumInputLength' => 0),
'api' => array(
);
$this->addEntityRef('parent_event_id', ts('Parent Event'), array(
- 'entity' => 'event',
+ 'entity' => 'Event',
'placeholder' => ts('- any -'),
'select' => array('minimumInputLength' => 0),
)
$this->add('datepicker', 'start_date', ts('Start'), [], !$this->_isTemplate, ['time' => TRUE]);
$this->add('datepicker', 'end_date', ts('End'), [], FALSE, ['time' => TRUE]);
- $this->add('text', 'max_participants', ts('Max Number of Participants'),
+ $this->add('number', 'max_participants', ts('Max Number of Participants'),
array('onchange' => "if (this.value != '') {cj('#id-waitlist').show(); showHideByValue('has_waitlist','0','id-waitlist-text','table-row','radio',false); showHideByValue('has_waitlist','0','id-event_full','table-row','radio',true); return;} else {cj('#id-event_full, #id-waitlist, #id-waitlist-text').hide(); return;}")
);
$this->addRule('max_participants', ts('Max participants should be a positive number'), 'positiveInteger');
);
}
- $this->_values['address'] = array();
- // if 'create new loc' optioin is selected OR selected new loc is different
+ $this->_values['address'] = $this->_values['phone'] = $this->_values['email'] = array();
+ // if 'create new loc' option is selected OR selected new loc is different
// from old one, go ahead and delete the old loc provided thats not being
// used by any other event
if ($this->_oldLocBlockId && $deleteOldBlock) {
}
$eventFieldParams = array(
- 'entity' => 'event',
+ 'entity' => 'Event',
'select' => array('minimumInputLength' => 0),
'api' => array(
'extra' => array('campaign_id', 'default_role_id', 'event_type_id'),
*/
public $_noFees;
+ /**
+ * @var array Fee Block
+ */
+ public $_feeBlock;
+
/**
* Array of payment related fields to potentially display on this form (generally credit card or debit card fields).
*
* Get the contact id for the registration.
*
* @param array $fields
- * @param CRM_Core_Form $self
+ * @param CRM_Event_Form_Registration $form
* @param bool $isAdditional
*
* @return int|null
*/
- public static function getRegistrationContactID($fields, $self, $isAdditional) {
-
+ public static function getRegistrationContactID($fields, $form, $isAdditional) {
$contactID = NULL;
if (!$isAdditional) {
- $contactID = $self->getContactID();
+ $contactID = $form->getContactID();
}
if (!$contactID && is_array($fields) && $fields) {
- $contactID = CRM_Contact_BAO_Contact::getFirstDuplicateContact($fields, 'Individual', 'Unsupervised', array(), FALSE, CRM_Utils_Array::value('dedupe_rule_group_id', $self->_values['event']));
+ $contactID = CRM_Contact_BAO_Contact::getFirstDuplicateContact($fields, 'Individual', 'Unsupervised', array(), FALSE, CRM_Utils_Array::value('dedupe_rule_group_id', $form->_values['event']));
}
return $contactID;
}
/**
* Build the radio/text form elements for the amount field
*
- * @param CRM_Core_Form $form
+ * @param CRM_Event_Form_Registration_Register $form
* Form object.
* @param bool $required
* True if you want to add formRule.
}
/**
- * @param CRM_Core_Form $form
+ * @param CRM_Event_Form_Registration $form
*/
public static function formatFieldsForOptionFull(&$form) {
$priceSet = $form->get('priceSet');
* The input form values.
* @param array $files
* The uploaded files if any.
- * @param $self
+ * @param CRM_Event_Form_Registration $form
*
*
* @return bool|array
* true if no errors, else array of errors
*/
- public static function formRule($fields, $files, $self) {
+ public static function formRule($fields, $files, $form) {
$errors = array();
//check that either an email or firstname+lastname is included in the form(CRM-9587)
- self::checkProfileComplete($fields, $errors, $self->_eventId);
+ self::checkProfileComplete($fields, $errors, $form->_eventId);
//To check if the user is already registered for the event(CRM-2426)
- if (!$self->_skipDupeRegistrationCheck) {
- self::checkRegistration($fields, $self);
+ if (!$form->_skipDupeRegistrationCheck) {
+ self::checkRegistration($fields, $form);
}
//check for availability of registrations.
- if (!$self->_allowConfirmation && empty($fields['bypass_payment']) &&
- is_numeric($self->_availableRegistrations) &&
- CRM_Utils_Array::value('additional_participants', $fields) >= $self->_availableRegistrations
+ if (!$form->_allowConfirmation && empty($fields['bypass_payment']) &&
+ is_numeric($form->_availableRegistrations) &&
+ CRM_Utils_Array::value('additional_participants', $fields) >= $form->_availableRegistrations
) {
- $errors['additional_participants'] = ts("There is only enough space left on this event for %1 participant(s).", array(1 => $self->_availableRegistrations));
+ $errors['additional_participants'] = ts("There is only enough space left on this event for %1 participant(s).", array(1 => $form->_availableRegistrations));
}
// during confirmation don't allow to increase additional participants, CRM-4320
- if ($self->_allowConfirmation && !empty($fields['additional_participants']) &&
- is_array($self->_additionalParticipantIds) &&
- $fields['additional_participants'] > count($self->_additionalParticipantIds)
+ if ($form->_allowConfirmation && !empty($fields['additional_participants']) &&
+ is_array($form->_additionalParticipantIds) &&
+ $fields['additional_participants'] > count($form->_additionalParticipantIds)
) {
- $errors['additional_participants'] = ts("Oops. It looks like you are trying to increase the number of additional people you are registering for. You can confirm registration for a maximum of %1 additional people.", array(1 => count($self->_additionalParticipantIds)));
+ $errors['additional_participants'] = ts("Oops. It looks like you are trying to increase the number of additional people you are registering for. You can confirm registration for a maximum of %1 additional people.", array(1 => count($form->_additionalParticipantIds)));
}
//don't allow to register w/ waiting if enough spaces available.
- if (!empty($fields['bypass_payment']) && $self->_allowConfirmation) {
- if (!is_numeric($self->_availableRegistrations) ||
- (empty($fields['priceSetId']) && CRM_Utils_Array::value('additional_participants', $fields) < $self->_availableRegistrations)
+ if (!empty($fields['bypass_payment']) && $form->_allowConfirmation) {
+ if (!is_numeric($form->_availableRegistrations) ||
+ (empty($fields['priceSetId']) && CRM_Utils_Array::value('additional_participants', $fields) < $form->_availableRegistrations)
) {
$errors['bypass_payment'] = ts("Oops. There are enough available spaces in this event. You can not add yourself to the waiting list.");
}
// priceset validations
if (!empty($fields['priceSetId']) &&
- !$self->_requireApproval && !$self->_allowWaitlist
+ !$form->_requireApproval && !$form->_allowWaitlist
) {
//format params.
- $formatted = self::formatPriceSetParams($self, $fields);
+ $formatted = self::formatPriceSetParams($form, $fields);
$ppParams = array($formatted);
- $priceSetErrors = self::validatePriceSet($self, $ppParams);
- $primaryParticipantCount = self::getParticipantCount($self, $ppParams);
+ $priceSetErrors = self::validatePriceSet($form, $ppParams);
+ $primaryParticipantCount = self::getParticipantCount($form, $ppParams);
//get price set fields errors in.
$errors = array_merge($errors, CRM_Utils_Array::value(0, $priceSetErrors, array()));
}
if (empty($fields['bypass_payment']) &&
- !$self->_allowConfirmation &&
- is_numeric($self->_availableRegistrations) &&
- $self->_availableRegistrations < $totalParticipants
+ !$form->_allowConfirmation &&
+ is_numeric($form->_availableRegistrations) &&
+ $form->_availableRegistrations < $totalParticipants
) {
- $errors['_qf_default'] = ts("Only %1 Registrations available.", array(1 => $self->_availableRegistrations));
+ $errors['_qf_default'] = ts("Only %1 Registrations available.", array(1 => $form->_availableRegistrations));
}
$lineItem = array();
- CRM_Price_BAO_PriceSet::processAmount($self->_values['fee'], $fields, $lineItem);
+ CRM_Price_BAO_PriceSet::processAmount($form->_values['fee'], $fields, $lineItem);
$minAmt = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $fields['priceSetId'], 'min_amount');
if ($fields['amount'] < 0) {
}
// @todo - can we remove the 'is_monetary' concept?
- if ($self->_values['event']['is_monetary']) {
- if (empty($self->_requireApproval) && !empty($fields['amount']) && $fields['amount'] > 0 &&
+ if ($form->_values['event']['is_monetary']) {
+ if (empty($form->_requireApproval) && !empty($fields['amount']) && $fields['amount'] > 0 &&
!isset($fields['payment_processor_id'])) {
$errors['payment_processor_id'] = ts('Please select a Payment Method');
}
}
}
elseif (!empty($fields['amount']) &&
- (isset($self->_values['discount'][$fields['amount']])
- && CRM_Utils_Array::value('value', $self->_values['discount'][$fields['amount']]) == 0
+ (isset($form->_values['discount'][$fields['amount']])
+ && CRM_Utils_Array::value('value', $form->_values['discount'][$fields['amount']]) == 0
)
) {
$isZeroAmount = TRUE;
}
elseif (!empty($fields['amount']) &&
- (isset($self->_values['fee'][$fields['amount']])
- && CRM_Utils_Array::value('value', $self->_values['fee'][$fields['amount']]) == 0
+ (isset($form->_values['fee'][$fields['amount']])
+ && CRM_Utils_Array::value('value', $form->_values['fee'][$fields['amount']]) == 0
)
) {
$isZeroAmount = TRUE;
}
- if ($isZeroAmount && !($self->_forcePayement && !empty($fields['additional_participants']))) {
+ if ($isZeroAmount && !($form->_forcePayement && !empty($fields['additional_participants']))) {
$skipPaymentValidation = TRUE;
}
// also return if zero fees for valid members
if (!empty($fields['bypass_payment']) ||
$skipPaymentValidation ||
- (!$self->_allowConfirmation && ($self->_requireApproval || $self->_allowWaitlist))
+ (!$form->_allowConfirmation && ($form->_requireApproval || $form->_allowWaitlist))
) {
return empty($errors) ? TRUE : $errors;
}
$fields['payment_processor_id'],
$fields,
$errors,
- (!$self->_isBillingAddressRequiredForPayLater ? NULL : 'billing')
+ (!$form->_isBillingAddressRequiredForPayLater ? NULL : 'billing')
);
}
*
* @param array $fields
* The input form values(anonymous user).
- * @param CRM_Event_Form_Registration_Register $self
+ * @param CRM_Event_Form_Registration_Register $form
* Event data.
* @param bool $isAdditional
* Treat isAdditional participants a bit differently.
*
* @return int
*/
- public static function checkRegistration($fields, &$self, $isAdditional = FALSE) {
+ public static function checkRegistration($fields, $form, $isAdditional = FALSE) {
// CRM-3907, skip check for preview registrations
// CRM-4320 participant need to walk wizard
if (
- ($self->_mode == 'test' || $self->_allowConfirmation)
+ ($form->_mode == 'test' || $form->_allowConfirmation)
) {
return FALSE;
}
- $contactID = self::getRegistrationContactID($fields, $self, $isAdditional);
+ $contactID = self::getRegistrationContactID($fields, $form, $isAdditional);
if ($contactID) {
$participant = new CRM_Event_BAO_Participant();
$participant->contact_id = $contactID;
- $participant->event_id = $self->_values['event']['id'];
+ $participant->event_id = $form->_values['event']['id'];
if (!empty($fields['participant_role']) && is_numeric($fields['participant_role'])) {
$participant->role_id = $fields['participant_role'];
}
else {
- $participant->role_id = $self->_values['event']['default_role_id'];
+ $participant->role_id = $form->_values['event']['default_role_id'];
}
$participant->is_test = 0;
$participant->find();
$statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1');
while ($participant->fetch()) {
if (array_key_exists($participant->status_id, $statusTypes)) {
- if (!$isAdditional && !$self->_values['event']['allow_same_participant_emails']) {
+ if (!$isAdditional && !$form->_values['event']['allow_same_participant_emails']) {
$registerUrl = CRM_Utils_System::url('civicrm/event/register',
- "reset=1&id={$self->_values['event']['id']}&cid=0"
+ "reset=1&id={$form->_values['event']['id']}&cid=0"
);
- if ($self->_pcpId) {
- $registerUrl .= '&pcpId=' . $self->_pcpId;
+ if ($form->_pcpId) {
+ $registerUrl .= '&pcpId=' . $form->_pcpId;
}
$status = ts("It looks like you are already registered for this event. If you want to change your registration, or you feel that you've received this message in error, please contact the site administrator.") . ' ' . ts('You can also <a href="%1">register another participant</a>.', array(1 => $registerUrl));
CRM_Core_Session::singleton()->setStatus($status, ts('Oops.'), 'alert');
$url = CRM_Utils_System::url('civicrm/event/info',
- "reset=1&id={$self->_values['event']['id']}&noFullMsg=true"
+ "reset=1&id={$form->_values['event']['id']}&noFullMsg=true"
);
- if ($self->_action & CRM_Core_Action::PREVIEW) {
+ if ($form->_action & CRM_Core_Action::PREVIEW) {
$url .= '&action=preview';
}
- if ($self->_pcpId) {
- $url .= '&pcpId=' . $self->_pcpId;
+ if ($form->_pcpId) {
+ $url .= '&pcpId=' . $form->_pcpId;
}
CRM_Utils_System::redirect($url);
$this->_actionButtonName = $this->getButtonName('next', 'action');
$this->_done = FALSE;
- $this->defaults = array();
$this->loadStandardSearchOptionsFromUrl();
$this->loadFormValues();
* Group By Clause
*/
public static function getGroupBy($processor, $returnProperties, $query) {
- $groupBy = '';
+ $groupBy = NULL;
$exportMode = $processor->getExportMode();
$queryMode = $processor->getQueryMode();
if (!empty($returnProperties['tags']) || !empty($returnProperties['groups']) ||
$groupBy = 'civicrm_contribution.id';
if (CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled()) {
// especial group by when soft credit columns are included
- $groupBy = array('contribution_search_scredit_combined.id', 'contribution_search_scredit_combined.scredit_id');
+ $groupBy = ['contribution_search_scredit_combined.id', 'contribution_search_scredit_combined.scredit_id'];
}
break;
$groupBy = "civicrm_activity.id ";
}
- return $groupBy ? ' GROUP BY ' . $groupBy : '';
+ return $groupBy ? ' GROUP BY ' . implode(', ', (array) $groupBy) : '';
}
/**
*/
public static function createTempTable($sqlColumns) {
//creating a temporary table for the search result that need be exported
- $exportTempTable = CRM_Utils_SQL_TempTable::build()->setDurable()->setCategory('export')->getName();
+ $exportTempTable = CRM_Utils_SQL_TempTable::build()->setDurable()->setCategory('export')->setUtf8();
// also create the sql table
- $sql = "DROP TABLE IF EXISTS {$exportTempTable}";
- CRM_Core_DAO::executeQuery($sql);
+ $exportTempTable->drop();
$sql = "
-CREATE TABLE {$exportTempTable} (
id int unsigned NOT NULL AUTO_INCREMENT,
";
$sql .= implode(",\n", array_values($sqlColumns));
}
}
- $sql .= "
-) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci
-";
-
- CRM_Core_DAO::executeQuery($sql);
- return $exportTempTable;
+ $exportTempTable->createWithColumns($sql);
+ return $exportTempTable->getName();
}
/**
}
}
elseif ($attr === 'requires') {
- $this->requires = array();
- foreach ($val->ext as $ext) {
- $this->requires[] = (string) $ext;
- }
+ $this->requires = $this->filterRequirements($val);
}
else {
$this->$attr = CRM_Utils_XML::xmlObjToArray($val);
}
}
+ /**
+ * Filter out invalid requirements, e.g. extensions that have been moved to core.
+ *
+ * @param SimpleXMLElement $requirements
+ * @return array
+ */
+ public function filterRequirements($requirements) {
+ $filtered = [];
+ $compatInfo = CRM_Extension_System::getCompatibilityInfo();
+ foreach ($requirements->ext as $ext) {
+ $ext = (string) $ext;
+ if (empty($compatInfo[$ext]['obsolete'])) {
+ $filtered[] = $ext;
+ }
+ }
+ return $filtered;
+ }
+
}
return $this->_repoUrl;
}
+ /**
+ * Returns a list keyed by extension key
+ *
+ * @return array
+ */
+ public static function getCompatibilityInfo() {
+ if (!isset(Civi::$statics[__CLASS__]['compatibility'])) {
+ Civi::$statics[__CLASS__]['compatibility'] = json_decode(file_get_contents(Civi::paths()->getPath('[civicrm.root]/extension-compatibility.json')), TRUE);
+ }
+ return Civi::$statics[__CLASS__]['compatibility'];
+ }
+
/**
* Take an extension's raw XML info and add information about the
* extension's status on the local system.
return $membershipTypes;
}
+ /**
+ * This function adds the Financial ACL clauses to the where clause.
+ *
+ * This is currently somewhat mocking the native hook implementation
+ * for the acls that are in core. If the financialaclreport extension is installed
+ * core acls are not applied as that would result in them being applied twice.
+ *
+ * Long term we should either consolidate the financial acls in core or use only the extension.
+ * Both require substantial clean up before implementing and by the time the code is clean enough to
+ * take the final step we should
+ * be able to implement by removing one half of the other of this function.
+ *
+ * @param array $whereClauses
+ */
+ public static function addACLClausesToWhereClauses(&$whereClauses) {
+ $contributionBAO = new CRM_Contribute_BAO_Contribution();
+ $whereClauses = array_merge($whereClauses, $contributionBAO->addSelectWhereClause());
+
+ }
+
/**
* Function to build a permissioned sql where clause based on available financial types.
*
return $trxn;
}
+ /**
+ * Send an email confirming a payment that has been received.
+ *
+ * @param array $params
+ *
+ * @return array
+ */
+ public static function sendConfirmation($params) {
+
+ $entities = self::loadRelatedEntities($params['id']);
+ $sendTemplateParams = array(
+ 'groupName' => 'msg_tpl_workflow_contribution',
+ 'valueName' => 'payment_or_refund_notification',
+ 'PDFFilename' => ts('notification') . '.pdf',
+ 'contactId' => $entities['contact']['id'],
+ 'toName' => $entities['contact']['display_name'],
+ 'toEmail' => $entities['contact']['email'],
+ 'tplParams' => self::getConfirmationTemplateParameters($entities),
+ );
+ return CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
+ }
+
+ /**
+ * Load entities related to the current payment id.
+ *
+ * This gives us all the data we need to send an email confirmation but avoiding
+ * getting anything not tested for the confirmations. We retrieve the 'full' event as
+ * it has been traditionally assigned in full.
+ *
+ * @param int $id
+ *
+ * @return array
+ * - contact = ['id' => x, 'display_name' => y, 'email' => z]
+ * - event = [.... full event details......]
+ * - contribution = ['id' => x],
+ * - payment = [payment info + payment summary info]
+ */
+ protected static function loadRelatedEntities($id) {
+ $entities = [];
+ $contributionID = (int) civicrm_api3('EntityFinancialTrxn', 'getvalue', [
+ 'financial_trxn_id' => $id,
+ 'entity_table' => 'civicrm_contribution',
+ 'return' => 'entity_id',
+ ]);
+ $entities['contribution'] = ['id' => $contributionID];
+ $entities['payment'] = array_merge(civicrm_api3('FinancialTrxn', 'getsingle', ['id' => $id]),
+ CRM_Contribute_BAO_Contribution::getPaymentInfo($contributionID)
+ );
+
+ $contactID = self::getPaymentContactID($contributionID);
+ list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
+ $entities['contact'] = ['id' => $contactID, 'display_name' => $displayName, 'email' => $email];
+ $contact = civicrm_api3('Contact', 'getsingle', ['id' => $contactID, 'return' => 'email_greeting']);
+ $entities['contact']['email_greeting'] = $contact['email_greeting_display'];
+
+ $participantRecords = civicrm_api3('ParticipantPayment', 'get', [
+ 'contribution_id' => $contributionID,
+ 'api.Participant.get' => ['return' => 'event_id'],
+ 'sequential' => 1,
+ ])['values'];
+ if (!empty($participantRecords)) {
+ $entities['event'] = civicrm_api3('Event', 'getsingle', ['id' => $participantRecords[0]['api.Participant.get']['values'][0]['event_id']]);
+ if (!empty($entities['event']['is_show_location'])) {
+ $locationParams = [
+ 'entity_id' => $entities['event']['id'],
+ 'entity_table' => 'civicrm_event',
+ ];
+ $entities['location'] = CRM_Core_BAO_Location::getValues($locationParams, TRUE);
+ }
+ }
+
+ return $entities;
+ }
+
+ /**
+ * @param int $contributionID
+ *
+ * @return int
+ */
+ public static function getPaymentContactID($contributionID) {
+ $contribution = civicrm_api3('Contribution', 'getsingle', [
+ 'id' => $contributionID ,
+ 'return' => ['contact_id'],
+ ]);
+ return (int) $contribution['contact_id'];
+ }
+ /**
+ * @param array $entities
+ * Related entities as an array keyed by the various entities.
+ *
+ * @return array
+ * Values required for the notification
+ * - contact_id
+ * - template_variables
+ * - event (DAO of event if relevant)
+ */
+ public static function getConfirmationTemplateParameters($entities) {
+ $templateVariables = [
+ 'contactDisplayName' => $entities['contact']['display_name'],
+ 'emailGreeting' => $entities['contact']['email_greeting'],
+ 'totalAmount' => $entities['payment']['total'],
+ 'amountOwed' => $entities['payment']['balance'],
+ 'totalPaid' => $entities['payment']['paid'],
+ 'paymentAmount' => $entities['payment']['total_amount'],
+ 'checkNumber' => CRM_Utils_Array::value('check_number', $entities['payment']),
+ 'receive_date' => $entities['payment']['trxn_date'],
+ 'paidBy' => CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_FinancialTrxn', 'payment_instrument_id', $entities['payment']['payment_instrument_id']),
+ 'isShowLocation' => (!empty($entities['event']) ? $entities['event']['is_show_location'] : FALSE),
+ 'location' => CRM_Utils_Array::value('location', $entities),
+ 'event' => CRM_Utils_Array::value('event', $entities),
+ 'component' => (!empty($entities['event']) ? 'event' : 'contribution'),
+ 'isRefund' => $entities['payment']['total_amount'] < 0,
+ 'isAmountzero' => $entities['payment']['total_amount'] === 0,
+ 'refundAmount' => ($entities['payment']['total_amount'] < 0 ? $entities['payment']['total_amount'] : NULL),
+ 'paymentsComplete' => ($entities['payment']['balance'] == 0),
+ ];
+
+ return self::filterUntestedTemplateVariables($templateVariables);
+ }
+
+ /**
+ * Filter out any untested variables.
+ *
+ * This just serves to highlight if any variables are added without a unit test also being added.
+ *
+ * (if hit then add a unit test for the param & add to this array).
+ *
+ * @param array $params
+ *
+ * @return array
+ */
+ public static function filterUntestedTemplateVariables($params) {
+ $testedTemplateVariables = [
+ 'contactDisplayName',
+ 'totalAmount',
+ 'amountOwed',
+ 'paymentAmount',
+ 'event',
+ 'component',
+ 'checkNumber',
+ 'receive_date',
+ 'paidBy',
+ 'isShowLocation',
+ 'location',
+ 'isRefund',
+ 'isAmountzero',
+ 'refundAmount',
+ 'totalPaid',
+ 'paymentsComplete',
+ 'emailGreeting'
+ ];
+ // These are assigned by the payment form - they still 'get through' from the
+ // form for now without being in here but we should ideally load
+ // and assign. Note we should update the tpl to use {if $billingName}
+ // and ditch contributeMode - although it might need to be deprecated rather than removed.
+ $todoParams = [
+ 'contributeMode',
+ 'billingName',
+ 'address',
+ 'credit_card_type',
+ 'credit_card_number',
+ 'credit_card_exp_date',
+ ];
+ $filteredParams = [];
+ foreach ($testedTemplateVariables as $templateVariable) {
+ // This will cause an a-notice if any are NOT set - by design. Ensuring
+ // they are set prevents leakage.
+ $filteredParams[$templateVariable] = $params[$templateVariable];
+ }
+ return $filteredParams;
+ }
+
}
$this->_actionButtonName = $this->getButtonName('next', 'action');
$this->_done = FALSE;
- $this->defaults = array();
$this->loadStandardSearchOptionsFromUrl();
$this->loadFormValues();
* @return array
*/
public function getIndexesForTable($table) {
- return CRM_Core_DAO::executeQuery("
- SELECT constraint_name
- FROM information_schema.key_column_usage
- WHERE table_schema = %2 AND table_name = %1",
+ $indexes = [];
+ $result = CRM_Core_DAO::executeQuery("
+ SELECT constraint_name AS index_name
+ FROM information_schema.key_column_usage
+ WHERE table_schema = %2 AND table_name = %1
+ UNION
+ SELECT index_name AS index_name
+ FROM information_schema.statistics
+ WHERE table_schema = %2 AND table_name = %1
+ ",
array(1 => array($table, 'String'), 2 => array($this->db, 'String'))
- )->fetchAll();
+ );
+ while ($result->fetch()) {
+ $indexes[] = $result->index_name;
+ }
+ return $indexes;
}
/**
'EXTRA' => $dao->EXTRA,
);
if (($first = strpos($dao->COLUMN_TYPE, '(')) != 0) {
- \Civi::$statics[__CLASS__]['columnSpecs'][$dao->TABLE_NAME][$dao->COLUMN_NAME]['LENGTH'] = substr(
- $dao->COLUMN_TYPE, $first, strpos($dao->COLUMN_TYPE, ')')
+ // this extracts the value between parentheses after the column type.
+ // it could be the column length, i.e. "int(8)", "decimal(20,2)")
+ // or the permitted values of an enum (e.g. "enum('A','B')")
+ $parValue = substr(
+ $dao->COLUMN_TYPE, $first + 1, strpos($dao->COLUMN_TYPE, ')') - $first - 1
);
+ if (strpos($parValue, "'") === FALSE) {
+ // no quote in value means column length
+ \Civi::$statics[__CLASS__]['columnSpecs'][$dao->TABLE_NAME][$dao->COLUMN_NAME]['LENGTH'] = $parValue;
+ }
+ else {
+ // single quote means enum permitted values
+ \Civi::$statics[__CLASS__]['columnSpecs'][$dao->TABLE_NAME][$dao->COLUMN_NAME]['ENUM_VALUES'] = $parValue;
+ }
}
}
}
// if data-type is different, surely consider the column
$diff['MODIFY'][] = $col;
}
+ elseif ($civiTableSpecs[$col]['DATA_TYPE'] == 'enum' &&
+ CRM_Utils_Array::value('ENUM_VALUES', $civiTableSpecs[$col]) != CRM_Utils_Array::value('ENUM_VALUES', $logTableSpecs[$col])
+ ) {
+ // column is enum and the permitted values have changed
+ $diff['MODIFY'][] = $col;
+ }
elseif ($civiTableSpecs[$col]['IS_NULLABLE'] != CRM_Utils_Array::value('IS_NULLABLE', $logTableSpecs[$col]) &&
$logTableSpecs[$col]['IS_NULLABLE'] == 'NO'
) {
foreach ($columns as $column) {
$tableExceptions = array_key_exists('exceptions', $this->logTableSpec[$table]) ? $this->logTableSpec[$table]['exceptions'] : array();
// ignore modified_date changes
- if ($column != 'modified_date' && !in_array($column, $tableExceptions)) {
+ $tableExceptions[] = 'modified_date';
+ // exceptions may be provided with or without backticks
+ $excludeColumn = in_array($column, $tableExceptions) ||
+ in_array(str_replace('`', '', $column), $tableExceptions);
+ if (!$excludeColumn) {
$cond[] = "IFNULL(OLD.$column,'') <> IFNULL(NEW.$column,'')";
}
}
);
$actionLinks = array(CRM_Core_Action::VIEW => array('name' => ts('Report')));
- if (CRM_Core_Permission::check('view all contacts')) {
- $actionLinks[CRM_Core_Action::ADVANCED] = array(
- 'name' => ts('Advanced Search'),
- 'url' => 'civicrm/contact/search/advanced',
- );
- }
+ $actionLinks[CRM_Core_Action::ADVANCED] = array(
+ 'name' => ts('Advanced Search'),
+ 'url' => 'civicrm/contact/search/advanced',
+ );
$action = array_sum(array_keys($actionLinks));
$report['event_totals']['actionlinks'] = array();
$contacts = CRM_Contact_BAO_Contact::getTableName();
$domain_id = CRM_Core_Config::domainID();
$domainValues = civicrm_api3('Domain', 'get', array('sequential' => 1, 'id' => $domain_id));
+ $fromEmail = CRM_Core_BAO_Domain::getNoReplyEmailAddress();
$eq = new CRM_Core_DAO();
$eq->query("SELECT $contacts.display_name as display_name,
// to the forward goes to the sender of the reply
$parsed->setHeader('Reply-To', $replyto instanceof ezcMailAddress ? $replyto : $parsed->from->__toString());
+ // Using the original from address may not be permitted by the mailer.
+ $fromName = empty($parsed->from->name) ? $parsed->from->email : "{$parsed->from->name} ({$parsed->from->email})";
+ $parsed->from = new ezcMailAddress($fromEmail, $fromName);
+
// CRM-17754 Include re-sent headers to indicate that we have forwarded on the email
$domainEmail = $domainValues['values'][0]['from_email'];
$parsed->setHeader('Resent-From', $domainEmail);
$parsed->setHeader('Resent-Date', date('r'));
+ // Rewrite any invalid Return-Path headers.
+ $parsed->setHeader('Return-Path', $fromEmail);
// $h must be an array, so we can't use generateHeaders()'s result,
// but we have to regenerate the headers because we changed To
$h = $parsed->headers->getCaseSensitiveArray();
$b = $parsed->generateBody();
- // strip Return-Path of possible bounding brackets, CRM-4502
- if (!empty($h['Return-Path'])) {
- $h['Return-Path'] = trim($h['Return-Path'], '<>');
- }
-
// FIXME: ugly hack - find the first MIME boundary in
// the body and make the boundary in the header match it
$ct = $h['Content-Type'];
}
}
else {
- if (empty($eq->display_name)) {
- $from = $eq->email;
- }
- else {
- $from = "\"{$eq->display_name}\" <{$eq->email}>";
- }
+ $fromName = empty($eq->display_name) ? $eq->email : "{$eq->display_name} ({$eq->email})";
$message = new Mail_mime("\n");
$headers = array(
'Subject' => "Re: {$mailing->subject}",
'To' => $mailing->replyto_email,
- 'From' => $from,
+ 'From' => "\"$fromName\" <$fromEmail>",
'Reply-To' => empty($replyto) ? $eq->email : $replyto,
'Return-Path' => CRM_Core_BAO_Domain::getNoReplyEmailAddress(),
// CRM-17754 Include re-sent headers to indicate that we have forwarded on the email
$membership->id = $id;
$membership->save();
- $membership->free();
if (empty($membership->contact_id) || empty($membership->status_id)) {
// this means we are in renewal mode and are just updating the membership
$defaults['active'] = TRUE;
}
- $membership->free();
-
return $membership;
}
self::deleteRelatedMemberships($membership->id);
self::deleteMembership($membership->id);
}
- $membership->free();
}
/**
$memberDAO->end_date = CRM_Utils_Date::isoToMysql($memberDAO->end_date);
$memberDAO->save();
CRM_Core_DAO::storeValues($memberDAO, $currentMembership);
- $memberDAO->free();
$currentMembership['is_current_member'] = CRM_Core_DAO::getFieldValue(
'CRM_Member_DAO_MembershipStatus',
$relatedMembership->id = $membership->id;
$relatedMembership->copyValues($params);
$relatedMembership->save();
- $relatedMembership->free();
}
- $membership->free();
}
/**
$nestedRelMembership->id = $membership->owner_membership_id;
$nestedRelMembership->contact_id = $cid;
$nestedRelationship = $nestedRelMembership->find(TRUE);
- $nestedRelMembership->free();
}
if (!$nestedRelationship) {
$relatedContacts[$cid] = $status;
$membershipTypeValues[$dao->id][$mtField] = $dao->$mtField;
}
}
- $dao->free();
CRM_Utils_Hook::membershipTypeValues($form, $membershipTypeValues);
]);
$count++;
}
- $deceasedDAO->free();
return $count;
}
while ($dao1->fetch()) {
self::processOverriddenUntilDateMembership($dao1);
}
- $dao1->free();
$query = $baseQuery . " AND civicrm_membership.is_override IS NULL
AND civicrm_membership.status_id NOT IN (%1, %2, %3, %4)
$updateCount++;
}
}
- $dao2->free();
$result['is_error'] = 0;
$result['messages'] = ts('Processed %1 membership records. Updated %2 records.', array(
1 => $processCount,
$membershipLog = new CRM_Member_DAO_MembershipLog();
$membershipLog->copyValues($params);
$membershipLog->save();
- $membershipLog->free();
return $membershipLog;
}
}
$membershipStatus->delete();
CRM_Member_PseudoConstant::flush('membershipStatus');
- $membershipStatus->free();
}
/**
}
//end fetch
- $membershipStatus->free();
-
//we bundle the arguments into an array as we can't pass 8 variables to the hook otherwise
// the membership array might contain the pre-altered settings so we don't want to merge this
$arguments = array(
while ($membershipStatus->fetch()) {
$statusIds[] = $membershipStatus->id;
}
- $membershipStatus->free();
return $statusIds;
}
while ($membershipType->fetch()) {
$membershipTypes[$membershipType->id] = $membershipType->name;
}
- $membershipType->free();
return $membershipTypes;
}
$membershipType->id = $membershipTypeId;
if ($membershipType->find(TRUE)) {
CRM_Core_DAO::storeValues($membershipType, $membershipTypeDetails);
- $membershipType->free();
return $membershipTypeDetails;
}
else {
}
if ($this->_action & CRM_Core_Action::ADD) {
- $this->add('text', 'num_terms', ts('Number of Terms'), array('size' => 6));
+ $this->add('number', 'num_terms', ts('Number of Terms'), array('size' => 6));
}
$this->add('text', 'source', ts('Source'),
array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType()
);
- $this->add('text', 'num_terms', ts('Extend Membership by'), array('onchange' => "setPaymentBlock();"), TRUE);
+ $this->add('number', 'num_terms', ts('Extend Membership by'), array('onchange' => "setPaymentBlock();"), TRUE);
$this->addRule('num_terms', ts('Please enter a whole number for how many periods to renew.'), 'integer');
if (CRM_Core_Permission::access('CiviContribute') && !$this->_mode) {
);
$this->add('checkbox', 'is_current_member', ts('Current Membership?'));
- $this->add('text', 'weight', ts('Order'),
+ $this->add('number', 'weight', ts('Order'),
CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipStatus', 'weight')
);
$this->add('checkbox', 'is_default', ts('Default?'));
$this->_done = FALSE;
- $this->defaults = array();
-
$this->loadStandardSearchOptionsFromUrl();
// get user submitted values
$status = CRM_Member_BAO_MembershipStatus::getMembershipStatusCurrent();
$status = implode(',', $status);
- /*@codingStandardsIgnoreStart
- Disabled for lack of appropriate search
-
- The Membership search isn't able to properly filter by join or renewal events.
- Until that works properly, the subtotals shouldn't get links.
-
- foreach ($membershipSummary as $typeID => $details) {
- foreach ($details as $key => $value) {
- switch ($key) {
- case 'premonth':
- $membershipSummary[$typeID][$key]['new']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&join=$preMonth&joinEnd=$preMonthEnd&start=$preMonth&end=$preMonthEnd");
- $membershipSummary[$typeID][$key]['renew']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&joinEnd=$prePreMonthEnd&start=$preMonth&end=$preMonthEnd");
- $membershipSummary[$typeID][$key]['total']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&start=$preMonth&end=$preMonthEnd");
- break;
-
- case 'month':
- $membershipSummary[$typeID][$key]['new']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&join=$monthStart&joinEnd=$ymd&start=$monthStart&end=$ymd");
- $membershipSummary[$typeID][$key]['renew']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&joinEnd=$preMonthStart&start=$monthStart&end=$ymd");
- $membershipSummary[$typeID][$key]['total']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&start=$monthStart&end=$ymd");
- break;
-
- case 'year':
- $membershipSummary[$typeID][$key]['new']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&join=$yearStart&joinEnd=$ymd&start=$yearStart&end=$ymd");
- $membershipSummary[$typeID][$key]['renew']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&joinEnd=$preYearStart&start=$yearStart&end=$ymd");
- $membershipSummary[$typeID][$key]['total']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&start=$yearStart&end=$ymd");
- break;
-
- case 'current':
- $membershipSummary[$typeID][$key]['total']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID");
- break;
-
- case 'total':
- if (!$isCurrentMonth) {
- $membershipSummary[$typeID][$key]['total']['url'] = CRM_Utils_System::url('civicrm/member/search',
- "reset=1&force=1&start=&end=$ymd&status=$status&type=$typeID"
- );
- }
- else {
- $membershipSummary[$typeID][$key]['total']['url'] = CRM_Utils_System::url('civicrm/member/search',
- "reset=1&force=1&status=$status"
- );
- }
- break;
-
- //LCD add owner urls
-
- case 'premonth_owner':
- $membershipSummary[$typeID][$key]['premonth_owner']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&start=$preMonth&end=$preMonthEnd&owner=1");
- break;
-
- case 'month_owner':
- $membershipSummary[$typeID][$key]['month_owner']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&start=$monthStart&end=$ymd&owner=1");
- break;
-
- case 'year_owner':
- $membershipSummary[$typeID][$key]['year_owner']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&start=$yearStart&end=$ymd&owner=1");
- break;
-
- case 'current_owner':
- $membershipSummary[$typeID][$key]['current_owner']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&owner=1");
- break;
-
- case 'total_owner':
- if (!$isCurrentMonth) {
- $membershipSummary[$typeID][$key]['total_owner']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&start=&end=$ymd&status=$status&type=$typeID&owner=1");
- }
- else {
- $membershipSummary[$typeID][$key]['total_owner']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&owner=1");
- }
- break;
- //LCD end
- }
- }
- }
- @codingStandardsIgnoreEnd */
-
- // Temporary replacement for current totals column
-
foreach ($membershipSummary as $typeID => $details) {
if (!$isCurrentMonth) {
$membershipSummary[$typeID]['total']['total']['url'] = CRM_Utils_System::url('civicrm/member/search',
$totalCount['premonth']['new'] = array(
'count' => $newCountPreMonth,
- //'url' => CRM_Utils_System::url('civicrm/activity/search',
- // "reset=1&force=1&signupType=1&dateLow=$preMonth&dateHigh=$preMonthEnd"
- //),
);
$totalCount['premonth']['renew'] = array(
'count' => $renewCountPreMonth,
- //'url' => CRM_Utils_System::url('civicrm/activity/search',
- // "reset=1&force=1&signupType=2&dateLow=$preMonth&dateHigh=$preMonthEnd"
- //),
);
$totalCount['premonth']['total'] = array(
'count' => $totalCountPreMonth,
- //'url' => CRM_Utils_System::url('civicrm/activity/search',
- // "reset=1&force=1&signupType=3&dateLow=$preMonth&dateHigh=$preMonthEnd"
- //),
);
$totalCount['month']['new'] = array(
'count' => $newCountMonth,
- //'url' => CRM_Utils_System::url('civicrm/activity/search',
- // "reset=1&force=1&signupType=1&dateLow=$monthStart&dateHigh=$ymd"
- //),
);
$totalCount['month']['renew'] = array(
'count' => $renewCountMonth,
- //'url' => CRM_Utils_System::url('civicrm/activity/search',
- // "reset=1&force=1&signupType=2&dateLow=$monthStart&dateHigh=$ymd"
- //),
);
$totalCount['month']['total'] = array(
'count' => $totalCountMonth,
- //'url' => CRM_Utils_System::url('civicrm/activity/search',
- // "reset=1&force=1&signupType=3&dateLow=$monthStart&dateHigh=$ymd"
- //),
);
$totalCount['year']['new'] = array(
'count' => $newCountYear,
- //'url' => CRM_Utils_System::url('civicrm/activity/search',
- // "reset=1&force=1&signupType=1&dateLow=$yearStart&dateHigh=$ymd"
- //),
);
$totalCount['year']['renew'] = array(
'count' => $renewCountYear,
- //'url' => CRM_Utils_System::url('civicrm/activity/search',
- // "reset=1&force=1&signupType=2&dateLow=$yearStart&dateHigh=$ymd"
- //),
);
$totalCount['year']['total'] = array(
'count' => $totalCountYear,
- //'url' => CRM_Utils_System::url('civicrm/activity/search',
- // "reset=1&force=1&signupType=3&dateLow=$yearStart&dateHigh=$ymd"
- //),
);
$totalCount['current']['total'] = array(
return $defaults;
}
+ /**
+ * Explicitly declare the entity api name.
+ */
+ public function getDefaultEntity() {
+ return 'Note';
+ }
+
+ /**
+ * Explicitly declare the form context.
+ */
+ public function getDefaultContext() {
+ return 'create';
+ }
+
/**
* Build the form object.
*
return;
}
- $this->add('text', 'subject', ts('Subject:'), array('size' => 20));
- $this->add('textarea', 'note', ts('Note:'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Note', 'note'), TRUE);
- $this->add('select', 'privacy', ts('Privacy:'), CRM_Core_OptionGroup::values('note_privacy'));
-
+ $this->addField('subject');
+ $this->addField('note', [], TRUE);
+ $this->addField('privacy');
$this->add('hidden', 'parent_id');
// add attachments part
$form->addElement('checkbox', 'is_tellfriend_enabled', ts("Allow 'Tell a friend' functionality"), NULL, array('onclick' => "return showHideByValue('is_tellfriend_enabled',true,'tflimit','table-row','radio',false);"));
- $form->add('text',
+ $form->add('number',
'tellfriend_limit',
ts("'Tell a friend' maximum recipients limit"),
CRM_Core_DAO::getAttribute('CRM_PCP_DAO_PCPBlock', 'tellfriend_limit')
if (!empty($entityFile)) {
$fileInfo = reset($entityFile);
$fileId = $fileInfo['fileID'];
+ $fileHash = CRM_Core_BAO_File::generateFileHash($this->_id, $fileId);
$image = '<img src="' . CRM_Utils_System::url('civicrm/file',
- "reset=1&id=$fileId&eid={$this->_id}"
+ "reset=1&id=$fileId&eid={$this->_id}&fcs={$fileHash}"
) . '" />';
$this->assign('image', $image);
}
);
$this->addRule('installments', ts('Please enter a valid number of installments.'), 'positiveInteger');
- $frequencyInterval = $this->add('text', 'frequency_interval', ts('every'),
+ $frequencyInterval = $this->add('number', 'frequency_interval', ts('every'),
$attributes['pledge_frequency_interval'], TRUE
);
$this->addRule('frequency_interval', ts('Please enter a number for frequency (e.g. every "3" months).'), 'positiveInteger');
TRUE
);
- $frequencyDay = $this->add('text', 'frequency_day', ts('Payments are due on the'), $attributes['frequency_day'], TRUE);
+ $frequencyDay = $this->add('number', 'frequency_day', ts('Payments are due on the'), $attributes['frequency_day'], TRUE);
$this->addRule('frequency_day', ts('Please enter a valid payment due day.'), 'positiveInteger');
$this->add('text', 'eachPaymentAmount', ts('each'), array(
$this->_actionButtonName = $this->getButtonName('next', 'action');
$this->_done = FALSE;
- $this->defaults = array();
$this->loadStandardSearchOptionsFromUrl();
*
* Generated from xml/schema/CRM/Price/PriceFieldValue.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:fab6fa9814f0f984add020b2f1c58b18)
+ * (GenCodeChecksum:a3de204f039daa85984316fae2c60975)
*/
/**
public $label;
/**
- * >Price field option description.
+ * Price field option description.
*
* @var text
*/
'name' => 'description',
'type' => CRM_Utils_Type::T_TEXT,
'title' => ts('Description'),
- 'description' => ts('>Price field option description.'),
+ 'description' => ts('Price field option description.'),
'rows' => 2,
'cols' => 60,
'default' => 'NULL',
}
// weight
- $this->add('text', 'option_weight[' . $i . ']', ts('Order'), $attributes['weight']);
+ $this->add('number', 'option_weight[' . $i . ']', ts('Order'), $attributes['weight']);
// is active ?
$this->add('checkbox', 'option_status[' . $i . ']', ts('Active?'));
$this->add('checkbox', 'is_display_amounts', ts('Display Amount?'));
// weight
- $this->add('text', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Price_DAO_PriceField', 'weight'), TRUE);
+ $this->add('number', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Price_DAO_PriceField', 'weight'), TRUE);
$this->addRule('weight', ts('is a numeric field'), 'numeric');
// checkbox / radio options per line
'' => ' ',
) + $membershipTypes, FALSE,
array('onClick' => "calculateRowValues( );"));
- $this->add('text', 'membership_num_terms', ts('Number of Terms'), $attributes['membership_num_terms']);
+ $this->add('number', 'membership_num_terms', ts('Number of Terms'), $attributes['membership_num_terms']);
}
else {
$allComponents = explode(CRM_Core_DAO::VALUE_SEPARATOR, $extendComponentId);
if (in_array($eventComponentId, $allComponents)) {
$this->isEvent = TRUE;
// count
- $this->add('text', 'count', ts('Participant Count'));
+ $this->add('number', 'count', ts('Participant Count'));
$this->addRule('count', ts('Please enter a valid Max Participants.'), 'positiveInteger');
- $this->add('text', 'max_value', ts('Max Participants'));
+ $this->add('number', 'max_value', ts('Max Participants'));
$this->addRule('max_value', ts('Please enter a valid Max Participants.'), 'positiveInteger');
}
$this->add('textarea', 'help_post', ts('Post Option Help'));
// weight
- $this->add('text', 'weight', ts('Order'), NULL, TRUE);
+ $this->add('number', 'weight', ts('Order'), NULL, TRUE);
$this->addRule('weight', ts('is a numeric field'), 'numeric');
// is active ?
protected $_currentUserID = NULL;
protected $_session = NULL;
+ /**
+ * Check for any duplicates.
+ *
+ * Depending on form settings & usage scenario we potentially use the found id,
+ * create links to found ids or add an error.
+ *
+ * @param array $errors
+ * @param array $fields
+ * @param CRM_Profile_Form $form
+ *
+ * @return array
+ */
+ protected static function handleDuplicateChecking(&$errors, $fields, $form) {
+ if ($form->_mode == CRM_Profile_Form::MODE_CREATE) {
+ // fix for CRM-2888
+ $exceptions = [];
+ }
+ else {
+ // for edit mode we need to allow our own record to be a dupe match!
+ $exceptions = [$form->_session->get('userID')];
+ }
+ $contactType = CRM_Core_BAO_UFGroup::getContactType($form->_gid);
+ // If all profile fields is of Contact Type then consider
+ // profile is of Individual type(default).
+ if (!$contactType) {
+ $contactType = 'Individual';
+ }
+
+ $ids = CRM_Contact_BAO_Contact::getDuplicateContacts(
+ $fields, $contactType,
+ ($form->_context === 'dialog' ? 'Supervised' : 'Unsupervised'),
+ $exceptions,
+ FALSE,
+ $form->_ruleGroupID
+ );
+ if ($ids) {
+ if ($form->_isUpdateDupe == 2) {
+ CRM_Core_Session::setStatus(ts('Note: this contact may be a duplicate of an existing record.'), ts('Possible Duplicate Detected'), 'alert');
+ }
+ elseif ($form->_isUpdateDupe == 1) {
+ $form->_id = $ids[0];
+ }
+ else {
+ if ($form->_context == 'dialog') {
+ $contactLinks = CRM_Contact_BAO_Contact_Utils::formatContactIDSToLinks($ids, TRUE, TRUE);
+
+ $duplicateContactsLinks = '<div class="matching-contacts-found">';
+ $duplicateContactsLinks .= ts('One matching contact was found. ', [
+ 'count' => count($contactLinks['rows']),
+ 'plural' => '%count matching contacts were found.<br />',
+ ]);
+ if ($contactLinks['msg'] == 'view') {
+ $duplicateContactsLinks .= ts('You can View the existing contact.', [
+ 'count' => count($contactLinks['rows']),
+ 'plural' => 'You can View the existing contacts.',
+ ]);
+ }
+ else {
+ $duplicateContactsLinks .= ts('You can View or Edit the existing contact.', [
+ 'count' => count($contactLinks['rows']),
+ 'plural' => 'You can View or Edit the existing contacts.',
+ ]);
+ }
+ $duplicateContactsLinks .= '</div>';
+ $duplicateContactsLinks .= '<table class="matching-contacts-actions">';
+ $row = '';
+ for ($i = 0; $i < count($contactLinks['rows']); $i++) {
+ $row .= ' <tr> ';
+ $row .= ' <td class="matching-contacts-name"> ';
+ $row .= $contactLinks['rows'][$i]['display_name'];
+ $row .= ' </td>';
+ $row .= ' <td class="matching-contacts-email"> ';
+ $row .= $contactLinks['rows'][$i]['primary_email'];
+ $row .= ' </td>';
+ $row .= ' <td class="action-items"> ';
+ $row .= $contactLinks['rows'][$i]['view'] . ' ';
+ $row .= $contactLinks['rows'][$i]['edit'];
+ $row .= ' </td>';
+ $row .= ' </tr> ';
+ }
+
+ $duplicateContactsLinks .= $row . '</table>';
+ $duplicateContactsLinks .= "If you're sure this record is not a duplicate, click the 'Save Matching Contact' button below.";
+
+ $errors['_qf_default'] = $duplicateContactsLinks;
+
+ // let smarty know that there are duplicates
+ $template = CRM_Core_Smarty::singleton();
+ $template->assign('isDuplicate', 1);
+ }
+ else {
+ $errors['_qf_default'] = ts('A record already exists with the same information.');
+ }
+ }
+ }
+ return $errors;
+ }
+
/**
* Explicitly declare the entity api name.
*/
$deleteExtra = ts("Are you sure you want to delete attached file?");
$fileId = $url['file_id'];
+ $fileHash = CRM_Core_BAO_File::generateFileHash($entityId, $fileId);
$deleteURL = CRM_Utils_System::url('civicrm/file',
- "reset=1&id={$fileId}&eid=$entityId&fid={$key}&action=delete"
+ "reset=1&id={$fileId}&eid=$entityId&fid={$key}&action=delete&fcs={$fileHash}"
);
$text = ts("Delete Attached File");
$customFiles[$field['name']]['deleteURL'] = "<a href=\"{$deleteURL}\" onclick = \"if (confirm( ' $deleteExtra ' )) this.href+='&confirmed=1'; else return false;\">$text</a>";
$deleteExtra = ts("Are you sure you want to delete attached file?");
$fileId = $url['file_id'];
+ $fileHash = CRM_Core_BAO_File::generateFileHash($entityId, $fileId); /* fieldId=$customFieldID */
$deleteURL = CRM_Utils_System::url('civicrm/file',
- "reset=1&id={$fileId}&eid=$entityId&fid={$customFieldID}&action=delete"
+ "reset=1&id={$fileId}&eid=$entityId&fid={$customFieldID}&action=delete&fcs={$fileHash}"
);
$text = ts("Delete Attached File");
$customFiles[$field['name']]['deleteURL'] = "<a href=\"{$deleteURL}\" onclick = \"if (confirm( ' $deleteExtra ' )) this.href+='&confirmed=1'; else return false;\">$text</a>";
public static function formRule($fields, $files, $form) {
CRM_Utils_Hook::validateProfile($form->_ufGroup['name']);
- $errors = array();
// if no values, return
if (empty($fields)) {
return TRUE;
}
+ $errors = [];
$register = NULL;
// hack we use a -1 in options to indicate that its registration
+ // ... and I can't remove that comment because even though it's clear as mud
+ // perhaps someone will find it helpful in the absence of ANY OTHER EXPLANATION
+ // as to what it means....
if ($form->_id) {
+ // @todo - wonder if it ever occurred to someone that if they didn't document this param
+ // it might not be crystal clear why we have it....
$form->_isUpdateDupe = 1;
}
$fields['phone-Primary'] = $fields['phone-Primary-1'];
}
- $ctype = CRM_Core_BAO_UFGroup::getContactType($form->_gid);
- // If all profile fields is of Contact Type then consider
- // profile is of Individual type(default).
- if (!$ctype) {
- $ctype = 'Individual';
- }
-
- if ($form->_mode == CRM_Profile_Form::MODE_CREATE) {
- // fix for CRM-2888
- $exceptions = array();
- }
- else {
- // for edit mode we need to allow our own record to be a dupe match!
- $exceptions = array($form->_session->get('userID'));
- }
-
- $ids = CRM_Contact_BAO_Contact::getDuplicateContacts(
- $fields, $ctype,
- ($form->_context === 'dialog' ? 'Supervised' : 'Unsupervised'),
- $exceptions,
- FALSE,
- $form->_ruleGroupID
- );
- if ($ids) {
- if ($form->_isUpdateDupe == 2) {
- CRM_Core_Session::setStatus(ts('Note: this contact may be a duplicate of an existing record.'), ts('Possible Duplicate Detected'), 'alert');
- }
- elseif ($form->_isUpdateDupe == 1) {
- if (!$form->_id) {
- $form->_id = $ids[0];
- }
- }
- else {
- if ($form->_context == 'dialog') {
- $contactLinks = CRM_Contact_BAO_Contact_Utils::formatContactIDSToLinks($ids, TRUE, TRUE);
-
- $duplicateContactsLinks = '<div class="matching-contacts-found">';
- $duplicateContactsLinks .= ts('One matching contact was found. ', array(
- 'count' => count($contactLinks['rows']),
- 'plural' => '%count matching contacts were found.<br />',
- ));
- if ($contactLinks['msg'] == 'view') {
- $duplicateContactsLinks .= ts('You can View the existing contact.', array(
- 'count' => count($contactLinks['rows']),
- 'plural' => 'You can View the existing contacts.',
- ));
- }
- else {
- $duplicateContactsLinks .= ts('You can View or Edit the existing contact.', array(
- 'count' => count($contactLinks['rows']),
- 'plural' => 'You can View or Edit the existing contacts.',
- ));
- }
- $duplicateContactsLinks .= '</div>';
- $duplicateContactsLinks .= '<table class="matching-contacts-actions">';
- $row = '';
- for ($i = 0; $i < count($contactLinks['rows']); $i++) {
- $row .= ' <tr> ';
- $row .= ' <td class="matching-contacts-name"> ';
- $row .= $contactLinks['rows'][$i]['display_name'];
- $row .= ' </td>';
- $row .= ' <td class="matching-contacts-email"> ';
- $row .= $contactLinks['rows'][$i]['primary_email'];
- $row .= ' </td>';
- $row .= ' <td class="action-items"> ';
- $row .= $contactLinks['rows'][$i]['view'] . ' ';
- $row .= $contactLinks['rows'][$i]['edit'];
- $row .= ' </td>';
- $row .= ' </tr> ';
- }
-
- $duplicateContactsLinks .= $row . '</table>';
- $duplicateContactsLinks .= "If you're sure this record is not a duplicate, click the 'Save Matching Contact' button below.";
-
- $errors['_qf_default'] = $duplicateContactsLinks;
-
- // let smarty know that there are duplicates
- $template = CRM_Core_Smarty::singleton();
- $template->assign('isDuplicate', 1);
- }
- else {
- $errors['_qf_default'] = ts('A record already exists with the same information.');
- }
- }
+ if (!$form->_id) {
+ self::handleDuplicateChecking($errors, $fields, $form);
}
}
// CRM-16274 Determine if user has 'edit all contacts' or equivalent
$permission = CRM_Core_Permission::getPermission();
- if ($permission == CRM_Core_Permission::EDIT &&
+ if ($this->_instanceForm && $permission == CRM_Core_Permission::EDIT &&
$this->_add2groupSupported
) {
$this->addElement('select', 'groups', ts('Group'),
/**
* Get a standard set of contact fields.
- *
+ * @deprecated - use getColumns('Contact') instead
* @return array
*/
public function getBasicContactFields() {
/**
* Get a standard set of contact filters.
*
+ * @param array $defaults
+ *
* @return array
*/
- public function getBasicContactFilters() {
+ public function getBasicContactFilters($defaults = array()) {
return array(
'sort_name' => array(
'title' => ts('Contact Name'),
'is_deceased' => array(
'title' => ts('Deceased'),
'type' => CRM_Utils_Type::T_BOOLEAN,
- 'default' => 0,
+ 'default' => CRM_Utils_Array::value('deceased', $defaults, 0),
),
'do_not_email' => array(
'title' => ts('Do not email'),
'is_filters' => TRUE,
'is_group_bys' => FALSE,
),
+ $options['prefix'] . 'external_identifier' => array(
+ 'title' => $options['prefix_label'] . ts('Contact identifier from external system'),
+ 'name' => 'external_identifier',
+ 'is_fields' => TRUE,
+ 'is_filters' => FALSE,
+ 'is_group_bys' => FALSE,
+ 'is_order_bys' => TRUE,
+ ),
+ $options['prefix'] . 'preferred_language' => array(
+ 'title' => $options['prefix_label'] . ts('Preferred Language'),
+ 'name' => 'preferred_language',
+ 'is_fields' => TRUE,
+ 'is_filters' => TRUE,
+ 'is_group_bys' => TRUE,
+ 'is_order_bys' => TRUE,
+ ),
);
+ foreach ([
+ 'postal_greeting_display' => 'Postal Greeting',
+ 'email_greeting_display' => 'Email Greeting',
+ 'addressee_display' => 'Addressee',
+ ] as $field => $title) {
+ $spec[$options['prefix'] . $field] = array(
+ 'title' => $options['prefix_label'] . ts($title),
+ 'name' => $field,
+ 'is_fields' => TRUE,
+ 'is_filters' => FALSE,
+ 'is_group_bys' => FALSE,
+ );
+ }
+ foreach (['do_not_email', 'do_not_phone', 'do_not_mail', 'do_not_sms', 'is_opt_out'] as $field) {
+ $spec[$options['prefix'] . $field] = [
+ 'name' => $field,
+ 'type' => CRM_Utils_Type::T_BOOLEAN,
+ 'is_fields' => TRUE,
+ 'is_filters' => TRUE,
+ 'is_group_bys' => FALSE,
+ ];
+ }
$individualFields = array(
$options['prefix'] . 'first_name' => array(
'name' => 'first_name',
'is_filters' => TRUE,
'is_group_bys' => FALSE,
),
+ $options['prefix'] . 'job_title' => array(
+ 'name' => 'job_title',
+ 'is_fields' => TRUE,
+ 'is_filters' => FALSE,
+ 'is_group_bys' => FALSE,
+ ),
+ $options['prefix'] . 'employer_id' => array(
+ 'title' => $options['prefix_label'] . ts('Current Employer'),
+ 'type' => CRM_Utils_Type::T_INT,
+ 'name' => 'employer_id',
+ 'is_fields' => TRUE,
+ 'is_filters' => FALSE,
+ 'is_group_bys' => TRUE,
+ ),
);
if (!$options['contact_type'] || $options['contact_type'] === 'Individual') {
$spec = array_merge($spec, $individualFields);
'trxn_date' => array(
'title' => ts('Transaction Date'),
'default' => TRUE,
- 'type' => CRM_Utils_Type::T_DATE,
+ 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
),
'trxn_id' => array(
'title' => ts('Trans #'),
'trxn_date' => array(
'title' => ts('Transaction Date'),
'operatorType' => CRM_Report_Form::OP_DATE,
- 'type' => CRM_Utils_Type::T_DATE,
+ 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
),
'status_id' => array(
'title' => ts('Financial Transaction Status'),
*
* @return string
*/
- public function buildQuery($applyLimit = TRUE) {
+ public function buildQuery($applyLimit = FALSE) {
if ($this->isTempTableBuilt) {
- return "SELECT * FROM civireport_contribution_detail_temp3 $this->_orderBy";
+ $this->limit();
+ return "SELECT SQL_CALC_FOUND_ROWS * FROM civireport_contribution_detail_temp3 $this->_orderBy $this->_limit";
}
return parent::buildQuery($applyLimit);
}
// 1. use main contribution query to build temp table 1
$sql = $this->buildQuery();
$this->createTemporaryTable('civireport_contribution_detail_temp1', $sql);
- $this->setPager();
// 2. customize main contribution query for soft credit, and build temp table 2 with soft credit contributions only
$this->queryMode = 'SoftCredit';
'civicrm_contact' => array(
'dao' => 'CRM_Contact_DAO_Contact',
'grouping' => 'contact-fields',
- 'fields' => array(
- 'sort_name' => array(
- 'title' => ts('Contact Name'),
- 'no_repeat' => TRUE,
- 'default' => TRUE,
- ),
- 'display_name' => array(
- 'title' => ts('Display Name'),
- 'no_repeat' => TRUE,
- ),
- 'addressee_display' => array(
- 'title' => ts('Addressee Name'),
- 'no_repeat' => TRUE,
- ),
- 'id' => array(
- 'no_display' => TRUE,
- 'required' => TRUE,
- ),
- 'contact_type' => array(
- 'title' => ts('Contact Type'),
- 'no_repeat' => TRUE,
- ),
- 'contact_sub_type' => array(
- 'title' => ts('Contact Subtype'),
- 'no_repeat' => TRUE,
- ),
+ 'fields' => array_merge(
+ $this->getBasicContactFields(),
+ array(
+ 'sort_name' => array(
+ 'title' => ts('Contact Name'),
+ 'no_repeat' => TRUE,
+ 'default' => TRUE,
+ ),
+ )
),
- 'filters' => array(
- 'percentage_change' => array(
- 'title' => ts('Percentage Change'),
- 'type' => CRM_Utils_Type::T_INT,
- 'operatorType' => CRM_Report_Form::OP_INT,
- 'name' => 'percentage_change',
- 'dbAlias' => '( ( contribution_civireport2.total_amount_sum - contribution_civireport1.total_amount_sum ) * 100 / contribution_civireport1.total_amount_sum )',
- ),
+ 'filters' => array_merge(
+ $this->getBasicContactFilters(array('deceased' => NULL)),
+ array(
+ 'percentage_change' => array(
+ 'title' => ts('Percentage Change'),
+ 'type' => CRM_Utils_Type::T_INT,
+ 'operatorType' => CRM_Report_Form::OP_INT,
+ 'name' => 'percentage_change',
+ 'dbAlias' => '( ( contribution_civireport2.total_amount_sum - contribution_civireport1.total_amount_sum ) * 100 / contribution_civireport1.total_amount_sum )',
+ ),
+ )
),
'group_bys' => array(
'id' => array(
),
'grouping' => 'contact-fields',
),
- 'civicrm_address' => array(
- 'dao' => 'CRM_Core_DAO_Address',
- 'grouping' => 'contact-fields',
- 'fields' => array(
- 'street_address' => array('title' => ts('Street Address')),
- 'supplemental_address_1' => array('title' => ts('Supplemental Address 1')),
- 'city' => array('title' => ts('City')),
- 'country_id' => array('title' => ts('Country')),
- 'state_province_id' => array('title' => ts('State/Province')),
- 'postal_code' => array('title' => ts('Postal Code')),
- ),
- 'group_bys' => array(
- 'country_id' => array('title' => ts('Country')),
- 'state_province_id' => array(
- 'title' => ts('State/Province'),
- ),
- ),
- ),
'civicrm_financial_type' => array(
'dao' => 'CRM_Financial_DAO_FinancialType',
'fields' => array('financial_type' => array('title' => ts('Financial Type'))),
),
'group_bys' => array('contribution_source' => NULL),
),
- );
+ ) + $this->addAddressFields(TRUE, FALSE, TRUE, array('country_id' => FALSE));
$this->_groupFilter = TRUE;
$this->_tagFilter = TRUE;
$rules = array(
'id' => array(
'sort_name',
+ 'exposed_id',
'display_name',
'addressee_display',
'contact_type',
'state_province_id',
'country_id',
'city',
+ 'county_id',
'street_address',
'supplemental_address_1',
+ 'supplemental_address_2',
+ 'supplemental_address_3',
+ 'street_number',
+ 'street_name',
+ 'street_unit',
'postal_code',
+ 'postal_code_suffix',
+ 'prefix_id',
+ 'first_name',
+ 'nick_name',
+ 'middle_name',
+ 'last_name',
+ 'suffix_id',
+ 'postal_greeting_display',
+ 'email_greeting_display',
+ 'addressee_display',
+ 'gender_id',
+ 'birth_date',
+ 'age',
+ 'job_title',
+ 'organization_name',
+ 'external_identifier',
+ 'do_not_email',
+ 'do_not_phone',
+ 'do_not_mail',
+ 'do_not_sms',
+ 'is_opt_out',
+ 'is_deceased',
+ 'preferred_language',
),
'country_id' => array('country_id'),
'state_province_id' => array('country_id', 'state_province_id'),
CREATE TEMPORARY TABLE $this->tempTableRepeat1 (
{$create}
{$this->contributionJoinTableColumn} int unsigned,
-total_amount_sum int,
+total_amount_sum decimal(20,2),
total_amount_count int
) ENGINE=HEAP {$this->_databaseAttributes}";
$this->executeReportQuery($sql);
CREATE TEMPORARY TABLE $this->tempTableRepeat2 (
{$create}
{$this->contributionJoinTableColumn} int unsigned,
-total_amount_sum int,
+total_amount_sum decimal(20,2),
total_amount_count int,
currency varchar(3)
) ENGINE=HEAP {$this->_databaseAttributes}";
$this->buildACLClause(array('constituentname', 'contact_civireport'));
$sql = $this->buildQuery();
- $dao = CRM_Core_DAO::executeQuery($sql);
$rows = $graphRows = array();
- $count = 0;
- while ($dao->fetch()) {
- $row = array();
- foreach ($this->_columnHeaders as $key => $value) {
- $row[$key] = $dao->$key;
- }
- $rows[] = $row;
- }
- $this->formatDisplay($rows);
+ $this->buildRows($sql, $rows);
- // to hide the contact ID field from getting displayed
- unset($this->_columnHeaders['civicrm_contact_id_constituent']);
- unset($this->_columnHeaders['civicrm_contact_id_creditor']);
+ $this->formatDisplay($rows);
// assign variables to templates
$this->doTemplateAssignment($rows);
),
)
),
+ 'filters' => $this->getBasicContactFilters(array('deceased' => NULL)),
'grouping' => 'contact-fields',
'group_bys' => array(
'id' => array('title' => ts('Contact ID')),
FROM (SELECT {$this->_aliases['civicrm_contribution']}.total_amount as amount,
{$contriQuery} {$groupBy} {$orderBy}) as mode GROUP BY currency";
- $mode = CRM_Contribute_BAO_Contribution::computeStats('mode', $modeSQL);
-
- $medianSQL = "{$this->_from} {$this->_where}";
- $median = CRM_Contribute_BAO_Contribution::computeStats('median', $medianSQL, $this->_aliases['civicrm_contribution']);
+ $mode = $this->calculateMode($modeSQL);
+ $median = $this->calculateMedian();
if ($softCredit) {
$softDAO = CRM_Core_DAO::executeQuery($softSQL);
}
}
+ /**
+ * Calculate mode.
+ *
+ * Note this is a slow query. Alternative is extended reports.
+ *
+ * @param string $sql
+ * @return array|null
+ */
+ protected function calculateMode($sql) {
+ $mode = [];
+ $modeDAO = CRM_Core_DAO::executeQuery($sql);
+ while ($modeDAO->fetch()) {
+ if ($modeDAO->civicrm_contribution_total_amount_count > 1) {
+ $mode[] = CRM_Utils_Money::format($modeDAO->amount, $modeDAO->currency);
+ }
+ else {
+ $mode[] = 'N/A';
+ }
+ }
+ return $mode;
+ }
+
+ /**
+ * Calculate mode.
+ *
+ * Note this is a slow query. Alternative is extended reports.
+ *
+ * @return array|null
+ */
+ protected function calculateMedian() {
+ $sql = "{$this->_from} {$this->_where}";
+ $currencies = CRM_Core_OptionGroup::values('currencies_enabled');
+ $median = [];
+ foreach ($currencies as $currency => $val) {
+ $midValue = 0;
+ $where = "AND {$this->_aliases['civicrm_contribution']}.currency = '{$currency}'";
+ $rowCount = CRM_Core_DAO::singleValueQuery("SELECT count(*) as count {$sql} {$where}");
+
+ $even = FALSE;
+ $offset = 1;
+ $medianRow = floor($rowCount / 2);
+ if ($rowCount % 2 == 0 && !empty($medianRow)) {
+ $even = TRUE;
+ $offset++;
+ $medianRow--;
+ }
+
+ $medianValue = "SELECT {$this->_aliases['civicrm_contribution']}.total_amount as median
+ {$sql} {$where}
+ ORDER BY median LIMIT {$medianRow},{$offset}";
+ $medianValDAO = CRM_Core_DAO::executeQuery($medianValue);
+ while ($medianValDAO->fetch()) {
+ if ($even) {
+ $midValue = $midValue + $medianValDAO->median;
+ }
+ else {
+ $median[] = CRM_Utils_Money::format($medianValDAO->median, $currency);
+ }
+ }
+ if ($even) {
+ $midValue = $midValue / 2;
+ $median[] = CRM_Utils_Money::format($midValue, $currency);
+ }
+ }
+ return $median;
+ }
+
}
* $Id$
*
*/
-class CRM_Report_Form_Event_Income extends CRM_Report_Form_Event {
+class CRM_Report_Form_Event_Income extends CRM_Report_Form {
const ROW_COUNT_LIMIT = 2;
protected $_summary = NULL;
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2019
*/
-class CRM_Report_Form_Event_IncomeCountSummary extends CRM_Report_Form_Event {
+class CRM_Report_Form_Event_IncomeCountSummary extends CRM_Report_Form {
protected $_summary = NULL;
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2019
*/
-class CRM_Report_Form_Event_ParticipantListCount extends CRM_Report_Form_Event {
+class CRM_Report_Form_Event_ParticipantListCount extends CRM_Report_Form {
protected $_summary = NULL;
protected $_groupFilter = TRUE;
'operatorType' => CRM_Report_Form::OP_ENTITYREF,
'type' => CRM_Utils_Type::T_INT,
'attributes' => array(
- 'entity' => 'event',
+ 'entity' => 'Event',
'select' => array('minimumInputLength' => 0),
),
),
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2019
*/
-class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event {
+class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form {
protected $_summary = NULL;
'operatorType' => CRM_Report_Form::OP_ENTITYREF,
'type' => CRM_Utils_Type::T_INT,
'attributes' => array(
- 'entity' => 'event',
+ 'entity' => 'Event',
'select' => array('minimumInputLength' => 0),
),
),
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2019
*/
-class CRM_Report_Form_Event_Summary extends CRM_Report_Form_Event {
+class CRM_Report_Form_Event_Summary extends CRM_Report_Form {
protected $_summary = NULL;
),
'total_amount' => array(
'title' => ts('Amount Statistics'),
- 'required' => TRUE,
+ 'default' => TRUE,
'statistics' => array(
'sum' => ts('Total Payments Made'),
'count' => ts('Contribution Count'),
$this->add('text', 'label', ts('Title'), array('size' => 40), TRUE);
$this->add('text', 'value', ts('URL'), array('size' => 40), TRUE);
$this->add('text', 'name', ts('Class'), array('size' => 40), TRUE);
- $element = $this->add('text', 'weight', ts('Order'), array('size' => 4), TRUE);
+ $element = $this->add('number', 'weight', ts('Order'), array('size' => 4), TRUE);
// $element->freeze( );
$this->add('text', 'description', ts('Description'), array('size' => 40), TRUE);
CRM_Core_Error::fatal(ts('Could not find a mailing id'));
}
- $send_option = $this->controller->exportValue($this->_name, 'send_option');
+ $params['send_option'] = $this->controller->exportValue($this->_name, 'send_option');
if (isset($params['send_option']) && $params['send_option'] == 'send_immediate') {
$params['scheduled_date'] = date('YmdHis');
}
$attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFField');
// weight
- $this->add('text', 'weight', ts('Order'), $attributes['weight'], TRUE);
+ $this->add('number', 'weight', ts('Order'), $attributes['weight'], TRUE);
$this->addRule('weight', ts('is a numeric field'), 'numeric');
$this->add('textarea', 'help_pre', ts('Field Pre Help'), $attributes['help_pre']);
$this->add('wysiwyg', 'help_post', ts('Post-form Help'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFGroup', 'help_post'));
// weight
- $this->add('text', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFJoin', 'weight'), TRUE);
+ $this->add('number', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFJoin', 'weight'), TRUE);
$this->addRule('weight', ts('is a numeric field'), 'numeric');
// is this group active ?
+++ /dev/null
-{php}
- $dir = SMARTY_DIR . '/../../CRM/Upgrade/4.2.alpha1.msg_template/message_templates';
-
- $ovNames = array(
- 'contribution' => array(
- 'contribution_recurring_cancelled' => ts('Contributions - Recurring Cancellation Notification', array('escape' => 'sql')),
- 'contribution_recurring_billing' => ts('Contributions - Recurring Billing Updates', array('escape' => 'sql')),
- 'contribution_recurring_edit' => ts('Contributions - Recurring Updates', array('escape' => 'sql')),
- ),
- 'membership' => array(
- 'membership_autorenew_cancelled' => ts('Memberships - Auto-renew Cancellation Notification', array('escape' => 'sql')),
- 'membership_autorenew_billing' => ts('Memberships - Auto-renew Billing Updates', array('escape' => 'sql')),
- ),
- );
-
- $ignoreTemplate = array_merge(array_keys($ovNames['contribution']), array_keys($ovNames['membership']));
-
- $this->assign('ovNames', $ovNames);
- $this->assign('dir', $dir);
- $templates = array();
- foreach (preg_grep('/\.tpl$/', scandir($dir)) as $filename) {
- $parts = explode('_', basename($filename, '.tpl'));
- $type = array_pop($parts);
- $name = implode('_', $parts);
- if (!in_array($name,$ignoreTemplate)) {
- $templates[] = array('type' => $type, 'name' => $name, 'filename' => "$dir/$filename");
- }
- }
- $this->assign('templates', $templates);
-{/php}
-
-{foreach from=$templates item=tpl}
- {fetch assign=content file=$tpl.filename}
- SELECT @workflow_id := MAX(id) FROM civicrm_option_value WHERE name = '{$tpl.name}';
- SELECT @content := msg_{$tpl.type} FROM civicrm_msg_template WHERE workflow_id = @workflow_id AND is_reserved = 1 LIMIT 1;
- UPDATE civicrm_msg_template SET msg_{$tpl.type} = '{$content|escape:"quotes"}' WHERE workflow_id = @workflow_id AND (is_reserved = 1 OR (is_default = 1 AND msg_{$tpl.type} = @content));
-{/foreach}
-
-{foreach from=$ovNames key=name item=ignore}
- SELECT @tpl_ogid_{$name} := MAX(id) FROM civicrm_option_group WHERE name = 'msg_tpl_workflow_{$name}';
-{/foreach}
-
-INSERT INTO civicrm_option_value
- (option_group_id, name, {localize field='label'}label{/localize}, value, weight) VALUES
-{foreach from=$ovNames key=gName item=ovs name=for_groups}
-{foreach from=$ovs key=vName item=label name=for_values}
- (@tpl_ogid_{$gName}, '{$vName}', {localize}'{$label}'{/localize}, {$smarty.foreach.for_values.iteration}, {$smarty.foreach.for_values.iteration}) {if $smarty.foreach.for_groups.last and $smarty.foreach.for_values.last};{else},{/if}
-{/foreach}
-{/foreach}
-
-{foreach from=$ovNames key=gName item=ovs}
-{foreach from=$ovs key=vName item=label}
- SELECT @tpl_ovid_{$vName} := MAX(id) FROM civicrm_option_value WHERE option_group_id = @tpl_ogid_{$gName} AND name = '{$vName}';
-{/foreach}
-{/foreach}
-
-INSERT INTO civicrm_msg_template
- (msg_title, msg_subject, msg_text, msg_html, workflow_id, is_default, is_reserved) VALUES
-{foreach from=$ovNames key=gName item=ovs name=for_groups}
-{foreach from=$ovs key=vName item=title name=for_values}
- {fetch assign=subject file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/4.2.alpha1.msg_template/message_templates/`$vName`_subject.tpl"}
- {fetch assign=text file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/4.2.alpha1.msg_template/message_templates/`$vName`_text.tpl"}
- {fetch assign=html file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/4.2.alpha1.msg_template/message_templates/`$vName`_html.tpl"}
- ('{$title}', '{$subject|escape:"quotes"}', '{$text|escape:"quotes"}', '{$html|escape:"quotes"}', @tpl_ovid_{$vName}, 1, 0),
- ('{$title}', '{$subject|escape:"quotes"}', '{$text|escape:"quotes"}', '{$html|escape:"quotes"}', @tpl_ovid_{$vName}, 0, 1) {if $smarty.foreach.for_groups.last and $smarty.foreach.for_values.last};{else},{/if}
-{/foreach}
-{/foreach}
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="500" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
- <!-- BEGIN HEADER -->
- <!-- You can add table row(s) here with logo or other header elements -->
- <!-- END HEADER -->
-
- <!-- BEGIN CONTENT -->
-
- <tr>
- <td>
-
- {if $receipt_text}
- <p>{$receipt_text|htmlize}</p>
- {/if}
-
- {if $is_pay_later}
- <p>{$pay_later_receipt}</p> {* FIXME: this might be text rather than HTML *}
- {else}
- <p>{ts}Please print this confirmation for your records.{/ts}</p>
- {/if}
-
- </td>
- </tr>
- </table>
- <table width="500" style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse;">
-
- {if $amount}
-
-
- <tr>
- <th {$headerStyle}>
- {ts}Contribution Information{/ts}
- </th>
- </tr>
-
- {if $lineItem and $priceSetID and !$is_quick_config}
-
- {foreach from=$lineItem item=value key=priceset}
- <tr>
- <td colspan="2" {$valueStyle}>
- <table> {* FIXME: style this table so that it looks like the text version (justification, etc.) *}
- <tr>
- <th>{ts}Item{/ts}</th>
- <th>{ts}Qty{/ts}</th>
- <th>{ts}Each{/ts}</th>
- <th>{ts}Total{/ts}</th>
- </tr>
- {foreach from=$value item=line}
- <tr>
- <td>
- {if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description}<div>{$line.description|truncate:30:"..."}</div>{/if}
- </td>
- <td>
- {$line.qty}
- </td>
- <td>
- {$line.unit_price|crmMoney:$currency}
- </td>
- <td>
- {$line.line_total|crmMoney:$currency}
- </td>
- </tr>
- {/foreach}
- </table>
- </td>
- </tr>
- {/foreach}
- <tr>
- <td {$labelStyle}>
- {ts}Total Amount{/ts}
- </td>
- <td {$valueStyle}>
- {$amount|crmMoney:$currency}
- </td>
- </tr>
-
- {else}
-
- <tr>
- <td {$labelStyle}>
- {ts}Amount{/ts}
- </td>
- <td {$valueStyle}>
- {$amount|crmMoney:$currency} {if $amount_level} - {$amount_level}{/if}
- </td>
- </tr>
-
- {/if}
-
-
- {/if}
-
-
- {if $receive_date}
- <tr>
- <td {$labelStyle}>
- {ts}Date{/ts}
- </td>
- <td {$valueStyle}>
- {$receive_date|crmDate}
- </td>
- </tr>
- {/if}
-
- {if $is_monetary and $trxn_id}
- <tr>
- <td {$labelStyle}>
- {ts}Transaction #{/ts}
- </td>
- <td {$valueStyle}>
- {$trxn_id}
- </td>
- </tr>
- {/if}
-
- {if $is_recur}
- {if $contributeMode eq 'notify' or $contributeMode eq 'directIPN'}
- <tr>
- <td colspan="2" {$labelStyle}>
- {ts 1=$cancelSubscriptionUrl}This is a recurring contribution. You can cancel future contributions by <a href="%1">visiting this web page</a>.{/ts}
- </td>
- <tr>
- </tr>
- <td colspan="2" {$labelStyle}>
- {ts 1=$updateSubscriptionBillingUrl}You can update billing details for this recurring contribution by <a href="%1">visiting this web page</a>.{/ts}
- </td>
- <tr>
- </tr>
- <td colspan="2" {$labelStyle}>
- {ts 1=$updateSubscriptionUrl}You can update recurring contribution amount or change the number of installments for this recurring contribution by <a href="%1">visiting this web page</a>.{/ts}
- </td>
- </tr>
- {/if}
- {/if}
-
- {if $honor_block_is_active}
- <tr>
- <th {$headerStyle}>
- {$honor_type}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$labelStyle}>
- {$honor_prefix} {$honor_first_name} {$honor_last_name}
- </td>
- </tr>
- {if $honor_email}
- <tr>
- <td {$labelStyle}>
- {ts}Honoree Email{/ts}
- </td>
- <td {$valueStyle}>
- {$honor_email}
- </td>
- </tr>
- {/if}
- {/if}
-
- {if $pcpBlock}
- <tr>
- <th {$headerStyle}>
- {ts}Personal Campaign Page{/ts}
- </th>
- </tr>
- <tr>
- <td {$labelStyle}>
- {ts}Display In Honor Roll{/ts}
- </td>
- <td {$valueStyle}>
- {if $pcp_display_in_roll}{ts}Yes{/ts}{else}{ts}No{/ts}{/if}
- </td>
- </tr>
- {if $pcp_roll_nickname}
- <tr>
- <td {$labelStyle}>
- {ts}Nickname{/ts}
- </td>
- <td {$valueStyle}>
- {$pcp_roll_nickname}
- </td>
- </tr>
- {/if}
- {if $pcp_personal_note}
- <tr>
- <td {$labelStyle}>
- {ts}Personal Note{/ts}
- </td>
- <td {$valueStyle}>
- {$pcp_personal_note}
- </td>
- </tr>
- {/if}
- {/if}
-
- {if $onBehalfProfile}
- <tr>
- <th {$headerStyle}>
- {$onBehalfProfile_grouptitle}
- </th>
- </tr>
- {foreach from=$onBehalfProfile item=onBehalfValue key=onBehalfName}
- <tr>
- <td {$labelStyle}>
- {$onBehalfName}
- </td>
- <td {$valueStyle}>
- {$onBehalfValue}
- </td>
- </tr>
- {/foreach}
- {/if}
-
- {if $isShare}
- <tr>
- <td colspan="2" {$valueStyle}>
- {capture assign=contributionUrl}{crmURL p='civicrm/contribute/transact' q="reset=1&id=`$contributionPageId`" a=true fe=1 h=1}{/capture}
- {include file="CRM/common/SocialNetwork.tpl" emailMode=true url=$contributionUrl title=$title pageURL=$contributionUrl}
- </td>
- </tr>
- {/if}
-
- {if ! ($contributeMode eq 'notify' OR $contributeMode eq 'directIPN') and $is_monetary}
- {if $is_pay_later}
- <tr>
- <th {$headerStyle}>
- {ts}Registered Email{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {$email}
- </td>
- </tr>
- {elseif $amount GT 0}
- <tr>
- <th {$headerStyle}>
- {ts}Billing Name and Address{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {$billingName}<br />
- {$address|nl2br}<br />
- {$email}
- </td>
- </tr>
- {/if}
- {/if}
-
- {if $contributeMode eq 'direct' AND !$is_pay_later AND $amount GT 0}
- <tr>
- <th {$headerStyle}>
- {ts}Credit Card Information{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {$credit_card_type}<br />
- {$credit_card_number}<br />
- {ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}<br />
- </td>
- </tr>
- {/if}
-
- {if $selectPremium}
- <tr>
- <th {$headerStyle}>
- {ts}Premium Information{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$labelStyle}>
- {$product_name}
- </td>
- </tr>
- {if $option}
- <tr>
- <td {$labelStyle}>
- {ts}Option{/ts}
- </td>
- <td {$valueStyle}>
- {$option}
- </td>
- </tr>
- {/if}
- {if $sku}
- <tr>
- <td {$labelStyle}>
- {ts}SKU{/ts}
- </td>
- <td {$valueStyle}>
- {$sku}
- </td>
- </tr>
- {/if}
- {if $start_date}
- <tr>
- <td {$labelStyle}>
- {ts}Start Date{/ts}
- </td>
- <td {$valueStyle}>
- {$start_date|crmDate}
- </td>
- </tr>
- {/if}
- {if $end_date}
- <tr>
- <td {$labelStyle}>
- {ts}End Date{/ts}
- </td>
- <td {$valueStyle}>
- {$end_date|crmDate}
- </td>
- </tr>
- {/if}
- {if $contact_email OR $contact_phone}
- <tr>
- <td colspan="2" {$valueStyle}>
- <p>{ts}For information about this premium, contact:{/ts}</p>
- {if $contact_email}
- <p>{$contact_email}</p>
- {/if}
- {if $contact_phone}
- <p>{$contact_phone}</p>
- {/if}
- </td>
- </tr>
- {/if}
- {if $is_deductible AND $price}
- <tr>
- <td colspan="2" {$valueStyle}>
- <p>{ts 1=$price|crmMoney:$currency}The value of this premium is %1. This may affect the amount of the tax deduction you can claim. Consult your tax advisor for more information.{/ts}</p>
- </td>
- </tr>
- {/if}
- {/if}
-
- {if $customPre}
- <tr>
- <th {$headerStyle}>
- {$customPre_grouptitle}
- </th>
- </tr>
- {foreach from=$customPre item=customValue key=customName}
- {if ($trackingFields and ! in_array($customName, $trackingFields)) or ! $trackingFields}
- <tr>
- <td {$labelStyle}>
- {$customName}
- </td>
- <td {$valueStyle}>
- {$customValue}
- </td>
- </tr>
- {/if}
- {/foreach}
- {/if}
-
- {if $customPost}
- <tr>
- <th {$headerStyle}>
- {$customPost_grouptitle}
- </th>
- </tr>
- {foreach from=$customPost item=customValue key=customName}
- {if ($trackingFields and ! in_array($customName, $trackingFields)) or ! $trackingFields}
- <tr>
- <td {$labelStyle}>
- {$customName}
- </td>
- <td {$valueStyle}>
- {$customValue}
- </td>
- </tr>
- {/if}
- {/foreach}
- {/if}
-
- </table>
-</center>
-
-</body>
-</html>
+++ /dev/null
-{if $receipt_text}
-{$receipt_text}
-{/if}
-{if $is_pay_later}
-
-===========================================================
-{$pay_later_receipt}
-===========================================================
-{else}
-
-{ts}Please print this receipt for your records.{/ts}
-{/if}
-
-{if $amount}
-===========================================================
-{ts}Contribution Information{/ts}
-
-===========================================================
-{if $lineItem and $priceSetID}
-{foreach from=$lineItem item=value key=priceset}
----------------------------------------------------------
-{capture assign=ts_item}{ts}Item{/ts}{/capture}
-{capture assign=ts_qty}{ts}Qty{/ts}{/capture}
-{capture assign=ts_each}{ts}Each{/ts}{/capture}
-{capture assign=ts_total}{ts}Total{/ts}{/capture}
-{$ts_item|string_format:"%-30s"} {$ts_qty|string_format:"%5s"} {$ts_each|string_format:"%10s"} {$ts_total|string_format:"%10s"}
-----------------------------------------------------------
-{foreach from=$value item=line}
-{capture assign=ts_item}{if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description} {$line.description}{/if}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.qty|string_format:"%5s"} {$line.unit_price|crmMoney:$currency|string_format:"%10s"} {$line.line_total|crmMoney:$currency|string_format:"%10s"}
-{/foreach}
-{/foreach}
-
-{ts}Total Amount{/ts}: {$amount|crmMoney:$currency}
-{else}
-{ts}Amount{/ts}: {$amount|crmMoney:$currency} {if $amount_level } - {$amount_level} {/if}
-{/if}
-{/if}
-{if $receive_date}
-
-{ts}Date{/ts}: {$receive_date|crmDate}
-{/if}
-{if $is_monetary and $trxn_id}
-{ts}Transaction #{/ts}: {$trxn_id}
-{/if}
-
-{if $is_recur and ($contributeMode eq 'notify' or $contributeMode eq 'directIPN')}
-{ts}This is a recurring contribution. You can cancel future contributions at:{/ts}
-
-{$cancelSubscriptionUrl}
-
-{ts}You can update billing details for this recurring contribution at:{/ts}
-
-{$updateSubscriptionBillingUrl}
-
-{ts}You can update recurring contribution amount or change the number of installments for this recurring contribution at:{/ts}
-
-{$updateSubscriptionUrl}
-
-{/if}
-
-{if $honor_block_is_active }
-===========================================================
-{$honor_type}
-===========================================================
-{$honor_prefix} {$honor_first_name} {$honor_last_name}
-{if $honor_email}
-{ts}Honoree Email{/ts}: {$honor_email}
-{/if}
-
-{/if}
-{if $pcpBlock}
-===========================================================
-{ts}Personal Campaign Page{/ts}
-
-===========================================================
-{ts}Display In Honor Roll{/ts}: {if $pcp_display_in_roll}{ts}Yes{/ts}{else}{ts}No{/ts}{/if}
-
-{if $pcp_roll_nickname}{ts}Nickname{/ts}: {$pcp_roll_nickname}{/if}
-
-{if $pcp_personal_note}{ts}Personal Note{/ts}: {$pcp_personal_note}{/if}
-
-{/if}
-{if $onBehalfProfile}
-===========================================================
-{ts}On Behalf Of{/ts}
-
-===========================================================
-{foreach from=$onBehalfProfile item=onBehalfValue key=onBehalfName}
-{$onBehalfName}: {$onBehalfValue}
-{/foreach}
-{/if}
-
-{if !( $contributeMode eq 'notify' OR $contributeMode eq 'directIPN' ) and $is_monetary}
-{if $is_pay_later}
-===========================================================
-{ts}Registered Email{/ts}
-
-===========================================================
-{$email}
-{elseif $amount GT 0}
-===========================================================
-{ts}Billing Name and Address{/ts}
-
-===========================================================
-{$billingName}
-{$address}
-
-{$email}
-{/if} {* End ! is_pay_later condition. *}
-{/if}
-{if $contributeMode eq 'direct' AND !$is_pay_later AND $amount GT 0}
-
-===========================================================
-{ts}Credit Card Information{/ts}
-
-===========================================================
-{$credit_card_type}
-{$credit_card_number}
-{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
-{/if}
-
-{if $selectPremium }
-===========================================================
-{ts}Premium Information{/ts}
-
-===========================================================
-{$product_name}
-{if $option}
-{ts}Option{/ts}: {$option}
-{/if}
-{if $sku}
-{ts}SKU{/ts}: {$sku}
-{/if}
-{if $start_date}
-{ts}Start Date{/ts}: {$start_date|crmDate}
-{/if}
-{if $end_date}
-{ts}End Date{/ts}: {$end_date|crmDate}
-{/if}
-{if $contact_email OR $contact_phone}
-
-{ts}For information about this premium, contact:{/ts}
-
-{if $contact_email}
- {$contact_email}
-{/if}
-{if $contact_phone}
- {$contact_phone}
-{/if}
-{/if}
-{if $is_deductible AND $price}
-
-{ts 1=$price|crmMoney:$currency}The value of this premium is %1. This may affect the amount of the tax deduction you can claim. Consult your tax advisor for more information.{/ts}{/if}
-{/if}
-
-{if $customPre}
-===========================================================
-{$customPre_grouptitle}
-
-===========================================================
-{foreach from=$customPre item=customValue key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- {$customName}: {$customValue}
-{/if}
-{/foreach}
-{/if}
-
-
-{if $customPost}
-===========================================================
-{$customPost_grouptitle}
-
-===========================================================
-{foreach from=$customPost item=customValue key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- {$customName}: {$customValue}
-{/if}
-{/foreach}
-{/if}
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
- <!-- BEGIN HEADER -->
- <!-- You can add table row(s) here with logo or other header elements -->
- <!-- END HEADER -->
-
- <!-- BEGIN CONTENT -->
-
- <tr>
- <td>
- <p>{ts 1=$contact.display_name}Dear %1{/ts},</p>
- <p>{ts 1=$amount 2=$recur_frequency_interval 3=$recur_frequency_unit}Billing details for your recurring contribution of %1, every %2 %3 have been updated.{/ts}</p>
- </td>
- </tr>
- <tr>
- </table>
-
- <table width="500" style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse;">
-<tr>
- <th {$headerStyle}>
- {ts}Billing Name and Address{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {$billingName}<br />
- {$address|nl2br}<br />
- {$email}
- </td>
- </tr>
- <tr>
- <th {$headerStyle}>
- {ts}Credit Card Information{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {$credit_card_type}<br />
- {$credit_card_number}<br />
- {ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}<br />
- </td>
- </tr>
- <tr>
- <td {$labelStyle}>
- {ts 1=$receipt_from_email}If you have questions please contact us at %1{/ts}
- </td>
- </tr>
- </table>
-</center>
-
-</body>
-</html>
\ No newline at end of file
+++ /dev/null
-{ts}Recurring Contribution Updates{/ts}
\ No newline at end of file
+++ /dev/null
-{ts 1=$contact.display_name}Dear %1{/ts},
-
-{ts 1=$amount 2=$recur_frequency_interval 3=$recur_frequency_unit}Billing details for your recurring contribution of %1, every %2 %3 have been updated.{/ts}
-
-===========================================================
-{ts}Billing Name and Address{/ts}
-
-===========================================================
-{$billingName}
-{$address}
-
-{$email}
-
-===========================================================
-{ts}Credit Card Information{/ts}
-
-===========================================================
-{$credit_card_type}
-{$credit_card_number}
-{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
-
-
-{ts 1=$receipt_from_email}If you have questions please contact us at %1{/ts}
\ No newline at end of file
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
- <!-- BEGIN HEADER -->
- <!-- You can add table row(s) here with logo or other header elements -->
- <!-- END HEADER -->
-
- <!-- BEGIN CONTENT -->
-
- <tr>
- <td>
- <p>{ts 1=$contact.display_name}Dear %1{/ts},</p>
- <p>{ts 1=$amount 2=$recur_frequency_interval 3=$recur_frequency_unit}Your recurring contribution of %1, every %2 %3 has been cancelled.{/ts}</p>
- </td>
- </tr>
- <tr>
- </table>
-</center>
-
-</body>
-</html>
+++ /dev/null
-{ts}Recurring Contribution Cancellation Notification{/ts}
+++ /dev/null
-{ts 1=$contact.display_name}Dear %1{/ts},
-
-{ts 1=$amount 2=$recur_frequency_interval 3=$recur_frequency_unit}Your recurring contribution of %1, every %2 %3 has been cancelled.{/ts}
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
- <!-- BEGIN HEADER -->
- <!-- You can add table row(s) here with logo or other header elements -->
- <!-- END HEADER -->
-
- <!-- BEGIN CONTENT -->
-
- <tr>
- <td>
- <p>{ts 1=$contact.display_name}Dear %1{/ts},</p>
- <p>{ts 1=$amount 2=$recur_frequency_interval 3=$recur_frequency_unit}Recurring contribution is for %1, every %2(s) %3{/ts}</p>
- <p>{if $installments}{ts 1=$installments} for %1 installments.{/ts}{/if}</p>
-
- <p>{ts 1=$receipt_from_email}If you have questions please contact us at %1.{/ts}</p>
- </td>
- </tr>
- <tr>
- </table>
-</center>
-
-</body>
-</html>
+++ /dev/null
-{ts}Recurring Contribution Update Notification{/ts}
\ No newline at end of file
+++ /dev/null
-{ts 1=$contact.display_name}Dear %1{/ts},
-
-{ts}Your recurring contribution has been updated as requested:{/ts}
-
-{ts 1=$amount 2=$recur_frequency_interval 3=$recur_frequency_unit}Recurring contribution is for %1, every %2(s) %3{/ts}
-{if $installments}{ts 1=$installments} for %1 installments.{/ts}{/if}
-
-{ts 1=$receipt_from_email}If you have questions please contact us at %1.{/ts}
\ No newline at end of file
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
- <!-- BEGIN HEADER -->
- <!-- You can add table row(s) here with logo or other header elements -->
- <!-- END HEADER -->
-
- <!-- BEGIN CONTENT -->
-
- <tr>
- <td>
- <p>{ts 1=$displayName}Dear %1{/ts},</p>
- </td>
- </tr>
-
- <tr>
- <td> </td>
- </tr>
-
- {if $recur_txnType eq 'START'}
- {if $auto_renew_membership}
- <tr>
- <td>
- <p>{ts}Thanks for your auto renew membership sign-up.{/ts}</p>
- <p>{ts 1=$recur_frequency_interval 2=$recur_frequency_unit}This membership will be automatically renewed every %1 %2(s). {/ts}</p>
- </td>
- </tr>
- <tr>
- <td {$labelStyle}>
- {ts 1=$cancelSubscriptionUrl}This membership will be renewed automatically. You can cancel the auto-renewal option by <a href="%1">visiting this web page</a>.{/ts}
- </td>
- </tr>
- <tr>
- <td {$labelStyle}>
- {ts 1=$updateSubscriptionBillingUrl}You can update billing details for this automatically renewed membership by <a href="%1">visiting this web page</a>.{/ts}
- </td>
- </tr>
- {else}
- <tr>
- <td>
- <p>{ts}Thanks for your recurring contribution sign-up.{/ts}</p>
- <p>{ts 1=$recur_frequency_interval 2=$recur_frequency_unit 3=$recur_installments}This recurring contribution will be automatically processed every %1 %2(s) for a total of %3 installment(s).{/ts}</p>
- <p>{ts}Start Date{/ts}: {$recur_start_date|crmDate}</p>
- </td>
- </tr>
- <tr>
- <td {$labelStyle}>
- {ts 1=$cancelSubscriptionUrl} You can cancel the recurring contribution option by <a href="%1">visiting this web page</a>.{/ts}
- </td>
- </tr>
- <tr>
- <td {$labelStyle}>
- {ts 1=$updateSubscriptionBillingUrl}You can update billing details for this recurring contribution by <a href="%1">visiting this web page</a>.{/ts}
- </td>
- </tr>
- <tr>
- <td {$labelStyle}>
- {ts 1=$updateSubscriptionUrl}You can update recurring contribution amount or change the number of installments details for this recurring contribution by <a href="%1">visiting this web page</a>.{/ts}
- </td>
- </tr>
- {/if}
-
- {elseif $recur_txnType eq 'END'}
-
- {if $auto_renew_membership}
- <tr>
- <td>
- <p>{ts}Your auto renew membership sign-up has ended and your membership will not be automatically renewed.{/ts}</p>
- </td>
- </tr>
- {else}
- <tr>
- <td>
- <p>{ts}Your recurring contribution term has ended.{/ts}</p>
- <p>{ts 1=$recur_installments}You have successfully completed %1 recurring contributions. Thank you for your support.{/ts}</p>
- </td>
- </tr>
- <tr>
- <td>
- <table style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse; width:100%;">
- <tr>
- <th {$headerStyle}>
- {ts 1=$recur_installments}Interval of Subscription for %1 installment(s){/ts}
- </th>
- </tr>
- <tr>
- <td {$labelStyle}>
- {ts}Start Date{/ts}
- </td>
- <td {$valueStyle}>
- {$recur_start_date|crmDate}
- </td>
- </tr>
- <tr>
- <td {$labelStyle}>
- {ts}End Date{/ts}
- </td>
- <td {$valueStyle}>
- {$recur_end_date|crmDate}
- </td>
- </tr>
- </table>
- </td>
- </tr>
-
- {/if}
- {/if}
-
- </table>
-</center>
-
-</body>
-</html>
+++ /dev/null
-{ts 1=$displayName}Dear %1{/ts},
-
-{if $recur_txnType eq 'START'}
-{if $auto_renew_membership}
-{ts}Thanks for your auto renew membership sign-up.{/ts}
-
-
-{ts 1=$recur_frequency_interval 2=$recur_frequency_unit}This membership will be automatically renewed every %1 %2(s).{/ts}
-
-{ts 1=$cancelSubscriptionUrl}This membership will be renewed automatically. You can cancel the auto-renewal option by <a href="%1">visiting this web page</a>.{/ts}
-
-{ts 1=$updateSubscriptionBillingUrl}You can update billing details for this automatically renewed membership by <a href="%1">visiting this web page</a>.{/ts}
-
-{else}
-{ts}Thanks for your recurring contribution sign-up.{/ts}
-
-
-{ts 1=$recur_frequency_interval 2=$recur_frequency_unit 3=$recur_installments}This recurring contribution will be automatically processed every %1 %2(s) for a total of %3 installment(s).{/ts}
-
-{ts}Start Date{/ts}: {$recur_start_date|crmDate}
-
-{ts 1=$cancelSubscriptionUrl}You can cancel the recurring contribution option by <a href="%1">visiting this web page</a>.{/ts}
-
-{ts 1=$updateSubscriptionBillingUrl}You can update billing details for this recurring contribution by <a href="%1">visiting this web page</a>.{/ts}
-
-{ts 1=$updateSubscriptionUrl}You can update recurring contribution amount or change the number of installments for this recurring contribution by <a href="%1">visiting this web page</a>.{/ts}
-{/if}
-
-{elseif $recur_txnType eq 'END'}
-{if $auto_renew_membership}
-{ts}Your auto renew membership sign-up has ended and your membership will not be automatically renewed.{/ts}
-
-
-{else}
-{ts}Your recurring contribution term has ended.{/ts}
-
-
-{ts 1=$recur_installments}You have successfully completed %1 recurring contributions. Thank you for your support.{/ts}
-
-
-==================================================
-{ts 1=$recur_installments}Interval of Subscription for %1 installment(s){/ts}
-
-==================================================
-{ts}Start Date{/ts}: {$recur_start_date|crmDate}
-
-{ts}End Date{/ts}: {$recur_end_date|crmDate}
-
-{/if}
-{/if}
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="500" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
- <!-- BEGIN HEADER -->
- <!-- You can add table row(s) here with logo or other header elements -->
- <!-- END HEADER -->
-
- <!-- BEGIN CONTENT -->
-
- <tr>
- <td>
- <p>Dear {contact.display_name},</p>
-
- {if $event.confirm_email_text AND (not $isOnWaitlist AND not $isRequireApproval)}
- <p>{$event.confirm_email_text|htmlize}</p>
-
- {else}
- <p>Thank you for your participation. This letter is a confirmation that your registration has been received and your status has been updated to <strong>{if $isOnWaitlist}waitlisted{else}registered{/if}</strong> for the following:</p>
-
- {/if}
-
- <p>
- {if $isOnWaitlist}
- <p>{ts}You have been added to the WAIT LIST for this event.{/ts}</p>
- {if $isPrimary}
- <p>{ts}If space becomes available you will receive an email with a link to a web page where you can complete your registration.{/ts}</p>
- {/if}
- {elseif $isRequireApproval}
- <p>{ts}Your registration has been submitted.{/ts}</p>
- {if $isPrimary}
- <p>{ts}Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.{/ts}</p>
- {/if}
- {elseif $is_pay_later && !$isAmountzero}
- <p>{$pay_later_receipt}</p> {* FIXME: this might be text rather than HTML *}
- {else}
- <p>{ts}Please print this confirmation for your records.{/ts}</p>
- {/if}
-
- </td>
- </tr>
- <tr>
- <td>
- <table width="500" style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse;">
- <tr>
- <th {$headerStyle}>
- {ts}Event Information and Location{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {$event.event_title}<br />
- {$event.event_start_date|date_format:"%A"} {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|date_format:"%A"} {$event.event_end_date|crmDate}{/if}{/if}
- </td>
- </tr>
-
-
- {if $conference_sessions}
- <tr>
- <td colspan="2" {$labelStyle}>
- {ts}Your schedule:{/ts}
- </td>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {assign var='group_by_day' value='NA'}
- {foreach from=$conference_sessions item=session}
- {if $session.start_date|date_format:"%Y/%m/%d" != $group_by_day|date_format:"%Y/%m/%d"}
- {assign var='group_by_day' value=$session.start_date}
- <em>{$group_by_day|date_format:"%m/%d/%Y"}</em><br />
- {/if}
- {$session.start_date|crmDate:0:1}{if $session.end_date}-{$session.end_date|crmDate:0:1}{/if} {$session.title}<br />
- {if $session.location} {$session.location}<br />{/if}
- {/foreach}
- </td>
- </tr>
- {/if}
-
- {if $event.participant_role neq 'Attendee' and $defaultRole}
- <tr>
- <td {$labelStyle}>
- {ts}Participant Role{/ts}
- </td>
- <td {$valueStyle}>
- {$event.participant_role}
- </td>
- </tr>
- {/if}
-
- {if $isShowLocation}
- <tr>
- <td colspan="2" {$valueStyle}>
- {if $location.address.1.name}
- {$location.address.1.name}<br />
- {/if}
- {if $location.address.1.street_address}
- {$location.address.1.street_address}<br />
- {/if}
- {if $location.address.1.supplemental_address_1}
- {$location.address.1.supplemental_address_1}<br />
- {/if}
- {if $location.address.1.supplemental_address_2}
- {$location.address.1.supplemental_address_2}<br />
- {/if}
- {if $location.address.1.city}
- {$location.address.1.city}, {$location.address.1.state_province} {$location.address.1.postal_code}{if $location.address.1.postal_code_suffix} - {$location.address.1.postal_code_suffix}{/if}<br />
- {/if}
- </td>
- </tr>
- {/if}
-
- {if $location.phone.1.phone || $location.email.1.email}
- <tr>
- <td colspan="2" {$labelStyle}>
- {ts}Event Contacts:{/ts}
- </td>
- </tr>
- {foreach from=$location.phone item=phone}
- {if $phone.phone}
- <tr>
- <td {$labelStyle}>
- {if $phone.phone_type}
- {$phone.phone_type_display}
- {else}
- {ts}Phone{/ts}
- {/if}
- </td>
- <td {$valueStyle}>
- {$phone.phone}
- </td>
- </tr>
- {/if}
- {/foreach}
- {foreach from=$location.email item=eventEmail}
- {if $eventEmail.email}
- <tr>
- <td {$labelStyle}>
- {ts}Email{/ts}
- </td>
- <td {$valueStyle}>
- {$eventEmail.email}
- </td>
- </tr>
- {/if}
- {/foreach}
- {/if}
- <tr>
- <td colspan="2" {$valueStyle}>
- {capture assign=icalFeed}{crmURL p='civicrm/event/ical' q="reset=1&id=`$event.id`" h=0 a=1 fe=1}{/capture}
- <a href="{$icalFeed}">{ts}Download iCalendar File{/ts}</a>
- </td>
- </tr>
- {if $event.is_share}
- <tr>
- <td colspan="2" {$valueStyle}>
- {capture assign=eventUrl}{crmURL p='civicrm/event/info' q="id=`$event.id`&reset=1" a=true fe=1 h=1}{/capture}
- {include file="CRM/common/SocialNetwork.tpl" emailMode=true url=$eventUrl title=$event.title pageURL=$eventUrl}
- </td>
- </tr>
- {/if}
- {if $payer.name}
- <tr>
- <th {$headerStyle}>
- {ts}You were registered by:{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {$payer.name}
- </td>
- </tr>
- {/if}
- {if $event.is_monetary}
-
- <tr>
- <th {$headerStyle}>
- {$event.fee_label}
- </th>
- </tr>
-
- {if $lineItem}
- {foreach from=$lineItem item=value key=priceset}
- {if $value neq 'skip'}
- {if $isPrimary}
- {if $lineItem|@count GT 1} {* Header for multi participant registration cases. *}
- <tr>
- <td colspan="2" {$labelStyle}>
- {ts 1=$priceset+1}Participant %1{/ts} {$part.$priceset.info}
- </td>
- </tr>
- {/if}
- {/if}
- <tr>
- <td colspan="2" {$valueStyle}>
- <table> {* FIXME: style this table so that it looks like the text version (justification, etc.) *}
- <tr>
- <th>{ts}Item{/ts}</th>
- <th>{ts}Qty{/ts}</th>
- <th>{ts}Each{/ts}</th>
- <th>{ts}Total{/ts}</th>
- {if $pricesetFieldsCount }<th>{ts}Total Participants{/ts}</th>{/if}
- </tr>
- {foreach from=$value item=line}
- <tr>
- <td>
- {if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description}<div>{$line.description|truncate:30:"..."}</div>{/if}
- </td>
- <td>
- {$line.qty}
- </td>
- <td>
- {$line.unit_price|crmMoney}
- </td>
- <td>
- {$line.line_total|crmMoney}
- </td>
- {if $pricesetFieldsCount }<td>{$line.participant_count}</td> {/if}
- </tr>
- {/foreach}
- </table>
- </td>
- </tr>
- {/if}
- {/foreach}
- {/if}
-
-
- {if $isPrimary}
- <tr>
- <td {$labelStyle}>
- {ts}Total Amount{/ts}
- </td>
- <td {$valueStyle}>
- {$totalAmount|crmMoney} {if $hookDiscount.message}({$hookDiscount.message}){/if}
- </td>
- </tr>
- {if $pricesetFieldsCount }
- <tr>
- <td {$labelStyle}>
- {ts}Total Participants{/ts}</td>
- <td {$valueStyle}>
- {assign var="count" value= 0}
- {foreach from=$lineItem item=pcount}
- {assign var="lineItemCount" value=0}
- {if $pcount neq 'skip'}
- {foreach from=$pcount item=p_count}
- {assign var="lineItemCount" value=$lineItemCount+$p_count.participant_count}
- {/foreach}
- {if $lineItemCount < 1 }
- {assign var="lineItemCount" value=1}
- {/if}
- {assign var="count" value=$count+$lineItemCount}
- {/if}
- {/foreach}
- {$count}
- </td> </tr>
- {/if}
- {if $is_pay_later}
- <tr>
- <td colspan="2" {$labelStyle}>
- {$pay_later_receipt}
- </td>
- </tr>
- {/if}
-
- {if $register_date}
- <tr>
- <td {$labelStyle}>
- {ts}Registration Date{/ts}
- </td>
- <td {$valueStyle}>
- {$register_date|crmDate}
- </td>
- </tr>
- {/if}
-
- {if $receive_date}
- <tr>
- <td {$labelStyle}>
- {ts}Transaction Date{/ts}
- </td>
- <td {$valueStyle}>
- {$receive_date|crmDate}
- </td>
- </tr>
- {/if}
-
- {if $contributionTypeName}
- <tr>
- <td {$labelStyle}>
- {ts}Contribution Type{/ts}
- </td>
- <td {$valueStyle}>
- {$contributionTypeName}
- </td>
- </tr>
- {/if}
-
- {if $trxn_id}
- <tr>
- <td {$labelStyle}>
- {ts}Transaction #{/ts}
- </td>
- <td {$valueStyle}>
- {$trxn_id}
- </td>
- </tr>
- {/if}
-
- {if $paidBy}
- <tr>
- <td {$labelStyle}>
- {ts}Paid By{/ts}
- </td>
- <td {$valueStyle}>
- {$paidBy}
- </td>
- </tr>
- {/if}
-
- {if $checkNumber}
- <tr>
- <td {$labelStyle}>
- {ts}Check Number{/ts}
- </td>
- <td {$valueStyle}>
- {$checkNumber}
- </td>
- </tr>
- {/if}
-
- {if $contributeMode ne 'notify' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
- <tr>
- <th {$headerStyle}>
- {ts}Billing Name and Address{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {$billingName}<br />
- {$address|nl2br}
- </td>
- </tr>
- {/if}
-
- {if $contributeMode eq 'direct' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
- <tr>
- <th {$headerStyle}>
- {ts}Credit Card Information{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {$credit_card_type}<br />
- {$credit_card_number}<br />
- {ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
- </td>
- </tr>
- {/if}
-
- {/if}
-
- {/if} {* End of conditional section for Paid events *}
-
-
-{if $customPre}
-{foreach from=$customPre item=customPr key=i}
- <tr> <th {$headerStyle}>{$customPre_grouptitle.$i}</th></tr>
- {foreach from=$customPr item=customValue key=customName}
- {if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- <tr>
- <td {$labelStyle}>{$customName}</td>
- <td {$valueStyle}>{$customValue}</td>
- </tr>
- {/if}
- {/foreach}
-{/foreach}
-{/if}
-
-{if $customPost}
-{foreach from=$customPost item=customPos key=j}
- <tr> <th {$headerStyle}>{$customPost_grouptitle.$j}</th></tr>
- {foreach from=$customPos item=customValue key=customName}
- {if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- <tr>
- <td {$labelStyle}>{$customName}</td>
- <td {$valueStyle}>{$customValue}</td>
- </tr>
-{/if}
-{/foreach}
-{/foreach}
-{/if}
-
-{if $customProfile}
-{foreach from=$customProfile.profile item=eachParticipant key=participantID}
- <tr><th {$headerStyle}>{ts 1=$participantID+2}Participant %1{/ts} </th></tr>
- {foreach from=$eachParticipant item=eachProfile key=pid}
- <tr><th {$headerStyle}>{$customProfile.title.$pid}</th></tr>
- {foreach from=$eachProfile item=val key=field}
- <tr>{foreach from=$val item=v key=f}
- <td {$labelStyle}>{$field}</td>
- <td {$valueStyle}>{$v}</td>
- {/foreach}
- </tr>
- {/foreach}
-{/foreach}
-{/foreach}
-{/if}
-
- {if $customGroup}
- {foreach from=$customGroup item=value key=customName}
- <tr>
- <th {$headerStyle}>
- {$customName}
- </th>
- </tr>
- {foreach from=$value item=v key=n}
- <tr>
- <td {$labelStyle}>
- {$n}
- </td>
- <td {$valueStyle}>
- {$v}
- </td>
- </tr>
- {/foreach}
- {/foreach}
- {/if}
- </table>
- </td>
- </tr>
- </table>
-</center>
-
-</body>
-</html>
+++ /dev/null
-Dear {contact.display_name},
-
-{if $event.confirm_email_text AND (not $isOnWaitlist AND not $isRequireApproval)}
-{$event.confirm_email_text}
-
-{else}
-Thank you for your participation. This letter is a confirmation that your registration has been received and your status has been updated to {if $participant_status}$participant_status{else}{if $isOnWaitlist}waitlisted{else}registered{/if}{/if} for the following:
-
-{/if}
-
-{if $isOnWaitlist}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}You have been added to the WAIT LIST for this event.{/ts}
-
-{if $isPrimary}
-{ts}If space becomes available you will receive an email with a link to a web page where you can complete your registration.{/ts}
-{/if}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{elseif $isRequireApproval}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Your registration has been submitted.{/ts}
-
-{if $isPrimary}
-{ts}Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.{/ts}
-
-{/if}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{elseif $is_pay_later && !$isAmountzero}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$pay_later_receipt}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{else}
-
-{ts}Please print this confirmation for your records.{/ts}
-{/if}
-
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Event Information and Location{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$event.event_title}
-{$event.event_start_date|date_format:"%A"} {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|date_format:"%A"} {$event.event_end_date|crmDate}{/if}{/if}
-{if $conference_sessions}
-
-
-{ts}Your schedule:{/ts}
-{assign var='group_by_day' value='NA'}
-{foreach from=$conference_sessions item=session}
-{if $session.start_date|date_format:"%Y/%m/%d" != $group_by_day|date_format:"%Y/%m/%d"}
-{assign var='group_by_day' value=$session.start_date}
-
-{$group_by_day|date_format:"%m/%d/%Y"}
-
-
-{/if}
-{$session.start_date|crmDate:0:1}{if $session.end_date}-{$session.end_date|crmDate:0:1}{/if} {$session.title}
-{if $session.location} {$session.location}{/if}
-{/foreach}
-{/if}
-
-{if $event.participant_role neq 'Attendee' and $defaultRole}
-{ts}Participant Role{/ts}: {$event.participant_role}
-{/if}
-
-{if $isShowLocation}
-{if $location.address.1.name}
-
-{$location.address.1.name}
-{/if}
-{if $location.address.1.street_address}{$location.address.1.street_address}
-{/if}
-{if $location.address.1.supplemental_address_1}{$location.address.1.supplemental_address_1}
-{/if}
-{if $location.address.1.supplemental_address_2}{$location.address.1.supplemental_address_2}
-{/if}
-{if $location.address.1.city}{$location.address.1.city}, {$location.address.1.state_province} {$location.address.1.postal_code}{if $location.address.1.postal_code_suffix} - {$location.address.1.postal_code_suffix}{/if}
-{/if}
-
-{/if}{*End of isShowLocation condition*}
-
-{if $location.phone.1.phone || $location.email.1.email}
-
-{ts}Event Contacts:{/ts}
-{foreach from=$location.phone item=phone}
-{if $phone.phone}
-
-{if $phone.phone_type}{$phone.phone_type_display}{else}{ts}Phone{/ts}{/if}: {$phone.phone}{/if}
-{/foreach}
-{foreach from=$location.email item=eventEmail}
-{if $eventEmail.email}
-
-{ts}Email{/ts}: {$eventEmail.email}{/if}{/foreach}
-{/if}
-
-{capture assign=icalFeed}{crmURL p='civicrm/event/ical' q="reset=1&id=`$event.id`" h=0 a=1 fe=1}{/capture}
-{ts}Download iCalendar File:{/ts} {$icalFeed}
-
-{if $payer.name}
-You were registered by: {$payer.name}
-{/if}
-{if $event.is_monetary} {* This section for Paid events only.*}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$event.fee_label}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{if $lineItem}{foreach from=$lineItem item=value key=priceset}
-
-{if $value neq 'skip'}
-{if $isPrimary}
-{if $lineItem|@count GT 1} {* Header for multi participant registration cases. *}
-{ts 1=$priceset+1}Participant %1{/ts} {$part.$priceset.info}
-
-{/if}
-{/if}
------------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{capture assign=ts_item}{ts}Item{/ts}{/capture}
-{capture assign=ts_qty}{ts}Qty{/ts}{/capture}
-{capture assign=ts_each}{ts}Each{/ts}{/capture}
-{capture assign=ts_total}{ts}Total{/ts}{/capture}
-{if $pricesetFieldsCount }{capture assign=ts_participant_total}{ts}Total Participants{/ts}{/capture}{/if}
-{$ts_item|string_format:"%-30s"} {$ts_qty|string_format:"%5s"} {$ts_each|string_format:"%10s"} {$ts_total|string_format:"%10s"} {$ts_participant_total|string_format:"%10s"}
------------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{foreach from=$value item=line}
-{if $pricesetFieldsCount }{capture assign=ts_participant_count}{$line.participant_count}{/capture}{/if}
-{capture assign=ts_item}{if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description} {$line.description}{/if}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.qty|string_format:"%5s"} {$line.unit_price|crmMoney|string_format:"%10s"} {$line.line_total|crmMoney|string_format:"%10s"}{$ts_participant_count|string_format:"%10s"}
-{/foreach}
-{/if}
-{/foreach}
-{/if}
-{if $isPrimary }
-
-{ts}Total Amount{/ts}: {$totalAmount|crmMoney} {if $hookDiscount.message}({$hookDiscount.message}){/if}
-
-{if $pricesetFieldsCount }
- {assign var="count" value= 0}
- {foreach from=$lineItem item=pcount}
- {assign var="lineItemCount" value=0}
- {if $pcount neq 'skip'}
- {foreach from=$pcount item=p_count}
- {assign var="lineItemCount" value=$lineItemCount+$p_count.participant_count}
- {/foreach}
- {if $lineItemCount < 1 }
- {assign var="lineItemCount" value=1}
- {/if}
- {assign var="count" value=$count+$lineItemCount}
- {/if}
- {/foreach}
-
-{ts}Total Participants{/ts}: {$count}
-{/if}
-
-{if $is_pay_later}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$pay_later_receipt}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{/if}
-
-{if $register_date}
-{ts}Registration Date{/ts}: {$register_date|crmDate}
-{/if}
-{if $receive_date}
-{ts}Transaction Date{/ts}: {$receive_date|crmDate}
-{/if}
-{if $contributionTypeName}
-{ts}Contribution Type{/ts}: {$contributionTypeName}
-{/if}
-{if $trxn_id}
-{ts}Transaction #{/ts}: {$trxn_id}
-{/if}
-{if $paidBy}
-{ts}Paid By{/ts}: {$paidBy}
-{/if}
-{if $checkNumber}
-{ts}Check Number{/ts}: {$checkNumber}
-{/if}
-{if $contributeMode ne 'notify' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Billing Name and Address{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$billingName}
-{$address}
-{/if}
-
-{if $contributeMode eq 'direct' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Credit Card Information{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$credit_card_type}
-{$credit_card_number}
-{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
-{/if}
-{/if}
-{/if} {* End of conditional section for Paid events *}
-
-{if $customPre}
-{foreach from=$customPre item=customPr key=i}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$customPre_grouptitle.$i}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$customPr item=customValue key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- {$customName}: {$customValue}
-{/if}
-{/foreach}
-{/foreach}
-{/if}
-
-{if $customPost}
-{foreach from=$customPost item=customPos key=j}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$customPost_grouptitle.$j}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$customPos item=customValue key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- {$customName}: {$customValue}
-{/if}
-{/foreach}
-{/foreach}
-{/if}
-{if $customProfile}
-
-{foreach from=$customProfile.profile item=eachParticipant key=participantID}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts 1=$participantID+2}Participant Information - Participant %1{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$eachParticipant item=eachProfile key=pid}
-----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{$customProfile.title.$pid}
-----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{foreach from=$eachProfile item=val key=field}
-{foreach from=$val item=v key=f}
-{$field}: {$v}
-{/foreach}
-{/foreach}
-{/foreach}
-{/foreach}
-{/if}
-{if $customGroup}
-{foreach from=$customGroup item=value key=customName}
-=========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$customName}
-=========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$value item=v key=n}
-{$n}: {$v}
-{/foreach}
-{/foreach}
-{/if}
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
- <!-- BEGIN HEADER -->
- <!-- You can add table row(s) here with logo or other header elements -->
- <!-- END HEADER -->
-
- <!-- BEGIN CONTENT -->
-
- <tr>
- <td>
- <p>{ts 1=$contact.display_name}Dear %1{/ts},</p>
- <p>{ts 1=$membershipType}Billing details for your automatically renewed %1 membership have been updated.{/ts}</p>
- </td>
- </tr>
- <tr>
- </table>
-
- <table width="500" style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse;">
-<tr>
- <th {$headerStyle}>
- {ts}Billing Name and Address{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {$billingName}<br />
- {$address|nl2br}<br />
- {$email}
- </td>
- </tr>
- <tr>
- <th {$headerStyle}>
- {ts}Credit Card Information{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {$credit_card_type}<br />
- {$credit_card_number}<br />
- {ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}<br />
- </td>
- </tr>
- <tr>
- <td {$labelStyle}>
- {ts 1=$receipt_from_email}If you have questions please contact us at %1{/ts}
- </td>
- </tr>
- </table>
-</center>
-
-</body>
-</html>
+++ /dev/null
-{ts}Membership Autorenewal Updates{/ts}
\ No newline at end of file
+++ /dev/null
-{ts 1=$contact.display_name}Dear %1{/ts},
-
-{ts 1=$membershipType}Billing details for your automatically renewed %1 membership have been updated.{/ts}
-
-===========================================================
-{ts}Billing Name and Address{/ts}
-
-===========================================================
-{$billingName}
-{$address}
-
-{$email}
-
-===========================================================
-{ts}Credit Card Information{/ts}
-
-===========================================================
-{$credit_card_type}
-{$credit_card_number}
-{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
-
-
-{ts 1=$receipt_from_email}If you have questions please contact us at %1{/ts}
\ No newline at end of file
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="500" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
- <!-- BEGIN HEADER -->
- <!-- You can add table row(s) here with logo or other header elements -->
- <!-- END HEADER -->
-
- <!-- BEGIN CONTENT -->
-
- <tr>
- <td>
-
- <p>{ts 1=$membershipType}The automatic renewal of your %1 membership has been cancelled as requested. This does not affect the status of your membership - you will receive a separate notification when your membership is up for renewal.{/ts}</p>
-
- </td>
- </tr>
- </table>
- <table width="500" style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse;">
-
- <tr>
- <th {$headerStyle}>
- {ts}Membership Information{/ts}
- </th>
- </tr>
- <tr>
- <td {$labelStyle}>
- {ts}Membership Status{/ts}
- </td>
- <td {$valueStyle}>
- {$membership_status}
- </td>
- </tr>
- {if $mem_start_date}
- <tr>
- <td {$labelStyle}>
- {ts}Membership Start Date{/ts}
- </td>
- <td {$valueStyle}>
- {$mem_start_date|crmDate}
- </td>
- </tr>
- {/if}
- {if $mem_end_date}
- <tr>
- <td {$labelStyle}>
- {ts}Membership End Date{/ts}
- </td>
- <td {$valueStyle}>
- {$mem_end_date|crmDate}
- </td>
- </tr>
- {/if}
-
- </table>
-</center>
-
-</body>
-</html>
+++ /dev/null
-{ts}Autorenew Membership Cancellation Notification{/ts}
+++ /dev/null
-{ts 1=$membershipType}The automatic renewal of your %1 membership has been cancelled as requested. This does not affect the status of your membership - you will receive a separate notification when your membership is up for renewal.{/ts}
-
-===========================================================
-{ts}Membership Information{/ts}
-
-===========================================================
-{ts}Membership Status{/ts}: {$membership_status}
-{if $mem_start_date}{ts}Membership Start Date{/ts}: {$mem_start_date|crmDate}
-{/if}
-{if $mem_end_date}{ts}Membership End Date{/ts}: {$mem_end_date|crmDate}
-{/if}
-
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="500" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
- <!-- BEGIN HEADER -->
- <!-- You can add table row(s) here with logo or other header elements -->
- <!-- END HEADER -->
-
- <!-- BEGIN CONTENT -->
-
- <tr>
- <td>
-
- {if $receipt_text}
- <p>{$receipt_text|htmlize}</p>
- {/if}
-
- {if $is_pay_later}
- <p>{$pay_later_receipt}</p> {* FIXME: this might be text rather than HTML *}
- {else}
- <p>{ts}Please print this confirmation for your records.{/ts}</p>
- {/if}
-
- </td>
- </tr>
- </table>
- <table width="500" style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse;">
-
- {if $membership_assign}
- <tr>
- <th {$headerStyle}>
- {ts}Membership Information{/ts}
- </th>
- </tr>
- <tr>
- <td {$labelStyle}>
- {ts}Membership Type{/ts}
- </td>
- <td {$valueStyle}>
- {$membership_name}
- </td>
- </tr>
- {if $mem_start_date}
- <tr>
- <td {$labelStyle}>
- {ts}Membership Start Date{/ts}
- </td>
- <td {$valueStyle}>
- {$mem_start_date|crmDate}
- </td>
- </tr>
- {/if}
- {if $mem_end_date}
- <tr>
- <td {$labelStyle}>
- {ts}Membership End Date{/ts}
- </td>
- <td {$valueStyle}>
- {$mem_end_date|crmDate}
- </td>
- </tr>
- {/if}
- {/if}
-
-
- {if $amount}
-
-
- <tr>
- <th {$headerStyle}>
- {ts}Membership Fee{/ts}
- </th>
- </tr>
-
- {if $membership_amount and $is_quick_config}
-
- <tr>
- <td {$labelStyle}>
- {ts 1=$membership_name}%1 Membership{/ts}
- </td>
- <td {$valueStyle}>
- {$membership_amount|crmMoney}
- </td>
- </tr>
- {if $amount}
- {if ! $is_separate_payment }
- <tr>
- <td {$labelStyle}>
- {ts}Contribution Amount{/ts}
- </td>
- <td {$valueStyle}>
- {$amount|crmMoney}
- </td>
- </tr>
- {else}
- <tr>
- <td {$labelStyle}>
- {ts}Additional Contribution{/ts}
- </td>
- <td {$valueStyle}>
- {$amount|crmMoney}
- </td>
- </tr>
- {/if}
- {/if}
- <tr>
- <td {$labelStyle}>
- {ts}Total{/ts}
- </td>
- <td {$valueStyle}>
- {$amount+$membership_amount|crmMoney}
- </td>
- </tr>
-
- {elseif !$useForMember && $lineItem and $priceSetID and !$is_quick_config}
-
- {foreach from=$lineItem item=value key=priceset}
- <tr>
- <td colspan="2" {$valueStyle}>
- <table> {* FIXME: style this table so that it looks like the text version (justification, etc.) *}
- <tr>
- <th>{ts}Item{/ts}</th>
- <th>{ts}Qty{/ts}</th>
- <th>{ts}Each{/ts}</th>
- <th>{ts}Total{/ts}</th>
- </tr>
- {foreach from=$value item=line}
- <tr>
- <td>
- {$line.description|truncate:30:"..."}
- </td>
- <td>
- {$line.qty}
- </td>
- <td>
- {$line.unit_price|crmMoney}
- </td>
- <td>
- {$line.line_total|crmMoney}
- </td>
- </tr>
- {/foreach}
- </table>
- </td>
- </tr>
- {/foreach}
- <tr>
- <td {$labelStyle}>
- {ts}Total Amount{/ts}
- </td>
- <td {$valueStyle}>
- {$amount|crmMoney}
- </td>
- </tr>
-
- {else}
- {if $useForMember && $lineItem and !$is_quick_config}
- {foreach from=$lineItem item=value key=priceset}
- <tr>
- <td colspan="2" {$valueStyle}>
- <table> {* FIXME: style this table so that it looks like the text version (justification, etc.) *}
- <tr>
- <th>{ts}Item{/ts}</th>
- <th>{ts}Fee{/ts}</th>
- <th>{ts}Membership Start Date{/ts}</th>
- <th>{ts}Membership End Date{/ts}</th>
- </tr>
- {foreach from=$value item=line}
- <tr>
- <td>
- {if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description}<div>{$line.description|truncate:30:"..."}</div>{/if}
- </td>
- <td>
- {$line.line_total|crmMoney}
- </td>
- <td>
- {$line.start_date}
- </td>
- <td>
- {$line.end_date}
- </td>
- </tr>
- {/foreach}
- </table>
- </td>
- </tr>
- {/foreach}
- {/if}
- <tr>
- <td {$labelStyle}>
- {ts}Amount{/ts}
- </td>
- <td {$valueStyle}>
- {$amount|crmMoney} {if $amount_level} - {$amount_level}{/if}
- </td>
- </tr>
-
- {/if}
-
-
- {elseif $membership_amount}
-
-
- <tr>
- <th {$headerStyle}>
- {ts}Membership Fee{/ts}
- </th>
- </tr>
- <tr>
- <td {$labelStyle}>
- {ts 1=$membership_name}%1 Membership{/ts}
- </td>
- <td {$valueStyle}>
- {$membership_amount|crmMoney}
- </td>
- </tr>
-
-
- {/if}
-
-
- {if $receive_date}
- <tr>
- <td {$labelStyle}>
- {ts}Date{/ts}
- </td>
- <td {$valueStyle}>
- {$receive_date|crmDate}
- </td>
- </tr>
- {/if}
-
- {if $is_monetary and $trxn_id}
- <tr>
- <td {$labelStyle}>
- {ts}Transaction #{/ts}
- </td>
- <td {$valueStyle}>
- {$trxn_id}
- </td>
- </tr>
- {/if}
-
- {if $membership_trx_id}
- <tr>
- <td {$labelStyle}>
- {ts}Membership Transaction #{/ts}
- </td>
- <td {$valueStyle}>
- {$membership_trx_id}
- </td>
- </tr>
- {/if}
- {if $is_recur}
- {if $contributeMode eq 'notify' or $contributeMode eq 'directIPN'}
- <tr>
- <td colspan="2" {$labelStyle}>
- {ts 1=$cancelSubscriptionUrl}This membership will be renewed automatically. You can cancel the auto-renewal option by <a href="%1">visiting this web page</a>.{/ts}
- </td>
- </tr>
- <tr>
- <td colspan="2" {$labelStyle}>
- {ts 1=$updateSubscriptionBillingUrl}You can update billing details for this automatically renewed membership by <a href="%1">visiting this web page</a>.{/ts}
- </td>
- </tr>
- {/if}
- {/if}
-
- {if $honor_block_is_active}
- <tr>
- <th {$headerStyle}>
- {$honor_type}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$labelStyle}>
- {$honor_prefix} {$honor_first_name} {$honor_last_name}
- </td>
- </tr>
- {if $honor_email}
- <tr>
- <td {$labelStyle}>
- {ts}Honoree Email{/ts}
- </td>
- <td {$valueStyle}>
- {$honor_email}
- </td>
- </tr>
- {/if}
- {/if}
-
- {if $pcpBlock}
- <tr>
- <th {$headerStyle}>
- {ts}Personal Campaign Page{/ts}
- </th>
- </tr>
- <tr>
- <td {$labelStyle}>
- {ts}Display In Honor Roll{/ts}
- </td>
- <td {$valueStyle}>
- {if $pcp_display_in_roll}{ts}Yes{/ts}{else}{ts}No{/ts}{/if}
- </td>
- </tr>
- {if $pcp_roll_nickname}
- <tr>
- <td {$labelStyle}>
- {ts}Nickname{/ts}
- </td>
- <td {$valueStyle}>
- {$pcp_roll_nickname}
- </td>
- </tr>
- {/if}
- {if $pcp_personal_note}
- <tr>
- <td {$labelStyle}>
- {ts}Personal Note{/ts}
- </td>
- <td {$valueStyle}>
- {$pcp_personal_note}
- </td>
- </tr>
- {/if}
- {/if}
-
- {if $onBehalfProfile}
- <tr>
- <th {$headerStyle}>
- {$onBehalfProfile_grouptitle}
- </th>
- </tr>
- {foreach from=$onBehalfProfile item=onBehalfValue key=onBehalfName}
- <tr>
- <td {$labelStyle}>
- {$onBehalfName}
- </td>
- <td {$valueStyle}>
- {$onBehalfValue}
- </td>
- </tr>
- {/foreach}
- {/if}
-
- {if ! ($contributeMode eq 'notify' OR $contributeMode eq 'directIPN') and $is_monetary}
- {if $is_pay_later}
- <tr>
- <th {$headerStyle}>
- {ts}Registered Email{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {$email}
- </td>
- </tr>
- {elseif $amount GT 0 OR $membership_amount GT 0}
- <tr>
- <th {$headerStyle}>
- {ts}Billing Name and Address{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {$billingName}<br />
- {$address|nl2br}<br />
- {$email}
- </td>
- </tr>
- {/if}
- {/if}
-
- {if $contributeMode eq 'direct' AND !$is_pay_later AND ($amount GT 0 OR $membership_amount GT 0)}
- <tr>
- <th {$headerStyle}>
- {ts}Credit Card Information{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {$credit_card_type}<br />
- {$credit_card_number}<br />
- {ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}<br />
- </td>
- </tr>
- {/if}
-
- {if $selectPremium}
- <tr>
- <th {$headerStyle}>
- {ts}Premium Information{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$labelStyle}>
- {$product_name}
- </td>
- </tr>
- {if $option}
- <tr>
- <td {$labelStyle}>
- {ts}Option{/ts}
- </td>
- <td {$valueStyle}>
- {$option}
- </td>
- </tr>
- {/if}
- {if $sku}
- <tr>
- <td {$labelStyle}>
- {ts}SKU{/ts}
- </td>
- <td {$valueStyle}>
- {$sku}
- </td>
- </tr>
- {/if}
- {if $start_date}
- <tr>
- <td {$labelStyle}>
- {ts}Start Date{/ts}
- </td>
- <td {$valueStyle}>
- {$start_date|crmDate}
- </td>
- </tr>
- {/if}
- {if $end_date}
- <tr>
- <td {$labelStyle}>
- {ts}End Date{/ts}
- </td>
- <td {$valueStyle}>
- {$end_date|crmDate}
- </td>
- </tr>
- {/if}
- {if $contact_email OR $contact_phone}
- <tr>
- <td colspan="2" {$valueStyle}>
- <p>{ts}For information about this premium, contact:{/ts}</p>
- {if $contact_email}
- <p>{$contact_email}</p>
- {/if}
- {if $contact_phone}
- <p>{$contact_phone}</p>
- {/if}
- </td>
- </tr>
- {/if}
- {if $is_deductible AND $price}
- <tr>
- <td colspan="2" {$valueStyle}>
- <p>{ts 1=$price|crmMoney}The value of this premium is %1. This may affect the amount of the tax deduction you can claim. Consult your tax advisor for more information.{/ts}</p>
- </td>
- </tr>
- {/if}
- {/if}
-
- {if $customPre}
- <tr>
- <th {$headerStyle}>
- {$customPre_grouptitle}
- </th>
- </tr>
- {foreach from=$customPre item=customValue key=customName}
- {if ($trackingFields and ! in_array($customName, $trackingFields)) or ! $trackingFields}
- <tr>
- <td {$labelStyle}>
- {$customName}
- </td>
- <td {$valueStyle}>
- {$customValue}
- </td>
- </tr>
- {/if}
- {/foreach}
- {/if}
-
- {if $customPost}
- <tr>
- <th {$headerStyle}>
- {$customPost_grouptitle}
- </th>
- </tr>
- {foreach from=$customPost item=customValue key=customName}
- {if ($trackingFields and ! in_array($customName, $trackingFields)) or ! $trackingFields}
- <tr>
- <td {$labelStyle}>
- {$customName}
- </td>
- <td {$valueStyle}>
- {$customValue}
- </td>
- </tr>
- {/if}
- {/foreach}
- {/if}
-
- </table>
-</center>
-
-</body>
-</html>
+++ /dev/null
-{if $receipt_text}
-{$receipt_text}
-{/if}
-{if $is_pay_later}
-
-===========================================================
-{$pay_later_receipt}
-===========================================================
-{else}
-
-{ts}Please print this receipt for your records.{/ts}
-{/if}
-
-{if $membership_assign && !$useForMember}
-===========================================================
-{ts}Membership Information{/ts}
-
-===========================================================
-{ts}Membership Type{/ts}: {$membership_name}
-{if $mem_start_date}{ts}Membership Start Date{/ts}: {$mem_start_date|crmDate}
-{/if}
-{if $mem_end_date}{ts}Membership End Date{/ts}: {$mem_end_date|crmDate}
-{/if}
-
-{/if}
-{if $amount}
-===========================================================
-{ts}Membership Fee{/ts}
-
-===========================================================
-{if !$useForMember && $membership_amount }
-{ts 1=$membership_name}%1 Membership{/ts}: {$membership_amount|crmMoney}
-{if $amount}
-{if ! $is_separate_payment }
-{ts}Contribution Amount{/ts}: {$amount|crmMoney}
-{else}
-{ts}Additional Contribution{/ts}: {$amount|crmMoney}
-{/if}
-{/if}
--------------------------------------------
-{ts}Total{/ts}: {$amount+$membership_amount|crmMoney}
-{elseif !$useForMember && $lineItem and $priceSetID}
-{foreach from=$lineItem item=value key=priceset}
----------------------------------------------------------
-{capture assign=ts_item}{ts}Item{/ts}{/capture}
-{capture assign=ts_qty}{ts}Qty{/ts}{/capture}
-{capture assign=ts_each}{ts}Each{/ts}{/capture}
-{capture assign=ts_total}{ts}Total{/ts}{/capture}
-{$ts_item|string_format:"%-30s"} {$ts_qty|string_format:"%5s"} {$ts_each|string_format:"%10s"} {$ts_total|string_format:"%10s"}
-----------------------------------------------------------
-{foreach from=$value item=line}
-{$line.description|truncate:30:"..."|string_format:"%-30s"} {$line.qty|string_format:"%5s"} {$line.unit_price|crmMoney|string_format:"%10s"} {$line.line_total|crmMoney|string_format:"%10s"}
-{/foreach}
-{/foreach}
-
-{ts}Total Amount{/ts}: {$amount|crmMoney}
-{else}
-{if $useForMember && $lineItem}
-{foreach from=$lineItem item=value key=priceset}
-{capture assign=ts_item}{ts}Item{/ts}{/capture}
-{capture assign=ts_total}{ts}Fee{/ts}{/capture}
-{capture assign=ts_start_date}{ts}Membership Start Date{/ts}{/capture}
-{capture assign=ts_end_date}{ts}Membership End Date{/ts}{/capture}
-{$ts_item|string_format:"%-30s"} {$ts_total|string_format:"%10s"} {$ts_start_date|string_format:"%20s"} {$ts_end_date|string_format:"%20s"}
---------------------------------------------------------------------------------------------------
-
-{foreach from=$value item=line}
-{capture assign=ts_item}{if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description} {$line.description}{/if}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.line_total|crmMoney|string_format:"%10s"} {$line.start_date|string_format:"%20s"} {$line.end_date|string_format:"%20s"}
-{/foreach}
-{/foreach}
---------------------------------------------------------------------------------------------------
-{/if}
-{ts}Amount{/ts}: {$amount|crmMoney} {if $amount_level } - {$amount_level} {/if}
-{/if}
-{elseif $membership_amount}
-===========================================================
-{ts}Membership Fee{/ts}
-
-===========================================================
-{ts 1=$membership_name}%1 Membership{/ts}: {$membership_amount|crmMoney}
-{/if}
-{if $receive_date}
-
-{ts}Date{/ts}: {$receive_date|crmDate}
-{/if}
-{if $is_monetary and $trxn_id}
-{ts}Transaction #{/ts}: {$trxn_id}
-
-{/if}
-{if $membership_trx_id}
-{ts}Membership Transaction #{/ts}: {$membership_trx_id}
-
-{/if}
-{if $is_recur}
-{if $contributeMode eq 'notify' or $contributeMode eq 'directIPN'}
-{ts 1=$cancelSubscriptionUrl}This membership will be renewed automatically. You can cancel the auto-renewal option by visiting this web page: %1.{/ts}
-
-{ts 1=$updateSubscriptionBillingUrl}You can update billing details for this automatically renewed membership by <a href="%1">visiting this web page</a>.{/ts}
-{/if}
-{/if}
-
-{if $honor_block_is_active }
-===========================================================
-{$honor_type}
-===========================================================
-{$honor_prefix} {$honor_first_name} {$honor_last_name}
-{if $honor_email}
-{ts}Honoree Email{/ts}: {$honor_email}
-{/if}
-
-{/if}
-{if $pcpBlock}
-===========================================================
-{ts}Personal Campaign Page{/ts}
-
-===========================================================
-{ts}Display In Honor Roll{/ts}: {if $pcp_display_in_roll}{ts}Yes{/ts}{else}{ts}No{/ts}{/if}
-
-{if $pcp_roll_nickname}{ts}Nickname{/ts}: {$pcp_roll_nickname}{/if}
-
-{if $pcp_personal_note}{ts}Personal Note{/ts}: {$pcp_personal_note}{/if}
-
-{/if}
-{if $onBehalfProfile}
-===========================================================
-{ts}On Behalf Of{/ts}
-
-===========================================================
-{foreach from=$onBehalfProfile item=onBehalfValue key=onBehalfName}
-{$onBehalfName}: {$onBehalfValue}
-{/foreach}
-{/if}
-
-{if !( $contributeMode eq 'notify' OR $contributeMode eq 'directIPN' ) and $is_monetary}
-{if $is_pay_later}
-===========================================================
-{ts}Registered Email{/ts}
-
-===========================================================
-{$email}
-{elseif $amount GT 0 OR $membership_amount GT 0 }
-===========================================================
-{ts}Billing Name and Address{/ts}
-
-===========================================================
-{$billingName}
-{$address}
-
-{$email}
-{/if} {* End ! is_pay_later condition. *}
-{/if}
-{if $contributeMode eq 'direct' AND !$is_pay_later AND ( $amount GT 0 OR $membership_amount GT 0 ) }
-
-===========================================================
-{ts}Credit Card Information{/ts}
-
-===========================================================
-{$credit_card_type}
-{$credit_card_number}
-{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
-{/if}
-
-{if $selectPremium }
-===========================================================
-{ts}Premium Information{/ts}
-
-===========================================================
-{$product_name}
-{if $option}
-{ts}Option{/ts}: {$option}
-{/if}
-{if $sku}
-{ts}SKU{/ts}: {$sku}
-{/if}
-{if $start_date}
-{ts}Start Date{/ts}: {$start_date|crmDate}
-{/if}
-{if $end_date}
-{ts}End Date{/ts}: {$end_date|crmDate}
-{/if}
-{if $contact_email OR $contact_phone}
-
-{ts}For information about this premium, contact:{/ts}
-
-{if $contact_email}
- {$contact_email}
-{/if}
-{if $contact_phone}
- {$contact_phone}
-{/if}
-{/if}
-{if $is_deductible AND $price}
-
-{ts 1=$price|crmMoney}The value of this premium is %1. This may affect the amount of the tax deduction you can claim. Consult your tax advisor for more information.{/ts}{/if}
-{/if}
-
-{if $customPre}
-===========================================================
-{$customPre_grouptitle}
-
-===========================================================
-{foreach from=$customPre item=customValue key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- {$customName}: {$customValue}
-{/if}
-{/foreach}
-{/if}
-
-
-{if $customPost}
-===========================================================
-{$customPost_grouptitle}
-
-===========================================================
-{foreach from=$customPost item=customValue key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- {$customName}: {$customValue}
-{/if}
-{/foreach}
-{/if}
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
- <!-- BEGIN HEADER -->
- <!-- You can add table row(s) here with logo or other header elements -->
- <!-- END HEADER -->
-
- <!-- BEGIN CONTENT -->
-
- <tr>
- <td>
- <p>{ts 1=$contact.display_name}dear %1{/ts},</p>
- <p>{ts}thank you for your generous pledge. please print this acknowledgment for your records.{/ts}</p>
- </td>
- </tr>
- <tr>
- <td>
- <table style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse; width:100%;">
- <tr>
- <th {$headerStyle}>
- {ts}Pledge Information{/ts}
- </th>
- </tr>
- <tr>
- <td {$labelStyle}>
- {ts}Pledge Received{/ts}
- </td>
- <td {$valueStyle}>
- {$create_date|truncate:10:''|crmDate}
- </td>
- </tr>
- <tr>
- <td {$labelStyle}>
- {ts}Total Pledge Amount{/ts}
- </td>
- <td {$valueStyle}>
- {$total_pledge_amount|crmMoney:$currency}
- </td>
- </tr>
- <tr>
- <th {$headerStyle}>
- {ts}Payment Schedule{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- <p>{ts 1=$scheduled_amount|crmMoney:$currency 2=$frequency_interval 3=$frequency_unit 4=$installments}%1 every %2 %3 for %4 installments.{/ts}</p>
-
- {if $frequency_day}
- <p>{ts 1=$frequency_day 2=$frequency_unit}Payments are due on day %1 of the %2.{/ts}</p>
- {/if}
- </td>
- </tr>
-
- {if $payments}
- {assign var="count" value="1"}
- {foreach from=$payments item=payment}
- <tr>
- <td {$labelStyle}>
- {ts 1=$count}Payment %1{/ts}
- </td>
- <td {$valueStyle}>
- {$payment.amount|crmMoney:$currency} {if $payment.status eq 1}{ts}paid{/ts} {$payment.receive_date|truncate:10:''|crmDate}{else}{ts}due{/ts} {$payment.due_date|truncate:10:''|crmDate}{/if}
- </td>
- </tr>
- {assign var="count" value=`$count+1`}
- {/foreach}
- {/if}
-
- <tr>
- <td colspan="2" {$valueStyle}>
- <p>{ts 1=$domain.phone 2=$domain.email}Please contact us at %1 or send email to %2 if you have questions
-or need to modify your payment schedule.{/ts}</p>
- </td>
- </tr>
- {if $honor_block_is_active}
- <tr>
- <th {$headerStyle}>
- {$honor_type}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- <p>{$honor_prefix} {$honor_first_name} {$honor_last_name}</p>
- {if $honor_email}
- <p>{ts}Honoree Email{/ts}: {$honor_email}</p>
- {/if}
- </td>
- </tr>
- {/if}
-
- {if $customGroup}
- {foreach from=$customGroup item=value key=customName}
- <tr>
- <th {$headerStyle}>
- {$customName}
- </th>
- </tr>
- {foreach from=$value item=v key=n}
- <tr>
- <td {$labelStyle}>
- {$n}
- </td>
- <td {$valueStyle}>
- {$v}
- </td>
- </tr>
- {/foreach}
- {/foreach}
- {/if}
-
- </table>
- </td>
- </tr>
-
- </table>
-</center>
-
-</body>
-</html>
+++ /dev/null
-{ts 1=$contact.display_name}Dear %1{/ts},
-
-{ts}Thank you for your generous pledge. Please print this acknowledgment for your records.{/ts}
-
-===========================================================
-{ts}Pledge Information{/ts}
-
-===========================================================
-{ts}Pledge Received{/ts}: {$create_date|truncate:10:''|crmDate}
-{ts}Total Pledge Amount{/ts}: {$total_pledge_amount|crmMoney:$currency}
-
-===========================================================
-{ts}Payment Schedule{/ts}
-
-===========================================================
-{ts 1=$scheduled_amount|crmMoney:$currency 2=$frequency_interval 3=$frequency_unit 4=$installments}%1 every %2 %3 for %4 installments.{/ts}
-
-{if $frequency_day}
-
-{ts 1=$frequency_day 2=$frequency_unit}Payments are due on day %1 of the %2.{/ts}
-{/if}
-
-{if $payments}
-{assign var="count" value="1"}
-{foreach from=$payments item=payment}
-
-{ts 1=$count}Payment %1{/ts}: {$payment.amount|crmMoney:$currency} {if $payment.status eq 1}{ts}paid{/ts} {$payment.receive_date|truncate:10:''|crmDate}{else}{ts}due{/ts} {$payment.due_date|truncate:10:''|crmDate}{/if}
-{assign var="count" value=`$count+1`}
-{/foreach}
-{/if}
-
-
-{ts 1=$domain.phone 2=$domain.email}Please contact us at %1 or send email to %2 if you have questions
-or need to modify your payment schedule.{/ts}
-
-{if $honor_block_is_active}
-===========================================================
-{$honor_type}
-===========================================================
-{$honor_prefix} {$honor_first_name} {$honor_last_name}
-{if $honor_email}
-{ts}Honoree Email{/ts}: {$honor_email}
-{/if}
-{/if}
-
-{if $customGroup}
-{foreach from=$customGroup item=value key=customName}
-===========================================================
-{$customName}
-===========================================================
-{foreach from=$value item=v key=n}
-{$n}: {$v}
-{/foreach}
-{/foreach}
-{/if}
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
- <!-- BEGIN HEADER -->
- <!-- You can add table row(s) here with logo or other header elements -->
- <!-- END HEADER -->
-
- <!-- BEGIN CONTENT -->
-
- <tr>
- <td>
- <p>{ts 1=$contact.display_name}Dear %1{/ts},</p>
- <p>{ts 1=$next_payment|truncate:10:''|crmDate}This is a reminder that the next payment on your pledge is due on %1.{/ts}</p>
- </td>
- </tr>
- <tr>
- <td>
- <table style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse; width:100%;">
- <tr>
- <th {$headerStyle}>
- {ts}Payment Due{/ts}
- </th>
- </tr>
- <tr>
- <td {$labelStyle}>
- {ts}Amount Due{/ts}
- </td>
- <td {$valueStyle}>
- {$amount_due|crmMoney:$currency}
- </td>
- </tr>
- </table>
- </td>
- </tr>
-
- <tr>
- <td>
- {if $contribution_page_id}
- {capture assign=contributionUrl}{crmURL p='civicrm/contribute/transact' q="reset=1&id=`$contribution_page_id`&cid=`$contact.contact_id`&pledgeId=`$pledge_id`&cs=`$checksumValue`" a=true h=0}{/capture}
- <p><a href="{$contributionUrl}">{ts}Go to a web page where you can make your payment online{/ts}</a></p>
- {else}
- <p>{ts}Please mail your payment to{/ts}: {$domain.address}</p>
- {/if}
- </td>
- </tr>
-
- <tr>
- <td>
- <table style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse; width:100%;">
- <tr>
- <th {$headerStyle}>
- {ts}Pledge Information{/ts}
- </th>
- </tr>
- <tr>
- <td {$labelStyle}>
- {ts}Pledge Received{/ts}
- </td>
- <td {$valueStyle}>
- {$create_date|truncate:10:''|crmDate}
- </td>
- </tr>
- <tr>
- <td {$labelStyle}>
- {ts}Total Pledge Amount{/ts}
- </td>
- <td {$valueStyle}>
- {$amount|crmMoney:$currency}
- </td>
- </tr>
- <tr>
- <td {$labelStyle}>
- {ts}Total Paid{/ts}
- </td>
- <td {$valueStyle}>
- {$amount_paid|crmMoney:$currency}
- </td>
- </tr>
- </table>
- </td>
- </tr>
-
- <tr>
- <td>
- <p>{ts 1=$domain.phone 2=$domain.email}Please contact us at %1 or send email to %2 if you have questions
-or need to modify your payment schedule.{/ts}</p>
- <p>{ts}Thank your for your generous support.{/ts}</p>
- </td>
- </tr>
-
- </table>
-</center>
-
-</body>
-</html>
+++ /dev/null
-{ts 1=$contact.display_name}Dear %1{/ts},
-
-{ts 1=$next_payment|truncate:10:''|crmDate}This is a reminder that the next payment on your pledge is due on %1.{/ts}
-
-===========================================================
-{ts}Payment Due{/ts}
-
-===========================================================
-{ts}Amount Due{/ts}: {$amount_due|crmMoney:$currency}
-{ts}Due Date{/ts}: {$scheduled_payment_date|truncate:10:''|crmDate}
-
-{if $contribution_page_id}
-{capture assign=contributionUrl}{crmURL p='civicrm/contribute/transact' q="reset=1&id=`$contribution_page_id`&cid=`$contact.contact_id`&pledgeId=`$pledge_id`&cs=`$checksumValue`" a=true h=0}{/capture}
-Click this link to go to a web page where you can make your payment online:
-{$contributionUrl}
-{else}
-{ts}Please mail your payment to{/ts}:
-{$domain.address}
-{/if}
-
-===========================================================
-{ts}Pledge Information{/ts}
-
-===========================================================
-{ts}Pledge Received{/ts}: {$create_date|truncate:10:''|crmDate}
-{ts}Total Pledge Amount{/ts}: {$amount|crmMoney:$currency}
-{ts}Total Paid{/ts}: {$amount_paid|crmMoney:$currency}
-
-{ts 1=$domain.phone 2=$domain.email}Please contact us at %1 or send email to %2 if you have questions
-or need to modify your payment schedule.{/ts}
-
-
-{ts}Thank your for your generous support.{/ts}
+++ /dev/null
-{php}
- $dir = SMARTY_DIR . '/../../CRM/Upgrade/4.2.alpha2.msg_template/message_templates';
- $templates = array();
- foreach (preg_grep('/\.tpl$/', scandir($dir)) as $filename) {
- $parts = explode('_', basename($filename, '.tpl'));
- $templates[] = array('type' => array_pop($parts), 'name' => implode('_', $parts), 'filename' => "$dir/$filename");
- }
- $this->assign('templates', $templates);
-{/php}
-
-{foreach from=$templates item=tpl}
- {fetch assign=content file=$tpl.filename}
- SELECT @workflow_id := MAX(id) FROM civicrm_option_value WHERE name = '{$tpl.name}';
- SELECT @content := msg_{$tpl.type} FROM civicrm_msg_template WHERE workflow_id = @workflow_id AND is_reserved = 1 LIMIT 1;
- UPDATE civicrm_msg_template SET msg_{$tpl.type} = '{$content|escape:"quotes"}' WHERE workflow_id = @workflow_id AND (is_reserved = 1 OR (is_default = 1 AND msg_{$tpl.type} = @content));
-{/foreach}
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
- <!-- BEGIN HEADER -->
- <!-- You can add table row(s) here with logo or other header elements -->
- <!-- END HEADER -->
-
- <!-- BEGIN CONTENT -->
-
- <tr>
- <td>
-
- {if $event.confirm_email_text AND (not $isOnWaitlist AND not $isRequireApproval)}
- <p>{$event.confirm_email_text|htmlize}</p>
- {/if}
-
- {if $isOnWaitlist}
- <p>{ts}You have been added to the WAIT LIST for this event.{/ts}</p>
- {if $isPrimary}
- <p>{ts}If space becomes available you will receive an email with a link to a web page where you can complete your registration.{/ts}</p>
- {/if}
- {elseif $isRequireApproval}
- <p>{ts}Your registration has been submitted.{/ts}</p>
- {if $isPrimary}
- <p>{ts}Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.{/ts}</p>
- {/if}
- {elseif $is_pay_later}
- <p>{$pay_later_receipt}</p> {* FIXME: this might be text rather than HTML *}
- {else}
- <p>{ts}Please print this confirmation for your records.{/ts}</p>
- {/if}
-
- </td>
- </tr>
- <tr>
- <td>
- <table style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse; width:100%;">
- <tr>
- <th {$headerStyle}>
- {ts}Event Information and Location{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {$event.event_title}<br />
- {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if}
- </td>
- </tr>
-
- {if $event.participant_role neq 'Attendee' and $defaultRole}
- <tr>
- <td {$labelStyle}>
- {ts}Participant Role{/ts}
- </td>
- <td {$valueStyle}>
- {$event.participant_role}
- </td>
- </tr>
- {/if}
-
- {if $isShowLocation}
- <tr>
- <td colspan="2" {$valueStyle}>
- {if $location.address.1.name}
- {$location.address.1.name}<br />
- {/if}
- {if $location.address.1.street_address}
- {$location.address.1.street_address}<br />
- {/if}
- {if $location.address.1.supplemental_address_1}
- {$location.address.1.supplemental_address_1}<br />
- {/if}
- {if $location.address.1.supplemental_address_2}
- {$location.address.1.supplemental_address_2}<br />
- {/if}
- {if $location.address.1.city}
- {$location.address.1.city} {$location.address.1.postal_code}{if $location.address.1.postal_code_suffix} - {$location.address.1.postal_code_suffix}{/if}<br />
- {/if}
- </td>
- </tr>
- {/if}
-
- {if $location.phone.1.phone || $location.email.1.email}
- <tr>
- <td colspan="2" {$labelStyle}>
- {ts}Event Contacts:{/ts}
- </td>
- </tr>
- {foreach from=$location.phone item=phone}
- {if $phone.phone}
- <tr>
- <td {$labelStyle}>
- {if $phone.phone_type}
- {$phone.phone_type_display}
- {else}
- {ts}Phone{/ts}
- {/if}
- </td>
- <td {$valueStyle}>
- {$phone.phone}
- </td>
- </tr>
- {/if}
- {/foreach}
- {foreach from=$location.email item=eventEmail}
- {if $eventEmail.email}
- <tr>
- <td {$labelStyle}>
- {ts}Email{/ts}
- </td>
- <td {$valueStyle}>
- {$eventEmail.email}
- </td>
- </tr>
- {/if}
- {/foreach}
- {/if}
- <tr>
- <td colspan="2" {$valueStyle}>
- {capture assign=icalFeed}{crmURL p='civicrm/event/ical' q="reset=1&id=`$event.id`" h=0 a=1 fe=1}{/capture}
- <a href="{$icalFeed}">{ts}Download iCalendar File{/ts}</a>
- </td>
- </tr>
- {if $email}
- <tr>
- <th {$headerStyle}>
- {ts}Registered Email{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {$email}
- </td>
- </tr>
- {/if}
-
-
- {if $event.is_monetary}
-
- <tr>
- <th {$headerStyle}>
- {$event.fee_label}
- </th>
- </tr>
-
- {if $lineItem}
- {foreach from=$lineItem item=value key=priceset}
- {if $value neq 'skip'}
- {if $isPrimary}
- {if $lineItem|@count GT 1} {* Header for multi participant registration cases. *}
- <tr>
- <td colspan="2" {$labelStyle}>
- {ts 1=$priceset+1}Participant %1{/ts}
- </td>
- </tr>
- {/if}
- {/if}
- <tr>
- <td colspan="2" {$valueStyle}>
- <table> {* FIXME: style this table so that it looks like the text version (justification, etc.) *}
- <tr>
- <th>{ts}Item{/ts}</th>
- <th>{ts}Qty{/ts}</th>
- <th>{ts}Each{/ts}</th>
- <th>{ts}Total{/ts}</th>
- {if $pricesetFieldsCount }<th>{ts}Total Participants{/ts}</th>{/if}
- </tr>
- {foreach from=$value item=line}
- <tr>
- <td>
- {if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description}<div>{$line.description|truncate:30:"..."}</div>{/if}
- </td>
- <td>
- {$line.qty}
- </td>
- <td>
- {$line.unit_price|crmMoney}
- </td>
- <td>
- {$line.line_total|crmMoney}
- </td>
- {if $pricesetFieldsCount }
- <td>
- {$line.participant_count}
- </td>
- {/if}
- </tr>
- {/foreach}
- </table>
- </td>
- </tr>
- {/if}
- {/foreach}
- {/if}
-
- {if $amount && !$lineItem}
- {foreach from=$amount item=amnt key=level}
- <tr>
- <td colspan="2" {$valueStyle}>
- {$amnt.amount|crmMoney} {$amnt.label}
- </td>
- </tr>
- {/foreach}
- {/if}
- {if $isPrimary}
- <tr>
- <td {$labelStyle}>
- {ts}Total Amount{/ts}
- </td>
- <td {$valueStyle}>
- {$totalAmount|crmMoney} {if $hookDiscount.message}({$hookDiscount.message}){/if}
- </td>
- </tr>
- {if $pricesetFieldsCount }
- <tr>
- <td {$labelStyle}>
- {ts}Total Participants{/ts}</td>
- <td {$valueStyle}>
- {assign var="count" value= 0}
- {foreach from=$lineItem item=pcount}
- {assign var="lineItemCount" value=0}
- {if $pcount neq 'skip'}
- {foreach from=$pcount item=p_count}
- {assign var="lineItemCount" value=$lineItemCount+$p_count.participant_count}
- {/foreach}
- {if $lineItemCount < 1 }
- assign var="lineItemCount" value=1}
- {/if}
- {assign var="count" value=$count+$lineItemCount}
- {/if}
- {/foreach}
- {$count}
- </td>
- </tr>
- {/if}
- {if $is_pay_later}
- <tr>
- <td colspan="2" {$labelStyle}>
- {$pay_later_receipt}
- </td>
- </tr>
- {/if}
-
- {if $register_date}
- <tr>
- <td {$labelStyle}>
- {ts}Registration Date{/ts}
- </td>
- <td {$valueStyle}>
- {$register_date|crmDate}
- </td>
- </tr>
- {/if}
-
- {if $receive_date}
- <tr>
- <td {$labelStyle}>
- {ts}Transaction Date{/ts}
- </td>
- <td {$valueStyle}>
- {$receive_date|crmDate}
- </td>
- </tr>
- {/if}
-
- {if $contributionTypeName}
- <tr>
- <td {$labelStyle}>
- {ts}Contribution Type{/ts}
- </td>
- <td {$valueStyle}>
- {$contributionTypeName}
- </td>
- </tr>
- {/if}
-
- {if $trxn_id}
- <tr>
- <td {$labelStyle}>
- {ts}Transaction #{/ts}
- </td>
- <td {$valueStyle}>
- {$trxn_id}
- </td>
- </tr>
- {/if}
-
- {if $paidBy}
- <tr>
- <td {$labelStyle}>
- {ts}Paid By{/ts}
- </td>
- <td {$valueStyle}>
- {$paidBy}
- </td>
- </tr>
- {/if}
-
- {if $checkNumber}
- <tr>
- <td {$labelStyle}>
- {ts}Check Number{/ts}
- </td>
- <td {$valueStyle}>
- {$checkNumber}
- </td>
- </tr>
- {/if}
-
- {if $contributeMode ne 'notify' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
- <tr>
- <th {$headerStyle}>
- {ts}Billing Name and Address{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {$billingName}<br />
- {$address|nl2br}
- </td>
- </tr>
- {/if}
-
- {if $contributeMode eq 'direct' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
- <tr>
- <th {$headerStyle}>
- {ts}Credit Card Information{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {$credit_card_type}<br />
- {$credit_card_number}<br />
- {ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
- </td>
- </tr>
- {/if}
-
- {/if}
-
- {/if} {* End of conditional section for Paid events *}
-
- {if $customPre}
- <tr>
- <th {$headerStyle}>
- {$customPre_grouptitle}
- </th>
- </tr>
- {foreach from=$customPre item=value key=customName}
- {if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- <tr>
- <td {$labelStyle}>
- {$customName}
- </td>
- <td {$valueStyle}>
- {$value}
- </td>
- </tr>
- {/if}
- {/foreach}
- {/if}
-
- {if $customPost}
- <tr>
- <th {$headerStyle}>
- {$customPost_grouptitle}
- </th>
- </tr>
- {foreach from=$customPost item=value key=customName}
- {if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- <tr>
- <td {$labelStyle}>
- {$customName}
- </td>
- <td {$valueStyle}>
- {$value}
- </td>
- </tr>
- {/if}
- {/foreach}
- {/if}
-
- {if $customProfile}
- {foreach from=$customProfile item=value key=customName}
- <tr>
- <th {$headerStyle}>
- {ts 1=$customName+1}Participant Information - Participant %1{/ts}
- </th>
- </tr>
- {foreach from=$value item=val key=field}
- {if $field eq 'additionalCustomPre' or $field eq 'additionalCustomPost'}
- <tr>
- <td colspan="2" {$labelStyle}>
- {if $field eq 'additionalCustomPre'}
- {$additionalCustomPre_grouptitle}
- {else}
- {$additionalCustomPost_grouptitle}
- {/if}
- </td>
- </tr>
- {foreach from=$val item=v key=f}
- <tr>
- <td {$labelStyle}>
- {$f}
- </td>
- <td {$valueStyle}>
- {$v}
- </td>
- </tr>
- {/foreach}
- {/if}
- {/foreach}
- {/foreach}
- {/if}
-
- {if $customGroup}
- {foreach from=$customGroup item=value key=customName}
- <tr>
- <th {$headerStyle}>
- {$customName}
- </th>
- </tr>
- {foreach from=$value item=v key=n}
- <tr>
- <td {$labelStyle}>
- {$n}
- </td>
- <td {$valueStyle}>
- {$v}
- </td>
- </tr>
- {/foreach}
- {/foreach}
- {/if}
-
- </table>
- </td>
- </tr>
-
- </table>
-</center>
-
-</body>
-</html>
+++ /dev/null
-{if $event.confirm_email_text AND (not $isOnWaitlist AND not $isRequireApproval)}
-{$event.confirm_email_text}
-{/if}
-
-{if $isOnWaitlist}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}You have been added to the WAIT LIST for this event.{/ts}
-
-{if $isPrimary}
-{ts}If space becomes available you will receive an email with a link to a web page where you can complete your registration.{/ts}
-
-{/if}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{elseif $isRequireApproval}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Your registration has been submitted.{/ts}
-
-{if $isPrimary}
-{ts}Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.{/ts}
-
-{/if}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{elseif $is_pay_later}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$pay_later_receipt}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{else}
-
-{ts}Please print this confirmation for your records.{/ts}
-{/if}
-
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Event Information and Location{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$event.event_title}
-{$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if}
-
-{if $event.participant_role neq 'Attendee' and $defaultRole}
-{ts}Participant Role{/ts}: {$event.participant_role}
-{/if}
-
-{if $isShowLocation}
-{if $location.address.1.name}
-
-{$location.address.1.name}
-{/if}
-{if $location.address.1.street_address}{$location.address.1.street_address}
-{/if}
-{if $location.address.1.supplemental_address_1}{$location.address.1.supplemental_address_1}
-{/if}
-{if $location.address.1.supplemental_address_2}{$location.address.1.supplemental_address_2}
-{/if}
-{if $location.address.1.city}{$location.address.1.city} {$location.address.1.postal_code}{if $location.address.1.postal_code_suffix} - {$location.address.1.postal_code_suffix}{/if}
-{/if}
-
-{/if}{*End of isShowLocation condition*}
-
-{if $location.phone.1.phone || $location.email.1.email}
-
-{ts}Event Contacts:{/ts}
-{foreach from=$location.phone item=phone}
-{if $phone.phone}
-
-{if $phone.phone_type}{$phone.phone_type_display}{else}{ts}Phone{/ts}{/if}: {$phone.phone}{/if}
-{/foreach}
-{foreach from=$location.email item=eventEmail}
-{if $eventEmail.email}
-
-{ts}Email{/ts}: {$eventEmail.email}{/if}{/foreach}
-{/if}
-
-{capture assign=icalFeed}{crmURL p='civicrm/event/ical' q="reset=1&id=`$event.id`" h=0 a=1 fe=1}{/capture}
-{ts}Download iCalendar File:{/ts} {$icalFeed}
-{if $email}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Registered Email{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$email}
-{/if}
-{if $event.is_monetary} {* This section for Paid events only.*}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$event.fee_label}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{if $lineItem}{foreach from=$lineItem item=value key=priceset}
-
-{if $value neq 'skip'}
-{if $isPrimary}
-{if $lineItem|@count GT 1} {* Header for multi participant registration cases. *}
-{ts 1=$priceset+1}Participant %1{/ts}
-{/if}
-{/if}
----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{capture assign=ts_item}{ts}Item{/ts}{/capture}
-{capture assign=ts_qty}{ts}Qty{/ts}{/capture}
-{capture assign=ts_each}{ts}Each{/ts}{/capture}
-{capture assign=ts_total}{ts}Total{/ts}{/capture}
-{capture assign=ts_participant_total}{if $pricesetFieldsCount }{ts}Total Participants{/ts}{/if}{/capture}
-{$ts_item|string_format:"%-30s"} {$ts_qty|string_format:"%5s"} {$ts_each|string_format:"%10s"} {$ts_total|string_format:"%10s"} {$ts_participant_total|string_format:"%10s"}
-----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{foreach from=$value item=line}
-{if $pricesetFieldsCount }{capture assign=ts_participant_count}{$line.participant_count}{/capture}{/if}
-{capture assign=ts_item}{if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description} {$line.description}{/if}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.qty|string_format:"%5s"} {$line.unit_price|crmMoney|string_format:"%10s"} {$line.line_total|crmMoney|string_format:"%10s"} {$ts_participant_count|string_format:"%10s"}
-{/foreach}
-{/if}
-{/foreach}
-{/if}
-{if $amount && !$lineItem}
-{foreach from=$amount item=amnt key=level}{$amnt.amount|crmMoney} {$amnt.label}
-{/foreach}
-{/if}
-{if $isPrimary }
-
-{ts}Total Amount{/ts}: {$totalAmount|crmMoney} {if $hookDiscount.message}({$hookDiscount.message}){/if}
-
-{if $pricesetFieldsCount }
- {assign var="count" value= 0}
- {foreach from=$lineItem item=pcount}
- {assign var="lineItemCount" value=0}
- {if $pcount neq 'skip'}
- {foreach from=$pcount item=p_count}
- {assign var="lineItemCount" value=$lineItemCount+$p_count.participant_count}
- {/foreach}
- {if $lineItemCount < 1 }
- {assign var="lineItemCount" value=1}
- {/if}
- {assign var="count" value=$count+$lineItemCount}
- {/if}
- {/foreach}
-
-{ts}Total Participants{/ts}: {$count}
-{/if}
-
-{if $is_pay_later }
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$pay_later_receipt}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{/if}
-
-{if $register_date}
-{ts}Registration Date{/ts}: {$register_date|crmDate}
-{/if}
-{if $receive_date}
-{ts}Transaction Date{/ts}: {$receive_date|crmDate}
-{/if}
-{if $contributionTypeName}
-{ts}Contribution Type{/ts}: {$contributionTypeName}
-{/if}
-{if $trxn_id}
-{ts}Transaction #{/ts}: {$trxn_id}
-{/if}
-{if $paidBy}
-{ts}Paid By{/ts}: {$paidBy}
-{/if}
-{if $checkNumber}
-{ts}Check Number{/ts}: {$checkNumber}
-{/if}
-{if $contributeMode ne 'notify' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Billing Name and Address{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$billingName}
-{$address}
-{/if}
-
-{if $contributeMode eq 'direct' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
-===========================================================
-{ts}Credit Card Information{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$credit_card_type}
-{$credit_card_number}
-{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
-{/if}
-{/if}
-{/if} {* End of conditional section for Paid events *}
-
-{if $customPre}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$customPre_grouptitle}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$customPre item=value key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
-{$customName}: {$value}
-{/if}
-{/foreach}
-{/if}
-
-{if $customPost}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$customPost_grouptitle}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$customPost item=value key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
-{$customName}: {$value}
-{/if}
-{/foreach}
-{/if}
-{if $customProfile}
-
-{foreach from=$customProfile item=value key=customName}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts 1=$customName+1}Participant Information - Participant %1{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$value item=val key=field}
-{if $field eq 'additionalCustomPre' or $field eq 'additionalCustomPost' }
-{if $field eq 'additionalCustomPre' }
-----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{$additionalCustomPre_grouptitle}
-----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{else}
-----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{$additionalCustomPost_grouptitle}
-----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{/if}
-{foreach from=$val item=v key=f}
-{$f}: {$v}
-{/foreach}
-{/if}
-{/foreach}
-{/foreach}
-{/if}
-{if $customGroup}
-{foreach from=$customGroup item=value key=customName}
-=========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$customName}
-=========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$value item=v key=n}
-{$n}: {$v}
-{/foreach}
-{/foreach}
-{/if}
-
-
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="500" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
- <!-- BEGIN HEADER -->
- <!-- You can add table row(s) here with logo or other header elements -->
- <!-- END HEADER -->
-
- <!-- BEGIN CONTENT -->
-
- <tr>
- <td>
- <p>Dear {contact.display_name},</p>
-
- {if $event.confirm_email_text AND (not $isOnWaitlist AND not $isRequireApproval)}
- <p>{$event.confirm_email_text|htmlize}</p>
-
- {else}
- <p>Thank you for your participation. This letter is a confirmation that your registration has been received and your status has been updated to <strong>{if $isOnWaitlist}waitlisted{else}registered{/if}</strong> for the following:</p>
-
- {/if}
-
- <p>
- {if $isOnWaitlist}
- <p>{ts}You have been added to the WAIT LIST for this event.{/ts}</p>
- {if $isPrimary}
- <p>{ts}If space becomes available you will receive an email with a link to a web page where you can complete your registration.{/ts}</p>
- {/if}
- {elseif $isRequireApproval}
- <p>{ts}Your registration has been submitted.{/ts}</p>
- {if $isPrimary}
- <p>{ts}Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.{/ts}</p>
- {/if}
- {elseif $is_pay_later && !$isAmountzero}
- <p>{$pay_later_receipt}</p> {* FIXME: this might be text rather than HTML *}
- {else}
- <p>{ts}Please print this confirmation for your records.{/ts}</p>
- {/if}
-
- </td>
- </tr>
- <tr>
- <td>
- <table width="500" style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse;">
- <tr>
- <th {$headerStyle}>
- {ts}Event Information and Location{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {$event.event_title}<br />
- {$event.event_start_date|date_format:"%A"} {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|date_format:"%A"} {$event.event_end_date|crmDate}{/if}{/if}
- </td>
- </tr>
-
-
- {if $conference_sessions}
- <tr>
- <td colspan="2" {$labelStyle}>
- {ts}Your schedule:{/ts}
- </td>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {assign var='group_by_day' value='NA'}
- {foreach from=$conference_sessions item=session}
- {if $session.start_date|date_format:"%Y/%m/%d" != $group_by_day|date_format:"%Y/%m/%d"}
- {assign var='group_by_day' value=$session.start_date}
- <em>{$group_by_day|date_format:"%m/%d/%Y"}</em><br />
- {/if}
- {$session.start_date|crmDate:0:1}{if $session.end_date}-{$session.end_date|crmDate:0:1}{/if} {$session.title}<br />
- {if $session.location} {$session.location}<br />{/if}
- {/foreach}
- </td>
- </tr>
- {/if}
-
- {if $event.participant_role neq 'Attendee' and $defaultRole}
- <tr>
- <td {$labelStyle}>
- {ts}Participant Role{/ts}
- </td>
- <td {$valueStyle}>
- {$event.participant_role}
- </td>
- </tr>
- {/if}
-
- {if $isShowLocation}
- <tr>
- <td colspan="2" {$valueStyle}>
- {if $location.address.1.name}
- {$location.address.1.name}<br />
- {/if}
- {if $location.address.1.street_address}
- {$location.address.1.street_address}<br />
- {/if}
- {if $location.address.1.supplemental_address_1}
- {$location.address.1.supplemental_address_1}<br />
- {/if}
- {if $location.address.1.supplemental_address_2}
- {$location.address.1.supplemental_address_2}<br />
- {/if}
- {if $location.address.1.city}
- {$location.address.1.city}, {$location.address.1.state_province} {$location.address.1.postal_code}{if $location.address.1.postal_code_suffix} - {$location.address.1.postal_code_suffix}{/if}<br />
- {/if}
- </td>
- </tr>
- {/if}
-
- {if $location.phone.1.phone || $location.email.1.email}
- <tr>
- <td colspan="2" {$labelStyle}>
- {ts}Event Contacts:{/ts}
- </td>
- </tr>
- {foreach from=$location.phone item=phone}
- {if $phone.phone}
- <tr>
- <td {$labelStyle}>
- {if $phone.phone_type}
- {$phone.phone_type_display}
- {else}
- {ts}Phone{/ts}
- {/if}
- </td>
- <td {$valueStyle}>
- {$phone.phone}
- </td>
- </tr>
- {/if}
- {/foreach}
- {foreach from=$location.email item=eventEmail}
- {if $eventEmail.email}
- <tr>
- <td {$labelStyle}>
- {ts}Email{/ts}
- </td>
- <td {$valueStyle}>
- {$eventEmail.email}
- </td>
- </tr>
- {/if}
- {/foreach}
- {/if}
- <tr>
- <td colspan="2" {$valueStyle}>
- {capture assign=icalFeed}{crmURL p='civicrm/event/ical' q="reset=1&id=`$event.id`" h=0 a=1 fe=1}{/capture}
- <a href="{$icalFeed}">{ts}Download iCalendar File{/ts}</a>
- </td>
- </tr>
- {if $event.is_share}
- <tr>
- <td colspan="2" {$valueStyle}>
- {capture assign=eventUrl}{crmURL p='civicrm/event/info' q="id=`$event.id`&reset=1" a=true fe=1 h=1}{/capture}
- {include file="CRM/common/SocialNetwork.tpl" emailMode=true url=$eventUrl title=$event.title pageURL=$eventUrl}
- </td>
- </tr>
- {/if}
- {if $payer.name}
- <tr>
- <th {$headerStyle}>
- {ts}You were registered by:{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {$payer.name}
- </td>
- </tr>
- {/if}
- {if $event.is_monetary}
-
- <tr>
- <th {$headerStyle}>
- {$event.fee_label}
- </th>
- </tr>
-
- {if $lineItem}
- {foreach from=$lineItem item=value key=priceset}
- {if $value neq 'skip'}
- {if $isPrimary}
- {if $lineItem|@count GT 1} {* Header for multi participant registration cases. *}
- <tr>
- <td colspan="2" {$labelStyle}>
- {ts 1=$priceset+1}Participant %1{/ts} {$part.$priceset.info}
- </td>
- </tr>
- {/if}
- {/if}
- <tr>
- <td colspan="2" {$valueStyle}>
- <table> {* FIXME: style this table so that it looks like the text version (justification, etc.) *}
- <tr>
- <th>{ts}Item{/ts}</th>
- <th>{ts}Qty{/ts}</th>
- <th>{ts}Each{/ts}</th>
- <th>{ts}Total{/ts}</th>
- {if $pricesetFieldsCount }<th>{ts}Total Participants{/ts}</th>{/if}
- </tr>
- {foreach from=$value item=line}
- <tr>
- <td>
- {if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description}<div>{$line.description|truncate:30:"..."}</div>{/if}
- </td>
- <td>
- {$line.qty}
- </td>
- <td>
- {$line.unit_price|crmMoney}
- </td>
- <td>
- {$line.line_total|crmMoney}
- </td>
- {if $pricesetFieldsCount }<td>{$line.participant_count}</td> {/if}
- </tr>
- {/foreach}
- </table>
- </td>
- </tr>
- {/if}
- {/foreach}
- {/if}
-
- {if $amounts && !$lineItem}
- {foreach from=$amounts item=amnt key=level}
- <tr>
- <td colspan="2" {$valueStyle}>
- {$amnt.amount|crmMoney} {$amnt.label}
- </td>
- </tr>
- {/foreach}
- {/if}
-
- {if $isPrimary}
- <tr>
- <td {$labelStyle}>
- {ts}Total Amount{/ts}
- </td>
- <td {$valueStyle}>
- {$totalAmount|crmMoney} {if $hookDiscount.message}({$hookDiscount.message}){/if}
- </td>
- </tr>
- {if $pricesetFieldsCount }
- <tr>
- <td {$labelStyle}>
- {ts}Total Participants{/ts}</td>
- <td {$valueStyle}>
- {assign var="count" value= 0}
- {foreach from=$lineItem item=pcount}
- {assign var="lineItemCount" value=0}
- {if $pcount neq 'skip'}
- {foreach from=$pcount item=p_count}
- {assign var="lineItemCount" value=$lineItemCount+$p_count.participant_count}
- {/foreach}
- {if $lineItemCount < 1 }
- {assign var="lineItemCount" value=1}
- {/if}
- {assign var="count" value=$count+$lineItemCount}
- {/if}
- {/foreach}
- {$count}
- </td> </tr>
- {/if}
- {if $is_pay_later}
- <tr>
- <td colspan="2" {$labelStyle}>
- {$pay_later_receipt}
- </td>
- </tr>
- {/if}
-
- {if $register_date}
- <tr>
- <td {$labelStyle}>
- {ts}Registration Date{/ts}
- </td>
- <td {$valueStyle}>
- {$register_date|crmDate}
- </td>
- </tr>
- {/if}
-
- {if $receive_date}
- <tr>
- <td {$labelStyle}>
- {ts}Transaction Date{/ts}
- </td>
- <td {$valueStyle}>
- {$receive_date|crmDate}
- </td>
- </tr>
- {/if}
-
- {if $contributionTypeName}
- <tr>
- <td {$labelStyle}>
- {ts}Contribution Type{/ts}
- </td>
- <td {$valueStyle}>
- {$contributionTypeName}
- </td>
- </tr>
- {/if}
-
- {if $trxn_id}
- <tr>
- <td {$labelStyle}>
- {ts}Transaction #{/ts}
- </td>
- <td {$valueStyle}>
- {$trxn_id}
- </td>
- </tr>
- {/if}
-
- {if $paidBy}
- <tr>
- <td {$labelStyle}>
- {ts}Paid By{/ts}
- </td>
- <td {$valueStyle}>
- {$paidBy}
- </td>
- </tr>
- {/if}
-
- {if $checkNumber}
- <tr>
- <td {$labelStyle}>
- {ts}Check Number{/ts}
- </td>
- <td {$valueStyle}>
- {$checkNumber}
- </td>
- </tr>
- {/if}
-
- {if $contributeMode ne 'notify' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
- <tr>
- <th {$headerStyle}>
- {ts}Billing Name and Address{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {$billingName}<br />
- {$address|nl2br}
- </td>
- </tr>
- {/if}
-
- {if $contributeMode eq 'direct' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
- <tr>
- <th {$headerStyle}>
- {ts}Credit Card Information{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {$credit_card_type}<br />
- {$credit_card_number}<br />
- {ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
- </td>
- </tr>
- {/if}
-
- {/if}
-
- {/if} {* End of conditional section for Paid events *}
-
-
-{if $customPre}
-{foreach from=$customPre item=customPr key=i}
- <tr> <th {$headerStyle}>{$customPre_grouptitle.$i}</th></tr>
- {foreach from=$customPr item=customValue key=customName}
- {if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- <tr>
- <td {$labelStyle}>{$customName}</td>
- <td {$valueStyle}>{$customValue}</td>
- </tr>
- {/if}
- {/foreach}
-{/foreach}
-{/if}
-
-{if $customPost}
-{foreach from=$customPost item=customPos key=j}
- <tr> <th {$headerStyle}>{$customPost_grouptitle.$j}</th></tr>
- {foreach from=$customPos item=customValue key=customName}
- {if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- <tr>
- <td {$labelStyle}>{$customName}</td>
- <td {$valueStyle}>{$customValue}</td>
- </tr>
-{/if}
-{/foreach}
-{/foreach}
-{/if}
-
-{if $customProfile}
-{foreach from=$customProfile.profile item=eachParticipant key=participantID}
- <tr><th {$headerStyle}>{ts 1=$participantID+2}Participant %1{/ts} </th></tr>
- {foreach from=$eachParticipant item=eachProfile key=pid}
- <tr><th {$headerStyle}>{$customProfile.title.$pid}</th></tr>
- {foreach from=$eachProfile item=val key=field}
- <tr>{foreach from=$val item=v key=f}
- <td {$labelStyle}>{$field}</td>
- <td {$valueStyle}>{$v}</td>
- {/foreach}
- </tr>
- {/foreach}
-{/foreach}
-{/foreach}
-{/if}
-
- {if $customGroup}
- {foreach from=$customGroup item=value key=customName}
- <tr>
- <th {$headerStyle}>
- {$customName}
- </th>
- </tr>
- {foreach from=$value item=v key=n}
- <tr>
- <td {$labelStyle}>
- {$n}
- </td>
- <td {$valueStyle}>
- {$v}
- </td>
- </tr>
- {/foreach}
- {/foreach}
- {/if}
-
- </table>
- </td>
- </tr>
- </table>
-</center>
-
-</body>
-</html>
+++ /dev/null
-Dear {contact.display_name},
-
-{if $event.confirm_email_text AND (not $isOnWaitlist AND not $isRequireApproval)}
-{$event.confirm_email_text}
-
-{else}
-Thank you for your participation. This letter is a confirmation that your registration has been received and your status has been updated to {if $participant_status}$participant_status{else}{if $isOnWaitlist}waitlisted{else}registered{/if}{/if} for the following:
-
-{/if}
-
-{if $isOnWaitlist}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}You have been added to the WAIT LIST for this event.{/ts}
-
-{if $isPrimary}
-{ts}If space becomes available you will receive an email with a link to a web page where you can complete your registration.{/ts}
-{/if}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{elseif $isRequireApproval}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Your registration has been submitted.{/ts}
-
-{if $isPrimary}
-{ts}Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.{/ts}
-
-{/if}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{elseif $is_pay_later && !$isAmountzero}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$pay_later_receipt}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{else}
-
-{ts}Please print this confirmation for your records.{/ts}
-{/if}
-
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Event Information and Location{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$event.event_title}
-{$event.event_start_date|date_format:"%A"} {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|date_format:"%A"} {$event.event_end_date|crmDate}{/if}{/if}
-{if $conference_sessions}
-
-
-{ts}Your schedule:{/ts}
-{assign var='group_by_day' value='NA'}
-{foreach from=$conference_sessions item=session}
-{if $session.start_date|date_format:"%Y/%m/%d" != $group_by_day|date_format:"%Y/%m/%d"}
-{assign var='group_by_day' value=$session.start_date}
-
-{$group_by_day|date_format:"%m/%d/%Y"}
-
-
-{/if}
-{$session.start_date|crmDate:0:1}{if $session.end_date}-{$session.end_date|crmDate:0:1}{/if} {$session.title}
-{if $session.location} {$session.location}{/if}
-{/foreach}
-{/if}
-
-{if $event.participant_role neq 'Attendee' and $defaultRole}
-{ts}Participant Role{/ts}: {$event.participant_role}
-{/if}
-
-{if $isShowLocation}
-{if $location.address.1.name}
-
-{$location.address.1.name}
-{/if}
-{if $location.address.1.street_address}{$location.address.1.street_address}
-{/if}
-{if $location.address.1.supplemental_address_1}{$location.address.1.supplemental_address_1}
-{/if}
-{if $location.address.1.supplemental_address_2}{$location.address.1.supplemental_address_2}
-{/if}
-{if $location.address.1.city}{$location.address.1.city}, {$location.address.1.state_province} {$location.address.1.postal_code}{if $location.address.1.postal_code_suffix} - {$location.address.1.postal_code_suffix}{/if}
-{/if}
-
-{/if}{*End of isShowLocation condition*}
-
-{if $location.phone.1.phone || $location.email.1.email}
-
-{ts}Event Contacts:{/ts}
-{foreach from=$location.phone item=phone}
-{if $phone.phone}
-
-{if $phone.phone_type}{$phone.phone_type_display}{else}{ts}Phone{/ts}{/if}: {$phone.phone}{/if}
-{/foreach}
-{foreach from=$location.email item=eventEmail}
-{if $eventEmail.email}
-
-{ts}Email{/ts}: {$eventEmail.email}{/if}{/foreach}
-{/if}
-
-{capture assign=icalFeed}{crmURL p='civicrm/event/ical' q="reset=1&id=`$event.id`" h=0 a=1 fe=1}{/capture}
-{ts}Download iCalendar File:{/ts} {$icalFeed}
-
-{if $payer.name}
-You were registered by: {$payer.name}
-{/if}
-{if $event.is_monetary} {* This section for Paid events only.*}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$event.fee_label}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{if $lineItem}{foreach from=$lineItem item=value key=priceset}
-
-{if $value neq 'skip'}
-{if $isPrimary}
-{if $lineItem|@count GT 1} {* Header for multi participant registration cases. *}
-{ts 1=$priceset+1}Participant %1{/ts} {$part.$priceset.info}
-
-{/if}
-{/if}
------------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{capture assign=ts_item}{ts}Item{/ts}{/capture}
-{capture assign=ts_qty}{ts}Qty{/ts}{/capture}
-{capture assign=ts_each}{ts}Each{/ts}{/capture}
-{capture assign=ts_total}{ts}Total{/ts}{/capture}
-{if $pricesetFieldsCount }{capture assign=ts_participant_total}{ts}Total Participants{/ts}{/capture}{/if}
-{$ts_item|string_format:"%-30s"} {$ts_qty|string_format:"%5s"} {$ts_each|string_format:"%10s"} {$ts_total|string_format:"%10s"} {$ts_participant_total|string_format:"%10s"}
------------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{foreach from=$value item=line}
-{if $pricesetFieldsCount }{capture assign=ts_participant_count}{$line.participant_count}{/capture}{/if}
-{capture assign=ts_item}{if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description} {$line.description}{/if}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.qty|string_format:"%5s"} {$line.unit_price|crmMoney|string_format:"%10s"} {$line.line_total|crmMoney|string_format:"%10s"}{$ts_participant_count|string_format:"%10s"}
-{/foreach}
-{/if}
-{/foreach}
-{/if}
-{if $amounts && !$lineItem}
-{foreach from=$amounts item=amnt key=level}{$amnt.amount|crmMoney} {$amnt.label}
-{/foreach}
-{/if}
-{if $isPrimary }
-
-{ts}Total Amount{/ts}: {$totalAmount|crmMoney} {if $hookDiscount.message}({$hookDiscount.message}){/if}
-
-{if $pricesetFieldsCount }
- {assign var="count" value= 0}
- {foreach from=$lineItem item=pcount}
- {assign var="lineItemCount" value=0}
- {if $pcount neq 'skip'}
- {foreach from=$pcount item=p_count}
- {assign var="lineItemCount" value=$lineItemCount+$p_count.participant_count}
- {/foreach}
- {if $lineItemCount < 1 }
- {assign var="lineItemCount" value=1}
- {/if}
- {assign var="count" value=$count+$lineItemCount}
- {/if}
- {/foreach}
-
-{ts}Total Participants{/ts}: {$count}
-{/if}
-
-{if $is_pay_later}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$pay_later_receipt}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{/if}
-
-{if $register_date}
-{ts}Registration Date{/ts}: {$register_date|crmDate}
-{/if}
-{if $receive_date}
-{ts}Transaction Date{/ts}: {$receive_date|crmDate}
-{/if}
-{if $contributionTypeName}
-{ts}Contribution Type{/ts}: {$contributionTypeName}
-{/if}
-{if $trxn_id}
-{ts}Transaction #{/ts}: {$trxn_id}
-{/if}
-{if $paidBy}
-{ts}Paid By{/ts}: {$paidBy}
-{/if}
-{if $checkNumber}
-{ts}Check Number{/ts}: {$checkNumber}
-{/if}
-{if $contributeMode ne 'notify' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Billing Name and Address{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$billingName}
-{$address}
-{/if}
-
-{if $contributeMode eq 'direct' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Credit Card Information{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$credit_card_type}
-{$credit_card_number}
-{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
-{/if}
-{/if}
-{/if} {* End of conditional section for Paid events *}
-
-{if $customPre}
-{foreach from=$customPre item=customPr key=i}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$customPre_grouptitle.$i}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$customPr item=customValue key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- {$customName}: {$customValue}
-{/if}
-{/foreach}
-{/foreach}
-{/if}
-
-{if $customPost}
-{foreach from=$customPost item=customPos key=j}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$customPost_grouptitle.$j}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$customPos item=customValue key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- {$customName}: {$customValue}
-{/if}
-{/foreach}
-{/foreach}
-{/if}
-{if $customProfile}
-
-{foreach from=$customProfile.profile item=eachParticipant key=participantID}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts 1=$participantID+2}Participant Information - Participant %1{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$eachParticipant item=eachProfile key=pid}
-----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{$customProfile.title.$pid}
-----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{foreach from=$eachProfile item=val key=field}
-{foreach from=$val item=v key=f}
-{$field}: {$v}
-{/foreach}
-{/foreach}
-{/foreach}
-{/foreach}
-{/if}
-{if $customGroup}
-{foreach from=$customGroup item=value key=customName}
-=========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$customName}
-=========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$value item=v key=n}
-{$n}: {$v}
-{/foreach}
-{/foreach}
-{/if}
+++ /dev/null
-{if $formValues.receipt_text_signup}
-{$formValues.receipt_text_signup}
-{elseif $formValues.receipt_text_renewal}
-{$formValues.receipt_text_renewal}
-{else}{ts}Thank you for your support.{/ts}{/if}
-
-{if ! $cancelled}{ts}Please print this receipt for your records.{/ts}
-
-
-{/if}
-{if !$lineItem}
-===========================================================
-{ts}Membership Information{/ts}
-
-===========================================================
-{ts}Membership Type{/ts}: {$membership_name}
-{/if}
-{if ! $cancelled}
-{if !$lineItem}
-{ts}Membership Start Date{/ts}: {$mem_start_date}
-{ts}Membership End Date{/ts}: {$mem_end_date}
-{/if}
-
-{if $formValues.total_amount}
-===========================================================
-{ts}Membership Fee{/ts}
-
-===========================================================
-{if $formValues.contributionType_name}
-{ts}Contribution Type{/ts}: {$formValues.contributionType_name}
-{/if}
-{if $lineItem}
-{foreach from=$lineItem item=value key=priceset}
-{capture assign=ts_item}{ts}Item{/ts}{/capture}
-{capture assign=ts_total}{ts}Fee{/ts}{/capture}
-{capture assign=ts_start_date}{ts}Membership Start Date{/ts}{/capture}
-{capture assign=ts_end_date}{ts}Membership End Date{/ts}{/capture}
-{$ts_item|string_format:"%-30s"} {$ts_total|string_format:"%10s"} {$ts_start_date|string_format:"%20s"} {$ts_end_date|string_format:"%20s"}
---------------------------------------------------------------------------------------------------
-
-{foreach from=$value item=line}
-{capture assign=ts_item}{if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description} {$line.description}{/if}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.line_total|crmMoney|string_format:"%10s"} {$line.start_date|string_format:"%20s"} {$line.end_date|string_format:"%20s"}
-{/foreach}
-{/foreach}
---------------------------------------------------------------------------------------------------
-{/if}
-{ts}Amount{/ts}: {$formValues.total_amount|crmMoney}
-{if $receive_date}
-{ts}Received Date{/ts}: {$receive_date|truncate:10:''|crmDate}
-{/if}
-{if $formValues.paidBy}
-{ts}Paid By{/ts}: {$formValues.paidBy}
-{if $formValues.check_number}
-{ts}Check Number{/ts}: {$formValues.check_number}
-{/if}
-{/if}
-{/if}
-{/if}
-
-{if $isPrimary }
-{if $contributeMode ne 'notify' and !$isAmountzero and !$is_pay_later }
-
-===========================================================
-{ts}Billing Name and Address{/ts}
-
-===========================================================
-{$billingName}
-{$address}
-{/if}
-
-{if $contributeMode eq 'direct' and !$isAmountzero and !$is_pay_later}
-===========================================================
-{ts}Credit Card Information{/ts}
-
-===========================================================
-{$credit_card_type}
-{$credit_card_number}
-{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
-{/if}
-{/if}
-
-{if $customValues}
-===========================================================
-{ts}Membership Options{/ts}
-
-===========================================================
-{foreach from=$customValues item=value key=customName}
- {$customName} : {$value}
-{/foreach}
-{/if}
+++ /dev/null
-{php}
- $dir = SMARTY_DIR . '/../../CRM/Upgrade/4.2.alpha3.msg_template/message_templates';
- $templates = array();
- foreach (preg_grep('/\.tpl$/', scandir($dir)) as $filename) {
- $parts = explode('_', basename($filename, '.tpl'));
- $templates[] = array('type' => array_pop($parts), 'name' => implode('_', $parts), 'filename' => "$dir/$filename");
- }
- $this->assign('templates', $templates);
-{/php}
-
-{foreach from=$templates item=tpl}
- {fetch assign=content file=$tpl.filename}
- SELECT @workflow_id := MAX(id) FROM civicrm_option_value WHERE name = '{$tpl.name}';
- SELECT @content := msg_{$tpl.type} FROM civicrm_msg_template WHERE workflow_id = @workflow_id AND is_reserved = 1 LIMIT 1;
- UPDATE civicrm_msg_template SET msg_{$tpl.type} = '{$content|escape:"quotes"}' WHERE workflow_id = @workflow_id AND (is_reserved = 1 OR (is_default = 1 AND msg_{$tpl.type} = @content));
-{/foreach}
+++ /dev/null
-{if $receipt_text}
-{$receipt_text}
-{/if}
-{if $is_pay_later}
-
-===========================================================
-{$pay_later_receipt}
-===========================================================
-{else}
-
-{ts}Please print this receipt for your records.{/ts}
-{/if}
-
-{if $amount}
-===========================================================
-{ts}Contribution Information{/ts}
-
-===========================================================
-{if $lineItem and $priceSetID and !$is_quick_config}
-{foreach from=$lineItem item=value key=priceset}
----------------------------------------------------------
-{capture assign=ts_item}{ts}Item{/ts}{/capture}
-{capture assign=ts_qty}{ts}Qty{/ts}{/capture}
-{capture assign=ts_each}{ts}Each{/ts}{/capture}
-{capture assign=ts_total}{ts}Total{/ts}{/capture}
-{$ts_item|string_format:"%-30s"} {$ts_qty|string_format:"%5s"} {$ts_each|string_format:"%10s"} {$ts_total|string_format:"%10s"}
-----------------------------------------------------------
-{foreach from=$value item=line}
-{capture assign=ts_item}{if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description} {$line.description}{/if}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.qty|string_format:"%5s"} {$line.unit_price|crmMoney:$currency|string_format:"%10s"} {$line.line_total|crmMoney:$currency|string_format:"%10s"}
-{/foreach}
-{/foreach}
-
-{ts}Total Amount{/ts}: {$amount|crmMoney:$currency}
-{else}
-{ts}Amount{/ts}: {$amount|crmMoney:$currency} {if $amount_level } - {$amount_level} {/if}
-{/if}
-{/if}
-{if $receive_date}
-
-{ts}Date{/ts}: {$receive_date|crmDate}
-{/if}
-{if $is_monetary and $trxn_id}
-{ts}Transaction #{/ts}: {$trxn_id}
-{/if}
-
-{if $is_recur and ($contributeMode eq 'notify' or $contributeMode eq 'directIPN')}
-{ts}This is a recurring contribution. You can cancel future contributions at:{/ts}
-
-{$cancelSubscriptionUrl}
-
-{ts}You can update billing details for this recurring contribution at:{/ts}
-
-{$updateSubscriptionBillingUrl}
-
-{ts}You can update recurring contribution amount or change the number of installments for this recurring contribution at:{/ts}
-
-{$updateSubscriptionUrl}
-
-{/if}
-
-{if $honor_block_is_active }
-===========================================================
-{$honor_type}
-===========================================================
-{$honor_prefix} {$honor_first_name} {$honor_last_name}
-{if $honor_email}
-{ts}Honoree Email{/ts}: {$honor_email}
-{/if}
-
-{/if}
-{if $pcpBlock}
-===========================================================
-{ts}Personal Campaign Page{/ts}
-
-===========================================================
-{ts}Display In Honor Roll{/ts}: {if $pcp_display_in_roll}{ts}Yes{/ts}{else}{ts}No{/ts}{/if}
-
-{if $pcp_roll_nickname}{ts}Nickname{/ts}: {$pcp_roll_nickname}{/if}
-
-{if $pcp_personal_note}{ts}Personal Note{/ts}: {$pcp_personal_note}{/if}
-
-{/if}
-{if $onBehalfProfile}
-===========================================================
-{ts}On Behalf Of{/ts}
-
-===========================================================
-{foreach from=$onBehalfProfile item=onBehalfValue key=onBehalfName}
-{$onBehalfName}: {$onBehalfValue}
-{/foreach}
-{/if}
-
-{if !( $contributeMode eq 'notify' OR $contributeMode eq 'directIPN' ) and $is_monetary}
-{if $is_pay_later}
-===========================================================
-{ts}Registered Email{/ts}
-
-===========================================================
-{$email}
-{elseif $amount GT 0}
-===========================================================
-{ts}Billing Name and Address{/ts}
-
-===========================================================
-{$billingName}
-{$address}
-
-{$email}
-{/if} {* End ! is_pay_later condition. *}
-{/if}
-{if $contributeMode eq 'direct' AND !$is_pay_later AND $amount GT 0}
-
-===========================================================
-{ts}Credit Card Information{/ts}
-
-===========================================================
-{$credit_card_type}
-{$credit_card_number}
-{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
-{/if}
-
-{if $selectPremium }
-===========================================================
-{ts}Premium Information{/ts}
-
-===========================================================
-{$product_name}
-{if $option}
-{ts}Option{/ts}: {$option}
-{/if}
-{if $sku}
-{ts}SKU{/ts}: {$sku}
-{/if}
-{if $start_date}
-{ts}Start Date{/ts}: {$start_date|crmDate}
-{/if}
-{if $end_date}
-{ts}End Date{/ts}: {$end_date|crmDate}
-{/if}
-{if $contact_email OR $contact_phone}
-
-{ts}For information about this premium, contact:{/ts}
-
-{if $contact_email}
- {$contact_email}
-{/if}
-{if $contact_phone}
- {$contact_phone}
-{/if}
-{/if}
-{if $is_deductible AND $price}
-
-{ts 1=$price|crmMoney:$currency}The value of this premium is %1. This may affect the amount of the tax deduction you can claim. Consult your tax advisor for more information.{/ts}{/if}
-{/if}
-
-{if $customPre}
-===========================================================
-{$customPre_grouptitle}
-
-===========================================================
-{foreach from=$customPre item=customValue key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- {$customName}: {$customValue}
-{/if}
-{/foreach}
-{/if}
-
-
-{if $customPost}
-===========================================================
-{$customPost_grouptitle}
-
-===========================================================
-{foreach from=$customPost item=customValue key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- {$customName}: {$customValue}
-{/if}
-{/foreach}
-{/if}
+++ /dev/null
-{php}
- $dir = SMARTY_DIR . '/../../CRM/Upgrade/4.2.beta3.msg_template/message_templates';
- $templates = array();
- foreach (preg_grep('/\.tpl$/', scandir($dir)) as $filename) {
- $parts = explode('_', basename($filename, '.tpl'));
- $templates[] = array('type' => array_pop($parts), 'name' => implode('_', $parts), 'filename' => "$dir/$filename");
- }
- $this->assign('templates', $templates);
-{/php}
-
-{foreach from=$templates item=tpl}
- {fetch assign=content file=$tpl.filename}
- SELECT @workflow_id := MAX(id) FROM civicrm_option_value WHERE name = '{$tpl.name}';
- SELECT @content := msg_{$tpl.type} FROM civicrm_msg_template WHERE workflow_id = @workflow_id AND is_reserved = 1 LIMIT 1;
- UPDATE civicrm_msg_template SET msg_{$tpl.type} = '{$content|escape:"quotes"}' WHERE workflow_id = @workflow_id AND (is_reserved = 1 OR (is_default = 1 AND msg_{$tpl.type} = @content));
-{/foreach}
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="500" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
- <!-- BEGIN HEADER -->
- <!-- You can add table row(s) here with logo or other header elements -->
- <!-- END HEADER -->
-
- <!-- BEGIN CONTENT -->
-
- <tr>
- <td>
- <p>Dear {contact.display_name},</p>
-
- {if $event.confirm_email_text AND (not $isOnWaitlist AND not $isRequireApproval)}
- <p>{$event.confirm_email_text|htmlize}</p>
-
- {else}
- <p>Thank you for your participation. This letter is a confirmation that your registration has been received and your status has been updated to <strong>{if $isOnWaitlist}waitlisted{else}registered{/if}</strong> for the following:</p>
-
- {/if}
-
- <p>
- {if $isOnWaitlist}
- <p>{ts}You have been added to the WAIT LIST for this event.{/ts}</p>
- {if $isPrimary}
- <p>{ts}If space becomes available you will receive an email with a link to a web page where you can complete your registration.{/ts}</p>
- {/if}
- {elseif $isRequireApproval}
- <p>{ts}Your registration has been submitted.{/ts}</p>
- {if $isPrimary}
- <p>{ts}Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.{/ts}</p>
- {/if}
- {elseif $is_pay_later && !$isAmountzero}
- <p>{$pay_later_receipt}</p> {* FIXME: this might be text rather than HTML *}
- {else}
- <p>{ts}Please print this confirmation for your records.{/ts}</p>
- {/if}
-
- </td>
- </tr>
- <tr>
- <td>
- <table width="500" style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse;">
- <tr>
- <th {$headerStyle}>
- {ts}Event Information and Location{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {$event.event_title}<br />
- {$event.event_start_date|date_format:"%A"} {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|date_format:"%A"} {$event.event_end_date|crmDate}{/if}{/if}
- </td>
- </tr>
-
-
- {if $conference_sessions}
- <tr>
- <td colspan="2" {$labelStyle}>
- {ts}Your schedule:{/ts}
- </td>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {assign var='group_by_day' value='NA'}
- {foreach from=$conference_sessions item=session}
- {if $session.start_date|date_format:"%Y/%m/%d" != $group_by_day|date_format:"%Y/%m/%d"}
- {assign var='group_by_day' value=$session.start_date}
- <em>{$group_by_day|date_format:"%m/%d/%Y"}</em><br />
- {/if}
- {$session.start_date|crmDate:0:1}{if $session.end_date}-{$session.end_date|crmDate:0:1}{/if} {$session.title}<br />
- {if $session.location} {$session.location}<br />{/if}
- {/foreach}
- </td>
- </tr>
- {/if}
-
- {if $event.participant_role neq 'Attendee' and $defaultRole}
- <tr>
- <td {$labelStyle}>
- {ts}Participant Role{/ts}
- </td>
- <td {$valueStyle}>
- {$event.participant_role}
- </td>
- </tr>
- {/if}
-
- {if $isShowLocation}
- <tr>
- <td colspan="2" {$valueStyle}>
- {if $location.address.1.name}
- {$location.address.1.name}<br />
- {/if}
- {if $location.address.1.street_address}
- {$location.address.1.street_address}<br />
- {/if}
- {if $location.address.1.supplemental_address_1}
- {$location.address.1.supplemental_address_1}<br />
- {/if}
- {if $location.address.1.supplemental_address_2}
- {$location.address.1.supplemental_address_2}<br />
- {/if}
- {if $location.address.1.city}
- {$location.address.1.city}, {$location.address.1.state_province} {$location.address.1.postal_code}{if $location.address.1.postal_code_suffix} - {$location.address.1.postal_code_suffix}{/if}<br />
- {/if}
- </td>
- </tr>
- {/if}
-
- {if $location.phone.1.phone || $location.email.1.email}
- <tr>
- <td colspan="2" {$labelStyle}>
- {ts}Event Contacts:{/ts}
- </td>
- </tr>
- {foreach from=$location.phone item=phone}
- {if $phone.phone}
- <tr>
- <td {$labelStyle}>
- {if $phone.phone_type}
- {$phone.phone_type_display}
- {else}
- {ts}Phone{/ts}
- {/if}
- </td>
- <td {$valueStyle}>
- {$phone.phone}
- </td>
- </tr>
- {/if}
- {/foreach}
- {foreach from=$location.email item=eventEmail}
- {if $eventEmail.email}
- <tr>
- <td {$labelStyle}>
- {ts}Email{/ts}
- </td>
- <td {$valueStyle}>
- {$eventEmail.email}
- </td>
- </tr>
- {/if}
- {/foreach}
- {/if}
- <tr>
- <td colspan="2" {$valueStyle}>
- {capture assign=icalFeed}{crmURL p='civicrm/event/ical' q="reset=1&id=`$event.id`" h=0 a=1 fe=1}{/capture}
- <a href="{$icalFeed}">{ts}Download iCalendar File{/ts}</a>
- </td>
- </tr>
- {if $event.is_share}
- <tr>
- <td colspan="2" {$valueStyle}>
- {capture assign=eventUrl}{crmURL p='civicrm/event/info' q="id=`$event.id`&reset=1" a=true fe=1 h=1}{/capture}
- {include file="CRM/common/SocialNetwork.tpl" emailMode=true url=$eventUrl title=$event.title pageURL=$eventUrl}
- </td>
- </tr>
- {/if}
- {if $payer.name}
- <tr>
- <th {$headerStyle}>
- {ts}You were registered by:{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {$payer.name}
- </td>
- </tr>
- {/if}
- {if $event.is_monetary}
-
- <tr>
- <th {$headerStyle}>
- {$event.fee_label}
- </th>
- </tr>
-
- {if $lineItem}
- {foreach from=$lineItem item=value key=priceset}
- {if $value neq 'skip'}
- {if $isPrimary}
- {if $lineItem|@count GT 1} {* Header for multi participant registration cases. *}
- <tr>
- <td colspan="2" {$labelStyle}>
- {ts 1=$priceset+1}Participant %1{/ts} {$part.$priceset.info}
- </td>
- </tr>
- {/if}
- {/if}
- <tr>
- <td colspan="2" {$valueStyle}>
- <table> {* FIXME: style this table so that it looks like the text version (justification, etc.) *}
- <tr>
- <th>{ts}Item{/ts}</th>
- <th>{ts}Qty{/ts}</th>
- <th>{ts}Each{/ts}</th>
- <th>{ts}Total{/ts}</th>
- {if $pricesetFieldsCount }<th>{ts}Total Participants{/ts}</th>{/if}
- </tr>
- {foreach from=$value item=line}
- <tr>
- <td>
- {if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description}<div>{$line.description|truncate:30:"..."}</div>{/if}
- </td>
- <td>
- {$line.qty}
- </td>
- <td>
- {$line.unit_price|crmMoney}
- </td>
- <td>
- {$line.line_total|crmMoney}
- </td>
- {if $pricesetFieldsCount }<td>{$line.participant_count}</td> {/if}
- </tr>
- {/foreach}
- </table>
- </td>
- </tr>
- {/if}
- {/foreach}
- {/if}
-
- {if $amounts && !$lineItem}
- {foreach from=$amounts item=amnt key=level}
- <tr>
- <td colspan="2" {$valueStyle}>
- {$amnt.amount|crmMoney} {$amnt.label}
- </td>
- </tr>
- {/foreach}
- {/if}
-
- {if $isPrimary}
- <tr>
- <td {$labelStyle}>
- {ts}Total Amount{/ts}
- </td>
- <td {$valueStyle}>
- {$totalAmount|crmMoney} {if $hookDiscount.message}({$hookDiscount.message}){/if}
- </td>
- </tr>
- {if $pricesetFieldsCount }
- <tr>
- <td {$labelStyle}>
- {ts}Total Participants{/ts}</td>
- <td {$valueStyle}>
- {assign var="count" value= 0}
- {foreach from=$lineItem item=pcount}
- {assign var="lineItemCount" value=0}
- {if $pcount neq 'skip'}
- {foreach from=$pcount item=p_count}
- {assign var="lineItemCount" value=$lineItemCount+$p_count.participant_count}
- {/foreach}
- {if $lineItemCount < 1 }
- {assign var="lineItemCount" value=1}
- {/if}
- {assign var="count" value=$count+$lineItemCount}
- {/if}
- {/foreach}
- {$count}
- </td> </tr>
- {/if}
-
- {if $register_date}
- <tr>
- <td {$labelStyle}>
- {ts}Registration Date{/ts}
- </td>
- <td {$valueStyle}>
- {$register_date|crmDate}
- </td>
- </tr>
- {/if}
-
- {if $receive_date}
- <tr>
- <td {$labelStyle}>
- {ts}Transaction Date{/ts}
- </td>
- <td {$valueStyle}>
- {$receive_date|crmDate}
- </td>
- </tr>
- {/if}
-
- {if $contributionTypeName}
- <tr>
- <td {$labelStyle}>
- {ts}Contribution Type{/ts}
- </td>
- <td {$valueStyle}>
- {$contributionTypeName}
- </td>
- </tr>
- {/if}
-
- {if $trxn_id}
- <tr>
- <td {$labelStyle}>
- {ts}Transaction #{/ts}
- </td>
- <td {$valueStyle}>
- {$trxn_id}
- </td>
- </tr>
- {/if}
-
- {if $paidBy}
- <tr>
- <td {$labelStyle}>
- {ts}Paid By{/ts}
- </td>
- <td {$valueStyle}>
- {$paidBy}
- </td>
- </tr>
- {/if}
-
- {if $checkNumber}
- <tr>
- <td {$labelStyle}>
- {ts}Check Number{/ts}
- </td>
- <td {$valueStyle}>
- {$checkNumber}
- </td>
- </tr>
- {/if}
-
- {if $contributeMode ne 'notify' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
- <tr>
- <th {$headerStyle}>
- {ts}Billing Name and Address{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {$billingName}<br />
- {$address|nl2br}
- </td>
- </tr>
- {/if}
-
- {if $contributeMode eq 'direct' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
- <tr>
- <th {$headerStyle}>
- {ts}Credit Card Information{/ts}
- </th>
- </tr>
- <tr>
- <td colspan="2" {$valueStyle}>
- {$credit_card_type}<br />
- {$credit_card_number}<br />
- {ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
- </td>
- </tr>
- {/if}
-
- {/if}
-
- {/if} {* End of conditional section for Paid events *}
-
-
-{if $customPre}
-{foreach from=$customPre item=customPr key=i}
- <tr> <th {$headerStyle}>{$customPre_grouptitle.$i}</th></tr>
- {foreach from=$customPr item=customValue key=customName}
- {if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- <tr>
- <td {$labelStyle}>{$customName}</td>
- <td {$valueStyle}>{$customValue}</td>
- </tr>
- {/if}
- {/foreach}
-{/foreach}
-{/if}
-
-{if $customPost}
-{foreach from=$customPost item=customPos key=j}
- <tr> <th {$headerStyle}>{$customPost_grouptitle.$j}</th></tr>
- {foreach from=$customPos item=customValue key=customName}
- {if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- <tr>
- <td {$labelStyle}>{$customName}</td>
- <td {$valueStyle}>{$customValue}</td>
- </tr>
-{/if}
-{/foreach}
-{/foreach}
-{/if}
-
-{if $customProfile}
-{foreach from=$customProfile.profile item=eachParticipant key=participantID}
- <tr><th {$headerStyle}>{ts 1=$participantID+2}Participant %1{/ts} </th></tr>
- {foreach from=$eachParticipant item=eachProfile key=pid}
- <tr><th {$headerStyle}>{$customProfile.title.$pid}</th></tr>
- {foreach from=$eachProfile item=val key=field}
- <tr>{foreach from=$val item=v key=f}
- <td {$labelStyle}>{$field}</td>
- <td {$valueStyle}>{$v}</td>
- {/foreach}
- </tr>
- {/foreach}
-{/foreach}
-{/foreach}
-{/if}
-
- {if $customGroup}
- {foreach from=$customGroup item=value key=customName}
- <tr>
- <th {$headerStyle}>
- {$customName}
- </th>
- </tr>
- {foreach from=$value item=v key=n}
- <tr>
- <td {$labelStyle}>
- {$n}
- </td>
- <td {$valueStyle}>
- {$v}
- </td>
- </tr>
- {/foreach}
- {/foreach}
- {/if}
-
- </table>
- </td>
- </tr>
- </table>
-</center>
-
-</body>
-</html>
+++ /dev/null
-Dear {contact.display_name},
-
-{if $event.confirm_email_text AND (not $isOnWaitlist AND not $isRequireApproval)}
-{$event.confirm_email_text}
-
-{else}
-Thank you for your participation. This letter is a confirmation that your registration has been received and your status has been updated to {if $participant_status}$participant_status{else}{if $isOnWaitlist}waitlisted{else}registered{/if}{/if} for the following:
-
-{/if}
-
-{if $isOnWaitlist}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}You have been added to the WAIT LIST for this event.{/ts}
-
-{if $isPrimary}
-{ts}If space becomes available you will receive an email with a link to a web page where you can complete your registration.{/ts}
-{/if}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{elseif $isRequireApproval}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Your registration has been submitted.{/ts}
-
-{if $isPrimary}
-{ts}Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.{/ts}
-
-{/if}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{elseif $is_pay_later && !$isAmountzero}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$pay_later_receipt}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{else}
-
-{ts}Please print this confirmation for your records.{/ts}
-{/if}
-
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Event Information and Location{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$event.event_title}
-{$event.event_start_date|date_format:"%A"} {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|date_format:"%A"} {$event.event_end_date|crmDate}{/if}{/if}
-{if $conference_sessions}
-
-
-{ts}Your schedule:{/ts}
-{assign var='group_by_day' value='NA'}
-{foreach from=$conference_sessions item=session}
-{if $session.start_date|date_format:"%Y/%m/%d" != $group_by_day|date_format:"%Y/%m/%d"}
-{assign var='group_by_day' value=$session.start_date}
-
-{$group_by_day|date_format:"%m/%d/%Y"}
-
-
-{/if}
-{$session.start_date|crmDate:0:1}{if $session.end_date}-{$session.end_date|crmDate:0:1}{/if} {$session.title}
-{if $session.location} {$session.location}{/if}
-{/foreach}
-{/if}
-
-{if $event.participant_role neq 'Attendee' and $defaultRole}
-{ts}Participant Role{/ts}: {$event.participant_role}
-{/if}
-
-{if $isShowLocation}
-{if $location.address.1.name}
-
-{$location.address.1.name}
-{/if}
-{if $location.address.1.street_address}{$location.address.1.street_address}
-{/if}
-{if $location.address.1.supplemental_address_1}{$location.address.1.supplemental_address_1}
-{/if}
-{if $location.address.1.supplemental_address_2}{$location.address.1.supplemental_address_2}
-{/if}
-{if $location.address.1.city}{$location.address.1.city}, {$location.address.1.state_province} {$location.address.1.postal_code}{if $location.address.1.postal_code_suffix} - {$location.address.1.postal_code_suffix}{/if}
-{/if}
-
-{/if}{*End of isShowLocation condition*}
-
-{if $location.phone.1.phone || $location.email.1.email}
-
-{ts}Event Contacts:{/ts}
-{foreach from=$location.phone item=phone}
-{if $phone.phone}
-
-{if $phone.phone_type}{$phone.phone_type_display}{else}{ts}Phone{/ts}{/if}: {$phone.phone}{/if}
-{/foreach}
-{foreach from=$location.email item=eventEmail}
-{if $eventEmail.email}
-
-{ts}Email{/ts}: {$eventEmail.email}{/if}{/foreach}
-{/if}
-
-{capture assign=icalFeed}{crmURL p='civicrm/event/ical' q="reset=1&id=`$event.id`" h=0 a=1 fe=1}{/capture}
-{ts}Download iCalendar File:{/ts} {$icalFeed}
-
-{if $payer.name}
-You were registered by: {$payer.name}
-{/if}
-{if $event.is_monetary} {* This section for Paid events only.*}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$event.fee_label}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{if $lineItem}{foreach from=$lineItem item=value key=priceset}
-
-{if $value neq 'skip'}
-{if $isPrimary}
-{if $lineItem|@count GT 1} {* Header for multi participant registration cases. *}
-{ts 1=$priceset+1}Participant %1{/ts} {$part.$priceset.info}
-
-{/if}
-{/if}
------------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{capture assign=ts_item}{ts}Item{/ts}{/capture}
-{capture assign=ts_qty}{ts}Qty{/ts}{/capture}
-{capture assign=ts_each}{ts}Each{/ts}{/capture}
-{capture assign=ts_total}{ts}Total{/ts}{/capture}
-{if $pricesetFieldsCount }{capture assign=ts_participant_total}{ts}Total Participants{/ts}{/capture}{/if}
-{$ts_item|string_format:"%-30s"} {$ts_qty|string_format:"%5s"} {$ts_each|string_format:"%10s"} {$ts_total|string_format:"%10s"} {$ts_participant_total|string_format:"%10s"}
------------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{foreach from=$value item=line}
-{if $pricesetFieldsCount }{capture assign=ts_participant_count}{$line.participant_count}{/capture}{/if}
-{capture assign=ts_item}{if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description} {$line.description}{/if}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.qty|string_format:"%5s"} {$line.unit_price|crmMoney|string_format:"%10s"} {$line.line_total|crmMoney|string_format:"%10s"}{$ts_participant_count|string_format:"%10s"}
-{/foreach}
-{/if}
-{/foreach}
-{/if}
-{if $amounts && !$lineItem}
-{foreach from=$amounts item=amnt key=level}{$amnt.amount|crmMoney} {$amnt.label}
-{/foreach}
-{/if}
-{if $isPrimary }
-
-{ts}Total Amount{/ts}: {$totalAmount|crmMoney} {if $hookDiscount.message}({$hookDiscount.message}){/if}
-
-{if $pricesetFieldsCount }
- {assign var="count" value= 0}
- {foreach from=$lineItem item=pcount}
- {assign var="lineItemCount" value=0}
- {if $pcount neq 'skip'}
- {foreach from=$pcount item=p_count}
- {assign var="lineItemCount" value=$lineItemCount+$p_count.participant_count}
- {/foreach}
- {if $lineItemCount < 1 }
- {assign var="lineItemCount" value=1}
- {/if}
- {assign var="count" value=$count+$lineItemCount}
- {/if}
- {/foreach}
-
-{ts}Total Participants{/ts}: {$count}
-{/if}
-
-{if $register_date}
-{ts}Registration Date{/ts}: {$register_date|crmDate}
-{/if}
-{if $receive_date}
-{ts}Transaction Date{/ts}: {$receive_date|crmDate}
-{/if}
-{if $contributionTypeName}
-{ts}Contribution Type{/ts}: {$contributionTypeName}
-{/if}
-{if $trxn_id}
-{ts}Transaction #{/ts}: {$trxn_id}
-{/if}
-{if $paidBy}
-{ts}Paid By{/ts}: {$paidBy}
-{/if}
-{if $checkNumber}
-{ts}Check Number{/ts}: {$checkNumber}
-{/if}
-{if $contributeMode ne 'notify' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Billing Name and Address{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$billingName}
-{$address}
-{/if}
-
-{if $contributeMode eq 'direct' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Credit Card Information{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$credit_card_type}
-{$credit_card_number}
-{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
-{/if}
-{/if}
-{/if} {* End of conditional section for Paid events *}
-
-{if $customPre}
-{foreach from=$customPre item=customPr key=i}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$customPre_grouptitle.$i}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$customPr item=customValue key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- {$customName}: {$customValue}
-{/if}
-{/foreach}
-{/foreach}
-{/if}
-
-{if $customPost}
-{foreach from=$customPost item=customPos key=j}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$customPost_grouptitle.$j}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$customPos item=customValue key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- {$customName}: {$customValue}
-{/if}
-{/foreach}
-{/foreach}
-{/if}
-{if $customProfile}
-
-{foreach from=$customProfile.profile item=eachParticipant key=participantID}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts 1=$participantID+2}Participant Information - Participant %1{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$eachParticipant item=eachProfile key=pid}
-----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{$customProfile.title.$pid}
-----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{foreach from=$eachProfile item=val key=field}
-{foreach from=$val item=v key=f}
-{$field}: {$v}
-{/foreach}
-{/foreach}
-{/foreach}
-{/foreach}
-{/if}
-{if $customGroup}
-{foreach from=$customGroup item=value key=customName}
-=========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$customName}
-=========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$value item=v key=n}
-{$n}: {$v}
-{/foreach}
-{/foreach}
-{/if}
/**
* Minimum previous CiviCRM version we can directly upgrade from
*/
- const MINIMUM_UPGRADABLE_VERSION = '4.1.3';
+ const MINIMUM_UPGRADABLE_VERSION = '4.2.9';
/**
* Minimum php version required to run (equal to or lower than the minimum install version)
);
$queue->createItem($task);
+ $task = new CRM_Queue_Task(
+ array('CRM_Upgrade_Form', 'disableOldExtensions'),
+ array($postUpgradeMessageFile),
+ "Checking extensions"
+ );
+ $queue->createItem($task);
+
$revisions = $upgrade->getRevisionSequence();
foreach ($revisions as $rev) {
// proceed only if $currentVer < $rev
return TRUE;
}
+ /**
+ * Disable any extensions not compatible with this new version.
+ *
+ * @param \CRM_Queue_TaskContext $ctx
+ * @param string $postUpgradeMessageFile
+ * @return bool
+ */
+ public static function disableOldExtensions(CRM_Queue_TaskContext $ctx, $postUpgradeMessageFile) {
+ $compatInfo = CRM_Extension_System::getCompatibilityInfo();
+ $disabled = [];
+ $manager = CRM_Extension_System::singleton()->getManager();
+ foreach ($compatInfo as $key => $ext) {
+ if (!empty($ext['obsolete']) && $manager->getStatus($key) == $manager::STATUS_INSTALLED) {
+ $disabled[$key] = sprintf("<li>%s</li>", ts('The extension %1 is now obsolete and has been disabled.', [1 => $key]));
+ }
+ }
+ if ($disabled) {
+ $manager->disable(array_keys($disabled));
+ file_put_contents($postUpgradeMessageFile,
+ '<br/><br/><ul>' . implode("\n", $disabled) . '</ul>',
+ FILE_APPEND
+ );
+ }
+
+ return TRUE;
+ }
+
/**
* Perform an incremental version update.
*
['name' => 'membership_online_receipt', 'type' => 'text'],
['name' => 'membership_online_receipt', 'type' => 'html'],
]
- ]
+ ],
+ [
+ 'version' => '5.12.alpha1',
+ 'upgrade_descriptor' => ts('Update payment notification to remove print text, use email greeting'),
+ 'label' => ts('Payment notification'),
+ 'templates' => [
+ ['name' => 'payment_or_refund_notification', 'type' => 'text'],
+ ['name' => 'payment_or_refund_notification', 'type' => 'html'],
+ ]
+ ],
];
}
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 5 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2019 |
+ +--------------------------------------------------------------------+
+ | 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. |
+ | |
+ | 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 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 |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ * Upgrade logic for FiveTwelve */
+class CRM_Upgrade_Incremental_php_FiveTwelve extends CRM_Upgrade_Incremental_Base {
+
+ /**
+ * Compute any messages which should be displayed beforeupgrade.
+ *
+ * Note: This function is called iteratively for each upcoming
+ * revision to the database.
+ *
+ * @param string $preUpgradeMessage
+ * @param string $rev
+ * a version number, e.g. '4.4.alpha1', '4.4.beta3', '4.4.0'.
+ * @param null $currentVer
+ */
+ public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL) {
+ // Example: Generate a pre-upgrade message.
+ // if ($rev == '5.12.34') {
+ // $preUpgradeMessage .= '<p>' . ts('A new permission, "%1", has been added. This permission is now used to control access to the Manage Tags screen.', array(1 => ts('manage tags'))) . '</p>';
+ // }
+ }
+
+ /**
+ * Compute any messages which should be displayed after upgrade.
+ *
+ * @param string $postUpgradeMessage
+ * alterable.
+ * @param string $rev
+ * an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs.
+ */
+ public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
+ // Example: Generate a post-upgrade message.
+ // if ($rev == '5.12.34') {
+ // $postUpgradeMessage .= '<br /><br />' . ts("By default, CiviCRM now disables the ability to import directly from SQL. To use this feature, you must explicitly grant permission 'import SQL datasource'.");
+ // }
+ }
+
+ /*
+ * Important! All upgrade functions MUST add a 'runSql' task.
+ * Uncomment and use the following template for a new upgrade version
+ * (change the x in the function name):
+ */
+
+ // /**
+ // * Upgrade function.
+ // *
+ // * @param string $rev
+ // */
+ // public function upgrade_5_0_x($rev) {
+ // $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
+ // $this->addTask('Do the foo change', 'taskFoo', ...);
+ // // Additional tasks here...
+ // // Note: do not use ts() in the addTask description because it adds unnecessary strings to transifex.
+ // // The above is an exception because 'Upgrade DB to %1: SQL' is generic & reusable.
+ // }
+
+ // public static function taskFoo(CRM_Queue_TaskContext $ctx, ...) {
+ // return TRUE;
+ // }
+
+}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | 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 |
- +--------------------------------------------------------------------+
- */
-
-/**
- * Upgrade logic for 4.2
- */
-class CRM_Upgrade_Incremental_php_FourTwo extends CRM_Upgrade_Incremental_Base {
- const SETTINGS_SNIPPET_PATTERN = '/CRM_Core_ClassLoader::singleton\(\)-\>register/';
- const SETTINGS_SNIPPET = "\nrequire_once 'CRM/Core/ClassLoader.php';\nCRM_Core_ClassLoader::singleton()->register();\n";
-
- /**
- * Compute any messages which should be displayed beforeupgrade.
- *
- * Note: This function is called iteratively for each upcoming
- * revision to the database.
- *
- * @param string $preUpgradeMessage
- * @param string $rev
- * a version number, e.g. '4.2.alpha1', '4.2.beta3', '4.2.0'.
- * @param null $currentVer
- *
- * @return bool
- */
- public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL) {
- if ($rev == '4.2.alpha1') {
- $tables = array('civicrm_contribution_page', 'civicrm_event', 'civicrm_group', 'civicrm_contact');
- if (!CRM_Core_DAO::schemaRequiresRebuilding($tables)) {
- $errors = "The upgrade has identified some schema integrity issues in the database. It seems some of your constraints are missing. You will have to rebuild your schema before re-trying the upgrade. Please refer to " . CRM_Utils_System::docURL2("Ensuring Schema Integrity on Upgrades", FALSE, "Ensuring Schema Integrity on Upgrades", NULL, NULL, "wiki");
- CRM_Core_Error::fatal($errors);
- return FALSE;
- }
-
- // CRM-10613, CRM-11120
- $query = "
-SELECT mp.contribution_id, mp.membership_id, mem.membership_type_id, mem.start_date, mem.end_date, mem.status_id, mem.contact_id
-FROM civicrm_membership_payment mp
-INNER JOIN ( SELECT cmp.contribution_id
- FROM civicrm_membership_payment cmp
- LEFT JOIN civicrm_line_item cli ON cmp.contribution_id=cli.entity_id and cli.entity_table = 'civicrm_contribution'
- WHERE cli.entity_id IS NULL
- GROUP BY cmp.contribution_id
- HAVING COUNT(cmp.membership_id) > 1) submp ON submp.contribution_id = mp.contribution_id
-INNER JOIN civicrm_membership mem ON mem.id = mp.membership_id
-ORDER BY mp.contribution_id, mp.membership_id";
- $invalidData = CRM_Core_DAO::executeQuery($query);
- if ($invalidData->N) {
- $invalidDataMessage = "<br /><strong>" . 'The upgrade is being aborted due to data integrity issues in your database. There are multiple membership records linked to the same contribution record. This is unexpected, and some of the membership records may be duplicates. The problem record sets are listed below. Refer to <a href="http://wiki.civicrm.org/confluence/display/CRMDOC42/Repair+database+script+for+4.2+upgrades">this wiki page for instructions on repairing your database</a> so that you can run the upgrade successfully.' . "</strong>";
- $membershipType = CRM_Member_PseudoConstant::membershipType();
- $membershipStatus = CRM_Member_PseudoConstant::membershipStatus();
- $invalidDataMessage .= "<table border=1><tr><th>Contact-ID</th><th>Contribution-ID</th><th>Membership-ID</th><th>Membership Type</th><th>Start Date</th><th>End Date</th><th>Membership Status</th></tr>";
- while ($invalidData->fetch()) {
- $invalidDataMessage .= "<tr>";
- $invalidDataMessage .= "<td>{$invalidData->contact_id}</td>";
- $invalidDataMessage .= "<td>{$invalidData->contribution_id}</td>";
- $invalidDataMessage .= "<td>{$invalidData->membership_id}</td>";
- $invalidDataMessage .= "<td>" . CRM_Utils_Array::value($invalidData->membership_type_id, $membershipType) . "</td>";
- $invalidDataMessage .= "<td>{$invalidData->start_date}</td>";
- $invalidDataMessage .= "<td>{$invalidData->end_date}</td>";
- $invalidDataMessage .= "<td>" . CRM_Utils_Array::value($invalidData->status_id, $membershipStatus) . "</td>";
- $invalidDataMessage .= "</tr>";
- }
- $clickHere = CRM_Utils_System::url('civicrm/upgrade/cleanup425', 'reset=1');
- $invalidDataMessage .= "</table><p>If you have reviewed the cleanup script documentation on the wiki and you are ready to run the cleanup now - <a href='$clickHere'>click here</a>.</p>";
- CRM_Core_Error::fatal($invalidDataMessage);
- return FALSE;
- }
- }
-
- if ($rev == '4.2.beta2') {
- // note: error conditions are also checked in upgrade_4_2_beta2()
- if (!defined('CIVICRM_SETTINGS_PATH')) {
- $preUpgradeMessage .= '<br />' . ts('Could not determine path to civicrm.settings.php. Please manually locate it and add these lines at the bottom: <pre>%1</pre>', array(
- 1 => self::SETTINGS_SNIPPET,
- ));
- }
- elseif (preg_match(self::SETTINGS_SNIPPET_PATTERN, file_get_contents(CIVICRM_SETTINGS_PATH))) {
- // OK, nothing to do
- }
- elseif (!is_writable(CIVICRM_SETTINGS_PATH)) {
- $preUpgradeMessage .= '<br />' . ts('The settings file (%1) must be updated. Please make it writable or manually add these lines:<pre>%2</pre>', array(
- 1 => CIVICRM_SETTINGS_PATH,
- 2 => self::SETTINGS_SNIPPET,
- ));
- }
- }
- if ($rev == '4.2.2' && version_compare($currentVer, '3.3.alpha1') >= 0) {
- $query = " SELECT cli.id
-FROM `civicrm_line_item` cli
-INNER JOIN civicrm_membership_payment cmp ON cmp.contribution_id = cli.entity_id AND cli.entity_table = 'civicrm_contribution'
-INNER JOIN civicrm_price_field_value cpfv ON cpfv.id = cli.price_field_value_id
-INNER JOIN civicrm_price_field cpf ON cpf.id = cpfv.price_field_id and cpf.id != cli.price_field_id
-INNER JOIN civicrm_price_set cps ON cps.id = cpf.price_set_id AND cps.name <>'default_membership_type_amount' ";
- $dao = CRM_Core_DAO::executeQuery($query);
- if ($dao->N) {
- $preUpgradeMessage .= "<br /><strong>We have identified extraneous data in your database that a previous upgrade likely introduced. We STRONGLY recommend making a backup of your site before continuing. We also STRONGLY suggest fixing this issue with unneeded records BEFORE you upgrade. You can find more information about this issue and the way to fix it by visiting <a href='http://forum.civicrm.org/index.php/topic,26181.0.html'>http://forum.civicrm.org/index.php/topic,26181.0.html</a>.</strong>";
- }
- }
-
- if (version_compare($rev, '4.2.9') >= 0) {
- //CRM-11980
- $sql = "SELECT id FROM civicrm_option_group WHERE name LIKE 'civicrm_price_field.amount.%' LIMIT 1";
- $dao = CRM_Core_DAO::executeQuery($sql);
- if ($dao->fetch()) {
- $errors = "We found unexpected data values from an older version of CiviCRM in your database. The upgrade can not be run until this condition is corrected.<br /><br />Details: One or more rows are present in the civicrm_option_group with name like 'civicrm_price_field.amount.%'. <a href='http://forum.civicrm.org/index.php/topic,27744.msg118748.html#msg118748'>Check here for information on diagnosing and correcting this problem.</a>";
- CRM_Core_Error::fatal($errors);
- return FALSE;
- }
- }
- }
-
- /**
- * Compute any messages which should be displayed after upgrade.
- *
- * @param string $postUpgradeMessage
- * alterable.
- * @param string $rev
- * an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs.
- */
- public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
- if ($rev == '4.2.beta5') {
- $config = CRM_Core_Config::singleton();
- if (!empty($config->extensionsDir)) {
- $postUpgradeMessage .= '<br />' . ts('Please <a href="%1" target="_blank">configure the Extension Resource URL</a>.', array(
- 1 => CRM_Utils_System::url('civicrm/admin/setting/url', 'reset=1'),
- ));
- }
- }
- if ($rev == '4.2.7') {
- $postUpgradeMessage .= '<br />' . ts('If you have configured a report instance to allow anonymous access, you will need to reset the permission to Everyone for that instance (under the Report Settings pane).');
- }
- }
-
- /**
- * @param $rev
- */
- public function upgrade_4_2_alpha1($rev) {
- //checking whether the foreign key exists before dropping it
- //drop foreign key queries of CRM-9850
- $params = array();
- $tables = array(
- 'civicrm_contribution_page' => 'FK_civicrm_contribution_page_payment_processor_id',
- 'civicrm_event' => 'FK_civicrm_event_payment_processor_id',
- 'civicrm_group' => 'FK_civicrm_group_saved_search_id',
- );
- foreach ($tables as $tableName => $fKey) {
- $foreignKeyExists = CRM_Core_DAO::checkConstraintExists($tableName, $fKey);
- if ($foreignKeyExists) {
- CRM_Core_DAO::executeQuery("ALTER TABLE {$tableName} DROP FOREIGN KEY {$fKey}", $params, TRUE, NULL, FALSE, FALSE);
- CRM_Core_DAO::executeQuery("ALTER TABLE {$tableName} DROP INDEX {$fKey}", $params, TRUE, NULL, FALSE, FALSE);
- }
- }
- // Drop index UI_title for civicrm_price_set
- $domain = new CRM_Core_DAO_Domain();
- $domain->find(TRUE);
- if ($domain->locales) {
- $locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
- foreach ($locales as $locale) {
- $query = "SHOW KEYS FROM `civicrm_price_set` WHERE key_name = 'UI_title_{$locale}'";
- $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, NULL, FALSE, FALSE);
- if ($dao->N) {
- CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_price_set` DROP INDEX `UI_title_{$locale}`", $params, TRUE, NULL, FALSE, FALSE);
- }
- }
- }
- else {
- $query = "SHOW KEYS FROM `civicrm_price_set` WHERE key_name = 'UI_title'";
- $dao = CRM_Core_DAO::executeQuery($query);
- if ($dao->N) {
- CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_price_set` DROP INDEX `UI_title`");
- }
- }
-
- // Some steps take a long time, so we break them up into separate
- // tasks and enqueue them separately.
- $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.2.alpha1')), 'runSql', $rev);
- $this->addTask('Upgrade DB to 4.2.alpha1: Price Sets', 'task_4_2_alpha1_createPriceSets', $rev);
- self::convertContribution();
- $this->addTask('Upgrade DB to 4.2.alpha1: Event Profile', 'task_4_2_alpha1_eventProfile');
- }
-
- /**
- * @param $rev
- */
- public function upgrade_4_2_beta2($rev) {
- // note: error conditions are also checked in setPreUpgradeMessage()
- if (defined('CIVICRM_SETTINGS_PATH')) {
- if (!preg_match(self::SETTINGS_SNIPPET_PATTERN, file_get_contents(CIVICRM_SETTINGS_PATH))) {
- if (is_writable(CIVICRM_SETTINGS_PATH)) {
- file_put_contents(CIVICRM_SETTINGS_PATH, self::SETTINGS_SNIPPET, FILE_APPEND);
- }
- }
- }
- }
-
- /**
- * @param $rev
- */
- public function upgrade_4_2_beta3($rev) {
- $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.2.beta3')), 'runSql', $rev);
- $minParticipantId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(min(id),0) FROM civicrm_participant');
- $maxParticipantId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(max(id),0) FROM civicrm_participant');
-
- for ($startId = $minParticipantId; $startId <= $maxParticipantId; $startId += self::BATCH_SIZE) {
- $endId = $startId + self::BATCH_SIZE - 1;
- $title = "Upgrade DB to 4.2.alpha1: Participant ($startId => $endId)";
- $this->addTask($title, 'task_4_2_alpha1_convertParticipants', $startId, $endId);
- }
- }
-
- /**
- * @param $rev
- */
- public function upgrade_4_2_beta5($rev) {
- // CRM-10629 Create a setting for extension URLs
- // For some reason, this isn't working when placed in the .sql file
- CRM_Core_DAO::executeQuery("
- INSERT INTO civicrm_setting(group_name,name,value,domain_id,is_domain)
- VALUES ('URL Preferences', 'extensionsURL',NULL,1,1);
- ");
- }
-
- /**
- * @param $rev
- */
- public function upgrade_4_2_0($rev) {
- $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.2.0')), 'runSql', $rev);
- }
-
- /**
- * @param $rev
- */
- public function upgrade_4_2_2($rev) {
- $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.2.2')), 'runSql', $rev);
- //create line items for memberships and participants for api/import
- self::convertContribution();
-
- // CRM-10937 Fix the title on civicrm_dedupe_rule_group
- $upgrade = new CRM_Upgrade_Form();
- if ($upgrade->multilingual) {
- // Check if the 'title' field exists
- $query = "SELECT column_name
- FROM information_schema.COLUMNS
- WHERE table_name = 'civicrm_dedupe_rule_group'
- AND table_schema = DATABASE()
- AND column_name = 'title'";
-
- $dao = CRM_Core_DAO::executeQuery($query);
-
- if (!$dao->N) {
- $domain = new CRM_Core_DAO_Domain();
- $domain->find(TRUE);
-
- if ($domain->locales) {
- $locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
- $locale = array_shift($locales);
-
- // Use the first language (they should all have the same value)
- CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_dedupe_rule_group` CHANGE `title_{$locale}` `title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Label of the rule group'", $params, TRUE, NULL, FALSE, FALSE);
-
- // Drop remaining the column for the remaining languages
- foreach ($locales as $locale) {
- CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_dedupe_rule_group` DROP `title_{$locale}`", $params, TRUE, NULL, FALSE, FALSE);
- }
- }
- }
- }
- }
-
- /**
- * @param $rev
- */
- public function upgrade_4_2_3($rev) {
- $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.2.3')), 'runSql', $rev);
- // CRM-10953 Remove duplicate activity type for 'Reminder Sent' which is mistakenly inserted by 4.2.alpha1 upgrade script
- $queryMin = "
-SELECT coalesce(min(value),0) from civicrm_option_value ov
-WHERE ov.option_group_id =
- (SELECT id from civicrm_option_group og WHERE og.name = 'activity_type') AND
-ov.name = 'Reminder Sent'";
-
- $minReminderSent = CRM_Core_DAO::singleValueQuery($queryMin);
-
- $queryMax = "
-SELECT coalesce(max(value),0) from civicrm_option_value ov
-WHERE ov.option_group_id =
- (SELECT id from civicrm_option_group og WHERE og.name = 'activity_type') AND
-ov.name = 'Reminder Sent'";
-
- $maxReminderSent = CRM_Core_DAO::singleValueQuery($queryMax);
-
- // If we have two different values, replace new value with original in any activities
- if ($maxReminderSent > $minReminderSent) {
- $query = "
-UPDATE civicrm_activity
-SET activity_type_id = {$minReminderSent}
-WHERE activity_type_id = {$maxReminderSent}";
-
- CRM_Core_DAO::executeQuery($query);
-
- // Then delete the newer (duplicate) option_value row
- $query = "
-DELETE from civicrm_option_value
- WHERE option_group_id =
- (SELECT id from civicrm_option_group og WHERE og.name = 'activity_type') AND
- value = '{$maxReminderSent}'";
-
- CRM_Core_DAO::executeQuery($query);
- }
- }
-
- /**
- * @param $rev
- */
- public function upgrade_4_2_5($rev) {
- $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.2.5')), 'runSql', $rev);
- //CRM-11077
- $sql = " SELECT cpse.entity_id, cpse.price_set_id
-FROM `civicrm_price_set_entity` cpse
-LEFT JOIN civicrm_price_set cps ON cps.id = cpse.price_set_id
-LEFT JOIN civicrm_price_set_entity cpse1 ON cpse1.price_set_id = cpse.price_set_id
-WHERE cpse.entity_table = 'civicrm_event' AND cps.is_quick_config = 1
-GROUP BY cpse.id
-HAVING COUNT(cpse.price_set_id) > 1 AND MIN(cpse1.id) <> cpse.id ";
-
- $dao = CRM_Core_DAO::executeQuery($sql);
- while ($dao->fetch()) {
- if ($dao->price_set_id) {
- $copyPriceSet = &CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set::copy($dao->price_set_id);
- CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set::addTo('civicrm_event', $dao->entity_id, $copyPriceSet->id);
- }
- }
- }
-
- public function convertContribution() {
- $minContributionId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(min(id),0) FROM civicrm_contribution');
- $maxContributionId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(max(id),0) FROM civicrm_contribution');
- for ($startId = $minContributionId; $startId <= $maxContributionId; $startId += self::BATCH_SIZE) {
- $endId = $startId + self::BATCH_SIZE - 1;
- $title = "Upgrade DB to 4.2.alpha1: Contributions ($startId => $endId)";
- $this->addTask($title, 'task_4_2_alpha1_convertContributions', $startId, $endId);
- }
- $minParticipantId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(min(id),0) FROM civicrm_participant');
- $maxParticipantId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(max(id),0) FROM civicrm_participant');
-
- for ($startId = $minParticipantId; $startId <= $maxParticipantId; $startId += self::BATCH_SIZE) {
- $endId = $startId + self::BATCH_SIZE - 1;
- $title = "Upgrade DB to 4.2.alpha1: Participant ($startId => $endId)";
- $this->addTask($title, 'task_4_2_alpha1_convertParticipants', $startId, $endId);
- }
- }
-
- /**
- * (Queue Task Callback)
- *
- * Upgrade code to create priceset for contribution pages and events
- *
- * @param \CRM_Queue_TaskContext $ctx
- * @param string $rev
- *
- * @return bool
- */
- public static function task_4_2_alpha1_createPriceSets(CRM_Queue_TaskContext $ctx, $rev) {
- $upgrade = new CRM_Upgrade_Form();
- $daoName = array(
- 'civicrm_contribution_page' => array(
- 'CRM_Contribute_BAO_ContributionPage',
- CRM_Core_Component::getComponentID('CiviContribute'),
- ),
- 'civicrm_event' => array(
- 'CRM_Event_BAO_Event',
- CRM_Core_Component::getComponentID('CiviEvent'),
- ),
- );
-
- // get all option group used for event and contribution page
- $query = "
-SELECT id, name
-FROM civicrm_option_group
-WHERE name LIKE '%.amount.%' ";
- $dao = CRM_Core_DAO::executeQuery($query);
- while ($dao->fetch()) {
- $addTo = explode('.', $dao->name);
- if (!empty($addTo[2])) {
- $options = array('optionGroup' => $dao->name);
- self::createPriceSet($daoName, $addTo, $options);
- }
- CRM_Core_OptionGroup::deleteAssoc($dao->name);
- }
-
- //create pricesets for contribution with only other amount
- $query = "
-SELECT ccp.id as contribution_page_id, ccp.is_allow_other_amount, cmb.id as membership_block_id
-FROM civicrm_contribution_page ccp
-LEFT JOIN civicrm_membership_block cmb ON cmb.entity_id = ccp.id AND cmb.entity_table = 'civicrm_contribution_page'
-LEFT JOIN civicrm_price_set_entity cpse ON cpse.entity_id = ccp.id and cpse.entity_table = 'civicrm_contribution_page'
-WHERE cpse.price_set_id IS NULL";
- $dao = CRM_Core_DAO::executeQuery($query);
- $addTo = array('civicrm_contribution_page');
- while ($dao->fetch()) {
- $addTo[2] = $dao->contribution_page_id;
- $options = array(
- 'otherAmount' => $dao->is_allow_other_amount,
- 'membership' => $dao->membership_block_id,
- );
- self::createPriceSet($daoName, $addTo, $options);
- }
-
- return TRUE;
- }
-
- /**
- * Create price sets.
- *
- * @param string $daoName
- * @param string $addTo
- * @param array $options
- */
- public static function createPriceSet($daoName, $addTo, $options = array()) {
- $query = "SELECT title FROM {$addTo[0]} where id =%1";
- $setParams['title'] = CRM_Core_DAO::singleValueQuery($query,
- array(1 => array($addTo[2], 'Integer'))
- );
- $pageTitle = strtolower(CRM_Utils_String::munge($setParams['title'], '_', 245));
-
- // an event or contrib page has been deleted but left the option group behind - (this may be fixed in later versions?)
- // we should probably delete the option group - but at least early exit here as the code following it does not fatal
- // CRM-10298
- if (empty($pageTitle)) {
- return;
- }
-
- $optionValue = array();
- if (!empty($options['optionGroup'])) {
- CRM_Core_OptionGroup::getAssoc($options['optionGroup'], $optionValue);
- if (empty($optionValue)) {
- return;
- }
- }
- elseif (empty($options['otherAmount']) && empty($options['membership'])) {
- //CRM-12273
- //if options group, otherAmount, membersip is empty then return, contribution should be default price set
- return;
- }
-
- if (!CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set', $pageTitle, 'id', 'name', TRUE)) {
- $setParams['name'] = $pageTitle;
- }
- else {
- $timeSec = explode(".", microtime(TRUE));
- $setParams['name'] = $pageTitle . '_' . date('is', $timeSec[0]) . $timeSec[1];
- }
- $setParams['extends'] = $daoName[$addTo[0]][1];
- $setParams['is_quick_config'] = 1;
- $priceSet = CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set::create($setParams);
- CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set::addTo($addTo[0], $addTo[2], $priceSet->id, 1);
-
- $fieldParams['price_set_id'] = $priceSet->id;
- if (!empty($options['optionGroup'])) {
- $fieldParams['html_type'] = 'Radio';
- $fieldParams['is_required'] = 1;
- if ($addTo[0] == 'civicrm_event') {
- $query = "SELECT fee_label FROM civicrm_event where id =%1";
- $fieldParams['name'] = $fieldParams['label'] = CRM_Core_DAO::singleValueQuery($query,
- array(1 => array($addTo[2], 'Integer'))
- );
- $defaultAmountColumn = 'default_fee_id';
- }
- else {
- $options['membership'] = 1;
- $fieldParams['name'] = strtolower(CRM_Utils_String::munge("Contribution Amount", '_', 245));
- $fieldParams['label'] = "Contribution Amount";
- $defaultAmountColumn = 'default_amount_id';
- $options['otherAmount'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $addTo[2], 'is_allow_other_amount');
- if (!empty($options['otherAmount'])) {
- $fieldParams['is_required'] = 0;
- }
- }
- $fieldParams['option_label'] = $optionValue['label'];
- $fieldParams['option_amount'] = $optionValue['value'];
- $fieldParams['option_weight'] = $optionValue['weight'];
- $fieldParams['is_quick_config'] = $setParams['is_quick_config'];
- if ($defaultAmount = CRM_Core_DAO::getFieldValue($daoName[$addTo[0]][0], $addTo[2], $defaultAmountColumn)) {
- $fieldParams['default_option'] = array_search($defaultAmount, $optionValue['amount_id']);
- }
- $priceField = CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::create($fieldParams);
-
- }
- if (!empty($options['membership'])) {
- $dao = new CRM_Member_DAO_MembershipBlock();
- $dao->entity_table = 'civicrm_contribution_page';
- $dao->entity_id = $addTo[2];
-
- if ($dao->find(TRUE)) {
- if ($dao->membership_types) {
- $fieldParams = array(
- 'name' => strtolower(CRM_Utils_String::munge("Membership Amount", '_', 245)),
- 'label' => "Membership Amount",
- 'is_required' => $dao->is_required,
- 'is_display_amounts' => $dao->display_min_fee,
- 'is_active' => $dao->is_active,
- 'price_set_id' => $priceSet->id,
- 'html_type' => 'Radio',
- 'weight' => 1,
- );
- $membershipTypes = unserialize($dao->membership_types);
- $rowcount = 0;
- foreach ($membershipTypes as $membershipType => $autoRenew) {
- $membershipTypeDetail = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($membershipType);
- $rowcount++;
- $fieldParams['option_label'][$rowcount] = $membershipTypeDetail['name'];
- $fieldParams['option_amount'][$rowcount] = $membershipTypeDetail['minimum_fee'];
- $fieldParams['option_weight'][$rowcount] = $rowcount;
- $fieldParams['membership_type_id'][$rowcount] = $membershipType;
- if ($membershipType == $dao->membership_type_default) {
- $fieldParams['default_option'] = $rowcount;
- }
- }
- $priceField = CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::create($fieldParams);
-
- $setParams = array(
- 'id' => $priceSet->id,
- 'extends' => CRM_Core_Component::getComponentID('CiviMember'),
- 'contribution_type_id' => CRM_Core_DAO::getFieldValue($daoName[$addTo[0]][0], $addTo[2], 'contribution_type_id'),
- );
- CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set::create($setParams);
- }
- }
- }
- if (!empty($options['otherAmount'])) {
-
- $fieldParams = array(
- 'name' => strtolower(CRM_Utils_String::munge("Other Amount", '_', 245)),
- 'label' => "Other Amount",
- 'is_required' => 0,
- 'is_display_amounts' => 0,
- 'is_active' => 1,
- 'price_set_id' => $priceSet->id,
- 'html_type' => 'Text',
- 'weight' => 3,
- );
- $fieldParams['option_label'][1] = "Other Amount";
- $fieldParams['option_amount'][1] = 1;
- $fieldParams['option_weight'][1] = 1;
- $priceField = CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::create($fieldParams);
- }
- }
-
- /**
- * (Queue Task Callback)
- *
- * Find any contribution records and create corresponding line-item
- * records.
- *
- * @param CRM_Queue_TaskContext $ctx
- * @param int $startId
- * the first/lowest contribution ID to convert.
- * @param int $endId
- * the last/highest contribution ID to convert.
- *
- * @return bool
- */
- public static function task_4_2_alpha1_convertContributions(CRM_Queue_TaskContext $ctx, $startId, $endId) {
- $upgrade = new CRM_Upgrade_Form();
- $query = "
- INSERT INTO civicrm_line_item(`entity_table` ,`entity_id` ,`price_field_id` ,`label` , `qty` ,`unit_price` ,`line_total` ,`participant_count` ,`price_field_value_id`)
- SELECT 'civicrm_contribution',cc.id, cpf.id as price_field_id, cpfv.label, 1, cc.total_amount, cc.total_amount line_total, 0, cpfv.id as price_field_value
- FROM civicrm_membership_payment cmp
- LEFT JOIN `civicrm_contribution` cc ON cc.id = cmp.contribution_id
- LEFT JOIN civicrm_line_item cli ON cc.id=cli.entity_id and cli.entity_table = 'civicrm_contribution'
- LEFT JOIN civicrm_membership cm ON cm.id=cmp.membership_id
- LEFT JOIN civicrm_membership_type cmt ON cmt.id = cm.membership_type_id
- LEFT JOIN civicrm_price_field cpf ON BINARY cpf.name = cmt.member_of_contact_id
- LEFT JOIN civicrm_price_field_value cpfv ON cpfv.membership_type_id = cm.membership_type_id AND cpf.id = cpfv.price_field_id
- WHERE (cc.id BETWEEN %1 AND %2) AND cli.entity_id IS NULL ;
- ";
- $sqlParams = array(
- 1 => array($startId, 'Integer'),
- 2 => array($endId, 'Integer'),
- );
- CRM_Core_DAO::executeQuery($query, $sqlParams);
-
- // create lineitems for contribution done for membership
- $sql = "
-SELECT cc.id, cmp.membership_id, cpse.price_set_id, cc.total_amount
-FROM civicrm_contribution cc
-LEFT JOIN civicrm_line_item cli ON cc.id=cli.entity_id AND cli.entity_table = 'civicrm_contribution'
-LEFT JOIN civicrm_membership_payment cmp ON cc.id = cmp.contribution_id
-LEFT JOIN civicrm_participant_payment cpp ON cc.id = cpp.contribution_id
-LEFT JOIN civicrm_price_set_entity cpse on cpse.entity_table = 'civicrm_contribution_page' AND cpse.entity_id = cc.contribution_page_id
-WHERE (cc.id BETWEEN %1 AND %2)
-AND cli.entity_id IS NULL AND cc.contribution_page_id IS NOT NULL AND cpp.contribution_id IS NULL
-GROUP BY cc.id, cmp.membership_id
-";
- $result = CRM_Core_DAO::executeQuery($sql, $sqlParams);
-
- while ($result->fetch()) {
- $sql = "
-SELECT cpf.id, cpfv.id as price_field_value_id, cpfv.label, cpfv.amount, cpfv.count
-FROM civicrm_price_field cpf
-LEFT JOIN civicrm_price_field_value cpfv ON cpf.id = cpfv.price_field_id
-WHERE cpf.price_set_id = %1
-";
- $lineParams = array(
- 'entity_table' => 'civicrm_contribution',
- 'entity_id' => $result->id,
- );
- if ($result->membership_id) {
- $sql .= " AND cpf.name = %2 AND cpfv.membership_type_id = %3 ";
- $params = array(
- '1' => array($result->price_set_id, 'Integer'),
- '2' => array('membership_amount', 'String'),
- '3' => array(
- CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $result->membership_id, 'membership_type_id'),
- 'Integer',
- ),
- );
- $res = CRM_Core_DAO::executeQuery($sql, $params);
- if ($res->fetch()) {
- $lineParams += array(
- 'price_field_id' => $res->id,
- 'label' => $res->label,
- 'qty' => 1,
- 'unit_price' => $res->amount,
- 'line_total' => $res->amount,
- 'participant_count' => $res->count ? $res->count : 0,
- 'price_field_value_id' => $res->price_field_value_id,
- );
- }
- else {
- $lineParams['price_field_id'] = CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $result->price_set_id, 'id', 'price_set_id');
- $lineParams['label'] = 'Membership Amount';
- $lineParams['qty'] = 1;
- $lineParams['unit_price'] = $lineParams['line_total'] = $result->total_amount;
- $lineParams['participant_count'] = 0;
- }
- }
- else {
- $sql .= "AND cpfv.amount = %2";
-
- //CRM-12273
- //check if price_set_id is exist, if not use the default contribution amount
- if (isset($result->price_set_id)) {
- $priceSetId = $result->price_set_id;
- }
- else {
- $defaultPriceSets = CRM_Price_BAO_PriceSet::getDefaultPriceSet();
- foreach ($defaultPriceSets as $key => $pSet) {
- if ($pSet['name'] == 'contribution_amount') {
- $priceSetId = $pSet['setID'];
- }
- }
- }
-
- $params = array(
- '1' => array($priceSetId, 'Integer'),
- '2' => array($result->total_amount, 'String'),
- );
- $res = CRM_Core_DAO::executeQuery($sql, $params);
- if ($res->fetch()) {
- $lineParams += array(
- 'price_field_id' => $res->id,
- 'label' => $res->label,
- 'qty' => 1,
- 'unit_price' => $res->amount,
- 'line_total' => $res->amount,
- 'participant_count' => $res->count ? $res->count : 0,
- 'price_field_value_id' => $res->price_field_value_id,
- );
- }
- else {
- $params = array(
- 'price_set_id' => $priceSetId,
- 'name' => 'other_amount',
- );
- $defaults = array();
- CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::retrieve($params, $defaults);
- if (!empty($defaults)) {
- $lineParams['price_field_id'] = $defaults['id'];
- $lineParams['label'] = $defaults['label'];
- $lineParams['price_field_value_id']
- = CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue', $defaults['id'], 'id', 'price_field_id');
- }
- else {
- $lineParams['price_field_id']
- = CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $priceSetId, 'id', 'price_set_id');
- $lineParams['label'] = 'Contribution Amount';
- }
- $lineParams['qty'] = 1;
- $lineParams['participant_count'] = 0;
- $lineParams['unit_price'] = $lineParams['line_total'] = $result->total_amount;
- }
- }
- CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem::create($lineParams);
- }
-
- return TRUE;
- }
-
- /**
- * (Queue Task Callback)
- *
- * Find any participant records and create corresponding line-item
- * records.
- *
- * @param CRM_Queue_TaskContext $ctx
- * @param int $startId
- * the first/lowest participant ID to convert.
- * @param int $endId
- * the last/highest participant ID to convert.
- *
- * @return bool
- */
- public static function task_4_2_alpha1_convertParticipants(CRM_Queue_TaskContext $ctx, $startId, $endId) {
- $upgrade = new CRM_Upgrade_Form();
- //create lineitems for participant in edge cases using default price set for contribution.
- $query = "
-SELECT cp.id as participant_id, cp.fee_amount, cp.fee_level,ce.is_monetary,
- cpse.price_set_id, cpf.id as price_field_id, cpfv.id as price_field_value_id
-FROM civicrm_participant cp
-LEFT JOIN civicrm_line_item cli ON cli.entity_id=cp.id and cli.entity_table = 'civicrm_participant'
-LEFT JOIN civicrm_event ce ON ce.id=cp.event_id
-LEFT JOIN civicrm_price_set_entity cpse ON cp.event_id = cpse.entity_id and cpse.entity_table = 'civicrm_event'
-LEFT JOIN civicrm_price_field cpf ON cpf.price_set_id = cpse.price_set_id
-LEFT JOIN civicrm_price_field_value cpfv ON cpfv.price_field_id = cpf.id AND cpfv.label = cp.fee_level
-WHERE (cp.id BETWEEN %1 AND %2)
-AND cli.entity_id IS NULL AND cp.fee_amount IS NOT NULL";
- $sqlParams = array(
- 1 => array($startId, 'Integer'),
- 2 => array($endId, 'Integer'),
- );
- $dao = CRM_Core_DAO::executeQuery($query, $sqlParams);
- if ($dao->N) {
- $defaultPriceSetId = CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', 'default_contribution_amount', 'id', 'name');
- $priceSets = current(CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set::getSetDetail($defaultPriceSetId));
- $fieldID = key($priceSets['fields']);
- }
-
- while ($dao->fetch()) {
- $lineParams = array(
- 'entity_table' => 'civicrm_participant',
- 'entity_id' => $dao->participant_id,
- 'label' => $dao->fee_level ? $dao->fee_level : ts('Default'),
- 'qty' => 1,
- 'unit_price' => $dao->fee_amount,
- 'line_total' => $dao->fee_amount,
- 'participant_count' => 1,
- );
- if ($dao->is_monetary && $dao->price_field_id) {
- $lineParams += array(
- 'price_field_id' => $dao->price_field_id,
- 'price_field_value_id' => $dao->price_field_value_id,
- );
- $priceSetId = $dao->price_set_id;
- }
- else {
- $lineParams['price_field_id'] = $fieldID;
- $priceSetId = $defaultPriceSetId;
- }
- CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem::create($lineParams);
- }
- return TRUE;
- }
-
- /**
- * (Queue Task Callback)
- *
- * Create an event registration profile with a single email field CRM-9587
- *
- * @param \CRM_Queue_TaskContext $ctx
- *
- * @return bool
- */
- public static function task_4_2_alpha1_eventProfile(CRM_Queue_TaskContext $ctx) {
- $upgrade = new CRM_Upgrade_Form();
- $profileTitle = ts('Your Registration Info');
-
- $sql = "
-INSERT INTO civicrm_uf_group
- (is_active, group_type, title, help_pre, help_post, limit_listings_group_id, post_URL, add_to_group_id, add_captcha, is_map, is_edit_link, is_uf_link, is_update_dupe, cancel_URL, is_cms_user, notify, is_reserved, name, created_id, created_date, is_proximity_search)
-VALUES
- (1, 'Individual, Contact', %1, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, 0, NULL, 0, 'event_registration', NULL, NULL, 0);
-";
-
- $params = array(
- 1 => array($profileTitle, 'String'),
- );
-
- CRM_Core_DAO::executeQuery($sql, $params);
-
- $eventRegistrationId = CRM_Core_DAO::singleValueQuery('SELECT LAST_INSERT_ID()');
- $sql = "
-INSERT INTO civicrm_uf_field
- (uf_group_id, field_name, is_active, is_view, is_required, weight, help_post, help_pre, visibility, in_selector, is_searchable, location_type_id, phone_type_id, label, field_type, is_reserved)
-VALUES
- ({$eventRegistrationId}, 'email', 1, 0, 1, 1, NULL, NULL, 'User and User Admin Only', 0, 0, NULL, NULL, 'Email Address', 'Contact', 0);
-";
- CRM_Core_DAO::executeQuery($sql);
-
- $sql = "SELECT * FROM civicrm_event WHERE is_online_registration = 1;";
- $events = CRM_Core_DAO::executeQuery($sql);
- while ($events->fetch()) {
- // Get next weights for the event registration profile
- $nextMainWeight = $nextAdditionalWeight = 1;
- $sql = "
-SELECT weight
-FROM civicrm_uf_join
-WHERE entity_id = {$events->id} AND module = 'CiviEvent'
-ORDER BY weight DESC LIMIT 1";
- $weights = CRM_Core_DAO::executeQuery($sql);
- $weights->fetch();
- if (isset($weights->weight)) {
- $nextMainWeight += $weights->weight;
- }
- $sql = "
-SELECT weight
-FROM civicrm_uf_join
-WHERE entity_id = {$events->id} AND module = 'CiviEvent_Additional'
-ORDER BY weight DESC LIMIT 1";
- $weights = CRM_Core_DAO::executeQuery($sql);
- $weights->fetch();
- if (isset($weights->weight)) {
- $nextAdditionalWeight += $weights->weight;
- }
- // Add an event registration profile to the event
- $sql = "
-INSERT INTO civicrm_uf_join
- (is_active, module, entity_table, entity_id, weight, uf_group_id)
-VALUES
- (1, 'CiviEvent', 'civicrm_event', {$events->id}, {$nextMainWeight}, {$eventRegistrationId});
-";
- CRM_Core_DAO::executeQuery($sql);
- $sql = "
-INSERT INTO civicrm_uf_join
- (is_active, module, entity_table, entity_id, weight, uf_group_id)
-VALUES
- (1, 'CiviEvent_Additional', 'civicrm_event', {$events->id}, {$nextAdditionalWeight}, {$eventRegistrationId});";
- CRM_Core_DAO::executeQuery($sql);
- }
- return TRUE;
- }
-
- /**
- * @return array
- */
- public static function deleteInvalidPairs() {
- require_once 'CRM/Member/PseudoConstant.php';
- require_once 'CRM/Contribute/PseudoConstant.php';
- $processedRecords = array();
-
- $tempTableName1 = CRM_Core_DAO::createTempTableName();
- // 1. collect all duplicates
- $sql = "
- CREATE TEMPORARY TABLE {$tempTableName1} SELECT mp.id as payment_id, mp.contribution_id, mp.membership_id, mem.membership_type_id, mem.start_date, mem.end_date, mem.status_id, mem.contact_id, con.contribution_status_id
- FROM civicrm_membership_payment mp
- INNER JOIN ( SELECT cmp.contribution_id
- FROM civicrm_membership_payment cmp
- LEFT JOIN civicrm_line_item cli ON cmp.contribution_id=cli.entity_id and cli.entity_table = 'civicrm_contribution'
- WHERE cli.entity_id IS NULL
- GROUP BY cmp.contribution_id
- HAVING COUNT(cmp.membership_id) > 1) submp ON submp.contribution_id = mp.contribution_id
- INNER JOIN civicrm_membership mem ON mem.id = mp.membership_id
- INNER JOIN civicrm_contribution con ON con.id = mp.contribution_id
- ORDER BY mp.contribution_id, mp.membership_id";
- $dao = CRM_Core_DAO::executeQuery($sql);
-
- $tempTableName2 = CRM_Core_DAO::createTempTableName();
- // 2. collect all records that are going to be retained
- $sql = "
- CREATE TEMPORARY TABLE {$tempTableName2}
- SELECT MAX(payment_id) as payment_id FROM {$tempTableName1} GROUP BY contribution_id HAVING COUNT(*) > 1";
- CRM_Core_DAO::executeQuery($sql);
-
- // 3. do the un-linking
- $sql = "
- DELETE cmp.*
- FROM civicrm_membership_payment cmp
- INNER JOIN $tempTableName1 temp1 ON temp1.payment_id = cmp.id
- LEFT JOIN $tempTableName2 temp2 ON temp1.payment_id = temp2.payment_id
- WHERE temp2.payment_id IS NULL";
- CRM_Core_DAO::executeQuery($sql);
-
- // 4. show all records that were Processed, i.e Retained vs Un-linked
- $sql = "
- SELECT temp1.contact_id, temp1.contribution_id, temp1.contribution_status_id, temp1.membership_id, temp1.membership_type_id, temp1.start_date, temp1.end_date, temp1.status_id, temp2.payment_id as retain_id
- FROM $tempTableName1 temp1
- LEFT JOIN $tempTableName2 temp2 ON temp1.payment_id = temp2.payment_id";
- $dao = CRM_Core_DAO::executeQuery($sql);
- if ($dao->N) {
- $membershipType = CRM_Member_PseudoConstant::membershipType();
- $membershipStatus = CRM_Member_PseudoConstant::membershipStatus();
- $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus();
- while ($dao->fetch()) {
- $status = $dao->retain_id ? 'Retained' : 'Un-linked';
- $memType = CRM_Utils_Array::value($dao->membership_type_id, $membershipType);
- $memStatus = CRM_Utils_Array::value($dao->status_id, $membershipStatus);
- $contribStatus = CRM_Utils_Array::value($dao->contribution_status_id, $contributionStatus);
- $processedRecords[] = array(
- $dao->contact_id,
- $dao->contribution_id,
- $contribStatus,
- $dao->membership_id,
- $memType,
- $dao->start_date,
- $dao->end_date,
- $memStatus,
- $status,
- );
- }
- }
-
- if (!empty($processedRecords)) {
- CRM_Core_Error::debug_log_message("deleteInvalidPairs() - The following records have been processed. Membership records with action:");
- CRM_Core_Error::debug_log_message("Contact ID, ContributionID, Contribution Status, MembershipID, Membership Type, Start Date, End Date, Membership Status, Action");
- foreach ($processedRecords as $record) {
- CRM_Core_Error::debug_log_message(implode(', ', $record));
- }
- }
- else {
- CRM_Core_Error::debug_log_message("deleteInvalidPairs() - Could not find any records to process.");
- }
- return $processedRecords;
- }
-
-}
+++ /dev/null
--- CRM-10641 (fix duplicate option values)
-
-SELECT @option_group_id_act := max(id) from civicrm_option_group where name = 'activity_type';
-SELECT @maxValue := MAX(ROUND(value)) FROM civicrm_option_value WHERE option_group_id = @option_group_id_act;
-SELECT @clientSMSValue := value FROM civicrm_option_value WHERE name = 'BULK SMS' AND option_group_id = @option_group_id_act;
-
-SELECT @smsVal := value FROM civicrm_option_value WHERE option_group_id = @option_group_id_act GROUP BY value
-HAVING count(value) > 1 AND value = @clientSMSValue;
-
-UPDATE civicrm_option_value
-SET value = @maxValue + 1
-WHERE value = @smsVal
-AND name = 'BULK SMS' AND option_group_id = @option_group_id_act;
-
-SELECT @newClientSMSValue := value FROM civicrm_option_value WHERE name = 'BULK SMS' AND option_group_id = @option_group_id_act;
-
-UPDATE civicrm_activity
-INNER JOIN civicrm_mailing ON civicrm_activity.source_record_id = civicrm_mailing.id
-SET civicrm_activity.activity_type_id = @newClientSMSValue
-WHERE civicrm_activity.activity_type_id = @clientSMSValue;
-
--- CRM-10671 remove incomplete price set reports (inserted in 4.2 alpha 1)
-SELECT @option_group_id_report := MAX(id) FROM civicrm_option_group WHERE name = 'report_template';
-DELETE from civicrm_option_value
-WHERE name = 'CRM_Report_Form_Price_Lineitem' AND
-option_group_id = @option_group_id_report;
-
-DELETE from civicrm_option_value
-WHERE name = 'CRM_Report_Form_Price_Contributionbased' AND
-option_group_id = @option_group_id_report;
-
-DELETE from civicrm_option_value
-WHERE name = 'CRM_Report_Form_Price_Lineitemparticipant' AND
-option_group_id = @option_group_id_report;
\ No newline at end of file
+++ /dev/null
--- CRM-10794
-DELETE FROM civicrm_payment_processor_type WHERE name = 'ClickAndPledge';
-DELETE FROM civicrm_payment_processor WHERE payment_processor_type = 'ClickAndPledge';
-
+++ /dev/null
--- CRM-10810
-SELECT @max_strict := max(id), @cnt_strict := count(*) FROM `civicrm_dedupe_rule_group` WHERE `contact_type` = 'Individual' AND `level` = 'Strict' AND `is_default` = 1;
-UPDATE `civicrm_dedupe_rule_group` SET `is_default` = 0 WHERE @cnt_strict > 1 AND id = @max_strict;
-
-SELECT @max_fuzzy := max(id), @cnt_fuzzy := count(*) FROM `civicrm_dedupe_rule_group` WHERE `contact_type` = 'Individual' AND `level` = 'Fuzzy' AND `is_default` = 1;
-UPDATE `civicrm_dedupe_rule_group` SET `is_default` = 0 WHERE @cnt_fuzzy > 1 AND id = @max_fuzzy;
-
--- Insert line items for contribution for api/import
-SELECT @fieldID := cpf.id, @fieldValueID := cpfv.id FROM civicrm_price_set cps
-LEFT JOIN civicrm_price_field cpf ON cps.id = cpf.price_set_id
-LEFT JOIN civicrm_price_field_value cpfv ON cpf.id = cpfv.price_field_id
-WHERE cps.name = 'default_contribution_amount';
-
-INSERT INTO civicrm_line_item ( entity_table, entity_id, price_field_id,label, qty, unit_price, line_total, participant_count, price_field_value_id )
-SELECT 'civicrm_contribution', cc.id, @fieldID, 'Contribution Amount', 1, total_amount, total_amount , 0, @fieldValueID
-FROM `civicrm_contribution` cc
-LEFT JOIN civicrm_line_item cli ON cc.id=cli.entity_id and cli.entity_table = 'civicrm_contribution'
-LEFT JOIN civicrm_membership_payment cmp ON cc.id = cmp.contribution_id
-LEFT JOIN civicrm_participant_payment cpp ON cc.id = cpp.contribution_id
-WHERE cli.entity_id IS NULL AND cc.contribution_page_id IS NULL AND cmp.contribution_id IS NULL AND cpp.contribution_id IS NULL
-GROUP BY cc.id;
+++ /dev/null
--- CRM-10969
-SELECT @mailingsID := MAX(id) FROM civicrm_navigation WHERE name = 'Mailings' AND domain_id = {$domainID};
-SELECT @navWeight := MAX(id) FROM civicrm_navigation WHERE name = 'New SMS' AND parent_id = @mailingsID;
-
-UPDATE civicrm_navigation SET has_separator = NULL
-WHERE name = 'New SMS' AND parent_id = @mailingsID AND has_separator = 1;
-
-INSERT INTO civicrm_navigation
- ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
-VALUES
- ( {$domainID}, 'civicrm/mailing/browse?reset=1&sms=1', '{ts escape="sql" skip="true"}Find Mass SMS{/ts}', 'Find Mass SMS', 'administer CiviCRM', NULL, @mailingsID, '1', 1, @navWeight+1 );
-
--- CRM-10980 and CRM-11014
-SELECT @optionID := max(id) FROM civicrm_option_value WHERE name = 'BULK SMS';
-{if $multilingual}
- {foreach from=$locales item=locale}
- UPDATE `civicrm_option_value` SET label_{$locale} = '{ts escape="sql"}Mass SMS{/ts}',name = 'Mass SMS',description_{$locale} = '{ts escape="sql"}Mass SMS{/ts}' WHERE id = @optionID;
- ALTER TABLE `civicrm_price_field_value` CHANGE name name VARCHAR(255) NULL DEFAULT NULL, CHANGE label_{$locale} label_{$locale} VARCHAR(255) NULL DEFAULT NULL;
- {/foreach}
-{else}
- UPDATE `civicrm_option_value` SET label = '{ts escape="sql"}Mass SMS{/ts}',name = 'Mass SMS',description = '{ts escape="sql"}Mass SMS{/ts}' WHERE name = 'BULK SMS';
- ALTER TABLE `civicrm_price_field_value` CHANGE `name` `name` VARCHAR(255) NULL DEFAULT NULL, CHANGE `label` `label` VARCHAR(255) NULL DEFAULT NULL;
-{/if}
-
--- CRM-11014
- ALTER TABLE `civicrm_line_item` CHANGE `label` `label` VARCHAR(255) NULL DEFAULT NULL;
-
--- CRM-10986: Rename Batches UI elements to Bulk Data Entry
--- update reserved profile titles
-{if $multilingual}
- {foreach from=$locales item=locale}
- UPDATE `civicrm_uf_group` SET title_{$locale} = '{ts escape="sql"}Contribution Bulk Entry{/ts}' WHERE name = 'contribution_batch_entry';
- UPDATE `civicrm_uf_group` SET title_{$locale} = '{ts escape="sql"}Membership Bulk Entry{/ts}' WHERE name = 'membership_batch_entry';
- {/foreach}
-{else}
- UPDATE `civicrm_uf_group` SET title = '{ts escape="sql"}Contribution Bulk Entry{/ts}' WHERE name = 'contribution_batch_entry';
- UPDATE `civicrm_uf_group` SET title = '{ts escape="sql"}Membership Bulk Entry{/ts}' WHERE name = 'membership_batch_entry';
-{/if}
-
--- update navigation menu items and fix typo in permission column
-UPDATE `civicrm_navigation` SET label = '{ts escape="sql"}Bulk Data Entry{/ts}', name = 'Bulk Data Entry',
-permission = 'access CiviMember, access CiviContribute'
-WHERE url = 'civicrm/batch&reset=1';
-
--- CRM-11018
-ALTER TABLE civicrm_discount DROP FOREIGN KEY FK_civicrm_discount_option_group_id;
-ALTER TABLE `civicrm_discount`
- ADD CONSTRAINT `FK_civicrm_discount_option_group_id` FOREIGN KEY (`option_group_id`) REFERENCES `civicrm_price_set` (`id`) ON DELETE CASCADE;
-ALTER TABLE `civicrm_discount` CHANGE `option_group_id` `option_group_id` int(10) unsigned NOT NULL COMMENT 'FK to civicrm_price_set';
\ No newline at end of file
+++ /dev/null
--- Placeholder which ensures that PHP upgrade tasks are executed
-
--- Get domain id
-SELECT @domainID := min(id) FROM civicrm_domain;
-
--- CRM-11060
-INSERT INTO `civicrm_job`
- ( domain_id, run_frequency, last_run, name, description, api_prefix, api_entity, api_action, parameters, is_active )
-VALUES
- ( @domainID, 'Always' , NULL, '{ts escape="sql" skip="true"}Send Scheduled SMS{/ts}', '{ts escape="sql" skip="true"}Sends out scheduled SMS{/ts}', 'civicrm_api3', 'job', 'process_sms', NULL, 0);
+++ /dev/null
--- Placeholder which ensures that PHP upgrade tasks are executed
-
+++ /dev/null
--- CRM-11354 Fix empty permissions for report instances
-UPDATE civicrm_report_instance SET permission = 'access CiviReport'
-WHERE report_id = 'survey/detail' and permission = '';
-
-UPDATE civicrm_report_instance SET permission = 'access CiviMail'
-WHERE report_id = 'mailing/detail' and permission = '';
-
-UPDATE civicrm_report_instance SET permission = 'access CiviMember'
-WHERE report_id = 'member/contributionDetail' and permission = '';
-
-UPDATE civicrm_report_instance SET permission = 'access CiviGrant'
-WHERE report_id = 'grant/statistics' and permission = '';
-
-UPDATE civicrm_report_instance SET permission = 'access CiviReport'
-WHERE permission = '0' OR permission = '' OR permission IS NULL;
\ No newline at end of file
+++ /dev/null
--- Placeholder which ensures that PHP upgrade tasks are executed
-
+++ /dev/null
--- Placeholder which ensures that PHP upgrade tasks are executed
-
+++ /dev/null
-{include file='../CRM/Upgrade/4.2.alpha1.msg_template/civicrm_msg_template.tpl'}
-
--- CRM-9542 mailing detail report template
-SELECT @option_group_id_report := MAX(id) FROM civicrm_option_group WHERE name = 'report_template';
-SELECT @weight := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_report;
-SELECT @mailCompId := MAX(id) FROM civicrm_component where name = 'CiviMail';
-INSERT INTO civicrm_option_value
- (option_group_id, {localize field='label'}label{/localize}, value, name, weight, {localize field='description'}description{/localize}, is_active, component_id) VALUES
- (@option_group_id_report, {localize}'Mail Detail Report'{/localize}, 'mailing/detail', 'CRM_Report_Form_Mailing_Detail', @weight := @weight + 1, {localize}'Provides reporting on Intended and Successful Deliveries, Unsubscribes and Opt-outs, Replies and Forwards.'{/localize}, 1, @mailCompId);
-
-INSERT INTO `civicrm_report_instance`
- ( `domain_id`, `title`, `report_id`, `description`, `permission`, `form_values`)
-VALUES
- ( {$domainID}, 'Mailing Detail Report', 'mailing/detail', 'Provides reporting on Intended and Successful Deliveries, Unsubscribes and Opt-outs, Replies and Forwards.', 'access CiviMail', '{literal}a:30:{s:6:"fields";a:6:{s:9:"sort_name";s:1:"1";s:12:"mailing_name";s:1:"1";s:11:"delivery_id";s:1:"1";s:14:"unsubscribe_id";s:1:"1";s:9:"optout_id";s:1:"1";s:5:"email";s:1:"1";}s:12:"sort_name_op";s:3:"has";s:15:"sort_name_value";s:0:"";s:6:"id_min";s:0:"";s:6:"id_max";s:0:"";s:5:"id_op";s:3:"lte";s:8:"id_value";s:0:"";s:13:"mailing_id_op";s:2:"in";s:16:"mailing_id_value";a:0:{}s:18:"delivery_status_op";s:2:"eq";s:21:"delivery_status_value";s:0:"";s:18:"is_unsubscribed_op";s:2:"eq";s:21:"is_unsubscribed_value";s:0:"";s:12:"is_optout_op";s:2:"eq";s:15:"is_optout_value";s:0:"";s:13:"is_replied_op";s:2:"eq";s:16:"is_replied_value";s:0:"";s:15:"is_forwarded_op";s:2:"eq";s:18:"is_forwarded_value";s:0:"";s:6:"gid_op";s:2:"in";s:9:"gid_value";a:0:{}s:9:"order_bys";a:1:{i:1;a:2:{s:6:"column";s:9:"sort_name";s:5:"order";s:3:"ASC";}}s:11:"description";s:21:"Mailing Detail Report";s:13:"email_subject";s:0:"";s:8:"email_to";s:0:"";s:8:"email_cc";s:0:"";s:10:"permission";s:15:"access CiviMail";s:9:"parent_id";s:0:"";s:6:"groups";s:0:"";s:9:"domain_id";i:1;}{/literal}');
-
-SELECT @reportlastID := MAX(id) FROM civicrm_navigation where name = 'Reports' AND domain_id = {$domainID};
-SELECT @nav_max_weight := MAX(ROUND(weight)) from civicrm_navigation WHERE parent_id = @reportlastID;
-
-SET @instanceID:=LAST_INSERT_ID();
-INSERT INTO civicrm_navigation
- ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
-VALUES
- ( {$domainID}, CONCAT('civicrm/report/instance/', @instanceID,'&reset=1'), '{ts escape="sql"}Mailing Detail Report{/ts}', 'Mailing Detail Report', 'access CiviMail', 'OR', @reportlastID, '1', NULL, @nav_max_weight+1 );
-UPDATE civicrm_report_instance SET navigation_id = LAST_INSERT_ID() WHERE id = @instanceID;
-
--- CRM-9600
-ALTER TABLE `civicrm_custom_group` CHANGE `extends_entity_column_value` `extends_entity_column_value` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'linking custom group for dynamic object.';
-
--- CRM-9534
-ALTER TABLE `civicrm_prevnext_cache` ADD COLUMN is_selected tinyint(4) DEFAULT '0';
-
--- CRM-9834
--- civicrm_batch table changes
-ALTER TABLE `civicrm_batch` ADD UNIQUE KEY `UI_name` ( name );
-
-
-ALTER TABLE `civicrm_batch` ADD `saved_search_id` int(10) unsigned DEFAULT NULL COMMENT 'FK to Saved Search ID';
-ALTER TABLE `civicrm_batch` ADD `status_id` int(10) unsigned NOT NULL COMMENT 'fk to Batch Status options in civicrm_option_values';
-ALTER TABLE `civicrm_batch` ADD `type_id` int(10) unsigned NOT NULL COMMENT 'fk to Batch Type options in civicrm_option_values';
-ALTER TABLE `civicrm_batch` ADD `mode_id` int(10) unsigned DEFAULT NULL COMMENT 'fk to Batch mode options in civicrm_option_values';
-ALTER TABLE `civicrm_batch` ADD `total` decimal(20,2) DEFAULT NULL COMMENT 'Total amount for this batch.';
-ALTER TABLE `civicrm_batch` ADD `item_count` int(10) unsigned NOT NULL COMMENT 'Number of items in a batch.';
-
-ALTER TABLE `civicrm_batch` ADD CONSTRAINT `FK_civicrm_batch_saved_search_id` FOREIGN KEY (`saved_search_id`) REFERENCES `civicrm_saved_search` (`id`) ON DELETE SET NULL;
-
---batch type and batch status option groups
-INSERT INTO
- `civicrm_option_group` (`name`, {localize field='title'}title{/localize}, `is_reserved`, `is_active`)
-VALUES
- ('batch_type' , {localize}'Batch Type'{/localize} , 1, 1),
- ('batch_status' , {localize}'Batch Status'{/localize} , 1, 1);
-
-SELECT @option_group_id_batch_type := max(id) from civicrm_option_group where name = 'batch_type';
-SELECT @option_group_id_batch_status := max(id) from civicrm_option_group where name = 'batch_status';
-
-INSERT INTO
- `civicrm_option_value` (`option_group_id`, {localize field='label'}label{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`)
-VALUES
- (@option_group_id_batch_type, {localize}'Contribution'{/localize}, 1, 'Contribution', NULL, 0, 0, 1),
- (@option_group_id_batch_type, {localize}'Membership'{/localize}, 2, 'Membership', NULL, 0, 0, 2),
- (@option_group_id_batch_status, {localize}'Open'{/localize}, 1, 'Open', NULL, 0, 0, 1),
- (@option_group_id_batch_status, {localize}'Closed'{/localize}, 2, 'Closed', NULL, 0, 0, 2);
-
---default profile for contribution and membership batch entry
-INSERT INTO civicrm_uf_group
- ( name, group_type, {localize field='title'}title{/localize}, is_cms_user, is_reserved)
- VALUES
- ( 'contribution_batch_entry', 'Contribution', {localize}'Contribution Batch Entry'{/localize} , 0, 1),
- ( 'membership_batch_entry', 'Membership', {localize}'Membership Batch Entry'{/localize} , 0, 1);
-
-SELECT @uf_group_contribution_batch_entry := max(id) FROM civicrm_uf_group WHERE name = 'contribution_batch_entry';
-SELECT @uf_group_membership_batch_entry := max(id) FROM civicrm_uf_group WHERE name = 'membership_batch_entry';
-
-INSERT INTO civicrm_uf_join
- (is_active, module, entity_table, entity_id, weight, uf_group_id)
-VALUES
- (1, 'Profile', NULL, NULL, 9, @uf_group_contribution_batch_entry),
- (1, 'Profile', NULL, NULL, 9, @uf_group_membership_batch_entry);
-
-INSERT INTO civicrm_uf_field
- ( uf_group_id, field_name, is_required, is_reserved, weight, visibility, in_selector, is_searchable, location_type_id, {localize field='label'}label{/localize}, field_type )
-VALUES
- ( @uf_group_contribution_batch_entry, 'contribution_type', 1, 1, 1, 'User and User Admin Only', 0, 0, NULL, {localize}'Type'{/localize}, 'Contribution'),
- ( @uf_group_contribution_batch_entry, 'total_amount', 1, 1, 2, 'User and User Admin Only', 0, 0, NULL, {localize}'Amount'{/localize}, 'Contribution' ),
- ( @uf_group_contribution_batch_entry, 'contribution_status_id', 1, 1, 3, 'User and User Admin Only', 0, 0, NULL, {localize}'Status'{/localize}, 'Contribution' ),
- ( @uf_group_contribution_batch_entry, 'receive_date', 1, 1, 4, 'User and User Admin Only', 0, 0, NULL, {localize}'Received'{/localize}, 'Contribution'),
- ( @uf_group_contribution_batch_entry, 'contribution_source', 0, 0, 5, 'User and User Admin Only', 0, 0, NULL, {localize}'Source'{/localize}, 'Contribution' ),
- ( @uf_group_contribution_batch_entry, 'payment_instrument', 0, 0, 6, 'User and User Admin Only', 0, 0, NULL, {localize}'Payment Instrument'{/localize}, 'Contribution' ),
- ( @uf_group_contribution_batch_entry, 'check_number', 0, 0, 7, 'User and User Admin Only', 0, 0, NULL, {localize}'Check Number'{/localize}, 'Contribution' ),
- ( @uf_group_contribution_batch_entry, 'send_receipt', 0, 0, 8, 'User and User Admin Only', 0, 0, NULL, {localize}'Send Receipt'{/localize}, 'Contribution' ),
- ( @uf_group_contribution_batch_entry, 'invoice_id', 0, 0, 9, 'User and User Admin Only', 0, 0, NULL, {localize}'Invoice ID'{/localize}, 'Contribution' ),
- ( @uf_group_membership_batch_entry, 'membership_type', 1, 1, 1, 'User and User Admin Only', 0, 0, NULL, {localize}'Type'{/localize}, 'Membership' ),
- ( @uf_group_membership_batch_entry, 'join_date', 1, 1, 2, 'User and User Admin Only', 0, 0, NULL, {localize}'Member Since'{/localize}, 'Membership' ),
- ( @uf_group_membership_batch_entry, 'membership_start_date', 0, 1, 3, 'User and User Admin Only', 0, 0, NULL, {localize}'Start Date'{/localize}, 'Membership' ),
- ( @uf_group_membership_batch_entry, 'membership_end_date', 0, 1, 4, 'User and User Admin Only', 0, 0, NULL, {localize}'End Date'{/localize}, 'Membership' ),
- ( @uf_group_membership_batch_entry, 'membership_source', 0, 0, 5, 'User and User Admin Only', 0, 0, NULL, {localize}'Source'{/localize}, 'Membership' ),
- ( @uf_group_membership_batch_entry, 'send_receipt', 0, 0, 6, 'User and User Admin Only', 0, 0, NULL, {localize}'Send Receipt'{/localize}, 'Membership' ),
- ( @uf_group_membership_batch_entry, 'contribution_type', 1, 1, 7, 'User and User Admin Only', 0, 0, NULL, {localize}'Contribution Type'{/localize}, 'Membership' ),
- ( @uf_group_membership_batch_entry, 'total_amount', 1, 1, 8, 'User and User Admin Only', 0, 0, NULL, {localize}'Amount'{/localize}, 'Membership' ),
- ( @uf_group_membership_batch_entry, 'receive_date', 1, 1, 9, 'User and User Admin Only', 0, 0, NULL, {localize}'Received'{/localize}, 'Membership' ),
- ( @uf_group_membership_batch_entry, 'payment_instrument', 0, 0, 10, 'User and User Admin Only', 0, 0, NULL, {localize}'Payment Instrument'{/localize}, 'Membership' ),
- ( @uf_group_membership_batch_entry, 'contribution_status_id', 1, 1, 11, 'User and User Admin Only', 0, 0, NULL, {localize}'Payment Status'{/localize}, 'Membership' );
-
---navigation menu entries
-SELECT @navContributionsID := MAX(id) FROM civicrm_navigation where name = 'Contributions' AND domain_id = {$domainID};
-SELECT @navMembershipsID := MAX(id) FROM civicrm_navigation where name = 'Memberships' AND domain_id = {$domainID};
-
-INSERT INTO civicrm_navigation
- ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
-VALUES
- ( {$domainID}, 'civicrm/batch&reset=1', '{ts escape="sql" skip="true"}Batches{/ts}', 'Batches', 'access CiviContribute,access CiviMember', '', @navContributionsID, '1', NULL, 4 ),
- ( {$domainID}, 'civicrm/batch&reset=1', '{ts escape="sql" skip="true"}Batches{/ts}', 'Batches', 'access CiviMember,access CiviContribute', '', @navMembershipsID, '1', NULL, 4 );
-
--- CRM-9686
-INSERT INTO `civicrm_state_province`(`country_id`, `abbreviation`, `name`) VALUES(1097, "LP", "La Paz");
-
--- CRM-9905
-ALTER TABLE civicrm_contribution_page CHANGE COLUMN is_email_receipt is_email_receipt TINYINT(4) DEFAULT 0;
-
--- CRM-9850
- ALTER TABLE `civicrm_contribution_page` CHANGE `payment_processor_id` `payment_processor` VARCHAR( 128 ) NULL DEFAULT NULL COMMENT 'Payment Processor for this contribution Page ';
-
- ALTER TABLE `civicrm_event` CHANGE `payment_processor_id` `payment_processor` VARCHAR( 128 ) NULL DEFAULT NULL COMMENT 'Payment Processor for this event ';
-
--- CRM-9783
-CREATE TABLE `civicrm_sms_provider` (
- `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'SMS Provider ID',
- `name` varchar(64) DEFAULT NULL COMMENT 'Provider internal name points to option_value of option_group sms_provider_name',
- `title` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Provider name visible to user',
- `username` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
- `password` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
- `api_type` int(10) unsigned NOT NULL COMMENT 'points to value in civicrm_option_value for group sms_api_type',
- `api_url` varchar(128) COLLATE utf8_unicode_ci DEFAULT NULL,
- `api_params` text COLLATE utf8_unicode_ci COMMENT 'the api params in xml, http or smtp format',
- `is_default` tinyint(4) DEFAULT '0',
- `is_active` tinyint(4) DEFAULT '0',
- PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
-
-ALTER TABLE `civicrm_mailing` ADD `sms_provider_id` int(10) unsigned NULL COMMENT 'FK to civicrm_sms_provider id ';
-ALTER TABLE `civicrm_mailing` ADD CONSTRAINT `FK_civicrm_mailing_sms_provider_id` FOREIGN KEY (`sms_provider_id`) REFERENCES `civicrm_sms_provider` (`id`) ON DELETE SET NULL;
-
-INSERT INTO
- `civicrm_option_group` (`name`, {localize field='title'}`title`{/localize}, `is_reserved`, `is_active`)
-VALUES
- ('sms_provider_name', {localize}'Sms provider Internal Name'{/localize} , 1, 1);
-SELECT @option_group_id_sms_provider_name := max(id) from civicrm_option_group where name = 'sms_provider_name';
-
-INSERT INTO civicrm_option_value
- (option_group_id, {localize field='label'}label{/localize}, value, name, weight, filter, is_default, component_id)
-VALUES
- (@option_group_id_sms_provider_name, {localize}'Clickatell'{/localize}, 'Clickatell', 'Clickatell', 1, 0, NULL, NULL);
-
-INSERT INTO
- `civicrm_option_group` (`name`, {localize field='title'}`title`{/localize}, `is_reserved`, `is_active`)
-VALUES
- ( 'sms_api_type', {localize}'{ts escape="sql"}Api Type{/ts}'{/localize} , 1, 1 );
-SELECT @option_group_id_sms_api_type := max(id) from civicrm_option_group where name = 'sms_api_type';
-
-INSERT INTO civicrm_option_value
- (option_group_id, {localize field='label'}label{/localize}, value, name, weight, filter, is_default, is_reserved, component_id)
-VALUES
- (@option_group_id_sms_api_type, {localize}'http'{/localize}, 1, 'http', 1, NULL, 0, 1, NULL),
- (@option_group_id_sms_api_type, {localize}'xml'{/localize}, 2, 'xml', 2, NULL, 0, 1, NULL),
- (@option_group_id_sms_api_type, {localize}'smtp'{/localize}, 3, 'smtp', 3, NULL, 0, 1, NULL);
-
--- CRM-9784
-SELECT @adminSystemSettingsID := MAX(id) FROM civicrm_navigation where name = 'System Settings' AND domain_id = {$domainID};
-
-INSERT INTO civicrm_navigation
- ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
-VALUES
- ( {$domainID}, 'civicrm/admin/sms/provider?reset=1', '{ts escape="sql" skip="true"}SMS Providers{/ts}', 'SMS Providers', 'administer CiviCRM', '', @adminSystemSettingsID, '1', NULL, 16 );
-
--- CRM-9799
-
-SELECT @mailingsID := MAX(id) FROM civicrm_navigation where name = 'Mailings' AND domain_id = {$domainID};
-
-INSERT INTO civicrm_navigation
- ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
-VALUES
- ( {$domainID}, 'civicrm/sms/send?reset=1', '{ts escape="sql" skip="true"}New SMS{/ts}', 'New SMS', 'administer CiviCRM', NULL, @mailingsID, '1', 1, 8 );
-
-SELECT @fromEmailAddressesID := MAX(id) FROM civicrm_navigation where name = 'From Email Addresses' AND domain_id = {$domainID};
-
-UPDATE civicrm_navigation SET has_separator = 1 WHERE parent_id = @mailingsID AND name = 'From Email Addresses';
-
-SELECT @option_group_id_act := max(id) from civicrm_option_group where name = 'activity_type';
-SELECT @max_wt := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_act;
-
-INSERT INTO
- `civicrm_option_value` (`option_group_id`, {localize field='label'}`label`{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, {localize field='description'}`description`{/localize}, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
-VALUES
- (@option_group_id_act, {localize}'BULK SMS'{/localize}, @max_wt, 'BULK SMS', NULL, 1, NULL, @max_wt, {localize}'BULK SMS'{/localize}, 0, 1, 1, NULL, NULL);
-
-ALTER TABLE `civicrm_mailing_recipients` ADD `phone_id` int(10) unsigned DEFAULT NULL;
-
-ALTER TABLE `civicrm_mailing_recipients` ADD CONSTRAINT `FK_civicrm_mailing_recipients_phone_id` FOREIGN KEY (`phone_id`) REFERENCES `civicrm_phone` (`id`) ON DELETE CASCADE;
-
-ALTER TABLE `civicrm_mailing_event_queue` ADD `phone_id` int(10) unsigned DEFAULT NULL;
-
-ALTER TABLE `civicrm_mailing_event_queue` ADD CONSTRAINT `FK_civicrm_mailing_event_queue_phone_id` FOREIGN KEY (`phone_id`) REFERENCES `civicrm_phone` (`id`) ON DELETE CASCADE;
-
-ALTER TABLE `civicrm_mailing_event_queue` CHANGE `email_id` `email_id` int(10) unsigned DEFAULT NULL;
-ALTER TABLE `civicrm_mailing_recipients` CHANGE `email_id` `email_id` int(10) unsigned DEFAULT NULL;
-
--- CRM-9982
-ALTER TABLE `civicrm_contribution_page` ADD COLUMN is_confirm_enabled tinyint(4) DEFAULT '1';
-
--- CRM-9980
-{if $multilingual}
- {foreach from=$locales item=locale}
- {if !$loc}
- {assign var=loc value="_$locale"}
- {/if}
- ALTER TABLE civicrm_group ADD title_{$locale} VARCHAR(64);
- ALTER TABLE civicrm_group ADD UNIQUE KEY `UI_title_{$locale}` (title_{$locale});
-
- ALTER TABLE `civicrm_batch` CHANGE `label_{$locale}` `title_{$locale}` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Friendly Name.';
- UPDATE civicrm_group SET title_{$locale} = title;
-
- ALTER TABLE civicrm_survey
- ADD COLUMN thankyou_title_{$locale} varchar(255) COMMENT 'Title for Thank-you page (header title tag, and display at the top of the page).',
- ADD COLUMN thankyou_text_{$locale} text COMMENT 'text and html allowed. displayed above result on success page';
- {/foreach}
-
- ALTER TABLE civicrm_group DROP INDEX `UI_title`;
- ALTER TABLE civicrm_group DROP title;
-{else}
- ALTER TABLE `civicrm_batch` CHANGE `label` `title` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Friendly Name.';
- ALTER TABLE civicrm_survey
- ADD COLUMN thankyou_title varchar(255) COMMENT 'Title for Thank-you page (header title tag, and display at the top of the page).',
- ADD COLUMN thankyou_text text COMMENT 'text and html allowed. displayed above result on success page';
-{/if}
-
--- CRM-9780
-SELECT @country_id := max(id) from civicrm_country where iso_code = "AN";
-DELETE FROM civicrm_state_province WHERE country_id = @country_id;
-DELETE FROM civicrm_country WHERE id = @country_id;
-
-SELECT @region_id := max(id) from civicrm_worldregion where name = "America South, Central, North and Caribbean";
-
-INSERT INTO civicrm_country (name,iso_code,region_id,is_province_abbreviated) VALUES("Curaçao", "CW", @region_id, 0);
-INSERT INTO civicrm_country (name,iso_code,region_id,is_province_abbreviated) VALUES("Sint Maarten (Dutch Part)", "SX", @region_id, 0);
-INSERT INTO civicrm_country (name,iso_code,region_id,is_province_abbreviated) VALUES("Bonaire, Saint Eustatius and Saba", "BQ", @region_id, 0);
-
--- CRM-12428
-{if $multilingual}
- {foreach from=$locales item=locale}
- ALTER TABLE `civicrm_price_field_value` CHANGE label_{$locale} label_{$locale} VARCHAR(255) NULL DEFAULT NULL;
- {/foreach}
-{else}
- ALTER TABLE `civicrm_price_field_value` CHANGE `label` `label` VARCHAR(255) NULL DEFAULT NULL;
-{/if}
-
--- CRM-9714 create a default price set for contribution and membership
-ALTER TABLE `civicrm_price_set`
-ADD `is_quick_config` TINYINT(4) NOT NULL DEFAULT '0'
- COMMENT 'Is set if edited on Contribution or Event Page rather than through Manage Price Sets'
- AFTER `contribution_type_id`,
-ADD `is_reserved` TINYINT(4) DEFAULT '0'
- COMMENT 'Is this a predefined system price set (i.e. it can not be deleted, edited)?';
-
-SELECT @contribution_type_id := max(id) FROM `civicrm_contribution_type` WHERE `name` = 'Member Dues';
-INSERT INTO `civicrm_price_set` ( `name`, {localize field='title'}`title`{/localize}, `is_active`, `extends`, `is_quick_config`, `is_reserved`, `contribution_type_id`)
-VALUES ( 'default_contribution_amount', {localize}'Contribution Amount'{/localize}, '1', '2', '1', '1', null),
- ( 'default_membership_type_amount', {localize}'Membership Amount'{/localize}, '1', '3', '1', '1', @contribution_type_id);
-
-SELECT @setID := max(id) FROM civicrm_price_set WHERE name = 'default_contribution_amount' AND extends = 2 AND is_quick_config = 1 ;
-
-INSERT INTO `civicrm_price_field` (`price_set_id`, `name`, {localize field='label'}`label`{/localize}, `html_type`,`weight`, `is_display_amounts`, `options_per_line`, `is_active`, `is_required`,`visibility_id` )
-VALUES ( @setID, 'contribution_amount', {localize}'Contribution Amount'{/localize}, 'Text', '1', '1', '1', '1', '1', '1' );
-
-SELECT @fieldID := max(id) FROM civicrm_price_field WHERE name = 'contribution_amount' AND price_set_id = @setID;
-
-INSERT INTO `civicrm_price_field_value` ( `price_field_id`, `name`, {localize field='label'}`label`{/localize}, `amount`, `weight`, `is_default`, `is_active`)
-VALUES ( @fieldID, 'contribution_amount', {localize}'Contribution Amount'{/localize}, '1', '1', '0', '1');
-ALTER TABLE `civicrm_custom_group` CHANGE `extends_entity_column_value` `extends_entity_column_value` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'linking custom group for dynamic object.';
-
--- CRM-9714 create price fields for all membershiptype
-SELECT @setID := max(id) FROM civicrm_price_set WHERE name = 'default_membership_type_amount' AND extends = 3 AND is_quick_config = 1 ;
-
-INSERT INTO civicrm_price_field ( price_set_id, name, {localize field='label'}label{/localize}, html_type, is_display_amounts, is_required )
-SELECT @setID as price_set_id, cmt.member_of_contact_id as name, {localize}'Membership Amount'{/localize}, 'Radio' as html_type, 0 as is_display_amounts, 0 as is_required
-FROM `civicrm_membership_type` cmt
-GROUP BY cmt.member_of_contact_id;
-
-INSERT INTO civicrm_price_field_value ( price_field_id, name, {localize field='label'}label{/localize}, {localize field='description'}description{/localize}, amount, membership_type_id)
-SELECT
-cpf.id, cmt.name{$loc} as label1, {localize field='name'}cmt.name as label2{/localize},{localize field='description'}cmt.description{/localize}, cmt.minimum_fee, cmt.id
-FROM `civicrm_membership_type` cmt
-LEFT JOIN civicrm_price_field cpf ON cmt.member_of_contact_id = BINARY cpf.name;
-
--- CRM-9714
-SELECT @fieldID := cpf.id, @fieldValueID := cpfv.id FROM civicrm_price_set cps
-LEFT JOIN civicrm_price_field cpf ON cps.id = cpf.price_set_id
-LEFT JOIN civicrm_price_field_value cpfv ON cpf.id = cpfv.price_field_id
-WHERE cps.name = 'default_contribution_amount';
-
-INSERT INTO civicrm_line_item ( entity_table, entity_id, price_field_id, label, qty, unit_price, line_total, participant_count, price_field_value_id )
-SELECT 'civicrm_contribution', cc.id, @fieldID, 'Contribution Amount', 1, total_amount, total_amount , 0, @fieldValueID
-FROM `civicrm_contribution` cc
-LEFT JOIN civicrm_line_item cli ON cc.id=cli.entity_id and cli.entity_table = 'civicrm_contribution'
-LEFT JOIN civicrm_membership_payment cmp ON cc.id = cmp.contribution_id
-LEFT JOIN civicrm_participant_payment cpp ON cc.id = cpp.contribution_id
-WHERE cli.entity_id IS NULL AND cc.contribution_page_id IS NULL AND cmp.contribution_id IS NULL AND cpp.contribution_id IS NULL
-GROUP BY cc.id;
-
--- CRM-10071 contribution membership detail report template
-SELECT @option_group_id_report := MAX(id) FROM civicrm_option_group WHERE name = 'report_template';
-SELECT @weight := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_report;
-SELECT @memberCompId := max(id) FROM civicrm_component where name = 'CiviMember';
-INSERT INTO civicrm_option_value
- (option_group_id, {localize field='label'}label{/localize}, value, name, weight, {localize field='description'}description{/localize}, is_active, component_id) VALUES
- (@option_group_id_report, {localize}'Contribution and Membership Details'{/localize}, 'member/contributionDetail', 'CRM_Report_Form_Member_ContributionDetail', @weight := @weight + 1, {localize}'Contribution details for any type of contribution, plus associated membership information for contributions which are in payment for memberships.'{/localize}, 1, @memberCompId);
-
-INSERT INTO `civicrm_report_instance`
- ( `domain_id`, `title`, `report_id`, `description`, `permission`, `form_values`)
-VALUES
- ( {$domainID}, 'Contribution and Membership Details', 'member/contributionDetail', 'Contribution details for any type of contribution, plus associated membership information for contributions which are in payment for memberships.', 'access CiviMember', '{literal}a:67:{s:6:"fields";a:12:{s:9:"sort_name";s:1:"1";s:5:"email";s:1:"1";s:5:"phone";s:1:"1";s:20:"contribution_type_id";s:1:"1";s:12:"receive_date";s:1:"1";s:12:"total_amount";s:1:"1";s:18:"membership_type_id";s:1:"1";s:21:"membership_start_date";s:1:"1";s:19:"membership_end_date";s:1:"1";s:9:"join_date";s:1:"1";s:22:"membership_status_name";s:1:"1";s:10:"country_id";s:1:"1";}s:12:"sort_name_op";s:3:"has";s:15:"sort_name_value";s:0:"";s:6:"id_min";s:0:"";s:6:"id_max";s:0:"";s:5:"id_op";s:3:"lte";s:8:"id_value";s:0:"";s:21:"receive_date_relative";s:1:"0";s:17:"receive_date_from";s:0:"";s:15:"receive_date_to";s:0:"";s:23:"contribution_type_id_op";s:2:"in";s:26:"contribution_type_id_value";a:0:{}s:24:"payment_instrument_id_op";s:2:"in";s:27:"payment_instrument_id_value";a:0:{}s:25:"contribution_status_id_op";s:2:"in";s:28:"contribution_status_id_value";a:0:{}s:16:"total_amount_min";s:0:"";s:16:"total_amount_max";s:0:"";s:15:"total_amount_op";s:3:"lte";s:18:"total_amount_value";s:0:"";s:6:"gid_op";s:2:"in";s:9:"gid_value";a:0:{}s:13:"ordinality_op";s:2:"in";s:16:"ordinality_value";a:0:{}s:18:"join_date_relative";s:1:"0";s:14:"join_date_from";s:0:"";s:12:"join_date_to";s:0:"";s:30:"membership_start_date_relative";s:1:"0";s:26:"membership_start_date_from";s:0:"";s:24:"membership_start_date_to";s:0:"";s:28:"membership_end_date_relative";s:1:"0";s:24:"membership_end_date_from";s:0:"";s:22:"membership_end_date_to";s:0:"";s:23:"owner_membership_id_min";s:0:"";s:23:"owner_membership_id_max";s:0:"";s:22:"owner_membership_id_op";s:3:"lte";s:25:"owner_membership_id_value";s:0:"";s:6:"tid_op";s:2:"in";s:9:"tid_value";a:0:{}s:6:"sid_op";s:2:"in";s:9:"sid_value";a:0:{}s:17:"street_number_min";s:0:"";s:17:"street_number_max";s:0:"";s:16:"street_number_op";s:3:"lte";s:19:"street_number_value";s:0:"";s:14:"street_name_op";s:3:"has";s:17:"street_name_value";s:0:"";s:15:"postal_code_min";s:0:"";s:15:"postal_code_max";s:0:"";s:14:"postal_code_op";s:3:"lte";s:17:"postal_code_value";s:0:"";s:7:"city_op";s:3:"has";s:10:"city_value";s:0:"";s:12:"county_id_op";s:2:"in";s:15:"county_id_value";a:0:{}s:20:"state_province_id_op";s:2:"in";s:23:"state_province_id_value";a:0:{}s:13:"country_id_op";s:2:"in";s:16:"country_id_value";a:0:{}s:8:"tagid_op";s:2:"in";s:11:"tagid_value";a:0:{}s:11:"description";s:35:"Contribution and Membership Details";s:13:"email_subject";s:0:"";s:8:"email_to";s:0:"";s:8:"email_cc";s:0:"";s:10:"permission";s:17:"access CiviMember";s:9:"domain_id";i:1;}{s:6:"fields";a:12:{s:9:"sort_name";s:1:"1";s:5:"email";s:1:"1";s:5:"phone";s:1:"1";s:20:"contribution_type_id";s:1:"1";s:12:"receive_date";s:1:"1";s:12:"total_amount";s:1:"1";s:18:"membership_type_id";s:1:"1";s:21:"membership_start_date";s:1:"1";s:19:"membership_end_date";s:1:"1";s:9:"join_date";s:1:"1";s:22:"membership_status_name";s:1:"1";s:10:"country_id";s:1:"1";}s:12:"sort_name_op";s:3:"has";s:15:"sort_name_value";s:0:"";s:6:"id_min";s:0:"";s:6:"id_max";s:0:"";s:5:"id_op";s:3:"lte";s:8:"id_value";s:0:"";s:21:"receive_date_relative";s:1:"0";s:17:"receive_date_from";s:0:"";s:15:"receive_date_to";s:0:"";s:23:"contribution_type_id_op";s:2:"in";s:26:"contribution_type_id_value";a:0:{}s:24:"payment_instrument_id_op";s:2:"in";s:27:"payment_instrument_id_value";a:0:{}s:25:"contribution_status_id_op";s:2:"in";s:28:"contribution_status_id_value";a:0:{}s:16:"total_amount_min";s:0:"";s:16:"total_amount_max";s:0:"";s:15:"total_amount_op";s:3:"lte";s:18:"total_amount_value";s:0:"";s:6:"gid_op";s:2:"in";s:9:"gid_value";a:0:{}s:13:"ordinality_op";s:2:"in";s:16:"ordinality_value";a:0:{}s:18:"join_date_relative";s:1:"0";s:14:"join_date_from";s:0:"";s:12:"join_date_to";s:0:"";s:30:"membership_start_date_relative";s:1:"0";s:26:"membership_start_date_from";s:0:"";s:24:"membership_start_date_to";s:0:"";s:28:"membership_end_date_relative";s:1:"0";s:24:"membership_end_date_from";s:0:"";s:22:"membership_end_date_to";s:0:"";s:23:"owner_membership_id_min";s:0:"";s:23:"owner_membership_id_max";s:0:"";s:22:"owner_membership_id_op";s:3:"lte";s:25:"owner_membership_id_value";s:0:"";s:6:"tid_op";s:2:"in";s:9:"tid_value";a:0:{}s:6:"sid_op";s:2:"in";s:9:"sid_value";a:0:{}s:17:"street_number_min";s:0:"";s:17:"street_number_max";s:0:"";s:16:"street_number_op";s:3:"lte";s:19:"street_number_value";s:0:"";s:14:"street_name_op";s:3:"has";s:17:"street_name_value";s:0:"";s:15:"postal_code_min";s:0:"";s:15:"postal_code_max";s:0:"";s:14:"postal_code_op";s:3:"lte";s:17:"postal_code_value";s:0:"";s:7:"city_op";s:3:"has";s:10:"city_value";s:0:"";s:12:"county_id_op";s:2:"in";s:15:"county_id_value";a:0:{}s:20:"state_province_id_op";s:2:"in";s:23:"state_province_id_value";a:0:{}s:13:"country_id_op";s:2:"in";s:16:"country_id_value";a:0:{}s:8:"tagid_op";s:2:"in";s:11:"tagid_value";a:0:{}s:11:"description";s:35:"Contribution and Membership Details";s:13:"email_subject";s:0:"";s:8:"email_to";s:0:"";s:8:"email_cc";s:0:"";s:10:"permission";s:1:"0";s:9:"domain_id";i:1;}{/literal}');
-
-SELECT @reportlastID := MAX(id) FROM civicrm_navigation where name = 'Reports' AND domain_id = {$domainID};
-SELECT @nav_max_weight := MAX(ROUND(weight)) from civicrm_navigation WHERE parent_id = @reportlastID;
-
-SET @instanceID:=LAST_INSERT_ID();
-INSERT INTO civicrm_navigation
- ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
-VALUES
- ( {$domainID}, CONCAT('civicrm/report/instance/', @instanceID,'&reset=1'), '{ts escape="sql" skip="true"}Contribution and Membership Details{/ts}', 'Contribution and Membership Details', 'access CiviMember', 'AND', @reportlastID, '1', NULL, @instanceID+2 );
-UPDATE civicrm_report_instance SET navigation_id = LAST_INSERT_ID() WHERE id = @instanceID;
-
--- CRM-9936
-ALTER TABLE civicrm_group ADD is_reserved TINYINT( 4 ) NULL DEFAULT '0' ;
-
--- CRM-9501 price set report templates
-SELECT @option_group_id_report := MAX(id) FROM civicrm_option_group WHERE name = 'report_template';
-SELECT @weight := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_report;
-SELECT @CompId := MAX(id) FROM civicrm_component where name = 'CiviContribute';
-INSERT INTO civicrm_option_value
- (option_group_id, {localize field='label'}label{/localize}, value, name, weight, {localize field='description'}description{/localize}, is_active, component_id) VALUES
- (@option_group_id_report, {localize}'Line Item Report'{/localize}, 'price/lineitem', 'CRM_Report_Form_Price_Lineitem', @weight := @weight + 1, {localize}'Price set report by line item.'{/localize}, 1, @CompId);
-SELECT @weight := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_report;
-INSERT INTO civicrm_option_value
- (option_group_id, {localize field='label'}label{/localize}, value, name, weight, {localize field='description'}description{/localize}, is_active, component_id) VALUES
- (@option_group_id_report, {localize}'Contribution Report with Line Item information'{/localize}, 'price/contributionbased', 'CRM_Report_Form_Price_Contributionbased', @weight := @weight + 1, {localize}'Contribution Line Item Report.'{/localize}, 1, @CompId);
-SELECT @weight := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_report;
-INSERT INTO civicrm_option_value
- (option_group_id, {localize field='label'}label{/localize}, value, name, weight, {localize field='description'}description{/localize}, is_active, component_id) VALUES
- (@option_group_id_report, {localize}'Participant Report with Line Item information'{/localize}, 'price/lineitemparticipant', 'CRM_Report_Form_Price_Lineitemparticipant', @weight := @weight + 1, {localize}'Participant Line Item Report.'{/localize}, 1, @CompId);
-
--- CRM-10148
-ALTER TABLE civicrm_report_instance ADD is_reserved TINYINT( 4 ) NULL DEFAULT '0' ;
-
--- CRM-9438
-SELECT @option_group_id_act := MAX(id) FROM civicrm_option_group WHERE name = 'activity_type';
-SELECT @max_val := MAX(ROUND(op.value)) FROM civicrm_option_value op WHERE op.option_group_id = @option_group_id_act;
-SELECT @max_wt := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_act;
-SELECT @CompId := MAX(id) FROM civicrm_component where name = 'CiviMember';
-INSERT INTO civicrm_option_value
- (option_group_id, {localize field='label'}label{/localize}, value, name, weight, {localize field='description'}description{/localize}, is_active, is_reserved, component_id)
-VALUES
- (@option_group_id_act, {localize field='label'}'Change Membership Status'{/localize}, (SELECT @max_val := @max_val+1), 'Change Membership Status', (SELECT @max_wt := @max_wt+1), {localize field='description'}'Change Membership Status.'{/localize}, 1, 1, @CompId),
- (@option_group_id_act, {localize field='label'}'Change Membership Type'{/localize}, (SELECT @max_val := @max_val+1), 'Change Membership Type', (SELECT @max_wt := @max_wt+1), {localize field='description'}'Change Membership Type.'{/localize}, 1, 1, @CompId);
-
--- CRM-10084
-INSERT INTO
- `civicrm_option_value` (`option_group_id`, {localize field='label'}`label`{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, {localize field='description'}`description`{/localize}, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
-VALUES
- (@option_group_id_act, {localize}'Cancel Recurring Contribution'{/localize}, (SELECT @max_val := @max_val+1), 'Cancel Recurring Contribution', NULL,1, 0, (SELECT @max_wt := @max_wt+1), {localize}''{/localize}, 0, 1, 1, NULL, NULL);
-
--- CRM-10090
-INSERT INTO
- `civicrm_option_value` (`option_group_id`, {localize field='label'}`label`{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, {localize field='description'}`description`{/localize}, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
-VALUES
-(@option_group_id_act, {localize}'Update Recurring Contribution Billing Details'{/localize}, (SELECT @max_val := @max_val+1), 'Update Recurring Contribution Billing Details', NULL,1, 0, (SELECT @max_wt := @max_wt+1), {localize}''{/localize}, 0, 1, 1, NULL, NULL),
-(@option_group_id_act, {localize}'Update Recurring Contribution'{/localize}, (SELECT @max_val := @max_val+1), 'Update Recurring Contribution', NULL,1, 0, (SELECT @max_wt := @max_wt+1), {localize}''{/localize}, 0, 1, 1, NULL, NULL);
-
--- CRM-10117
-ALTER TABLE `civicrm_price_field_value` CHANGE `is_active` `is_active` TINYINT( 4 ) NULL DEFAULT '1' COMMENT 'Is this price field value active';
-
-
--- CRM-8359
-INSERT INTO
- `civicrm_action_mapping` (`entity`, `entity_value`, `entity_value_label`, `entity_status`, `entity_status_label`, `entity_date_start`, `entity_date_end`, `entity_recipient`) VALUES
- ('civicrm_membership', 'civicrm_membership_type', 'Membership Type', 'auto_renew_options', 'Auto Renew Options', 'membership_join_date', 'membership_end_date', NULL);
-
-INSERT INTO
- `civicrm_option_group` (`name`, {localize field='title'}title{/localize}, `is_reserved`, `is_active`)
-VALUES
- ('auto_renew_options', {localize}'Auto Renew Options'{/localize}, 1, 1);
-
-SELECT @option_group_id_aro := max(id) from civicrm_option_group where name = 'auto_renew_options';
-
-INSERT INTO
- `civicrm_option_value` (`option_group_id`, {localize field='label'}label{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`)
-VALUES
- (@option_group_id_aro, {localize}'Renewal Reminder (non-auto-renew memberships only)'{/localize}, 1, 'Renewal Reminder (non-auto-renew memberships only)', NULL, 0, 0, 1),
- (@option_group_id_aro, {localize}'Auto-renew Memberships Only'{/localize}, 2, 'Auto-renew Memberships Only', NULL, 0, 0, 2),
- (@option_group_id_aro, {localize}'Reminder for Both'{/localize}, 3, 'Reminder for Both', NULL, 0, 0, 3);
-
--- CRM-10335, truncate cache to begin to speed the alter table
-TRUNCATE civicrm_cache;
-ALTER TABLE civicrm_cache
- DROP INDEX UI_group_path,
- ADD UNIQUE INDEX `UI_group_path_date` (`group_name`, `path`, `created_date`);
-
--- CRM-10337
-ALTER TABLE civicrm_survey
- ADD COLUMN bypass_confirm tinyint(4) DEFAULT '0' COMMENT 'Used to store option group id.';
+++ /dev/null
-{include file='../CRM/Upgrade/4.2.alpha2.msg_template/civicrm_msg_template.tpl'}
-
--- CRM-10326
-DELETE FROM `civicrm_price_set_entity` WHERE entity_table = "civicrm_contribution" or entity_table = "civicrm_participant";
-
--- When deleting saved searches, null-out references from groups
-ALTER TABLE civicrm_group ADD CONSTRAINT `FK_civicrm_group_saved_search_id`
- FOREIGN KEY (`saved_search_id`) REFERENCES `civicrm_saved_search` (`id`)
- ON DELETE SET NULL;
+++ /dev/null
-{include file='../CRM/Upgrade/4.2.alpha3.msg_template/civicrm_msg_template.tpl'}
-
+++ /dev/null
--- /*******************************************************
--- * CRM-10477 - Extensions updates
--- *******************************************************/
-CREATE TABLE `civicrm_extension` (
- `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Local Extension ID',
- `type` enum('payment', 'search', 'report', 'module') NOT NULL ,
- `full_name` varchar(255) NOT NULL COMMENT 'Fully qualified extension name',
- `name` varchar(255) COMMENT 'Short name',
- `label` varchar(255) COMMENT 'Short, printable name',
- `file` varchar(255) COMMENT 'Primary PHP file',
- `schema_version` varchar(63) COMMENT 'Revision code of the database schema; the format is module-defined',
- `is_active` tinyint DEFAULT 1 COMMENT 'Is this extension active?' ,
- PRIMARY KEY ( `id` ) ,
- UNIQUE INDEX `UI_extension_full_name`(
- `full_name`
- ),
- INDEX `UI_extension_name`(
- `name`
- )
-) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-
--- assuming first value of array $locales is always en_US
-{if $multilingual}
- INSERT INTO civicrm_extension (label, full_name, name, type, file, is_active)
- SELECT ov.label_{$locales.0}, ov.value, ov.name, ov.grouping, ov.description_{$locales.0}, ov.is_active
- FROM civicrm_option_group og
- INNER JOIN civicrm_option_value ov ON og.id = ov.option_group_id
- WHERE og.name = "system_extensions";
-{else}
- INSERT INTO civicrm_extension (label, full_name, name, type, file, is_active)
- SELECT ov.label, ov.value, ov.name, ov.grouping, ov.description, ov.is_active
- FROM civicrm_option_group og
- INNER JOIN civicrm_option_value ov ON og.id = ov.option_group_id
- WHERE og.name = "system_extensions";
-{/if}
-DELETE FROM civicrm_option_group WHERE name = "system_extensions";
--- Note: Deletion cascades to civicrm_option_value
+++ /dev/null
--- Placeholder which ensures that PHP upgrade tasks are executed
+++ /dev/null
-{include file='../CRM/Upgrade/4.2.beta3.msg_template/civicrm_msg_template.tpl'}
-
+++ /dev/null
--- Placeholder which ensures that PHP upgrade tasks are executed
+++ /dev/null
--- FIXME: the final release version is uncertain -- could 4.2.0 or 4.2.1; make sure this fixed before merging
--- CRM-10660
-CREATE TABLE `civicrm_managed` (
-
-
- `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Surrogate Key',
- `module` varchar(127) NOT NULL COMMENT 'Name of the module which declared this object',
- `name` varchar(127) COMMENT 'Symbolic name used by the module to identify the object',
- `entity_type` varchar(64) NOT NULL COMMENT 'API entity type',
- `entity_id` int unsigned NOT NULL COMMENT 'Foreign key to the referenced item.',
- PRIMARY KEY ( `id` )
-
- , INDEX `UI_managed_module_name`(
- `module`
- , `name`
- )
- , INDEX `UI_managed_entity`(
- `entity_type`
- , `entity_id`
- )
-
-
-) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
--- /dev/null
+{* file to handle db changes in 5.11.beta1 during upgrade *}
--- /dev/null
+{* file to handle db changes in 5.12.alpha1 during upgrade *}
+
+-- dev/core#683 Incorrectly encoded state and country names
+UPDATE civicrm_country SET name = 'Åland Islands' WHERE iso_code = 'AX';
+UPDATE civicrm_country SET name = 'Côte d’Ivoire' WHERE iso_code = 'CI';
+UPDATE civicrm_country SET name = 'Curaçao' WHERE iso_code = 'CW';
+UPDATE civicrm_country SET name = 'Saint Barthélemy' WHERE iso_code = 'BL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'dolnośląskie' WHERE iso_code = 'PL' AND abbreviation = 'DS';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'łódzkie' WHERE iso_code = 'PL' AND abbreviation = 'LD';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'małopolskie' WHERE iso_code = 'PL' AND abbreviation = 'MA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'śląskie' WHERE iso_code = 'PL' AND abbreviation = 'SL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'świętokrzyskie' WHERE iso_code = 'PL' AND abbreviation = 'SK';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'warmińsko-mazurskie' WHERE iso_code = 'PL' AND abbreviation = 'WN';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Bulqizë' WHERE iso_code = 'AL' AND abbreviation = 'BU';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Delvinë' WHERE iso_code = 'AL' AND abbreviation = 'DL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Dibër' WHERE iso_code = 'AL' AND abbreviation = 'DI';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Durrës' WHERE iso_code = 'AL' AND abbreviation = 'DR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Gjirokastër' WHERE iso_code = 'AL' AND abbreviation = 'GJ';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kavajë' WHERE iso_code = 'AL' AND abbreviation = 'KA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kolonjë' WHERE iso_code = 'AL' AND abbreviation = 'ER';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Korçë' WHERE iso_code = 'AL' AND abbreviation = 'KO';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Krujë' WHERE iso_code = 'AL' AND abbreviation = 'KR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kuçovë' WHERE iso_code = 'AL' AND abbreviation = 'KC';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kukës' WHERE iso_code = 'AL' AND abbreviation = 'KU';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Lezhë' WHERE iso_code = 'AL' AND abbreviation = 'LE';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Lushnjë' WHERE iso_code = 'AL' AND abbreviation = 'LU';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Malësi e Madhe' WHERE iso_code = 'AL' AND abbreviation = 'MM';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Mallakastër' WHERE iso_code = 'AL' AND abbreviation = 'MK';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Mirditë' WHERE iso_code = 'AL' AND abbreviation = 'MR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Përmet' WHERE iso_code = 'AL' AND abbreviation = 'PR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Pukë' WHERE iso_code = 'AL' AND abbreviation = 'PU';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Sarandë' WHERE iso_code = 'AL' AND abbreviation = 'SR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Shkodër' WHERE iso_code = 'AL' AND abbreviation = 'SH';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Tepelenë' WHERE iso_code = 'AL' AND abbreviation = 'TE';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Tiranë' WHERE iso_code = 'AL' AND abbreviation = 'TR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Tropojë' WHERE iso_code = 'AL' AND abbreviation = 'TP';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Vlorë' WHERE iso_code = 'AL' AND abbreviation = 'VL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kärnten' WHERE iso_code = 'AT' AND abbreviation = '2';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Niederösterreich' WHERE iso_code = 'AT' AND abbreviation = '3';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Oberösterreich' WHERE iso_code = 'AT' AND abbreviation = '4';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Brèsckaja voblasc\'' WHERE iso_code = 'BY' AND abbreviation = 'BR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Mahilëuskaja voblasc\'' WHERE iso_code = 'BY' AND abbreviation = 'MA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Distrito Capital de Bogotá' WHERE iso_code = 'CO' AND abbreviation = 'DC';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Atlántico' WHERE iso_code = 'CO' AND abbreviation = 'ATL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Bolívar' WHERE iso_code = 'CO' AND abbreviation = 'BOL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Boyacá' WHERE iso_code = 'CO' AND abbreviation = 'BOY';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Caquetá' WHERE iso_code = 'CO' AND abbreviation = 'CAQ';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Córdoba' WHERE iso_code = 'CO' AND abbreviation = 'COR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Chocó' WHERE iso_code = 'CO' AND abbreviation = 'CHO';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Guainía' WHERE iso_code = 'CO' AND abbreviation = 'GUA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Nariño' WHERE iso_code = 'CO' AND abbreviation = 'NAR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'San Andrés, Providencia y Santa Catalina' WHERE iso_code = 'CO' AND abbreviation = 'SAP';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Vaupés' WHERE iso_code = 'CO' AND abbreviation = 'VAU';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Jihočeský kraj' WHERE iso_code = 'CZ' AND abbreviation = 'JC';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Jihomoravský kraj' WHERE iso_code = 'CZ' AND abbreviation = 'JM';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Karlovarský kraj' WHERE iso_code = 'CZ' AND abbreviation = 'KA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Královéhradecký kraj' WHERE iso_code = 'CZ' AND abbreviation = 'KR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Liberecký kraj' WHERE iso_code = 'CZ' AND abbreviation = 'LI';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Moravskoslezský kraj' WHERE iso_code = 'CZ' AND abbreviation = 'MO';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Olomoucký kraj' WHERE iso_code = 'CZ' AND abbreviation = 'OL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Pardubický kraj' WHERE iso_code = 'CZ' AND abbreviation = 'PA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Plzeňský kraj' WHERE iso_code = 'CZ' AND abbreviation = 'PL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Praha, hlavní město' WHERE iso_code = 'CZ' AND abbreviation = 'PR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Středočeský kraj' WHERE iso_code = 'CZ' AND abbreviation = 'ST';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ústecký kraj' WHERE iso_code = 'CZ' AND abbreviation = 'US';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Vysočina' WHERE iso_code = 'CZ' AND abbreviation = 'VY';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Zlínský kraj' WHERE iso_code = 'CZ' AND abbreviation = 'ZL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Baden-Württemberg' WHERE iso_code = 'DE' AND abbreviation = 'BW';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Thüringen' WHERE iso_code = 'DE' AND abbreviation = 'TH';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Vestsjælland' WHERE iso_code = 'DK' AND abbreviation = '030';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Storstrøm' WHERE iso_code = 'DK' AND abbreviation = '035';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ringkjøbing' WHERE iso_code = 'DK' AND abbreviation = '065';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Århus' WHERE iso_code = 'DK' AND abbreviation = '070';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Dajabón' WHERE iso_code = 'DO' AND abbreviation = '05';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Maroia Trinidad Sánchez' WHERE iso_code = 'DO' AND abbreviation = '14';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Monseñor Nouel' WHERE iso_code = 'DO' AND abbreviation = '28';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Samaná' WHERE iso_code = 'DO' AND abbreviation = '20';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'San Cristóbal' WHERE iso_code = 'DO' AND abbreviation = '21';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'San Pedro de Macorís' WHERE iso_code = 'DO' AND abbreviation = '23';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Sánchez Ramírez' WHERE iso_code = 'DO' AND abbreviation = '24';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Santiago Rodríguez' WHERE iso_code = 'DO' AND abbreviation = '26';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Jõgevamaa' WHERE iso_code = 'EE' AND abbreviation = '49';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Järvamaa' WHERE iso_code = 'EE' AND abbreviation = '51';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Läänemaa' WHERE iso_code = 'EE' AND abbreviation = '57';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Lääne-Virumaa' WHERE iso_code = 'EE' AND abbreviation = '59';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Põlvamaa' WHERE iso_code = 'EE' AND abbreviation = '65';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Pärnumaa' WHERE iso_code = 'EE' AND abbreviation = '67';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Võrumaa' WHERE iso_code = 'EE' AND abbreviation = '86';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Álava' WHERE iso_code = 'ES' AND abbreviation = 'VI';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Almería' WHERE iso_code = 'ES' AND abbreviation = 'AL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ávila' WHERE iso_code = 'ES' AND abbreviation = 'AV';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Cáceres' WHERE iso_code = 'ES' AND abbreviation = 'CC';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Cádiz' WHERE iso_code = 'ES' AND abbreviation = 'CA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Castellón' WHERE iso_code = 'ES' AND abbreviation = 'CS';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Guipúzcoa' WHERE iso_code = 'ES' AND abbreviation = 'SS';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Jaén' WHERE iso_code = 'ES' AND abbreviation = 'J';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'La Coruña' WHERE iso_code = 'ES' AND abbreviation = 'C';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'León' WHERE iso_code = 'ES' AND abbreviation = 'LE';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Lleida [Lérida]' WHERE iso_code = 'ES' AND abbreviation = 'L';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Málaga' WHERE iso_code = 'ES' AND abbreviation = 'MA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ardèche' WHERE iso_code = 'FR' AND abbreviation = '07';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ariège' WHERE iso_code = 'FR' AND abbreviation = '09';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Bouches-du-Rhône' WHERE iso_code = 'FR' AND abbreviation = '13';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Corrèze' WHERE iso_code = 'FR' AND abbreviation = '19';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Côte-d\'Or' WHERE iso_code = 'FR' AND abbreviation = '21';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Côtes-d\'Armor' WHERE iso_code = 'FR' AND abbreviation = '22';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Deux-Sèvres' WHERE iso_code = 'FR' AND abbreviation = '79';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Drôme' WHERE iso_code = 'FR' AND abbreviation = '26';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Finistère' WHERE iso_code = 'FR' AND abbreviation = '29';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Haute-Saône' WHERE iso_code = 'FR' AND abbreviation = '70';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Hautes-Pyrénées' WHERE iso_code = 'FR' AND abbreviation = '65';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Hérault' WHERE iso_code = 'FR' AND abbreviation = '34';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Isère' WHERE iso_code = 'FR' AND abbreviation = '38';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Lozère' WHERE iso_code = 'FR' AND abbreviation = '48';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Nièvre' WHERE iso_code = 'FR' AND abbreviation = '58';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Puy-de-Dôme' WHERE iso_code = 'FR' AND abbreviation = '63';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Pyrénées-Atlantiques' WHERE iso_code = 'FR' AND abbreviation = '64';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Pyrénées-Orientales' WHERE iso_code = 'FR' AND abbreviation = '66';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Rhône' WHERE iso_code = 'FR' AND abbreviation = '69';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Saône-et-Loire' WHERE iso_code = 'FR' AND abbreviation = '71';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Vendée' WHERE iso_code = 'FR' AND abbreviation = '85';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Achaïa' WHERE iso_code = 'GR' AND abbreviation = '13';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Sololá' WHERE iso_code = 'GT' AND abbreviation = 'SO';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Bács-Kiskun' WHERE iso_code = 'HU' AND abbreviation = 'BK';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Békés' WHERE iso_code = 'HU' AND abbreviation = 'BE';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Borsod-Abaúj-Zemplén' WHERE iso_code = 'HU' AND abbreviation = 'BZ';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Csongrád' WHERE iso_code = 'HU' AND abbreviation = 'CS';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Fejér' WHERE iso_code = 'HU' AND abbreviation = 'FE';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Győr-Moson-Sopron' WHERE iso_code = 'HU' AND abbreviation = 'GS';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Jász-Nagykun-Szolnok' WHERE iso_code = 'HU' AND abbreviation = 'JN';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Komárom-Esztergom' WHERE iso_code = 'HU' AND abbreviation = 'KE';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Nográd' WHERE iso_code = 'HU' AND abbreviation = 'NO';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Szabolcs-Szatmár-Bereg' WHERE iso_code = 'HU' AND abbreviation = 'SZ';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Veszprém' WHERE iso_code = 'HU' AND abbreviation = 'VE';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Békéscsaba' WHERE iso_code = 'HU' AND abbreviation = 'BC';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Dunaújváros' WHERE iso_code = 'HU' AND abbreviation = 'DU';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Győr' WHERE iso_code = 'HU' AND abbreviation = 'GY';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Hódmezővásárhely' WHERE iso_code = 'HU' AND abbreviation = 'HV';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kaposvár' WHERE iso_code = 'HU' AND abbreviation = 'KV';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kecskemét' WHERE iso_code = 'HU' AND abbreviation = 'KM';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Nyiregyháza' WHERE iso_code = 'HU' AND abbreviation = 'NY';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Pécs' WHERE iso_code = 'HU' AND abbreviation = 'PS';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Salgótarján' WHERE iso_code = 'HU' AND abbreviation = 'ST';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Székesfehérvár' WHERE iso_code = 'HU' AND abbreviation = 'SF';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Szekszárd' WHERE iso_code = 'HU' AND abbreviation = 'SS';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Tatabánya' WHERE iso_code = 'HU' AND abbreviation = 'TB';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Forlì-Cesena' WHERE iso_code = 'IT' AND abbreviation = 'FC';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Klaipėdos Apskritis' WHERE iso_code = 'LT' AND abbreviation = 'KL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Marijampolės Apskritis' WHERE iso_code = 'LT' AND abbreviation = 'MR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Panevėžio Apskritis' WHERE iso_code = 'LT' AND abbreviation = 'PN';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Šiaulių Apskritis' WHERE iso_code = 'LT' AND abbreviation = 'SA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Tauragės Apskritis' WHERE iso_code = 'LT' AND abbreviation = 'TA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Telšių Apskritis' WHERE iso_code = 'LT' AND abbreviation = 'TE';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Jūrmala' WHERE iso_code = 'LV' AND abbreviation = 'JUR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Liepāja' WHERE iso_code = 'LV' AND abbreviation = 'LPX';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Rēzekne' WHERE iso_code = 'LV' AND abbreviation = 'REZ';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Rīga' WHERE iso_code = 'LV' AND abbreviation = 'RIX';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ajdābiyā' WHERE iso_code = 'LY' AND abbreviation = 'AJ';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Al Buţnān' WHERE iso_code = 'LY' AND abbreviation = 'BU';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Al Hizām al Akhdar' WHERE iso_code = 'LY' AND abbreviation = 'HZ';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Al Jifārah' WHERE iso_code = 'LY' AND abbreviation = 'JI';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Al Qaţrūn' WHERE iso_code = 'LY' AND abbreviation = 'QT';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Al Wāhah' WHERE iso_code = 'LY' AND abbreviation = 'WA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'An Nuqaţ al Khams' WHERE iso_code = 'LY' AND abbreviation = 'NQ';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ash Shāţi\'' WHERE iso_code = 'LY' AND abbreviation = 'SH';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Az Zāwiyah' WHERE iso_code = 'LY' AND abbreviation = 'ZA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Banghāzī' WHERE iso_code = 'LY' AND abbreviation = 'BA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Banī Walīd' WHERE iso_code = 'LY' AND abbreviation = 'BW';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ghadāmis' WHERE iso_code = 'LY' AND abbreviation = 'GD';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Gharyān' WHERE iso_code = 'LY' AND abbreviation = 'GR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ghāt' WHERE iso_code = 'LY' AND abbreviation = 'GT';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Jaghbūb' WHERE iso_code = 'LY' AND abbreviation = 'JB';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Mişrātah' WHERE iso_code = 'LY' AND abbreviation = 'MI';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Nālūt' WHERE iso_code = 'LY' AND abbreviation = 'NL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Sabhā' WHERE iso_code = 'LY' AND abbreviation = 'SB';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Şabrātah Şurmān' WHERE iso_code = 'LY' AND abbreviation = 'SS';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Tājūrā\' wa an Nawāhī al Arbāh' WHERE iso_code = 'LY' AND abbreviation = 'TN';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ţarābulus' WHERE iso_code = 'LY' AND abbreviation = 'TB';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Tarhūnah-Masallātah' WHERE iso_code = 'LY' AND abbreviation = 'TM';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Wādī al hayāt' WHERE iso_code = 'LY' AND abbreviation = 'WD';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Yafran-Jādū' WHERE iso_code = 'LY' AND abbreviation = 'YJ';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Aït Baha' WHERE iso_code = 'MA' AND abbreviation = 'BAH';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Aït Melloul' WHERE iso_code = 'MA' AND abbreviation = 'MEL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Al Hoceïma' WHERE iso_code = 'MA' AND abbreviation = 'HOC';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Casablanca [Dar el Beïda]' WHERE iso_code = 'MA' AND abbreviation = 'CAS';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Fès' WHERE iso_code = 'MA' AND abbreviation = 'FES';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kénitra' WHERE iso_code = 'MA' AND abbreviation = 'KEN';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Laâyoune (EH)' WHERE iso_code = 'MA' AND abbreviation = 'LAA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Meknsès' WHERE iso_code = 'MA' AND abbreviation = 'MEK';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Rabat-Salé' WHERE iso_code = 'MA' AND abbreviation = 'RBA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Tétouan' WHERE iso_code = 'MA' AND abbreviation = 'TET';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Møre og Romsdal' WHERE iso_code = 'NO' AND abbreviation = '15';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Nord-Trøndelag' WHERE iso_code = 'NO' AND abbreviation = '17';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Sør-Trøndelag' WHERE iso_code = 'NO' AND abbreviation = '16';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Østfold' WHERE iso_code = 'NO' AND abbreviation = '01';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Argeș' WHERE iso_code = 'RO' AND abbreviation = 'AG';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Bacău' WHERE iso_code = 'RO' AND abbreviation = 'BC';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Bistrița-Năsăud' WHERE iso_code = 'RO' AND abbreviation = 'BN';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Botoșani' WHERE iso_code = 'RO' AND abbreviation = 'BT';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Brașov' WHERE iso_code = 'RO' AND abbreviation = 'BV';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Brăila' WHERE iso_code = 'RO' AND abbreviation = 'BR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Buzău' WHERE iso_code = 'RO' AND abbreviation = 'BZ';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Caraș-Severin' WHERE iso_code = 'RO' AND abbreviation = 'CS';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Călărași' WHERE iso_code = 'RO' AND abbreviation = 'CL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Constanța' WHERE iso_code = 'RO' AND abbreviation = 'CT';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Dâmbovița' WHERE iso_code = 'RO' AND abbreviation = 'DB';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Galați' WHERE iso_code = 'RO' AND abbreviation = 'GL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ialomița' WHERE iso_code = 'RO' AND abbreviation = 'IL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Iași' WHERE iso_code = 'RO' AND abbreviation = 'IS';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Maramureș' WHERE iso_code = 'RO' AND abbreviation = 'MM';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Mehedinți' WHERE iso_code = 'RO' AND abbreviation = 'MH';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Mureș' WHERE iso_code = 'RO' AND abbreviation = 'MS';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Neamț' WHERE iso_code = 'RO' AND abbreviation = 'NT';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Sălaj' WHERE iso_code = 'RO' AND abbreviation = 'SJ';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Timiș' WHERE iso_code = 'RO' AND abbreviation = 'TM';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Vâlcea' WHERE iso_code = 'RO' AND abbreviation = 'VL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Blekinge län' WHERE iso_code = 'SE' AND abbreviation = 'K';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Dalarnas län' WHERE iso_code = 'SE' AND abbreviation = 'W';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Gotlands län' WHERE iso_code = 'SE' AND abbreviation = 'I';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Gävleborgs län' WHERE iso_code = 'SE' AND abbreviation = 'X';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Hallands län' WHERE iso_code = 'SE' AND abbreviation = 'N';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Jämtlands län' WHERE iso_code = 'SE' AND abbreviation = 'Z';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Jönkopings län' WHERE iso_code = 'SE' AND abbreviation = 'F';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kalmar län' WHERE iso_code = 'SE' AND abbreviation = 'H';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kronobergs län' WHERE iso_code = 'SE' AND abbreviation = 'G';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Norrbottens län' WHERE iso_code = 'SE' AND abbreviation = 'BD';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Skåne län' WHERE iso_code = 'SE' AND abbreviation = 'M';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Stockholms län' WHERE iso_code = 'SE' AND abbreviation = 'AB';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Södermanlands län' WHERE iso_code = 'SE' AND abbreviation = 'D';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Uppsala län' WHERE iso_code = 'SE' AND abbreviation = 'C';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Värmlands län' WHERE iso_code = 'SE' AND abbreviation = 'S';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Västerbottens län' WHERE iso_code = 'SE' AND abbreviation = 'AC';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Västernorrlands län' WHERE iso_code = 'SE' AND abbreviation = 'Y';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Västmanlands län' WHERE iso_code = 'SE' AND abbreviation = 'U';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Västra Götalands län' WHERE iso_code = 'SE' AND abbreviation = 'Q';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Örebro län' WHERE iso_code = 'SE' AND abbreviation = 'T';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Östergötlands län' WHERE iso_code = 'SE' AND abbreviation = 'E';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ajdovščina' WHERE iso_code = 'SI' AND abbreviation = '001';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Braslovče' WHERE iso_code = 'SI' AND abbreviation = '151';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Brežice' WHERE iso_code = 'SI' AND abbreviation = '009';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Črenšovci' WHERE iso_code = 'SI' AND abbreviation = '015';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Črna na Koroškem' WHERE iso_code = 'SI' AND abbreviation = '016';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Črnomelj' WHERE iso_code = 'SI' AND abbreviation = '017';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Divača' WHERE iso_code = 'SI' AND abbreviation = '019';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Domžale' WHERE iso_code = 'SI' AND abbreviation = '023';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Gorišnica' WHERE iso_code = 'SI' AND abbreviation = '028';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Hoče-Slivnica' WHERE iso_code = 'SI' AND abbreviation = '160';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Hodoš' WHERE iso_code = 'SI' AND abbreviation = '161';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ivančna Gorica' WHERE iso_code = 'SI' AND abbreviation = '039';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Juršinci' WHERE iso_code = 'SI' AND abbreviation = '042';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kidričevo' WHERE iso_code = 'SI' AND abbreviation = '045';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kočevje' WHERE iso_code = 'SI' AND abbreviation = '048';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Križevci' WHERE iso_code = 'SI' AND abbreviation = '166';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Krško' WHERE iso_code = 'SI' AND abbreviation = '054';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Laško' WHERE iso_code = 'SI' AND abbreviation = '057';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Loška dolina' WHERE iso_code = 'SI' AND abbreviation = '065';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Loški Potok' WHERE iso_code = 'SI' AND abbreviation = '066';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Luče' WHERE iso_code = 'SI' AND abbreviation = '067';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Majšperk' WHERE iso_code = 'SI' AND abbreviation = '069';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Mengeš' WHERE iso_code = 'SI' AND abbreviation = '072';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Mežica' WHERE iso_code = 'SI' AND abbreviation = '074';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Miklavž na Dravskem polju' WHERE iso_code = 'SI' AND abbreviation = '169';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Mirna Peč' WHERE iso_code = 'SI' AND abbreviation = '170';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Moravče' WHERE iso_code = 'SI' AND abbreviation = '077';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Sveti Andraž v Slovenskih goricah' WHERE iso_code = 'SI' AND abbreviation = '182';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Šalovci' WHERE iso_code = 'SI' AND abbreviation = '033';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Šempeter-Vrtojba' WHERE iso_code = 'SI' AND abbreviation = '183';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Šenčur' WHERE iso_code = 'SI' AND abbreviation = '117';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Šentilj' WHERE iso_code = 'SI' AND abbreviation = '118';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Šentjernej' WHERE iso_code = 'SI' AND abbreviation = '119';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Šentjur' WHERE iso_code = 'SI' AND abbreviation = '120';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Škocjan' WHERE iso_code = 'SI' AND abbreviation = '121';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Škofja Loka' WHERE iso_code = 'SI' AND abbreviation = '122';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Škofljica' WHERE iso_code = 'SI' AND abbreviation = '123';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Šmarje pri Jelšah' WHERE iso_code = 'SI' AND abbreviation = '124';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Šmartno ob Paki' WHERE iso_code = 'SI' AND abbreviation = '125';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Šmartno pri Litiji' WHERE iso_code = 'SI' AND abbreviation = '194';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Šoštanj' WHERE iso_code = 'SI' AND abbreviation = '126';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Štore' WHERE iso_code = 'SI' AND abbreviation = '127';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Tišina' WHERE iso_code = 'SI' AND abbreviation = '010';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Tržič' WHERE iso_code = 'SI' AND abbreviation = '131';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Turnišče' WHERE iso_code = 'SI' AND abbreviation = '132';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Velike Lašče' WHERE iso_code = 'SI' AND abbreviation = '134';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Veržej' WHERE iso_code = 'SI' AND abbreviation = '188';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Zavrč' WHERE iso_code = 'SI' AND abbreviation = '143';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Zreče' WHERE iso_code = 'SI' AND abbreviation = '144';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Žalec' WHERE iso_code = 'SI' AND abbreviation = '190';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Železniki' WHERE iso_code = 'SI' AND abbreviation = '146';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Žetale' WHERE iso_code = 'SI' AND abbreviation = '191';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Žiri' WHERE iso_code = 'SI' AND abbreviation = '147';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Žirovnica' WHERE iso_code = 'SI' AND abbreviation = '192';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Žužemberk' WHERE iso_code = 'SI' AND abbreviation = '193';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Banskobystrický kraj' WHERE iso_code = 'SK' AND abbreviation = 'BC';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Bratislavský kraj' WHERE iso_code = 'SK' AND abbreviation = 'BL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Košický kraj' WHERE iso_code = 'SK' AND abbreviation = 'KI';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Prešovský kraj' WHERE iso_code = 'SK' AND abbreviation = 'PV';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Trenčiansky kraj' WHERE iso_code = 'SK' AND abbreviation = 'TC';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Trnavský kraj' WHERE iso_code = 'SK' AND abbreviation = 'TA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Žilinský kraj' WHERE iso_code = 'SK' AND abbreviation = 'ZI';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Béja' WHERE iso_code = 'TN' AND abbreviation = '31';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Gabès' WHERE iso_code = 'TN' AND abbreviation = '81';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Etelä-Savo' WHERE iso_code = 'FI' AND abbreviation = 'ES';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Häme' WHERE iso_code = 'FI' AND abbreviation = 'HH';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Itä-Uusimaa' WHERE iso_code = 'FI' AND abbreviation = 'IU';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Päijät-Häme' WHERE iso_code = 'FI' AND abbreviation = 'PH';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Åland' WHERE iso_code = 'FI' AND abbreviation = 'AL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Al Manāmah (Al ‘Āşimah)' WHERE iso_code = 'BH' AND abbreviation = '13';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Al Janūbīyah' WHERE iso_code = 'BH' AND abbreviation = '14';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Al Wusţá' WHERE iso_code = 'BH' AND abbreviation = '16';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ash Shamālīyah' WHERE iso_code = 'BH' AND abbreviation = '17';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Córdoba' WHERE iso_code = 'ES' AND abbreviation = 'CO';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Pļaviņu novads' WHERE iso_code = 'LV' AND abbreviation = '072';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Skrīveru novads' WHERE iso_code = 'LV' AND abbreviation = '092';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Alūksnes novads' WHERE iso_code = 'LV' AND abbreviation = '007';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Viļakas novads' WHERE iso_code = 'LV' AND abbreviation = '108';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Rugāju novads' WHERE iso_code = 'LV' AND abbreviation = '082';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Rundāles novads' WHERE iso_code = 'LV' AND abbreviation = '083';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Cēsu novads' WHERE iso_code = 'LV' AND abbreviation = '022';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Līgatnes novads' WHERE iso_code = 'LV' AND abbreviation = '055';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Priekuļu novads' WHERE iso_code = 'LV' AND abbreviation = '075';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Pārgaujas novads' WHERE iso_code = 'LV' AND abbreviation = '070';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ilūkstes novads' WHERE iso_code = 'LV' AND abbreviation = '036';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Tērvetes novads' WHERE iso_code = 'LV' AND abbreviation = '098';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Jēkabpils novads' WHERE iso_code = 'LV' AND abbreviation = '042';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Aknīstes novads' WHERE iso_code = 'LV' AND abbreviation = '004';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Viesītes novads' WHERE iso_code = 'LV' AND abbreviation = '107';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Krāslavas novads' WHERE iso_code = 'LV' AND abbreviation = '047';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kuldīgas novads' WHERE iso_code = 'LV' AND abbreviation = '050';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Grobiņas novads' WHERE iso_code = 'LV' AND abbreviation = '032';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Pāvilostas novads' WHERE iso_code = 'LV' AND abbreviation = '071';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Nīcas novads' WHERE iso_code = 'LV' AND abbreviation = '066';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Vaiņodes novads' WHERE iso_code = 'LV' AND abbreviation = '100';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Limbažu novads' WHERE iso_code = 'LV' AND abbreviation = '054';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Salacgrīvas novads' WHERE iso_code = 'LV' AND abbreviation = '086';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kārsavas novads' WHERE iso_code = 'LV' AND abbreviation = '044';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Lubānas novads' WHERE iso_code = 'LV' AND abbreviation = '057';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Varakļānu novads' WHERE iso_code = 'LV' AND abbreviation = '102';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ērgļu novads' WHERE iso_code = 'LV' AND abbreviation = '030';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ikšķiles novads' WHERE iso_code = 'LV' AND abbreviation = '035';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ķeguma novads' WHERE iso_code = 'LV' AND abbreviation = '051';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Lielvārdes novads' WHERE iso_code = 'LV' AND abbreviation = '053';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Preiļu novads' WHERE iso_code = 'LV' AND abbreviation = '073';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Līvānu novads' WHERE iso_code = 'LV' AND abbreviation = '056';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Riebiņu novads' WHERE iso_code = 'LV' AND abbreviation = '078';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Vārkavas novads' WHERE iso_code = 'LV' AND abbreviation = '103';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Rēzeknes novads' WHERE iso_code = 'LV' AND abbreviation = '077';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Viļānu novads' WHERE iso_code = 'LV' AND abbreviation = '109';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ķekavas novads' WHERE iso_code = 'LV' AND abbreviation = '052';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Inčukalna novads' WHERE iso_code = 'LV' AND abbreviation = '037';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ādažu novads' WHERE iso_code = 'LV' AND abbreviation = '011';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Babītes novads' WHERE iso_code = 'LV' AND abbreviation = '012';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Mālpils novads' WHERE iso_code = 'LV' AND abbreviation = '061';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Mārupes novads' WHERE iso_code = 'LV' AND abbreviation = '062';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ropažu novads' WHERE iso_code = 'LV' AND abbreviation = '080';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Sējas novads' WHERE iso_code = 'LV' AND abbreviation = '090';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Stopiņu novads' WHERE iso_code = 'LV' AND abbreviation = '095';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Brocēnu novads' WHERE iso_code = 'LV' AND abbreviation = '018';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Mērsraga novads' WHERE iso_code = 'LV' AND abbreviation = '063';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Strenču novads' WHERE iso_code = 'LV' AND abbreviation = '096';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kocēnu novads' WHERE iso_code = 'LV' AND abbreviation = '045';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Rūjienas novads' WHERE iso_code = 'LV' AND abbreviation = '084';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Beverīnas novads' WHERE iso_code = 'LV' AND abbreviation = '017';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Naukšēnu novads' WHERE iso_code = 'LV' AND abbreviation = '064';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Jēkabpils' WHERE iso_code = 'LV' AND abbreviation = 'JKB';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Apače' WHERE iso_code = 'SI' AND abbreviation = '87';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ormož' WHERE iso_code = 'SI' AND abbreviation = '97';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Podčetrtek' WHERE iso_code = 'SI' AND abbreviation = '102';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Poljčane' WHERE iso_code = 'SI' AND abbreviation = '105';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Rače-Fram' WHERE iso_code = 'SI' AND abbreviation = '113';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Radeče' WHERE iso_code = 'SI' AND abbreviation = '114';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ravne na Koroškem' WHERE iso_code = 'SI' AND abbreviation = '171';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Razkrižje' WHERE iso_code = 'SI' AND abbreviation = '172';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Rečica ob Savinji' WHERE iso_code = 'SI' AND abbreviation = '173';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Renče-Vogrsko' WHERE iso_code = 'SI' AND abbreviation = '174';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Rogaška Slatina' WHERE iso_code = 'SI' AND abbreviation = '177';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Rogašovci' WHERE iso_code = 'SI' AND abbreviation = '178';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ruše' WHERE iso_code = 'SI' AND abbreviation = '180';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Semič' WHERE iso_code = 'SI' AND abbreviation = '196';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Šentrupert' WHERE iso_code = 'SI' AND abbreviation = '197';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Sežana' WHERE iso_code = 'SI' AND abbreviation = '199';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Šmarješke Toplice' WHERE iso_code = 'SI' AND abbreviation = '203';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Sodražica' WHERE iso_code = 'SI' AND abbreviation = '204';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Solčava' WHERE iso_code = 'SI' AND abbreviation = '205';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Središče ob Dravi' WHERE iso_code = 'SI' AND abbreviation = '206';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Starše' WHERE iso_code = 'SI' AND abbreviation = '207';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Straža' WHERE iso_code = 'SI' AND abbreviation = '208';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Sveti Tomaž' WHERE iso_code = 'SI' AND abbreviation = '211';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'La Réunion' WHERE iso_code = 'FR' AND abbreviation = 'RE';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Nohiyahoi Tobei Jumhurí' WHERE iso_code = 'TJ' AND abbreviation = 'RA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Nouvelle-Calédonie' WHERE iso_code = 'FR' AND abbreviation = 'NC';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Haut-Ogooué' WHERE iso_code = 'GA' AND abbreviation = '02';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Moyen-Ogooué' WHERE iso_code = 'GA' AND abbreviation = '03';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ngounié' WHERE iso_code = 'GA' AND abbreviation = '04';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ogooué-Ivindo' WHERE iso_code = 'GA' AND abbreviation = '06';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ogooué-Lolo' WHERE iso_code = 'GA' AND abbreviation = '07';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ogooué-Maritime' WHERE iso_code = 'GA' AND abbreviation = '08';
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | 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-2019
- */
-
-/**
- * Business objects for managing price fields.
- */
-class CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field extends CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field {
-
- protected $_options;
-
- /**
- * Takes an associative array and creates a price field object.
- *
- * the function extract all the params it needs to initialize the create a
- * price field object. the params array could contain additional unused name/value
- * pairs
- *
- * @param array $params
- * (reference ) an assoc array of name/value pairs.
- *
- * @return CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field
- */
- public static function &add(&$params) {
- $priceFieldBAO = new CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field();
-
- $priceFieldBAO->copyValues($params);
-
- if ($id = CRM_Utils_Array::value('id', $params)) {
- $priceFieldBAO->id = $id;
- }
-
- $priceFieldBAO->save();
- return $priceFieldBAO;
- }
-
- /**
- * Takes an associative array and creates a price field object.
- *
- * This function is invoked from within the web form layer and also from the api layer
- *
- * @param array $params
- * (reference) an assoc array of name/value pairs.
- *
- * @return CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field
- */
- public static function create(&$params) {
-
- $transaction = new CRM_Core_Transaction();
-
- $priceField = self::add($params);
-
- if (is_a($priceField, 'CRM_Core_Error')) {
- $transaction->rollback();
- return $priceField;
- }
-
- $options = $optionsIds = array();
- $maxIndex = CRM_Price_Form_Field::NUM_OPTION;
-
- if ($priceField->html_type == 'Text') {
- $maxIndex = 1;
-
- $fieldValue = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue();
- $fieldValue->price_field_id = $priceField->id;
-
- // update previous field values( if any )
- if ($fieldValue->find(TRUE)) {
- $optionsIds['id'] = $fieldValue->id;
- }
- }
- $defaultArray = array();
- if ($params['html_type'] == 'CheckBox' && isset($params['default_checkbox_option'])) {
- $tempArray = array_keys($params['default_checkbox_option']);
- foreach ($tempArray as $v) {
- if ($params['option_amount'][$v]) {
- $defaultArray[$v] = 1;
- }
- }
- }
- else {
- if (!empty($params['default_option'])) {
- $defaultArray[$params['default_option']] = 1;
- }
- }
-
- for ($index = 1; $index <= $maxIndex; $index++) {
-
- if (array_key_exists('option_amount', $params) &&
- array_key_exists($index, $params['option_amount']) &&
- (CRM_Utils_Array::value($index, CRM_Utils_Array::value('option_label', $params)) || !empty($params['is_quick_config'])) &&
- !CRM_Utils_System::isNull($params['option_amount'][$index])
- ) {
- $options = array(
- 'price_field_id' => $priceField->id,
- 'label' => trim($params['option_label'][$index]),
- 'name' => CRM_Utils_String::munge($params['option_label'][$index], '_', 64),
- 'amount' => CRM_Utils_Rule::cleanMoney(trim($params['option_amount'][$index])),
- 'count' => CRM_Utils_Array::value($index, CRM_Utils_Array::value('option_count', $params), NULL),
- 'max_value' => CRM_Utils_Array::value($index, CRM_Utils_Array::value('option_max_value', $params), NULL),
- 'description' => CRM_Utils_Array::value($index, CRM_Utils_Array::value('option_description', $params), NULL),
- 'membership_type_id' => CRM_Utils_Array::value($index, CRM_Utils_Array::value('membership_type_id', $params), NULL),
- 'weight' => $params['option_weight'][$index],
- 'is_active' => 1,
- 'is_default' => CRM_Utils_Array::value($params['option_weight'][$index], $defaultArray) ? $defaultArray[$params['option_weight'][$index]] : 0,
- );
-
- if ($opIds = CRM_Utils_Array::value('option_id', $params)) {
- if ($opId = CRM_Utils_Array::value($index, $opIds)) {
- $optionsIds['id'] = $opId;
- }
- else {
- $optionsIds['id'] = NULL;
- }
- }
- CRM_Upgrade_Snapshot_V4p2_Price_BAO_FieldValue::create($options, $optionsIds);
- }
- }
-
- $transaction->commit();
- return $priceField;
- }
-
- /**
- * Fetch object based on array of properties.
- *
- * @param array $params
- * (reference ) an assoc array of name/value pairs.
- * @param array $defaults
- * (reference ) an assoc array to hold the flattened values.
- *
- * @return CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field
- */
- public static function retrieve(&$params, &$defaults) {
- return CRM_Core_DAO::commonRetrieve('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $params, $defaults);
- }
-
- /**
- * Update the is_active flag in the db.
- *
- * @param int $id
- * Id of the database record.
- * @param bool $is_active
- * Value we want to set the is_active field.
- *
- * @return bool
- * true if we found and updated the object, else false
- */
- public static function setIsActive($id, $is_active) {
- return CRM_Core_DAO::setFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $id, 'is_active', $is_active);
- }
-
- /**
- * Get the field title.
- *
- * @param int $id
- * Id of field.
- *
- * @return string
- * name
- */
- public static function getTitle($id) {
- return CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $id, 'label');
- }
-
- /**
- * This function for building custom fields.
- *
- * @param CRM_Core_Form $qf
- * Form object (reference).
- * @param string $elementName
- * Name of the custom field.
- * @param int $fieldId
- * @param bool $inactiveNeeded
- * @param bool $useRequired
- * True if required else false.
- * @param string $label
- * Label for custom field.
- * @param null $fieldOptions
- * @param array $freezeOptions
- *
- * @return null
- */
- public static function addQuickFormElement(
- &$qf,
- $elementName,
- $fieldId,
- $inactiveNeeded,
- $useRequired = TRUE,
- $label = NULL,
- $fieldOptions = NULL,
- $freezeOptions = array()
- ) {
-
- $field = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field();
- $field->id = $fieldId;
- if (!$field->find(TRUE)) {
- /* FIXME: failure! */
-
- return NULL;
- }
-
- $otherAmount = $qf->get('values');
- $config = CRM_Core_Config::singleton();
- $qf->assign('currencySymbol', CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Currency', $config->defaultCurrency, 'symbol', 'name'));
- // get currency name for price field and option attributes
- $currencyName = $config->defaultCurrency;
-
- if (!isset($label)) {
- $label = (property_exists($qf, '_membershipBlock') && !empty($qf->_membershipBlock['is_separate_payment']) && $field->name == 'contribution_amount' && empty($otherAmount['is_allow_other_amount'])) ? ts('Additional Contribution') : $field->label;
- }
-
- if ($field->name == 'contribution_amount') {
- $qf->_contributionAmount = 1;
- }
-
- if (isset($qf->_online) && $qf->_online) {
- $useRequired = FALSE;
- }
-
- $customOption = $fieldOptions;
- if (!is_array($customOption)) {
- $customOption = CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::getOptions($field->id, $inactiveNeeded);
- }
-
- //use value field.
- $valueFieldName = 'amount';
- $seperator = '|';
- switch ($field->html_type) {
- case 'Text':
- $optionKey = key($customOption);
- $count = CRM_Utils_Array::value('count', $customOption[$optionKey], '');
- $max_value = CRM_Utils_Array::value('max_value', $customOption[$optionKey], '');
- $priceVal = implode($seperator, array($customOption[$optionKey][$valueFieldName], $count, $max_value));
-
- $extra = array();
- if (property_exists($qf, '_quickConfig') && $qf->_quickConfig && property_exists($qf, '_contributionAmount') && $qf->_contributionAmount) {
- $qf->assign('priceset', $elementName);
- $extra = array('onclick' => 'useAmountOther();');
- }
-
- // if separate membership payment is used with quick config priceset then change the other amount label
- if (property_exists($qf, '_membershipBlock') && !empty($qf->_membershipBlock['is_separate_payment']) && $qf->_quickConfig && $field->name == 'other_amount' && !property_exists($qf, '_contributionAmount')) {
- $label = ts('Additional Contribution');
- $useRequired = 0;
- }
- elseif (!empty($fieldOptions[$optionKey]['label'])) {
- $label = $fieldOptions[$optionKey]['label'];
- }
-
- if ($field->is_display_amounts) {
- $label .= ' - ';
- $label .= CRM_Utils_Money::format(CRM_Utils_Array::value($valueFieldName, $customOption[$optionKey]));
- }
-
- $element = &$qf->add('text', $elementName, $label,
- array_merge($extra,
- array(
- 'price' => json_encode(array($optionKey, $priceVal)),
- 'size' => '4',
- )
- ),
- $useRequired && $field->is_required
- );
-
- // CRM-6902
- if (in_array($optionKey, $freezeOptions)) {
- $element->freeze();
- }
-
- //CRM-10117
- if (property_exists($qf, '_quickConfig') && $qf->_quickConfig) {
- $message = ts("Please enter a valid amount.");
- $type = "money";
- }
- else {
- $message = ts('%1 must be an integer (whole number).', array(1 => $label));
- $type = "positiveInteger";
- }
- // integers will have numeric rule applied to them.
- $qf->addRule($elementName, $message, $type);
- break;
-
- case 'Radio':
- $choice = array();
-
- if (property_exists($qf, '_quickConfig') && $qf->_quickConfig && property_exists($qf, '_contributionAmount') && $qf->_contributionAmount) {
- $qf->assign('contriPriceset', $elementName);
- }
-
- foreach ($customOption as $opId => $opt) {
- if ($field->is_display_amounts) {
- $opt['label'] = !empty($opt['label']) ? $opt['label'] . ' - ' : '';
- $opt['label'] .= CRM_Utils_Money::format($opt[$valueFieldName]);
- }
- $count = CRM_Utils_Array::value('count', $opt, '');
- $max_value = CRM_Utils_Array::value('max_value', $opt, '');
- $priceVal = implode($seperator, array($opt[$valueFieldName], $count, $max_value));
- $extra = array(
- 'price' => json_encode(array($elementName, $priceVal)),
- 'data-amount' => $opt[$valueFieldName],
- 'data-currency' => $currencyName,
- );
- if (property_exists($qf, '_quickConfig') && $qf->_quickConfig && $field->name == 'contribution_amount') {
- $extra += array('onclick' => 'clearAmountOther();');
- }
- elseif (property_exists($qf, '_quickConfig') && $qf->_quickConfig && $field->name == 'membership_amount') {
- $extra += array(
- 'onclick' => "return showHideAutoRenew({$opt['membership_type_id']});",
- 'membership-type' => $opt['membership_type_id'],
- );
- $qf->assign('membershipFieldID', $field->id);
- }
- $choice[$opId] = $qf->createElement('radio', NULL, '', $opt['label'], $opt['id'], $extra);
-
- // CRM-6902
- if (in_array($opId, $freezeOptions)) {
- $choice[$opId]->freeze();
- }
- }
-
- if (property_exists($qf, '_membershipBlock') && !empty($qf->_membershipBlock['is_separate_payment']) && $field->name == 'contribution_amount') {
- $choice[] = $qf->createElement('radio', NULL, '', 'No thank you', '-1',
- array(
- 'onclick' => 'clearAmountOther();',
- )
- );
- }
-
- if (!$field->is_required) {
- // add "none" option
- if (!empty($otherAmount['is_allow_other_amount']) && $field->name == 'contribution_amount') {
- $none = ts('Other Amount');
- }
- elseif (property_exists($qf, '_membershipBlock') && empty($qf->_membershipBlock['is_required']) && $field->name == 'membership_amount') {
- $none = ts('No thank you');
- }
- else {
- $none = ts('-none-');
- }
-
- $choice[] = $qf->createElement('radio', NULL, '', $none, '0',
- array('price' => json_encode(array($elementName, "0")))
- );
- }
-
- $element = &$qf->addGroup($choice, $elementName, $label);
-
- // make contribution field required for quick config when membership block is enabled
- if (($field->name == 'contribution_amount' || $field->name == 'membership_amount') && property_exists($qf, '_membershipBlock') && !empty($qf->_membershipBlock) && !$field->is_required) {
- $useRequired = $field->is_required = TRUE;
- }
-
- if ($useRequired && $field->is_required) {
- $qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
- }
- break;
-
- case 'Select':
- $selectOption = $allowedOptions = $priceVal = array();
-
- foreach ($customOption as $opt) {
- $count = CRM_Utils_Array::value('count', $opt, '');
- $max_value = CRM_Utils_Array::value('max_value', $opt, '');
- $priceVal[$opt['id']] = implode($seperator, array($opt[$valueFieldName], $count, $max_value));
-
- if ($field->is_display_amounts) {
- $opt['label'] .= ' - ';
- $opt['label'] .= CRM_Utils_Money::format($opt[$valueFieldName]);
- }
- $selectOption[$opt['id']] = $opt['label'];
-
- if (!in_array($opt['id'], $freezeOptions)) {
- $allowedOptions[] = $opt['id'];
- }
- }
- $element = &$qf->add('select', $elementName, $label,
- array('' => ts('- select -')) + $selectOption,
- $useRequired && $field->is_required,
- array('price' => json_encode($priceVal))
- );
-
- // CRM-6902
- $button = substr($qf->controller->getButtonName(), -4);
- if (!empty($freezeOptions) && $button != 'skip') {
- $qf->addRule($elementName, ts('Sorry, this option is currently sold out.'), 'regex', "/" . implode('|', $allowedOptions) . "/");
- }
- break;
-
- case 'CheckBox':
-
- $check = array();
- foreach ($customOption as $opId => $opt) {
- $count = CRM_Utils_Array::value('count', $opt, '');
- $max_value = CRM_Utils_Array::value('max_value', $opt, '');
- $priceVal = implode($seperator, array($opt[$valueFieldName], $count, $max_value));
-
- if ($field->is_display_amounts) {
- $opt['label'] .= ' - ';
- $opt['label'] .= CRM_Utils_Money::format($opt[$valueFieldName]);
- }
- $check[$opId] = &$qf->createElement('checkbox', $opt['id'], NULL, $opt['label'],
- array(
- 'price' => json_encode(array($opt['id'], $priceVal)),
- 'data-amount' => $opt[$valueFieldName],
- 'data-currency' => $currencyName,
- )
- );
-
- // CRM-6902
- if (in_array($opId, $freezeOptions)) {
- $check[$opId]->freeze();
- }
- }
- $element = &$qf->addGroup($check, $elementName, $label);
- if ($useRequired && $field->is_required) {
- $qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
- }
- break;
- }
- if (isset($qf->_online) && $qf->_online) {
- $element->freeze();
- }
- }
-
- /**
- * Retrieve a list of options for the specified field.
- *
- * @param int $fieldId
- * Price field ID.
- * @param bool $inactiveNeeded
- * Include inactive options.
- * @param bool $reset
- * Ignore stored values\.
- *
- * @return array
- * array of options
- */
- public static function getOptions($fieldId, $inactiveNeeded = FALSE, $reset = FALSE) {
- static $options = array();
-
- if ($reset || empty($options[$fieldId])) {
- $values = array();
- CRM_Upgrade_Snapshot_V4p2_Price_BAO_FieldValue::getValues($fieldId, $values, 'weight', !$inactiveNeeded);
- $options[$fieldId] = $values;
- }
-
- return $options[$fieldId];
- }
-
- /**
- * @param $optionLabel
- * @param int $fid
- *
- * @return mixed
- */
- public static function getOptionId($optionLabel, $fid) {
- if (!$optionLabel || !$fid) {
- return;
- }
-
- $optionGroupName = "civicrm_price_field.amount.{$fid}";
-
- $query = "
-SELECT
- option_value.id as id
-FROM
- civicrm_option_value option_value,
- civicrm_option_group option_group
-WHERE
- option_group.name = %1
- AND option_group.id = option_value.option_group_id
- AND option_value.label = %2";
-
- $dao = CRM_Core_DAO::executeQuery($query, array(
- 1 => array($optionGroupName, 'String'),
- 2 => array($optionLabel, 'String'),
- ));
-
- while ($dao->fetch()) {
- return $dao->id;
- }
- }
-
- /**
- * Delete the price set field.
- *
- * @param int $id
- * Field Id.
- *
- * @return mixed
- * Boolean-ish
- */
- public static function deleteField($id) {
- $field = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field();
- $field->id = $id;
-
- if ($field->find(TRUE)) {
- // delete the options for this field
- CRM_Upgrade_Snapshot_V4p2_Price_BAO_FieldValue::deleteValues($id);
-
- // reorder the weight before delete
- $fieldValues = array('price_set_id' => $field->price_set_id);
-
- CRM_Utils_Weight::delWeight('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $field->id, $fieldValues);
-
- // now delete the field
- return $field->delete();
- }
-
- return NULL;
- }
-
- /**
- * @return array
- */
- public static function &htmlTypes() {
- static $htmlTypes = NULL;
- if (!$htmlTypes) {
- $htmlTypes = array(
- 'Text' => ts('Text / Numeric Quantity'),
- 'Select' => ts('Select'),
- 'Radio' => ts('Radio'),
- 'CheckBox' => ts('CheckBox'),
- );
- }
- return $htmlTypes;
- }
-
- /**
- * Validate the priceset.
- *
- * @param int $priceSetId
- * @param array $fields
- * @param array $error
- */
- public static function priceSetValidation($priceSetId, $fields, &$error) {
- // check for at least one positive
- // amount price field should be selected.
- $priceField = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field();
- $priceField->price_set_id = $priceSetId;
- $priceField->find();
-
- $priceFields = array();
-
- while ($priceField->fetch()) {
- $key = "price_{$priceField->id}";
- if (!empty($fields[$key])) {
- $priceFields[$priceField->id] = $fields[$key];
- }
- }
-
- if (!empty($priceFields)) {
- // we should has to have positive amount.
- $sql = "
-SELECT id, html_type
-FROM civicrm_price_field
-WHERE id IN (" . implode(',', array_keys($priceFields)) . ')';
- $fieldDAO = CRM_Core_DAO::executeQuery($sql);
- $htmlTypes = array();
- while ($fieldDAO->fetch()) {
- $htmlTypes[$fieldDAO->id] = $fieldDAO->html_type;
- }
-
- $selectedAmounts = array();
-
- foreach ($htmlTypes as $fieldId => $type) {
- $options = array();
- CRM_Upgrade_Snapshot_V4p2_Price_BAO_FieldValue::getValues($fieldId, $options);
-
- if (empty($options)) {
-
- continue;
-
- }
-
- if ($type == 'Text') {
- foreach ($options as $opId => $option) {
- $selectedAmounts[$opId] = $priceFields[$fieldId] * $option['amount'];
- break;
- }
- }
- elseif (is_array($fields["price_{$fieldId}"])) {
- foreach (array_keys($fields["price_{$fieldId}"]) as $opId) {
- $selectedAmounts[$opId] = $options[$opId]['amount'];
- }
- }
- elseif (in_array($fields["price_{$fieldId}"], array_keys($options))) {
- $selectedAmounts[$fields["price_{$fieldId}"]] = $options[$fields["price_{$fieldId}"]]['amount'];
- }
- }
-
- list($componentName) = explode(':', $fields['_qf_default']);
- // now we have all selected amount in hand.
- $totalAmount = array_sum($selectedAmounts);
- if ($totalAmount < 0) {
- $error['_qf_default'] = ts('%1 amount can not be less than zero. Please select the options accordingly.', array(1 => $componentName));
- }
- }
- else {
- $error['_qf_default'] = ts("Please select at least one option from price set.");
- }
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | 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-2019
- * $Id$
- *
- */
-
-/**
- * Business objects for managing price fields values.
- *
- */
-class CRM_Upgrade_Snapshot_V4p2_Price_BAO_FieldValue extends CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue {
-
- /**
- * Insert/update a new entry in the database.
- *
- * @param array $params
- * (reference), array $ids.
- *
- * @param $ids
- *
- * @return CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue
- */
- public static function &add(&$params, $ids) {
-
- $fieldValueBAO = new CRM_Upgrade_Snapshot_V4p2_Price_BAO_FieldValue();
- $fieldValueBAO->copyValues($params);
-
- if ($id = CRM_Utils_Array::value('id', $ids)) {
- $fieldValueBAO->id = $id;
- }
- if (!empty($params['is_default'])) {
- $query = 'UPDATE civicrm_price_field_value SET is_default = 0 WHERE price_field_id = %1';
- $p = array(1 => array($params['price_field_id'], 'Integer'));
- CRM_Core_DAO::executeQuery($query, $p);
- }
-
- $fieldValueBAO->save();
- return $fieldValueBAO;
- }
-
- /**
- * Creates a new entry in the database.
- *
- * @param array $params
- * (reference), array $ids.
- *
- * @param $ids
- *
- * @return CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue
- */
- public static function create(&$params, $ids) {
-
- if (!is_array($params) || empty($params)) {
- return NULL;
- }
-
- if ($id = CRM_Utils_Array::value('id', $ids)) {
- if (isset($params['name'])) {
- unset($params['name']);
- }
-
- $oldWeight = NULL;
- if ($id) {
- $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue', $id, 'weight', 'id');
- }
-
- $fieldValues = array('price_field_id' => CRM_Utils_Array::value('price_field_id', $params, 0));
- $params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue', $oldWeight, $params['weight'], $fieldValues);
- }
- else {
- if (empty($params['name'])) {
- $params['name'] = CRM_Utils_String::munge(CRM_Utils_Array::value('label', $params), '_', 64);
- }
- if (empty($params['weight'])) {
- $params['weight'] = 1;
- }
- }
- $params['is_active'] = CRM_Utils_Array::value('is_active', $params, 0);
-
- return self::add($params, $ids);
- }
-
- /**
- * Retrieve DB object based on input parameters.
- *
- * It also stores all the retrieved values in the default array.
- *
- * @param array $params
- * (reference ) an assoc array.
- * @param array $defaults
- * (reference ) an assoc array to hold the flattened values.
- *
- * @return CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue
- */
- public static function retrieve(&$params, &$defaults) {
- return CRM_Core_DAO::commonRetrieve('CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue', $params, $defaults);
- }
-
- /**
- * Retrive the all values for given field id.
- *
- * @param int $fieldId
- * Price_field_id.
- * @param array $values
- * (reference ) to hold the values.
- * @param string $orderBy
- * For order by, default weight.
- * @param bool|int $isActive is_active, default false
- *
- * @return array
- *
- */
- public static function getValues($fieldId, &$values, $orderBy = 'weight', $isActive = FALSE) {
- $fieldValueDAO = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue();
- $fieldValueDAO->price_field_id = $fieldId;
- $fieldValueDAO->orderBy($orderBy, 'label');
- if ($isActive) {
- $fieldValueDAO->is_active = 1;
- }
- $fieldValueDAO->find();
-
- while ($fieldValueDAO->fetch()) {
- CRM_Core_DAO::storeValues($fieldValueDAO, $values[$fieldValueDAO->id]);
- }
-
- return $values;
- }
-
- /**
- * Get the price field option label.
- *
- * @param int $id
- * Id of field option.
- *
- * @return string
- * name
- *
- */
- public static function getOptionLabel($id) {
- return CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue', $id, 'label');
- }
-
- /**
- * Update the is_active flag in the db.
- *
- * @param int $id
- * Id of the database record.
- * @param bool $is_active
- * Value we want to set the is_active field.
- *
- * @return bool
- * true if we found and updated the object, else false
- */
- public static function setIsActive($id, $is_active) {
- return CRM_Core_DAO::setFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue', $id, 'is_active', $is_active);
- }
-
- /**
- * Delete all values of the given field id.
- *
- * @param int $fieldId
- * Price field id.
- *
- * @return bool
- *
- */
- public static function deleteValues($fieldId) {
- if (!$fieldId) {
- return FALSE;
- }
-
- $fieldValueDAO = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue();
- $fieldValueDAO->price_field_id = $fieldId;
- $fieldValueDAO->delete();
- }
-
- /**
- * Delete the value.
- *
- * @param int $id
- * Id.
- *
- * @return bool
- *
- */
- public static function del($id) {
- if (!$id) {
- return FALSE;
- }
-
- $fieldValueDAO = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue();
- $fieldValueDAO->id = $id;
- return $fieldValueDAO->delete();
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | 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-2019
- * $Id$
- *
- */
-
-/**
- *
- * @package CRM
- * @author Marshal Newrock <marshal@idealso.com>
- * $Id$
- */
-
-/**
- * Business objects for Line Items generated by monetary transactions
- */
-class CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem extends CRM_Upgrade_Snapshot_V4p2_Price_DAO_LineItem {
-
- /**
- * Creates a new entry in the database.
- *
- * @param array $params
- * (reference) an assoc array of name/value pairs.
- *
- * @return CRM_Upgrade_Snapshot_V4p2_Price_DAO_LineItem
- */
- public static function create(&$params) {
- //create mode only as we don't support editing line items
-
- CRM_Utils_Hook::pre('create', 'LineItem', $params['entity_id'], $params);
-
- $lineItemBAO = new CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem();
- $lineItemBAO->copyValues($params);
-
- $return = $lineItemBAO->save();
-
- CRM_Utils_Hook::post('create', 'LineItem', $params['entity_id'], $params);
-
- return $return;
- }
-
- /**
- * Retrieve DB object based on input parameters.
- *
- * It also stores all the retrieved values in the default array.
- *
- * @param array $params
- * (reference ) an assoc array of name/value pairs.
- * @param array $defaults
- * (reference ) an assoc array to hold the flattened values.
- *
- * @return CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem
- */
- public static function retrieve(&$params, &$defaults) {
- $lineItem = new CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem();
- $lineItem->copyValues($params);
- if ($lineItem->find(TRUE)) {
- CRM_Core_DAO::storeValues($lineItem, $defaults);
- return $lineItem;
- }
- return NULL;
- }
-
- /**
- * Given a participant id/contribution id,
- * return contribution/fee line items
- *
- * @param int $entityId
- * participant/contribution id.
- * @param string $entity
- * participant/contribution.
- *
- * @param null $isQuick
- *
- * @return array
- * Array of line items
- */
- public static function getLineItems($entityId, $entity = 'participant', $isQuick = NULL) {
- $selectClause = $whereClause = $fromClause = NULL;
-
- $selectClause = "
-SELECT li.id,
- li.label,
- li.qty,
- li.unit_price,
- li.line_total,
- pf.label as field_title,
- pf.html_type,
- pfv.membership_type_id,
- li.price_field_id,
- li.participant_count,
- li.price_field_value_id,
- pfv.description";
-
- $fromClause = "
-FROM civicrm_%2 as %2
-LEFT JOIN civicrm_line_item li ON ( li.entity_id = %2.id AND li.entity_table = 'civicrm_%2')
-LEFT JOIN civicrm_price_field_value pfv ON ( pfv.id = li.price_field_value_id )
-LEFT JOIN civicrm_price_field pf ON (pf.id = li.price_field_id )";
- $whereClause = "
-WHERE %2.id = %1";
-
- if ($isQuick) {
- $fromClause .= " LEFT JOIN civicrm_price_set cps on cps.id = pf.price_set_id ";
- $whereClause .= " and cps.is_quick_config = 0";
- }
- $lineItems = array();
-
- if (!$entityId || !$entity || !$fromClause) {
- return $lineItems;
- }
-
- $params = array(
- 1 => array($entityId, 'Integer'),
- 2 => array($entity, 'Text'),
- );
-
- $dao = CRM_Core_DAO::executeQuery("$selectClause $fromClause $whereClause", $params);
- while ($dao->fetch()) {
- if (!$dao->id) {
- continue;
- }
- $lineItems[$dao->id] = array(
- 'qty' => $dao->qty,
- 'label' => $dao->label,
- 'unit_price' => $dao->unit_price,
- 'line_total' => $dao->line_total,
- 'price_field_id' => $dao->price_field_id,
- 'participant_count' => $dao->participant_count,
- 'price_field_value_id' => $dao->price_field_value_id,
- 'field_title' => $dao->field_title,
- 'html_type' => $dao->html_type,
- 'description' => $dao->description,
- 'entity_id' => $entityId,
- 'membership_type_id' => $dao->membership_type_id,
- );
- }
- return $lineItems;
- }
-
- /**
- * This method will create the lineItem array required for.
- * processAmount method
- *
- * @param int $fid
- * Price set field id.
- * @param array $params
- * Reference to form values.
- * @param array $fields
- * Reference to array of fields belonging.
- * to the price set used for particular event
- * @param array $values
- * Reference to the values array(.
- * this is lineItem array)
- */
- public static function format($fid, &$params, &$fields, &$values) {
- if (empty($params["price_{$fid}"])) {
- return;
- }
-
- $optionIDs = implode(',', array_keys($params["price_{$fid}"]));
-
- //lets first check in fun parameter,
- //since user might modified w/ hooks.
- $options = array();
- if (array_key_exists('options', $fields)) {
- $options = $fields['options'];
- }
- else {
- CRM_Upgrade_Snapshot_V4p2_Price_BAO_FieldValue::getValues($fid, $options, 'weight', TRUE);
- }
- $fieldTitle = CRM_Utils_Array::value('label', $fields);
- if (!$fieldTitle) {
- $fieldTitle = CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $fid, 'label');
- }
-
- foreach ($params["price_{$fid}"] as $oid => $qty) {
- $price = $options[$oid]['amount'];
-
- // lets clean the price in case it is not yet cleaned
- // CRM-10974
- $price = CRM_Utils_Rule::cleanMoney($price);
-
- $participantsPerField = CRM_Utils_Array::value('count', $options[$oid], 0);
-
- $values[$oid] = array(
- 'price_field_id' => $fid,
- 'price_field_value_id' => $oid,
- 'label' => CRM_Utils_Array::value('label', $options[$oid]),
- 'field_title' => $fieldTitle,
- 'description' => CRM_Utils_Array::value('description', $options[$oid]),
- 'qty' => $qty,
- 'unit_price' => $price,
- 'line_total' => $qty * $price,
- 'participant_count' => $qty * $participantsPerField,
- 'max_value' => CRM_Utils_Array::value('max_value', $options[$oid]),
- 'membership_type_id' => CRM_Utils_Array::value('membership_type_id', $options[$oid]),
- 'auto_renew' => CRM_Utils_Array::value('auto_renew', $options[$oid]),
- 'html_type' => $fields['html_type'],
- );
- }
- }
-
- /**
- * Delete line items for given entity.
- *
- * @param int $entityId
- * @param int $entityTable
- *
- * @return bool
- */
- public static function deleteLineItems($entityId, $entityTable) {
- $result = FALSE;
- if (!$entityId || !$entityTable) {
- return $result;
- }
-
- if ($entityId && !is_array($entityId)) {
- $entityId = array($entityId);
- }
-
- $query = "DELETE FROM civicrm_line_item where entity_id IN ('" . implode("','", $entityId) . "') AND entity_table = '$entityTable'";
- $dao = CRM_Core_DAO::executeQuery($query);
- return $result;
- }
-
- /**
- * @param int $entityId
- * @param string $entityTable
- * @param $amount
- * @param array $otherParams
- */
- public static function syncLineItems($entityId, $entityTable = 'civicrm_contribution', $amount, $otherParams = NULL) {
- if (!$entityId || CRM_Utils_System::isNull($amount)) {
- return;
- }
-
- $from = " civicrm_line_item li
-LEFT JOIN civicrm_price_field pf ON pf.id = li.price_field_id
-LEFT JOIN civicrm_price_set ps ON ps.id = pf.price_set_id ";
-
- $set = " li.unit_price = %3,
- li.line_total = %3 ";
-
- $where = " li.entity_id = %1 AND
- li.entity_table = %2 ";
-
- $params = array(
- 1 => array($entityId, 'Integer'),
- 2 => array($entityTable, 'String'),
- 3 => array($amount, 'Float'),
- );
-
- if ($entityTable == 'civicrm_contribution') {
- $entityName = 'default_contribution_amount';
- $where .= " AND ps.name = %4 ";
- $params[4] = array($entityName, 'String');
- }
- elseif ($entityTable == 'civicrm_participant') {
- $from .= "
-LEFT JOIN civicrm_price_set_entity cpse ON cpse.price_set_id = ps.id
-LEFT JOIN civicrm_price_field_value cpfv ON cpfv.price_field_id = pf.id and cpfv.label = %4 ";
- $set .= " ,li.label = %4,
- li.price_field_value_id = cpfv.id ";
- $where .= " AND cpse.entity_table = 'civicrm_event' AND cpse.entity_id = %5 ";
- $amount = empty($amount) ? 0 : $amount;
- $params += array(
- 4 => array($otherParams['fee_label'], 'String'),
- 5 => array($otherParams['event_id'], 'String'),
- );
- }
-
- $query = "
-UPDATE $from
-SET $set
-WHERE $where
-";
-
- CRM_Core_DAO::executeQuery($query, $params);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | 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-2019
- */
-
-/**
- * Business object for managing price sets.
- */
-class CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set extends CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set {
-
- /**
- * Class constructor.
- */
- public function __construct() {
- parent::__construct();
- }
-
- /**
- * Takes an associative array and creates a price set object.
- *
- * @param array $params
- * (reference) an assoc array of name/value pairs.
- *
- * @return CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set
- */
- public static function create(&$params) {
- $priceSetBAO = new CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set();
- $priceSetBAO->copyValues($params);
- if (self::eventPriceSetDomainID()) {
- $priceSetBAO->domain_id = CRM_Core_Config::domainID();
- }
- return $priceSetBAO->save();
- }
-
- /**
- * Fetch object based on array of properties.
- *
- * @param array $params
- * (reference ) an assoc array of name/value pairs.
- * @param array $defaults
- * (reference ) an assoc array to hold the flattened values.
- *
- * @return CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set
- */
- public static function retrieve(&$params, &$defaults) {
- return CRM_Core_DAO::commonRetrieve('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', $params, $defaults);
- }
-
- /**
- * Update the is_active flag in the db.
- *
- * @param int $id
- * Id of the database record.
- * @param bool $isActive
- * Value we want to set the is_active field.
- *
- * @return bool
- * true if we found and updated the object, else false
- */
- public static function setIsActive($id, $isActive) {
- return CRM_Core_DAO::setFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', $id, 'is_active', $isActive);
- }
-
- /**
- * Calculate the default price set id assigned to the contribution/membership etc.
- *
- * @param string $entity
- *
- * @return int
- * priceSetID
- */
- public static function getDefaultPriceSet($entity = 'contribution') {
- if ($entity == 'contribution') {
- $entityName = 'default_contribution_amount';
- }
- elseif ($entity == 'membership') {
- $entityName = 'default_membership_type_amount';
- }
-
- $sql = "
-SELECT ps.id AS setID, pfv.price_field_id AS priceFieldID, pfv.id AS priceFieldValueID, pfv.name, pfv.label
-FROM civicrm_price_set ps
-LEFT JOIN civicrm_price_field pf ON pf.`price_set_id` = ps.id
-LEFT JOIN civicrm_price_field_value pfv ON pfv.price_field_id = pf.id
-WHERE ps.name = '{$entityName}'
-";
-
- $dao = CRM_Core_DAO::executeQuery($sql);
- $defaultPriceSet = array();
- while ($dao->fetch()) {
- $defaultPriceSet[$dao->priceFieldValueID]['setID'] = $dao->setID;
- $defaultPriceSet[$dao->priceFieldValueID]['priceFieldID'] = $dao->priceFieldID;
- $defaultPriceSet[$dao->priceFieldValueID]['name'] = $dao->name;
- $defaultPriceSet[$dao->priceFieldValueID]['label'] = $dao->label;
- }
-
- return $defaultPriceSet;
- }
-
- /**
- * Get the price set title.
- *
- * @param int $id
- * Id of price set.
- *
- * @return string
- * title
- */
- public static function getTitle($id) {
- return CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', $id, 'title');
- }
-
- /**
- * Return a list of all forms which use this price set.
- *
- * @param int $id
- * Id of price set.
- * @param bool|\str $simpleReturn - get raw data. Possible values: 'entity', 'table'
- *
- * @return array
- */
- public static function &getUsedBy($id, $simpleReturn = FALSE) {
- $usedBy = $forms = $tables = array();
- $queryString = "
-SELECT entity_table, entity_id
-FROM civicrm_price_set_entity
-WHERE price_set_id = %1";
- $params = array(1 => array($id, 'Integer'));
- $crmFormDAO = CRM_Core_DAO::executeQuery($queryString, $params);
-
- while ($crmFormDAO->fetch()) {
- $forms[$crmFormDAO->entity_table][] = $crmFormDAO->entity_id;
- $tables[] = $crmFormDAO->entity_table;
- }
- // Return only tables
- if ($simpleReturn == 'table') {
- return $tables;
- }
- if (empty($forms)) {
- $queryString = "
-SELECT cli.entity_table, cli.entity_id
-FROM civicrm_line_item cli
-LEFT JOIN civicrm_price_field cpf ON cli.price_field_id = cpf.id
-WHERE cpf.price_set_id = %1";
- $params = array(1 => array($id, 'Integer'));
- $crmFormDAO = CRM_Core_DAO::executeQuery($queryString, $params);
- while ($crmFormDAO->fetch()) {
- $forms[$crmFormDAO->entity_table][] = $crmFormDAO->entity_id;
- $tables[] = $crmFormDAO->entity_table;
- }
- if (empty($forms)) {
- return $usedBy;
- }
- }
- // Return only entity data
- if ($simpleReturn == 'entity') {
- return $forms;
- }
- foreach ($forms as $table => $entities) {
- switch ($table) {
- case 'civicrm_event':
- $ids = implode(',', $entities);
- $queryString = "SELECT ce.id as id, ce.title as title, ce.is_public as isPublic, ce.start_date as startDate, ce.end_date as endDate, civicrm_option_value.label as eventType
-FROM civicrm_event ce
-LEFT JOIN civicrm_option_value ON
- ( ce.event_type_id = civicrm_option_value.value )
-LEFT JOIN civicrm_option_group ON
- ( civicrm_option_group.id = civicrm_option_value.option_group_id )
-WHERE
- civicrm_option_group.name = 'event_type' AND
- ( ce.is_template IS NULL OR ce.is_template = 0) AND
- ce.id IN ($ids) AND
- ce.is_active = 1;";
- $crmDAO = CRM_Core_DAO::executeQuery($queryString);
- while ($crmDAO->fetch()) {
- $usedBy[$table][$crmDAO->id]['title'] = $crmDAO->title;
- $usedBy[$table][$crmDAO->id]['eventType'] = $crmDAO->eventType;
- $usedBy[$table][$crmDAO->id]['startDate'] = $crmDAO->startDate;
- $usedBy[$table][$crmDAO->id]['endDate'] = $crmDAO->endDate;
- $usedBy[$table][$crmDAO->id]['isPublic'] = $crmDAO->isPublic;
- }
- break;
-
- case 'civicrm_contribution_page':
- $ids = implode(',', $entities);
- $queryString = "SELECT cp.id as id, cp.title as title, cp.start_date as startDate, cp.end_date as endDate,ct.name as type
-FROM civicrm_contribution_page cp, civicrm_contribution_type ct
-WHERE ct.id = cp.contribution_type_id AND
- cp.id IN ($ids) AND
- cp.is_active = 1;";
- $crmDAO = CRM_Core_DAO::executeQuery($queryString);
- while ($crmDAO->fetch()) {
- $usedBy[$table][$crmDAO->id]['title'] = $crmDAO->title;
- $usedBy[$table][$crmDAO->id]['type'] = $crmDAO->type;
- $usedBy[$table][$crmDAO->id]['startDate'] = $crmDAO->startDate;
- $usedBy[$table][$crmDAO->id]['endDate'] = $crmDAO->endDate;
- }
- break;
-
- case 'civicrm_contribution':
- case 'civicrm_membership':
- case 'civicrm_participant':
- $usedBy[$table] = 1;
- break;
-
- default:
- CRM_Core_Error::fatal("$table is not supported in PriceSet::usedBy()");
- break;
- }
- }
-
- return $usedBy;
- }
-
- /**
- * Delete the price set.
- *
- * @param int $id
- * Price Set id.
- *
- * @return bool
- * false if fields exist for this set, true if the
- * set could be deleted
- */
- public static function deleteSet($id) {
- // remove from all inactive forms
- $usedBy = self::getUsedBy($id);
- if (isset($usedBy['civicrm_event'])) {
- foreach ($usedBy['civicrm_event'] as $eventId => $unused) {
- $eventDAO = new CRM_Event_DAO_Event();
- $eventDAO->id = $eventId;
- $eventDAO->find();
- while ($eventDAO->fetch()) {
- self::removeFrom('civicrm_event', $eventDAO->id);
- }
- }
- }
-
- // delete price fields
- $priceField = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field();
- $priceField->price_set_id = $id;
- $priceField->find();
- while ($priceField->fetch()) {
- // delete options first
- CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::deleteField($priceField->id);
- }
-
- $set = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set();
- $set->id = $id;
- return $set->delete();
- }
-
- /**
- * Link the price set with the specified table and id.
- *
- * @param string $entityTable
- * @param int $entityId
- * @param int $priceSetId
- *
- * @return bool
- */
- public static function addTo($entityTable, $entityId, $priceSetId) {
- // verify that the price set exists
- $dao = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set();
- $dao->id = $priceSetId;
- if (!$dao->find()) {
- return FALSE;
- }
- unset($dao);
-
- $dao = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_SetEntity();
- // find if this already exists
- $dao->entity_id = $entityId;
- $dao->entity_table = $entityTable;
- $dao->find(TRUE);
-
- // add or update price_set_id
- $dao->price_set_id = $priceSetId;
- return $dao->save();
- }
-
- /**
- * Delete price set for the given entity and id.
- *
- * @param string $entityTable
- * @param int $entityId
- *
- * @return mixed
- */
- public static function removeFrom($entityTable, $entityId) {
- $dao = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_SetEntity();
- $dao->entity_table = $entityTable;
- $dao->entity_id = $entityId;
- return $dao->delete();
- }
-
- /**
- * Find a price_set_id associated with the given details.
- *
- * Used For value for events:1, contribution:2, membership:3
- *
- * @param string $entityTable
- * @param int $entityId
- * @param int $usedFor
- * ( price set that extends/used for particular component ).
- *
- * @param null $isQuickConfig
- * @param null $setName
- *
- * @return int|false
- * price_set_id, or false if none found
- */
- public static function getFor($entityTable, $entityId, $usedFor = NULL, $isQuickConfig = NULL, &$setName = NULL) {
- if (!$entityTable || !$entityId) {
- return FALSE;
- }
-
- $sql = 'SELECT ps.id as price_set_id, ps.name as price_set_name
- FROM civicrm_price_set ps
- INNER JOIN civicrm_price_set_entity pse ON ps.id = pse.price_set_id
- WHERE pse.entity_table = %1 AND pse.entity_id = %2 ';
- if ($isQuickConfig) {
- $sql .= " AND ps.is_quick_config = 0 ";
- }
- $params = array(
- 1 => array($entityTable, 'String'),
- 2 => array($entityId, 'Integer'),
- );
- if ($usedFor) {
- $sql .= " AND ps.extends LIKE '%%3%' ";
- $params[3] = array($usedFor, 'Integer');
- }
-
- $dao = CRM_Core_DAO::executeQuery($sql, $params);
- $dao->fetch();
- $setName = (isset($dao->price_set_name)) ? $dao->price_set_name : FALSE;
- return (isset($dao->price_set_id)) ? $dao->price_set_id : FALSE;
- }
-
- /**
- * Find a price_set_id associatied with the given option value or field ID.
- *
- * @param array $params
- * (reference) an assoc array of name/value pairs.
- * array may contain either option id or
- * price field id
- *
- * @return int|null
- * price set id on success, null otherwise
- */
- public static function getSetId(&$params) {
- $fid = NULL;
-
- if ($oid = CRM_Utils_Array::value('oid', $params)) {
- $fieldValue = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue();
- $fieldValue->id = $oid;
- if ($fieldValue->find(TRUE)) {
- $fid = $fieldValue->price_field_id;
- }
- }
- else {
- $fid = CRM_Utils_Array::value('fid', $params);
- }
-
- if (isset($fid)) {
- return CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $fid, 'price_set_id');
- }
-
- return NULL;
- }
-
- /**
- * Return an associative array of all price sets.
- *
- * @param bool $withInactive
- * Whether or not to include inactive entries.
- * @param bool|string $extendComponentName name of the component like 'CiviEvent','CiviContribute'
- *
- * @return array
- * associative array of id => name
- */
- public static function getAssoc($withInactive = FALSE, $extendComponentName = FALSE) {
- $query = "
- SELECT
- DISTINCT ( price_set_id ) as id, title
- FROM
- civicrm_price_field,
- civicrm_price_set
- WHERE
- civicrm_price_set.id = civicrm_price_field.price_set_id AND is_quick_config = 0 ";
-
- if (!$withInactive) {
- $query .= " AND civicrm_price_set.is_active = 1 ";
- }
-
- if (self::eventPriceSetDomainID()) {
- $query .= " AND civicrm_price_set.domain_id = " . CRM_Core_Config::domainID();
- }
-
- $priceSets = array();
-
- if ($extendComponentName) {
- $componentId = CRM_Core_Component::getComponentID($extendComponentName);
- if (!$componentId) {
- return $priceSets;
- }
- $query .= " AND civicrm_price_set.extends LIKE '%$componentId%' ";
- }
-
- $dao = CRM_Core_DAO::executeQuery($query);
- while ($dao->fetch()) {
- $priceSets[$dao->id] = $dao->title;
- }
- return $priceSets;
- }
-
- /**
- * Get price set details.
- *
- * An array containing price set details (including price fields) is returned
- *
- * @param int $setID
- * Price set id whose details are needed.
- * @param bool $required
- * @param bool $validOnly
- *
- * @return array
- * array consisting of field details
- */
- public static function getSetDetail($setID, $required = TRUE, $validOnly = FALSE) {
- // create a new tree
- $setTree = array();
- $select = $from = $where = $orderBy = '';
-
- $priceFields = array(
- 'id',
- 'name',
- 'label',
- 'html_type',
- 'is_enter_qty',
- 'help_pre',
- 'help_post',
- 'weight',
- 'is_display_amounts',
- 'options_per_line',
- 'is_active',
- 'active_on',
- 'expire_on',
- 'javascript',
- 'visibility_id',
- 'is_required',
- );
- if ($required == TRUE) {
- $priceFields[] = 'is_required';
- }
-
- // create select
- $select = 'SELECT ' . implode(',', $priceFields);
- $from = ' FROM civicrm_price_field';
-
- $params = array();
- $params[1] = array($setID, 'Integer');
- $where = '
-WHERE price_set_id = %1
-AND is_active = 1
-';
- $dateSelect = '';
- if ($validOnly) {
- $currentTime = date('YmdHis');
- $dateSelect = "
-AND ( active_on IS NULL OR active_on <= {$currentTime} )
-AND ( expire_on IS NULL OR expire_on >= {$currentTime} )
-";
- }
-
- $orderBy = ' ORDER BY weight';
-
- $sql = $select . $from . $where . $dateSelect . $orderBy;
-
- $dao = CRM_Core_DAO::executeQuery($sql, $params);
-
- $visibility = CRM_Core_PseudoConstant::visibility('name');
- while ($dao->fetch()) {
- $fieldID = $dao->id;
-
- $setTree[$setID]['fields'][$fieldID] = array();
- $setTree[$setID]['fields'][$fieldID]['id'] = $fieldID;
-
- foreach ($priceFields as $field) {
- if ($field == 'id' || is_null($dao->$field)) {
- continue;
- }
-
- if ($field == 'visibility_id') {
- $setTree[$setID]['fields'][$fieldID]['visibility'] = $visibility[$dao->$field];
- }
- $setTree[$setID]['fields'][$fieldID][$field] = $dao->$field;
- }
- $setTree[$setID]['fields'][$fieldID]['options'] = CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::getOptions($fieldID, FALSE);
- }
-
- // also get the pre and post help from this price set
- $sql = "
-SELECT extends, contribution_type_id, help_pre, help_post, is_quick_config
-FROM civicrm_price_set
-WHERE id = %1";
- $dao = CRM_Core_DAO::executeQuery($sql, $params);
- if ($dao->fetch()) {
- $setTree[$setID]['extends'] = $dao->extends;
- $setTree[$setID]['contribution_type_id'] = $dao->contribution_type_id;
- $setTree[$setID]['help_pre'] = $dao->help_pre;
- $setTree[$setID]['help_post'] = $dao->help_post;
- $setTree[$setID]['is_quick_config'] = $dao->is_quick_config;
- }
- return $setTree;
- }
-
- /**
- * Initialise set.
- *
- * @param CRM_Core_Form $form
- * @param int $id
- * @param string $entityTable
- * @param bool $validOnly
- * @param int $priceSetId
- *
- * @return bool|false|int|null
- */
- public static function initSet(&$form, $id, $entityTable = 'civicrm_event', $validOnly = FALSE, $priceSetId = NULL) {
- if (!$priceSetId) {
- $priceSetId = self::getFor($entityTable, $id);
- }
-
- //check if priceset is is_config
- if (is_numeric($priceSetId)) {
- if (CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', $priceSetId, 'is_quick_config') && $form->getVar('_name') != 'Participant') {
- $form->assign('quickConfig', 1);
- }
- }
- // get price info
- if ($priceSetId) {
- if ($form->_action & CRM_Core_Action::UPDATE) {
- $entityId = $entity = NULL;
-
- switch ($entityTable) {
- case 'civicrm_event':
- $entity = 'participant';
- if (CRM_Utils_System::getClassName($form) == 'CRM_Event_Form_Participant') {
- $entityId = $form->_id;
- }
- else {
- $entityId = $form->_participantId;
- }
- break;
-
- case 'civicrm_contribution_page':
- case 'civicrm_contribution':
- $entity = 'contribution';
- $entityId = $form->_id;
- break;
- }
-
- if ($entityId && $entity) {
- $form->_values['line_items'] = CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem::getLineItems($entityId, $entity);
- }
- $required = FALSE;
- }
- else {
- $required = TRUE;
- }
-
- $form->_priceSetId = $priceSetId;
- $priceSet = self::getSetDetail($priceSetId, $required, $validOnly);
- $form->_priceSet = CRM_Utils_Array::value($priceSetId, $priceSet);
- $form->_values['fee'] = CRM_Utils_Array::value('fields', $form->_priceSet);
-
- //get the price set fields participant count.
- if ($entityTable == 'civicrm_event') {
- //get option count info.
- $form->_priceSet['optionsCountTotal'] = self::getPricesetCount($priceSetId);
- if ($form->_priceSet['optionsCountTotal']) {
- $optionsCountDeails = array();
- if (!empty($form->_priceSet['fields'])) {
- foreach ($form->_priceSet['fields'] as $field) {
- foreach ($field['options'] as $option) {
- $count = CRM_Utils_Array::value('count', $option, 0);
- $optionsCountDeails['fields'][$field['id']]['options'][$option['id']] = $count;
- }
- }
- }
- $form->_priceSet['optionsCountDetails'] = $optionsCountDeails;
- }
-
- //get option max value info.
- $optionsMaxValueTotal = 0;
- $optionsMaxValueDetails = array();
-
- if (!empty($form->_priceSet['fields'])) {
- foreach ($form->_priceSet['fields'] as $field) {
- foreach ($field['options'] as $option) {
- $maxVal = CRM_Utils_Array::value('max_value', $option, 0);
- $optionsMaxValueDetails['fields'][$field['id']]['options'][$option['id']] = $maxVal;
- $optionsMaxValueTotal += $maxVal;
- }
- }
- }
-
- $form->_priceSet['optionsMaxValueTotal'] = $optionsMaxValueTotal;
- if ($optionsMaxValueTotal) {
- $form->_priceSet['optionsMaxValueDetails'] = $optionsMaxValueDetails;
- }
- }
- $form->set('priceSetId', $form->_priceSetId);
- $form->set('priceSet', $form->_priceSet);
-
- return $priceSetId;
- }
- return FALSE;
- }
-
- /**
- * Process amount.
- *
- * @param array $fields
- * @param array $params
- * @param array $lineItem
- */
- public static function processAmount(&$fields, &$params, &$lineItem) {
- // using price set
- $totalPrice = 0;
- $radioLevel = $checkboxLevel = $selectLevel = $textLevel = array();
-
- foreach ($fields as $id => $field) {
- if (empty($params["price_{$id}"]) ||
- (empty($params["price_{$id}"]) && $params["price_{$id}"] == NULL)
- ) {
- // skip if nothing was submitted for this field
- continue;
- }
-
- switch ($field['html_type']) {
- case 'Text':
- $params["price_{$id}"] = array(key($field['options']) => $params["price_{$id}"]);
- CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem::format($id, $params, $field, $lineItem);
- $totalPrice += $lineItem[key($field['options'])]['line_total'];
- break;
-
- case 'Radio':
- //special case if user select -none-
- if ($params["price_{$id}"] <= 0) {
- continue;
- }
- $params["price_{$id}"] = array($params["price_{$id}"] => 1);
- $optionValueId = CRM_Utils_Array::key(1, $params["price_{$id}"]);
- $optionLabel = CRM_Utils_Array::value('label', $field['options'][$optionValueId]);
- $params['amount_priceset_level_radio'] = array();
- $params['amount_priceset_level_radio'][$optionValueId] = $optionLabel;
- if (isset($radioLevel)) {
- $radioLevel = array_merge($radioLevel,
- array_keys($params['amount_priceset_level_radio'])
- );
- }
- else {
- $radioLevel = array_keys($params['amount_priceset_level_radio']);
- }
- CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem::format($id, $params, $field, $lineItem);
- $totalPrice += $lineItem[$optionValueId]['line_total'];
- break;
-
- case 'Select':
- $params["price_{$id}"] = array($params["price_{$id}"] => 1);
- $optionValueId = CRM_Utils_Array::key(1, $params["price_{$id}"]);
- $optionLabel = $field['options'][$optionValueId]['label'];
- $params['amount_priceset_level_select'] = array();
- $params['amount_priceset_level_select'][CRM_Utils_Array::key(1, $params["price_{$id}"])] = $optionLabel;
- if (isset($selectLevel)) {
- $selectLevel = array_merge($selectLevel, array_keys($params['amount_priceset_level_select']));
- }
- else {
- $selectLevel = array_keys($params['amount_priceset_level_select']);
- }
- CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem::format($id, $params, $field, $lineItem);
- $totalPrice += $lineItem[$optionValueId]['line_total'];
- break;
-
- case 'CheckBox':
- $params['amount_priceset_level_checkbox'] = $optionIds = array();
- foreach ($params["price_{$id}"] as $optionId => $option) {
- $optionIds[] = $optionId;
- $optionLabel = $field['options'][$optionId]['label'];
- $params['amount_priceset_level_checkbox']["{$field['options'][$optionId]['id']}"] = $optionLabel;
- if (isset($checkboxLevel)) {
- $checkboxLevel = array_unique(array_merge(
- $checkboxLevel,
- array_keys($params['amount_priceset_level_checkbox'])
- )
- );
- }
- else {
- $checkboxLevel = array_keys($params['amount_priceset_level_checkbox']);
- }
- }
- CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem::format($id, $params, $field, $lineItem);
- foreach ($optionIds as $optionId) {
- $totalPrice += $lineItem[$optionId]['line_total'];
- }
- break;
- }
- }
-
- $amount_level = array();
- $totalParticipant = 0;
- if (is_array($lineItem)) {
- foreach ($lineItem as $values) {
- $totalParticipant += $values['participant_count'];
- if ($values['html_type'] == 'Text') {
- $amount_level[] = $values['label'] . ' - ' . $values['qty'];
- continue;
- }
- $amount_level[] = $values['label'];
- }
- }
-
- $displayParticipantCount = '';
- if ($totalParticipant > 0) {
- $displayParticipantCount = ' Participant Count -' . $totalParticipant;
- }
-
- $params['amount_level'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $amount_level) . $displayParticipantCount . CRM_Core_DAO::VALUE_SEPARATOR;
- $params['amount'] = $totalPrice;
- }
-
- /**
- * Build the price set form.
- *
- * @param CRM_Core_Form $form
- */
- public static function buildPriceSet(&$form) {
- $priceSetId = $form->get('priceSetId');
- $userid = $form->getVar('_userID');
- if (!$priceSetId) {
- return;
- }
-
- $validFieldsOnly = TRUE;
- $className = CRM_Utils_System::getClassName($form);
- if (in_array($className, array(
- 'CRM_Contribute_Form_Contribution',
- 'CRM_Member_Form_Membership',
- ))) {
- $validFieldsOnly = FALSE;
- }
-
- $priceSet = self::getSetDetail($priceSetId, TRUE, $validFieldsOnly);
- $form->_priceSet = CRM_Utils_Array::value($priceSetId, $priceSet);
- $form->_quickConfig = $quickConfig = 0;
- if (CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', $priceSetId, 'is_quick_config')) {
- $quickConfig = 1;
- }
-
- $form->assign('quickConfig', $quickConfig);
- if ($className == "CRM_Contribute_Form_Contribution_Main") {
- $form->_quickConfig = $quickConfig;
- }
- $form->assign('priceSet', $form->_priceSet);
-
- $component = 'contribution';
- if ($className == 'CRM_Member_Form_Membership') {
- $component = 'membership';
- }
-
- if ($className == 'CRM_Contribute_Form_Contribution_Main') {
- $feeBlock = &$form->_values['fee'];
- if (!empty($form->_useForMember)) {
- $component = 'membership';
- }
- }
- else {
- $feeBlock = &$form->_priceSet['fields'];
- }
-
- // call the hook.
- CRM_Utils_Hook::buildAmount($component, $form, $feeBlock);
-
- foreach ($feeBlock as $field) {
- if (CRM_Utils_Array::value('visibility', $field) == 'public' ||
- !$validFieldsOnly
- ) {
- $options = CRM_Utils_Array::value('options', $field);
- if ($className == 'CRM_Contribute_Form_Contribution_Main' && $component = 'membership') {
- $checklifetime = self::checkCurrentMembership($options, $userid);
- if ($checklifetime) {
- $form->assign('ispricelifetime', TRUE);
- }
- }
- if (!is_array($options)) {
- continue;
- }
- CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::addQuickFormElement($form,
- 'price_' . $field['id'],
- $field['id'],
- FALSE,
- CRM_Utils_Array::value('is_required', $field, FALSE),
- NULL,
- $options
- );
- }
- }
- }
-
- /**
- * Check the current Membership.
- *
- * @param array $options
- * @param int $userid
- *
- * @return bool
- */
- public static function checkCurrentMembership(&$options, $userid) {
- if (!$userid || empty($options)) {
- return FALSE;
- }
- static $_contact_memberships = array();
- $checklifetime = FALSE;
- foreach ($options as $key => $value) {
- if (!empty($value['membership_type_id'])) {
- if (!isset($_contact_memberships[$userid][$value['membership_type_id']])) {
- $_contact_memberships[$userid][$value['membership_type_id']] = CRM_Member_BAO_Membership::getContactMembership($userid, $value['membership_type_id'], FALSE);
- }
- $currentMembership = $_contact_memberships[$userid][$value['membership_type_id']];
- if (!empty($currentMembership) && empty($currentMembership['end_date'])) {
- unset($options[$key]);
- $checklifetime = TRUE;
- }
- }
- }
- if ($checklifetime) {
- return TRUE;
- }
- else {
- return FALSE;
- }
- }
-
- /**
- * Set default the price set fields.
- *
- * @param CRM_Core_Form $form
- * @param array $defaults
- *
- * @return array
- */
- public static function setDefaultPriceSet(&$form, &$defaults) {
- if (!isset($form->_priceSet) || empty($form->_priceSet['fields'])) {
- return $defaults;
- }
-
- foreach ($form->_priceSet['fields'] as $key => $val) {
- foreach ($val['options'] as $keys => $values) {
- if ($values['is_default']) {
- if ($val['html_type'] == 'CheckBox') {
- $defaults["price_{$key}"][$keys] = 1;
- }
- else {
- $defaults["price_{$key}"] = $keys;
- }
- }
- }
- }
- return $defaults;
- }
-
- /**
- * Get field ids of a price set.
- *
- * @param int $id Price Set id
- *
- * @return array
- * Array of the field ids
- */
- public static function getFieldIds($id) {
- $priceField = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field();
- $priceField->price_set_id = $id;
- $priceField->find();
- while ($priceField->fetch()) {
- $var[] = $priceField->id;
- }
- return $var;
- }
-
- /**
- * Copy a price set, including all the fields.
- *
- * @param int $id
- * The price set id to copy.
- *
- * @return CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field
- */
- public static function copy($id) {
- $maxId = CRM_Core_DAO::singleValueQuery("SELECT max(id) FROM civicrm_price_set");
-
- $title = ts('[Copy id %1]', array(1 => $maxId + 1));
- $fieldsFix = array(
- 'suffix' => array(
- 'title' => ' ' . $title,
- 'name' => '__Copy_id_' . ($maxId + 1) . '_',
- ),
- );
-
- $copy = &CRM_Core_DAO::copyGeneric('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set',
- array('id' => $id),
- NULL,
- $fieldsFix
- );
-
- //copying all the blocks pertaining to the price set
- $copyPriceField = &CRM_Core_DAO::copyGeneric('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field',
- array('price_set_id' => $id),
- array('price_set_id' => $copy->id)
- );
- if (!empty($copyPriceField)) {
- $price = array_combine(self::getFieldIds($id), self::getFieldIds($copy->id));
-
- //copy option group and values
- foreach ($price as $originalId => $copyId) {
- CRM_Core_DAO::copyGeneric('CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue',
- array('price_field_id' => $originalId),
- array('price_field_id' => $copyId)
- );
- }
- }
- $copy->save();
-
- CRM_Utils_Hook::copy('Set', $copy);
- return $copy;
- }
-
- /**
- * Check price set permission.
- *
- * @param int $sid
- * The price set id.
- *
- * @return bool
- */
- public function checkPermission($sid) {
- if ($sid &&
- self::eventPriceSetDomainID()
- ) {
- $domain_id = CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', $sid, 'domain_id', 'id');
- if (CRM_Core_Config::domainID() != $domain_id) {
- CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
- }
- }
- return TRUE;
- }
-
- /**
- * Get the sum of participant count for all fields of given price set.
- *
- * @param int $sid
- * The price set id.
- *
- * @param bool $onlyActive
- *
- * @return int|null|string
- */
- public static function getPricesetCount($sid, $onlyActive = TRUE) {
- $count = 0;
- if (!$sid) {
- return $count;
- }
-
- $where = NULL;
- if ($onlyActive) {
- $where = 'AND value.is_active = 1 AND field.is_active = 1';
- }
-
- static $pricesetFieldCount;
- if (!isset($pricesetFieldCount[$sid])) {
- $sql = "
- SELECT sum(value.count) as totalCount
- FROM civicrm_price_field_value value
-INNER JOIN civicrm_price_field field ON ( field.id = value.price_field_id )
-INNER JOIN civicrm_price_set pset ON ( pset.id = field.price_set_id )
- WHERE pset.id = %1
- $where";
-
- $count = CRM_Core_DAO::singleValueQuery($sql, array(1 => array($sid, 'Positive')));
- $pricesetFieldCount[$sid] = ($count) ? $count : 0;
- }
-
- return $pricesetFieldCount[$sid];
- }
-
- /**
- * Get membership count.
- *
- * @param array $ids
- *
- * @return array
- */
- public static function getMembershipCount($ids) {
- $queryString = "
-SELECT count( pfv.id ) AS count, pfv.id AS id
-FROM civicrm_price_field_value pfv
-INNER JOIN civicrm_membership_type mt ON mt.id = pfv.membership_type_id
-WHERE pfv.id IN ( $ids )
-GROUP BY mt.member_of_contact_id";
-
- $crmDAO = CRM_Core_DAO::executeQuery($queryString);
- $count = array();
-
- while ($crmDAO->fetch()) {
- $count[$crmDAO->id] = $crmDAO->count;
- }
-
- return $count;
- }
-
- /**
- * Function to check if auto renew option should be shown.
- *
- * @param int $priceSetId
- * Price set id.
- *
- * @return int
- * $autoRenewOption ( 0:hide, 1:optional 2:required )
- */
- public static function checkAutoRenewForPriceSet($priceSetId) {
- // auto-renew option should be visible if membership types associated with all the fields has
- // been set for auto-renew option
- // Auto renew checkbox should be frozen if for all the membership type auto renew is required
-
- // get the membership type auto renew option and check if required or optional
- $query = 'SELECT mt.auto_renew, mt.duration_interval, mt.duration_unit
- FROM civicrm_price_field_value pfv
- INNER JOIN civicrm_membership_type mt ON pfv.membership_type_id = mt.id
- INNER JOIN civicrm_price_field pf ON pfv.price_field_id = pf.id
- WHERE pf.price_set_id = %1
- AND pf.is_active = 1
- AND pfv.is_active = 1';
-
- $params = array(1 => array($priceSetId, 'Integer'));
-
- $dao = CRM_Core_DAO::executeQuery($query, $params);
- $autoRenewOption = 2;
- $interval = $unit = array();
- while ($dao->fetch()) {
- if (!$dao->auto_renew) {
- $autoRenewOption = 0;
- break;
- }
- if ($dao->auto_renew == 1) {
- $autoRenewOption = 1;
- }
-
- $interval[$dao->duration_interval] = $dao->duration_interval;
- $unit[$dao->duration_unit] = $dao->duration_unit;
- }
-
- if (count($interval) == 1 && count($unit) == 1 && $autoRenewOption > 0) {
- return $autoRenewOption;
- }
- else {
- return 0;
- }
- }
-
- /**
- * Retrieve auto renew frequency and interval.
- *
- * @param int $priceSetId
- * Price set id.
- *
- * @return array
- * associate array of frequency interval and unit
- */
- public static function getRecurDetails($priceSetId) {
- $query = 'SELECT mt.duration_interval, mt.duration_unit
- FROM civicrm_price_field_value pfv
- INNER JOIN civicrm_membership_type mt ON pfv.membership_type_id = mt.id
- INNER JOIN civicrm_price_field pf ON pfv.price_field_id = pf.id
- WHERE pf.price_set_id = %1 LIMIT 1';
-
- $params = array(1 => array($priceSetId, 'Integer'));
- $dao = CRM_Core_DAO::executeQuery($query, $params);
- $dao->fetch();
- return array($dao->duration_interval, $dao->duration_unit);
- }
-
- /**
- * Get event price set for domain.
- *
- * @return object
- */
- public static function eventPriceSetDomainID() {
- return Civi::settings()->get('event_price_set_domain_id');
- }
-
- /**
- * Update the is_quick_config flag in the db.
- *
- * @param int $id
- * Id of the database record.
- * @param bool $isQuickConfig we want to set the is_quick_config field.
- * Value we want to set the is_quick_config field.
- *
- * @return bool
- * true if we found and updated the object, else false
- */
- public static function setIsQuickConfig($id, $isQuickConfig) {
- return CRM_Core_DAO::setFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', $id, 'is_quick_config', $isQuickConfig);
- }
-
-}
+++ /dev/null
-<?php
-/*
-+--------------------------------------------------------------------+
-| CiviCRM version 5 |
-+--------------------------------------------------------------------+
-| Copyright CiviCRM LLC (c) 2004-2019 |
-+--------------------------------------------------------------------+
-| 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-2019
- * $Id$
- *
- */
-require_once 'CRM/Core/DAO.php';
-require_once 'CRM/Utils/Type.php';
-
-/**
- * Class CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field
- */
-class CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field extends CRM_Core_DAO {
- /**
- * static instance to hold the table name
- *
- * @var string
- */
- static $_tableName = 'civicrm_price_field';
- /**
- * static instance to hold the field values
- *
- * @var array
- */
- static $_fields = NULL;
- /**
- * static instance to hold the FK relationships
- *
- * @var string
- */
- static $_links = NULL;
- /**
- * static instance to hold the values that can
- * be imported
- *
- * @var array
- */
- static $_import = NULL;
- /**
- * static instance to hold the values that can
- * be exported
- *
- * @var array
- */
- static $_export = NULL;
- /**
- * static value to see if we should log any modifications to
- * this table in the civicrm_log table
- *
- * @var bool
- */
- static $_log = TRUE;
- /**
- * Price Field
- *
- * @var int unsigned
- */
- public $id;
- /**
- * FK to civicrm_price_set
- *
- * @var int unsigned
- */
- public $price_set_id;
- /**
- * Variable name/programmatic handle for this field.
- *
- * @var string
- */
- public $name;
- /**
- * Text for form field label (also friendly name for administering this field).
- *
- * @var string
- */
- public $label;
- /**
- *
- * @var enum('Text', 'Select', 'Radio', 'CheckBox')
- */
- public $html_type;
- /**
- * Enter a quantity for this field?
- *
- * @var bool
- */
- public $is_enter_qty;
- /**
- * Description and/or help text to display before this field.
- *
- * @var text
- */
- public $help_pre;
- /**
- * Description and/or help text to display after this field.
- *
- * @var text
- */
- public $help_post;
- /**
- * Order in which the fields should appear
- *
- * @var int
- */
- public $weight;
- /**
- * Should the price be displayed next to the label for each option?
- *
- * @var boolean
- */
- public $is_display_amounts;
- /**
- * number of options per line for checkbox and radio
- *
- * @var int unsigned
- */
- public $options_per_line;
- /**
- * Is this price field active
- *
- * @var boolean
- */
- public $is_active;
- /**
- * Is this price field required (value must be > 1)
- *
- * @var boolean
- */
- public $is_required;
- /**
- * If non-zero, do not show this field before the date specified
- *
- * @var datetime
- */
- public $active_on;
- /**
- * If non-zero, do not show this field after the date specified
- *
- * @var datetime
- */
- public $expire_on;
- /**
- * Optional scripting attributes for field
- *
- * @var string
- */
- public $javascript;
- /**
- * Implicit FK to civicrm_option_group with name = \'visibility\'
- *
- * @var int unsigned
- */
- public $visibility_id;
-
- /**
- * Class constructor.
- *
- * @return \CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field
- */
- public function __construct() {
- $this->__table = 'civicrm_price_field';
- parent::__construct();
- }
-
- /**
- * Return foreign links.
- *
- * @return array
- */
- public function links() {
- if (!(self::$_links)) {
- self::$_links = array(
- 'price_set_id' => 'civicrm_price_set:id',
- );
- }
- return self::$_links;
- }
-
- /**
- * Returns all the column names of this table.
- *
- * @return array
- */
- public static function &fields() {
- if (!(self::$_fields)) {
- self::$_fields = array(
- 'id' => array(
- 'name' => 'id',
- 'type' => CRM_Utils_Type::T_INT,
- 'required' => TRUE,
- ),
- 'price_set_id' => array(
- 'name' => 'price_set_id',
- 'type' => CRM_Utils_Type::T_INT,
- 'required' => TRUE,
- 'FKClassName' => 'Snapshot_v4p2_Price_DAO_Set',
- ),
- 'name' => array(
- 'name' => 'name',
- 'type' => CRM_Utils_Type::T_STRING,
- 'title' => ts('Name'),
- 'required' => TRUE,
- 'maxlength' => 255,
- 'size' => CRM_Utils_Type::HUGE,
- ),
- 'label' => array(
- 'name' => 'label',
- 'type' => CRM_Utils_Type::T_STRING,
- 'title' => ts('Label'),
- 'required' => TRUE,
- 'maxlength' => 255,
- 'size' => CRM_Utils_Type::HUGE,
- ),
- 'html_type' => array(
- 'name' => 'html_type',
- 'type' => CRM_Utils_Type::T_ENUM,
- 'title' => ts('Html Type'),
- 'required' => TRUE,
- 'enumValues' => 'Text, Select, Radio, CheckBox',
- ),
- 'is_enter_qty' => array(
- 'name' => 'is_enter_qty',
- 'type' => CRM_Utils_Type::T_BOOLEAN,
- ),
- 'help_pre' => array(
- 'name' => 'help_pre',
- 'type' => CRM_Utils_Type::T_TEXT,
- 'title' => ts('Help Pre'),
- 'rows' => 4,
- 'cols' => 80,
- ),
- 'help_post' => array(
- 'name' => 'help_post',
- 'type' => CRM_Utils_Type::T_TEXT,
- 'title' => ts('Help Post'),
- 'rows' => 4,
- 'cols' => 80,
- ),
- 'weight' => array(
- 'name' => 'weight',
- 'type' => CRM_Utils_Type::T_INT,
- 'title' => ts('Weight'),
- 'default' => '',
- ),
- 'is_display_amounts' => array(
- 'name' => 'is_display_amounts',
- 'type' => CRM_Utils_Type::T_BOOLEAN,
- 'default' => '',
- ),
- 'options_per_line' => array(
- 'name' => 'options_per_line',
- 'type' => CRM_Utils_Type::T_INT,
- 'title' => ts('Options Per Line'),
- 'default' => '',
- ),
- 'is_active' => array(
- 'name' => 'is_active',
- 'type' => CRM_Utils_Type::T_BOOLEAN,
- 'default' => '',
- ),
- 'is_required' => array(
- 'name' => 'is_required',
- 'type' => CRM_Utils_Type::T_BOOLEAN,
- 'default' => '',
- ),
- 'active_on' => array(
- 'name' => 'active_on',
- 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
- 'title' => ts('Active On'),
- 'default' => 'UL',
- ),
- 'expire_on' => array(
- 'name' => 'expire_on',
- 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
- 'title' => ts('Expire On'),
- 'default' => 'UL',
- ),
- 'javascript' => array(
- 'name' => 'javascript',
- 'type' => CRM_Utils_Type::T_STRING,
- 'title' => ts('Javascript'),
- 'maxlength' => 255,
- 'size' => CRM_Utils_Type::HUGE,
- ),
- 'visibility_id' => array(
- 'name' => 'visibility_id',
- 'type' => CRM_Utils_Type::T_INT,
- 'default' => '',
- ),
- );
- }
- return self::$_fields;
- }
-
- /**
- * returns the names of this table.
- *
- * @return string
- */
- public static function getTableName() {
- return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
- }
-
- /**
- * returns if this table needs to be logged.
- *
- * @return bool
- */
- public function getLog() {
- return self::$_log;
- }
-
- /**
- * returns the list of fields that can be imported.
- *
- * @param bool $prefix
- *
- * @return array
- */
- public static function &import($prefix = FALSE) {
- if (!(self::$_import)) {
- self::$_import = array();
- $fields = self::fields();
- foreach ($fields as $name => $field) {
- if (!empty($field['import'])) {
- if ($prefix) {
- self::$_import['price_field'] = &$fields[$name];
- }
- else {
- self::$_import[$name] = &$fields[$name];
- }
- }
- }
- }
- return self::$_import;
- }
-
- /**
- * Returns the list of fields that can be exported.
- *
- * @param bool $prefix
- *
- * @return array
- */
- public static function &export($prefix = FALSE) {
- if (!(self::$_export)) {
- self::$_export = array();
- $fields = self::fields();
- foreach ($fields as $name => $field) {
- if (!empty($field['export'])) {
- if ($prefix) {
- self::$_export['price_field'] = &$fields[$name];
- }
- else {
- self::$_export[$name] = &$fields[$name];
- }
- }
- }
- }
- return self::$_export;
- }
-
- /**
- * returns an array containing the enum fields of the civicrm_price_field table.
- *
- * @return array
- * (reference) the array of enum fields
- */
- public static function &getEnums() {
- static $enums = array(
- 'html_type',
- );
- return $enums;
- }
-
- /**
- * returns a ts()-translated enum value for display purposes
- *
- * @param string $field
- * The enum field in question.
- * @param string $value
- * The enum value up for translation.
- *
- * @return string
- * the display value of the enum
- */
- public static function tsEnum($field, $value) {
- static $translations = NULL;
- if (!$translations) {
- $translations = array(
- 'html_type' => array(
- 'Text' => ts('Text'),
- 'Select' => ts('Select'),
- 'Radio' => ts('Radio'),
- 'CheckBox' => ts('CheckBox'),
- ),
- );
- }
- return $translations[$field][$value];
- }
-
- /**
- * adds $value['foo_display'] for each $value['foo'] enum from civicrm_price_field
- *
- * @param array $values
- * (reference) the array up for enhancing.
- */
- public static function addDisplayEnums(&$values) {
- $enumFields = &Snapshot_v4p2_Price_DAO_Field::getEnums();
- foreach ($enumFields as $enum) {
- if (isset($values[$enum])) {
- $values[$enum . '_display'] = Snapshot_v4p2_Price_DAO_Field::tsEnum($enum, $values[$enum]);
- }
- }
- }
-
-}
+++ /dev/null
-<?php
-/*
-+--------------------------------------------------------------------+
-| CiviCRM version 5 |
-+--------------------------------------------------------------------+
-| Copyright CiviCRM LLC (c) 2004-2019 |
-+--------------------------------------------------------------------+
-| 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-2019
- * $Id$
- *
- */
-require_once 'CRM/Core/DAO.php';
-require_once 'CRM/Utils/Type.php';
-
-/**
- * Class CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue
- */
-class CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue extends CRM_Core_DAO {
- /**
- * static instance to hold the table name
- *
- * @var string
- */
- static $_tableName = 'civicrm_price_field_value';
- /**
- * static instance to hold the field values
- *
- * @var array
- */
- static $_fields = NULL;
- /**
- * static instance to hold the FK relationships
- *
- * @var string
- */
- static $_links = NULL;
- /**
- * static instance to hold the values that can
- * be imported
- *
- * @var array
- */
- static $_import = NULL;
- /**
- * static instance to hold the values that can
- * be exported
- *
- * @var array
- */
- static $_export = NULL;
- /**
- * static value to see if we should log any modifications to
- * this table in the civicrm_log table
- *
- * @var boolean
- */
- static $_log = FALSE;
- /**
- * Price Field Value
- *
- * @var int unsigned
- */
- public $id;
- /**
- * FK to civicrm_price_field
- *
- * @var int unsigned
- */
- public $price_field_id;
- /**
- * Price field option name
- *
- * @var string
- */
- public $name;
- /**
- * Price field option label
- *
- * @var string
- */
- public $label;
- /**
- * >Price field option description.
- *
- * @var text
- */
- public $description;
- /**
- * Price field option amount
- *
- * @var string
- */
- public $amount;
- /**
- * Number of participants per field option
- *
- * @var int unsigned
- */
- public $count;
- /**
- * Max number of participants per field options
- *
- * @var int unsigned
- */
- public $max_value;
- /**
- * Order in which the field options should appear
- *
- * @var int
- */
- public $weight;
- /**
- * FK to Membership Type
- *
- * @var int unsigned
- */
- public $membership_type_id;
- /**
- * Is this default price field option
- *
- * @var boolean
- */
- public $is_default;
- /**
- * Is this price field value active
- *
- * @var boolean
- */
- public $is_active;
-
- /**
- * Class constructor.
- *
- * @return \CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue
- */
- public function __construct() {
- $this->__table = 'civicrm_price_field_value';
- parent::__construct();
- }
-
- /**
- * Return foreign links.
- *
- * @return array
- */
- public function links() {
- if (!(self::$_links)) {
- self::$_links = array(
- 'price_field_id' => 'civicrm_price_field:id',
- 'membership_type_id' => 'civicrm_membership_type:id',
- );
- }
- return self::$_links;
- }
-
- /**
- * Returns all the column names of this table.
- *
- * @return array
- */
- public static function &fields() {
- if (!(self::$_fields)) {
- self::$_fields = array(
- 'id' => array(
- 'name' => 'id',
- 'type' => CRM_Utils_Type::T_INT,
- 'required' => TRUE,
- ),
- 'price_field_id' => array(
- 'name' => 'price_field_id',
- 'type' => CRM_Utils_Type::T_INT,
- 'required' => TRUE,
- 'FKClassName' => 'Snapshot_v4p2_Price_DAO_Field',
- ),
- 'name' => array(
- 'name' => 'name',
- 'type' => CRM_Utils_Type::T_STRING,
- 'title' => ts('Name'),
- 'maxlength' => 255,
- 'size' => CRM_Utils_Type::HUGE,
- ),
- 'label' => array(
- 'name' => 'label',
- 'type' => CRM_Utils_Type::T_STRING,
- 'title' => ts('Label'),
- 'maxlength' => 255,
- 'size' => CRM_Utils_Type::HUGE,
- ),
- 'description' => array(
- 'name' => 'description',
- 'type' => CRM_Utils_Type::T_TEXT,
- 'title' => ts('Description'),
- 'rows' => 2,
- 'cols' => 60,
- 'default' => 'UL',
- ),
- 'amount' => array(
- 'name' => 'amount',
- 'type' => CRM_Utils_Type::T_STRING,
- 'title' => ts('Amount'),
- 'required' => TRUE,
- 'maxlength' => 512,
- 'size' => CRM_Utils_Type::HUGE,
- ),
- 'count' => array(
- 'name' => 'count',
- 'type' => CRM_Utils_Type::T_INT,
- 'title' => ts('Count'),
- 'default' => 'UL',
- ),
- 'max_value' => array(
- 'name' => 'max_value',
- 'type' => CRM_Utils_Type::T_INT,
- 'title' => ts('Max Value'),
- 'default' => 'UL',
- ),
- 'weight' => array(
- 'name' => 'weight',
- 'type' => CRM_Utils_Type::T_INT,
- 'title' => ts('Weight'),
- 'default' => '',
- ),
- 'membership_type_id' => array(
- 'name' => 'membership_type_id',
- 'type' => CRM_Utils_Type::T_INT,
- 'default' => 'UL',
- 'FKClassName' => 'CRM_Member_DAO_MembershipType',
- ),
- 'is_default' => array(
- 'name' => 'is_default',
- 'type' => CRM_Utils_Type::T_BOOLEAN,
- ),
- 'is_active' => array(
- 'name' => 'is_active',
- 'type' => CRM_Utils_Type::T_BOOLEAN,
- 'default' => '',
- ),
- );
- }
- return self::$_fields;
- }
-
- /**
- * returns the names of this table.
- *
- * @return string
- */
- public static function getTableName() {
- return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
- }
-
- /**
- * returns if this table needs to be logged.
- *
- * @return boolean
- */
- public function getLog() {
- return self::$_log;
- }
-
- /**
- * Returns the list of fields that can be imported.
- *
- * @param bool $prefix
- *
- * @return array
- */
- static function &import($prefix = FALSE) {
- if (!(self::$_import)) {
- self::$_import = array();
- $fields = self::fields();
- foreach ($fields as $name => $field) {
- if (!empty($field['import'])) {
- if ($prefix) {
- self::$_import['price_field_value'] = &$fields[$name];
- }
- else {
- self::$_import[$name] = &$fields[$name];
- }
- }
- }
- }
- return self::$_import;
- }
-
- /**
- * Returns the list of fields that can be exported.
- *
- * @param bool $prefix
- *
- * @return array
- */
- static function &export($prefix = FALSE) {
- if (!(self::$_export)) {
- self::$_export = array();
- $fields = self::fields();
- foreach ($fields as $name => $field) {
- if (!empty($field['export'])) {
- if ($prefix) {
- self::$_export['price_field_value'] = &$fields[$name];
- }
- else {
- self::$_export[$name] = &$fields[$name];
- }
- }
- }
- }
- return self::$_export;
- }
-}
+++ /dev/null
-<?php
-/*
-+--------------------------------------------------------------------+
-| CiviCRM version 5 |
-+--------------------------------------------------------------------+
-| Copyright CiviCRM LLC (c) 2004-2019 |
-+--------------------------------------------------------------------+
-| 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-2019
- * $Id$
- *
- */
-require_once 'CRM/Core/DAO.php';
-require_once 'CRM/Utils/Type.php';
-
-/**
- * Class CRM_Upgrade_Snapshot_V4p2_Price_DAO_LineItem
- */
-class CRM_Upgrade_Snapshot_V4p2_Price_DAO_LineItem extends CRM_Core_DAO {
- /**
- * static instance to hold the table name
- *
- * @var string
- */
- static $_tableName = 'civicrm_line_item';
- /**
- * static instance to hold the field values
- *
- * @var array
- */
- static $_fields = NULL;
- /**
- * static instance to hold the FK relationships
- *
- * @var string
- */
- static $_links = NULL;
- /**
- * static instance to hold the values that can
- * be imported
- *
- * @var array
- */
- static $_import = NULL;
- /**
- * static instance to hold the values that can
- * be exported
- *
- * @var array
- */
- static $_export = NULL;
- /**
- * static value to see if we should log any modifications to
- * this table in the civicrm_log table
- *
- * @var boolean
- */
- static $_log = TRUE;
- /**
- * Line Item
- *
- * @var int unsigned
- */
- public $id;
- /**
- * table which has the transaction
- *
- * @var string
- */
- public $entity_table;
- /**
- * entry in table
- *
- * @var int unsigned
- */
- public $entity_id;
- /**
- * FK to price_field
- *
- * @var int unsigned
- */
- public $price_field_id;
- /**
- * descriptive label for item - from price_field_value.label
- *
- * @var string
- */
- public $label;
- /**
- * How many items ordered
- *
- * @var int unsigned
- */
- public $qty;
- /**
- * price of each item
- *
- * @var float
- */
- public $unit_price;
- /**
- * qty * unit_price
- *
- * @var float
- */
- public $line_total;
- /**
- * Participant count for field
- *
- * @var int unsigned
- */
- public $participant_count;
- /**
- * Implicit FK to civicrm_option_value
- *
- * @var int unsigned
- */
- public $price_field_value_id;
-
- /**
- * Class constructor.
- *
- * @return \CRM_Upgrade_Snapshot_V4p2_Price_DAO_LineItem
- */
- public function __construct() {
- $this->__table = 'civicrm_line_item';
- parent::__construct();
- }
-
- /**
- * Return foreign links.
- *
- * @return array
- */
- public function links() {
- if (!(self::$_links)) {
- self::$_links = array(
- 'price_field_id' => 'civicrm_price_field:id',
- 'price_field_value_id' => 'civicrm_price_field_value:id',
- );
- }
- return self::$_links;
- }
-
- /**
- * Returns all the column names of this table.
- *
- * @return array
- */
- public static function &fields() {
- if (!(self::$_fields)) {
- self::$_fields = array(
- 'id' => array(
- 'name' => 'id',
- 'type' => CRM_Utils_Type::T_INT,
- 'required' => TRUE,
- ),
- 'entity_table' => array(
- 'name' => 'entity_table',
- 'type' => CRM_Utils_Type::T_STRING,
- 'title' => ts('Entity Table'),
- 'required' => TRUE,
- 'maxlength' => 64,
- 'size' => CRM_Utils_Type::BIG,
- ),
- 'entity_id' => array(
- 'name' => 'entity_id',
- 'type' => CRM_Utils_Type::T_INT,
- 'required' => TRUE,
- ),
- 'price_field_id' => array(
- 'name' => 'price_field_id',
- 'type' => CRM_Utils_Type::T_INT,
- 'required' => TRUE,
- 'FKClassName' => 'Snapshot_v4p2_Price_DAO_Field',
- ),
- 'label' => array(
- 'name' => 'label',
- 'type' => CRM_Utils_Type::T_STRING,
- 'title' => ts('Label'),
- 'maxlength' => 255,
- 'size' => CRM_Utils_Type::HUGE,
- 'default' => 'UL',
- ),
- 'qty' => array(
- 'name' => 'qty',
- 'type' => CRM_Utils_Type::T_INT,
- 'title' => ts('Qty'),
- 'required' => TRUE,
- ),
- 'unit_price' => array(
- 'name' => 'unit_price',
- 'type' => CRM_Utils_Type::T_MONEY,
- 'title' => ts('Unit Price'),
- 'required' => TRUE,
- ),
- 'line_total' => array(
- 'name' => 'line_total',
- 'type' => CRM_Utils_Type::T_MONEY,
- 'title' => ts('Line Total'),
- 'required' => TRUE,
- ),
- 'participant_count' => array(
- 'name' => 'participant_count',
- 'type' => CRM_Utils_Type::T_INT,
- 'title' => ts('Participant Count'),
- 'default' => 'UL',
- ),
- 'price_field_value_id' => array(
- 'name' => 'price_field_value_id',
- 'type' => CRM_Utils_Type::T_INT,
- 'default' => 'UL',
- 'FKClassName' => 'Snapshot_v4p2_Price_DAO_FieldValue',
- ),
- );
- }
- return self::$_fields;
- }
-
- /**
- * returns the names of this table.
- *
- * @return string
- */
- public static function getTableName() {
- return self::$_tableName;
- }
-
- /**
- * returns if this table needs to be logged.
- *
- * @return boolean
- */
- public function getLog() {
- return self::$_log;
- }
-
- /**
- * returns the list of fields that can be imported.
- *
- * @param bool $prefix
- *
- * @return array
- */
- static function &import($prefix = FALSE) {
- if (!(self::$_import)) {
- self::$_import = array();
- $fields = self::fields();
- foreach ($fields as $name => $field) {
- if (!empty($field['import'])) {
- if ($prefix) {
- self::$_import['line_item'] = &$fields[$name];
- }
- else {
- self::$_import[$name] = &$fields[$name];
- }
- }
- }
- }
- return self::$_import;
- }
-
- /**
- * Returns the list of fields that can be exported.
- *
- * @param bool $prefix
- *
- * @return array
- */
- static function &export($prefix = FALSE) {
- if (!(self::$_export)) {
- self::$_export = array();
- $fields = self::fields();
- foreach ($fields as $name => $field) {
- if (!empty($field['export'])) {
- if ($prefix) {
- self::$_export['line_item'] = &$fields[$name];
- }
- else {
- self::$_export[$name] = &$fields[$name];
- }
- }
- }
- }
- return self::$_export;
- }
-}
+++ /dev/null
-<?php
-/*
-+--------------------------------------------------------------------+
-| CiviCRM version 5 |
-+--------------------------------------------------------------------+
-| Copyright CiviCRM LLC (c) 2004-2019 |
-+--------------------------------------------------------------------+
-| 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-2019
- * $Id$
- *
- */
-require_once 'CRM/Core/DAO.php';
-require_once 'CRM/Utils/Type.php';
-
-/**
- * Class CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set
- */
-class CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set extends CRM_Core_DAO {
- /**
- * static instance to hold the table name
- *
- * @var string
- */
- static $_tableName = 'civicrm_price_set';
- /**
- * static instance to hold the field values
- *
- * @var array
- */
- static $_fields = NULL;
- /**
- * static instance to hold the FK relationships
- *
- * @var string
- */
- static $_links = NULL;
- /**
- * static instance to hold the values that can
- * be imported
- *
- * @var array
- */
- static $_import = NULL;
- /**
- * static instance to hold the values that can
- * be exported
- *
- * @var array
- */
- static $_export = NULL;
- /**
- * static value to see if we should log any modifications to
- * this table in the civicrm_log table
- *
- * @var boolean
- */
- static $_log = TRUE;
- /**
- * Price Set
- *
- * @var int unsigned
- */
- public $id;
- /**
- * Which Domain is this price-set for
- *
- * @var int unsigned
- */
- public $domain_id;
- /**
- * Variable name/programmatic handle for this set of price fields.
- *
- * @var string
- */
- public $name;
- /**
- * Displayed title for the Price Set.
- *
- * @var string
- */
- public $title;
- /**
- * Is this price set active
- *
- * @var boolean
- */
- public $is_active;
- /**
- * Description and/or help text to display before fields in form.
- *
- * @var text
- */
- public $help_pre;
- /**
- * Description and/or help text to display after fields in form.
- *
- * @var text
- */
- public $help_post;
- /**
- * Optional Javascript script function(s) included on the form with this price_set. Can be used for conditional
- *
- * @var string
- */
- public $javascript;
- /**
- * What components are using this price set?
- *
- * @var string
- */
- public $extends;
- /**
- * FK to Contribution Type(for membership price sets only).
- *
- * @var int unsigned
- */
- public $contribution_type_id;
- /**
- * Is set if edited on Contribution or Event Page rather than through Manage Price Sets
- *
- * @var boolean
- */
- public $is_quick_config;
- /**
- * Is this a predefined system price set (i.e. it can not be deleted, edited)?
- *
- * @var boolean
- */
- public $is_reserved;
-
- /**
- * Class constructor.
- *
- * @return \CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set
- */
- public function __construct() {
- $this->__table = 'civicrm_price_set';
- parent::__construct();
- }
-
- /**
- * Return foreign links.
- *
- * @return array
- */
- public function links() {
- if (!(self::$_links)) {
- self::$_links = array(
- 'domain_id' => 'civicrm_domain:id',
- 'contribution_type_id' => 'civicrm_contribution_type:id',
- );
- }
- return self::$_links;
- }
-
- /**
- * Returns all the column names of this table.
- *
- * @return array
- */
- public static function &fields() {
- if (!(self::$_fields)) {
- self::$_fields = array(
- 'id' => array(
- 'name' => 'id',
- 'type' => CRM_Utils_Type::T_INT,
- 'required' => TRUE,
- ),
- 'domain_id' => array(
- 'name' => 'domain_id',
- 'type' => CRM_Utils_Type::T_INT,
- 'FKClassName' => 'CRM_Core_DAO_Domain',
- ),
- 'name' => array(
- 'name' => 'name',
- 'type' => CRM_Utils_Type::T_STRING,
- 'title' => ts('Name'),
- 'required' => TRUE,
- 'maxlength' => 255,
- 'size' => CRM_Utils_Type::HUGE,
- ),
- 'title' => array(
- 'name' => 'title',
- 'type' => CRM_Utils_Type::T_STRING,
- 'title' => ts('Title'),
- 'required' => TRUE,
- 'maxlength' => 255,
- 'size' => CRM_Utils_Type::HUGE,
- ),
- 'is_active' => array(
- 'name' => 'is_active',
- 'type' => CRM_Utils_Type::T_BOOLEAN,
- 'default' => '',
- ),
- 'help_pre' => array(
- 'name' => 'help_pre',
- 'type' => CRM_Utils_Type::T_TEXT,
- 'title' => ts('Help Pre'),
- 'rows' => 4,
- 'cols' => 80,
- ),
- 'help_post' => array(
- 'name' => 'help_post',
- 'type' => CRM_Utils_Type::T_TEXT,
- 'title' => ts('Help Post'),
- 'rows' => 4,
- 'cols' => 80,
- ),
- 'javascript' => array(
- 'name' => 'javascript',
- 'type' => CRM_Utils_Type::T_STRING,
- 'title' => ts('Javascript'),
- 'maxlength' => 64,
- 'size' => CRM_Utils_Type::BIG,
- ),
- 'extends' => array(
- 'name' => 'extends',
- 'type' => CRM_Utils_Type::T_STRING,
- 'title' => ts('Extends'),
- 'required' => TRUE,
- 'maxlength' => 255,
- 'size' => CRM_Utils_Type::HUGE,
- ),
- 'contribution_type_id' => array(
- 'name' => 'contribution_type_id',
- 'type' => CRM_Utils_Type::T_INT,
- 'default' => 'UL',
- 'FKClassName' => 'CRM_Contribute_DAO_ContributionType',
- ),
- 'is_quick_config' => array(
- 'name' => 'is_quick_config',
- 'type' => CRM_Utils_Type::T_BOOLEAN,
- ),
- 'is_reserved' => array(
- 'name' => 'is_reserved',
- 'type' => CRM_Utils_Type::T_BOOLEAN,
- ),
- );
- }
- return self::$_fields;
- }
-
- /**
- * returns the names of this table.
- *
- * @return string
- */
- public static function getTableName() {
- return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
- }
-
- /**
- * returns if this table needs to be logged.
- *
- * @return boolean
- */
- public function getLog() {
- return self::$_log;
- }
-
- /**
- * Returns the list of fields that can be imported.
- *
- * @param bool $prefix
- *
- * @return array
- */
- static function &import($prefix = FALSE) {
- if (!(self::$_import)) {
- self::$_import = array();
- $fields = self::fields();
- foreach ($fields as $name => $field) {
- if (!empty($field['import'])) {
- if ($prefix) {
- self::$_import['price_set'] = &$fields[$name];
- }
- else {
- self::$_import[$name] = &$fields[$name];
- }
- }
- }
- }
- return self::$_import;
- }
-
- /**
- * returns the list of fields that can be exported.
- *
- * @param bool $prefix
- *
- * @return array
- */
- static function &export($prefix = FALSE) {
- if (!(self::$_export)) {
- self::$_export = array();
- $fields = self::fields();
- foreach ($fields as $name => $field) {
- if (!empty($field['export'])) {
- if ($prefix) {
- self::$_export['price_set'] = &$fields[$name];
- }
- else {
- self::$_export[$name] = &$fields[$name];
- }
- }
- }
- }
- return self::$_export;
- }
-}
+++ /dev/null
-<?php
-/*
-+--------------------------------------------------------------------+
-| CiviCRM version 5 |
-+--------------------------------------------------------------------+
-| Copyright CiviCRM LLC (c) 2004-2019 |
-+--------------------------------------------------------------------+
-| 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-2019
- * $Id$
- *
- */
-require_once 'CRM/Core/DAO.php';
-require_once 'CRM/Utils/Type.php';
-
-/**
- * Class CRM_Upgrade_Snapshot_V4p2_Price_DAO_SetEntity
- */
-class CRM_Upgrade_Snapshot_V4p2_Price_DAO_SetEntity extends CRM_Core_DAO {
- /**
- * static instance to hold the table name
- *
- * @var string
- */
- static $_tableName = 'civicrm_price_set_entity';
- /**
- * static instance to hold the field values
- *
- * @var array
- */
- static $_fields = NULL;
- /**
- * static instance to hold the FK relationships
- *
- * @var string
- */
- static $_links = NULL;
- /**
- * static instance to hold the values that can
- * be imported
- *
- * @var array
- */
- static $_import = NULL;
- /**
- * static instance to hold the values that can
- * be exported
- *
- * @var array
- */
- static $_export = NULL;
- /**
- * static value to see if we should log any modifications to
- * this table in the civicrm_log table
- *
- * @var boolean
- */
- static $_log = TRUE;
- /**
- * Price Set Entity
- *
- * @var int unsigned
- */
- public $id;
- /**
- * Table which uses this price set
- *
- * @var string
- */
- public $entity_table;
- /**
- * Item in table
- *
- * @var int unsigned
- */
- public $entity_id;
- /**
- * price set being used
- *
- * @var int unsigned
- */
- public $price_set_id;
-
- /**
- * Class constructor.
- *
- * @return \CRM_Upgrade_Snapshot_V4p2_Price_DAO_SetEntity
- */
- public function __construct() {
- $this->__table = 'civicrm_price_set_entity';
- parent::__construct();
- }
-
- /**
- * Return foreign links.
- *
- * @return array
- */
- public function links() {
- if (!(self::$_links)) {
- self::$_links = array(
- 'price_set_id' => 'civicrm_price_set:id',
- );
- }
- return self::$_links;
- }
-
- /**
- * Returns all the column names of this table.
- *
- * @return array
- */
- public static function &fields() {
- if (!(self::$_fields)) {
- self::$_fields = array(
- 'id' => array(
- 'name' => 'id',
- 'type' => CRM_Utils_Type::T_INT,
- 'required' => TRUE,
- ),
- 'entity_table' => array(
- 'name' => 'entity_table',
- 'type' => CRM_Utils_Type::T_STRING,
- 'title' => ts('Entity Table'),
- 'required' => TRUE,
- 'maxlength' => 64,
- 'size' => CRM_Utils_Type::BIG,
- ),
- 'entity_id' => array(
- 'name' => 'entity_id',
- 'type' => CRM_Utils_Type::T_INT,
- 'required' => TRUE,
- ),
- 'price_set_id' => array(
- 'name' => 'price_set_id',
- 'type' => CRM_Utils_Type::T_INT,
- 'required' => TRUE,
- 'FKClassName' => 'Snapshot_v4p2_Price_DAO_Set',
- ),
- );
- }
- return self::$_fields;
- }
-
- /**
- * returns the names of this table.
- *
- * @return string
- */
- public static function getTableName() {
- return self::$_tableName;
- }
-
- /**
- * returns if this table needs to be logged.
- *
- * @return boolean
- */
- public function getLog() {
- return self::$_log;
- }
-
- /**
- * Returns the list of fields that can be imported.
- *
- * @param bool $prefix
- *
- * @return array
- */
- static function &import($prefix = FALSE) {
- if (!(self::$_import)) {
- self::$_import = array();
- $fields = self::fields();
- foreach ($fields as $name => $field) {
- if (!empty($field['import'])) {
- if ($prefix) {
- self::$_import['price_set_entity'] = &$fields[$name];
- }
- else {
- self::$_import[$name] = &$fields[$name];
- }
- }
- }
- }
- return self::$_import;
- }
-
- /**
- * returns the list of fields that can be exported.
- *
- * @param bool $prefix
- *
- * @return array
- */
- static function &export($prefix = FALSE) {
- if (!(self::$_export)) {
- self::$_export = array();
- $fields = self::fields();
- foreach ($fields as $name => $field) {
- if (!empty($field['export'])) {
- if ($prefix) {
- self::$_export['price_set_entity'] = &$fields[$name];
- }
- else {
- self::$_export[$name] = &$fields[$name];
- }
- }
- }
- }
- return self::$_export;
- }
-}
public function returnResult() {
$result = array();
$result['is_error'] = $this->returnError;
- $result['messages'] = implode("", $this->returnMessages);
+ $result['messages'] = '';
+ // Pad message size to allow for prefix added by CRM_Core_JobManager.
+ $messageSize = 255;
+ // Ensure that each message can fit in the civicrm_job_log.data column.
+ foreach ($this->returnMessages as $message) {
+ $messageSize += strlen($message);
+ if ($messageSize > CRM_Utils_Type::BLOB_SIZE) {
+ $result['messages'] .= '...';
+ break;
+ }
+ $result['messages'] .= $message;
+ }
return $result;
}
* should function correctly, but it can be harder to inspect/debug.
* - type: array|string, list of acceptable cache types, in order of preference.
* - prefetch: bool, whether to prefetch all data in cache (if possible).
+ * - withArray: bool|null|'fast', whether to setup a thread-local array-cache in front of the cache driver.
+ * Note that cache-values may be passed to the underlying driver with extra metadata,
+ * so this will slightly change/enlarge the on-disk format.
+ * Support varies by driver:
+ * - For most memory backed caches, this option is meaningful.
+ * - For SqlGroup, this option is ignored. SqlGroup has equivalent behavior built-in.
+ * - For Arraycache, this option is ignored. It's redundant.
+ * If this is a short-lived process in which TTL's don't matter, you might
+ * use 'fast' mode. It sacrifices some PSR-16 compliance and cache-coherency
+ * protections to improve performance.
* @return CRM_Utils_Cache_Interface
* @throws CRM_Core_Exception
* @see Civi::cache()
$dbCacheClass = 'CRM_Utils_Cache_' . CIVICRM_DB_CACHE_CLASS;
$settings = self::getCacheSettings(CIVICRM_DB_CACHE_CLASS);
$settings['prefix'] = CRM_Utils_Array::value('prefix', $settings, '') . self::DELIMITER . $params['name'] . self::DELIMITER;
- return new $dbCacheClass($settings);
+ $cache = new $dbCacheClass($settings);
+ if (!empty($params['withArray'])) {
+ $cache = $params['withArray'] === 'fast' ? new CRM_Utils_Cache_FastArrayDecorator($cache) : new CRM_Utils_Cache_ArrayDecorator($cache);
+ }
+ return $cache;
}
break;
return $className;
}
+ /**
+ * Generate a unique negative-acknowledgement token (NACK).
+ *
+ * When using PSR-16 to read a value, the `$cahce->get()` will a return a default
+ * value on cache-miss, so it's hard to know if you've gotten a geniune value
+ * from the cache or just a default. If you're in an edge-case where it matters
+ * (and you want to do has()+get() in a single roundtrip), use the nack() as
+ * the default:
+ *
+ * $nack = CRM_Utils_Cache::nack();
+ * $value = $cache->get('foo', $nack);
+ * echo ($value === $nack) ? "Cache has a value, and we got it" : "Cache has no value".
+ *
+ * The value should be unique to avoid accidental matches.
+ *
+ * @return string
+ * Unique nonce value indicating a "negative acknowledgement" (failed read).
+ * If we need to accurately perform has($key)+get($key), we can
+ * use `get($key,$nack)`.
+ */
+ public static function nack() {
+ $st =& Civi::$statics[__CLASS__];
+ if (!isset($st['nack-c'])) {
+ $st['nack-c'] = md5(CRM_Utils_Request::id() . CIVICRM_SITE_KEY . CIVICRM_DSN . mt_rand(0, 10000));
+ $st['nack-i'] = 0;
+ }
+ return 'NACK:' . $st['nack-c'] . $st['nack-i']++;
+ }
+
}
}
private function reobjectify($value) {
- return is_object($value) ? unserialize(serialize($value)) : $value;
+ if (is_object($value)) {
+ return unserialize(serialize($value));
+ }
+ if (is_array($value)) {
+ foreach ($value as $p) {
+ if (is_object($p)) {
+ return unserialize(serialize($value));
+ }
+ }
+ }
+ return $value;
+ }
+
+ /**
+ * @param string $key
+ * @return int|null
+ */
+ public function getExpires($key) {
+ return $this->_expires[$key] ?: NULL;
}
}
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 5 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2019 |
+ +--------------------------------------------------------------------+
+ | 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-2019
+ */
+
+/**
+ * Class CRM_Utils_Cache_ArrayDecorator
+ *
+ * This creates a two-tier cache-hierarchy: a thread-local, array-based cache
+ * combined with some third-party cache driver.
+ *
+ * Ex: $cache = new CRM_Utils_Cache_ArrayDecorator(new CRM_Utils_Cache_Redis(...));
+ */
+class CRM_Utils_Cache_ArrayDecorator implements CRM_Utils_Cache_Interface {
+
+ use CRM_Utils_Cache_NaiveMultipleTrait; // TODO Consider native implementation.
+
+ /**
+ * @var int
+ * Default time-to-live (seconds) for cache items that don't have a TTL.
+ */
+ protected $defaultTimeout;
+
+ /**
+ * @var CRM_Utils_Cache_Interface
+ */
+ private $delegate;
+
+ /**
+ * @var array
+ * Array(string $cacheKey => mixed $cacheValue).
+ */
+ private $values = [];
+
+ /**
+ * @var array
+ * Array(string $cacheKey => int $expirationTime).
+ */
+ private $expires = [];
+
+ /**
+ * CRM_Utils_Cache_ArrayDecorator constructor.
+ * @param \CRM_Utils_Cache_Interface $delegate
+ * @param int $defaultTimeout
+ * Default number of seconds each cache-item should endure.
+ */
+ public function __construct(\CRM_Utils_Cache_Interface $delegate, $defaultTimeout = 3600) {
+ $this->defaultTimeout = $defaultTimeout;
+ $this->delegate = $delegate;
+ }
+
+ public function set($key, $value, $ttl = NULL) {
+ if (is_int($ttl) && $ttl <= 0) {
+ return $this->delete($key);
+ }
+
+ $expiresAt = CRM_Utils_Date::convertCacheTtlToExpires($ttl, $this->defaultTimeout);
+ if ($this->delegate->set($key, [$expiresAt, $value], $ttl)) {
+ $this->values[$key] = $this->reobjectify($value);
+ $this->expires[$key] = $expiresAt;
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+ }
+
+ public function get($key, $default = NULL) {
+ if (array_key_exists($key, $this->values) && $this->expires[$key] > CRM_Utils_Time::getTimeRaw()) {
+ return $this->reobjectify($this->values[$key]);
+ }
+
+ $nack = CRM_Utils_Cache::nack();
+ $value = $this->delegate->get($key, $nack);
+ if ($value === $nack) {
+ return $default;
+ }
+
+ $this->expires[$key] = $value[0];
+ $this->values[$key] = $value[1];
+ return $this->reobjectify($this->values[$key]);
+ }
+
+ public function delete($key) {
+ unset($this->values[$key]);
+ unset($this->expires[$key]);
+ return $this->delegate->delete($key);
+ }
+
+ public function flush() {
+ return $this->clear();
+ }
+
+ public function clear() {
+ $this->values = [];
+ $this->expires = [];
+ return $this->delegate->clear();
+ }
+
+ public function has($key) {
+ if (array_key_exists($key, $this->values) && $this->expires[$key] > CRM_Utils_Time::getTimeRaw()) {
+ return TRUE;
+ }
+ return $this->delegate->has($key);
+ }
+
+ private function reobjectify($value) {
+ return is_object($value) ? unserialize(serialize($value)) : $value;
+ }
+
+}
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 5 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2019 |
+ +--------------------------------------------------------------------+
+ | 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-2019
+ */
+
+/**
+ * Class CRM_Utils_Cache_FastArrayDecorator
+ *
+ * Like CRM_Utils_Cache_ArrayDecorator, this creates a two-tier cache.
+ * But it's... faster. The speed improvements are achieved by sacrificing
+ * compliance with PSR-16. Specific trade-offs:
+ *
+ * 1. TTL values are not tracked locally. Any data cached locally will stay
+ * active until the instance is destroyed (i.e. until the request ends).
+ * You won't notice this is you have short-lived requests and long-lived caches.
+ * 2. If you store an *object* in the local cache, the same object instance
+ * will be used through the end of the request. If you modify a property
+ * of the object, the change will endure within the current pageview but
+ * will not pass-through to the persistent cache.
+ *
+ * But... it is twice as fast (on high-volume reads).
+ *
+ * Ex: $cache = new CRM_Utils_Cache_FastArrayDecorator(new CRM_Utils_Cache_Redis(...));
+ *
+ * @see CRM_Utils_Cache_ArrayDecorator
+ */
+class CRM_Utils_Cache_FastArrayDecorator implements CRM_Utils_Cache_Interface {
+
+ use CRM_Utils_Cache_NaiveMultipleTrait; // TODO Consider native implementation.
+
+ /**
+ * @var int
+ * Default time-to-live (seconds) for cache items that don't have a TTL.
+ */
+ protected $defaultTimeout;
+
+ /**
+ * @var CRM_Utils_Cache_Interface
+ */
+ private $delegate;
+
+ /**
+ * @var array
+ * Array(string $cacheKey => mixed $cacheValue).
+ */
+ private $values = [];
+
+ /**
+ * CRM_Utils_Cache_FastArrayDecorator constructor.
+ * @param \CRM_Utils_Cache_Interface $delegate
+ * @param int $defaultTimeout
+ * Default number of seconds each cache-item should endure.
+ */
+ public function __construct(\CRM_Utils_Cache_Interface $delegate, $defaultTimeout = 3600) {
+ $this->defaultTimeout = $defaultTimeout;
+ $this->delegate = $delegate;
+ }
+
+ public function set($key, $value, $ttl = NULL) {
+ if (is_int($ttl) && $ttl <= 0) {
+ return $this->delete($key);
+ }
+
+ if ($this->delegate->set($key, $value, $ttl)) {
+ $this->values[$key] = $value;
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+ }
+
+ public function get($key, $default = NULL) {
+ if (array_key_exists($key, $this->values)) {
+ return $this->values[$key];
+ }
+
+ $nack = CRM_Utils_Cache::nack();
+ $value = $this->delegate->get($key, $nack);
+ if ($value === $nack) {
+ return $default;
+ }
+
+ $this->values[$key] = $value;
+ return $value;
+ }
+
+ public function delete($key) {
+ unset($this->values[$key]);
+ return $this->delegate->delete($key);
+ }
+
+ public function flush() {
+ return $this->clear();
+ }
+
+ public function clear() {
+ $this->values = [];
+ return $this->delegate->clear();
+ }
+
+ public function has($key) {
+ return $this->delegate->has($key);
+ }
+
+}
* The traditional CRM_Utils_Cache_Interface did not support has().
* To get drop-in compliance with PSR-16, we use a naive adapter.
*
- * Ideally, these should be replaced with more performant/native versions.
+ * There may be opportunities to replace/optimize in specific drivers.
*/
trait CRM_Utils_Cache_NaiveHasTrait {
public function has($key) {
- // This is crazy-talk. If you've got an environment setup where you might
- // be investigating this, fix your preferred cache driver by
- // replacing `NaiveHasTrait` with a decent function.
- $hasDefaultA = ($this->get($key, NULL) === NULL);
- $hasDefaultB = ($this->get($key, 123) === 123);
- return !($hasDefaultA && $hasDefaultB);
+ $nack = CRM_Utils_Cache::nack();
+ $value = $this->get($key, $nack);
+ return ($value !== $nack);
}
}
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 5 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2019 |
+ +--------------------------------------------------------------------+
+ | 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-2019
+ */
+
+/**
+ * Class CRM_Utils_Cache_Tiered
+ *
+ * `Tiered` implements a hierarchy of fast and slow caches. For example, you
+ * might have a configuration in which:
+ *
+ * - A local/in-memory array caches info for up to 1 minute (60s).
+ * - A Redis cache retains info for up to 10 minutes (600s).
+ * - A SQL cache retains info for up to 1 hour (3600s).
+ *
+ * Cached data will be written to all three tiers. When reading, you'll hit the
+ * fastest available tier.
+ *
+ * The example would be created with:
+ *
+ * $cache = new CRM_Utils_Cache_Tiered([
+ * new CRM_Utils_Cache_ArrayCache(...),
+ * new CRM_Utils_Cache_Redis(...),
+ * new CRM_Utils_Cache_SqlGroup(...),
+ * ], [60, 600, 3600]);
+ *
+ * Note:
+ * - Correctly implementing PSR-16 leads to a small amount of CPU+mem overhead.
+ * If you need an extremely high number of re-reads within a thread and can live
+ * with only two tiers, try CRM_Utils_Cache_ArrayDecorator or
+ * CRM_Utils_Cache_FastArrayDecorator instead.
+ * - With the exception of unit-testing, you should not access the underlying
+ * tiers directly. The data-format may be different than your expectation.
+ */
+class CRM_Utils_Cache_Tiered implements CRM_Utils_Cache_Interface {
+
+ use CRM_Utils_Cache_NaiveMultipleTrait; // TODO Consider native implementation.
+
+ /**
+ * @var array
+ * Array(int $tierNum => int $seconds).
+ */
+ protected $maxTimeouts;
+
+ /**
+ * @var array
+ * List of cache instances, with fastest/closest first.
+ * Array(int $tierNum => CRM_Utils_Cache_Interface).
+ */
+ protected $tiers;
+
+ /**
+ * CRM_Utils_Cache_Tiered constructor.
+ * @param array $tiers
+ * List of cache instances, with fastest/closest first.
+ * Must be indexed numerically (0, 1, 2...).
+ * @param array $maxTimeouts
+ * A list of maximum timeouts for each cache-tier.
+ * There must be at least one value in this array.
+ * If timeouts are omitted for slower tiers, they are filled in with the last value.
+ * @throws CRM_Core_Exception
+ */
+ public function __construct($tiers, $maxTimeouts = [86400]) {
+ $this->tiers = $tiers;
+ $this->maxTimeouts = [];
+
+ foreach ($tiers as $k => $tier) {
+ $this->maxTimeouts[$k] = isset($maxTimeouts[$k])
+ ? $maxTimeouts[$k]
+ : $this->maxTimeouts[$k - 1];
+ }
+
+ for ($far = 1; $far < count($tiers); $far++) {
+ $near = $far - 1;
+ if ($this->maxTimeouts[$near] > $this->maxTimeouts[$far]) {
+ throw new \CRM_Core_Exception("Invalid configuration: Near cache #{$near} has longer timeout than far cache #{$far}");
+ }
+ }
+ }
+
+ public function set($key, $value, $ttl = NULL) {
+ if ($ttl !== NULL & !is_int($ttl) && !($ttl instanceof DateInterval)) {
+ throw new CRM_Utils_Cache_InvalidArgumentException("Invalid cache TTL");
+ }
+ foreach ($this->tiers as $tierNum => $tier) {
+ /** @var CRM_Utils_Cache_Interface $tier */
+ $effTtl = $this->getEffectiveTtl($tierNum, $ttl);
+ $expiresAt = CRM_Utils_Date::convertCacheTtlToExpires($effTtl, $this->maxTimeouts[$tierNum]);
+ if (!$tier->set($key, [0 => $expiresAt, 1 => $value], $effTtl)) {
+ return FALSE;
+ }
+ }
+ return TRUE;
+ }
+
+ public function get($key, $default = NULL) {
+ $nack = CRM_Utils_Cache::nack();
+ foreach ($this->tiers as $readTierNum => $tier) {
+ /** @var CRM_Utils_Cache_Interface $tier */
+ $wrapped = $tier->get($key, $nack);
+ if ($wrapped !== $nack && $wrapped[0] >= CRM_Utils_Time::getTimeRaw()) {
+ list ($parentExpires, $value) = $wrapped;
+ // (Re)populate the faster caches; and then return the value we found.
+ for ($i = 0; $i < $readTierNum; $i++) {
+ $now = CRM_Utils_Time::getTimeRaw();
+ $effExpires = min($parentExpires, $now + $this->maxTimeouts[$i]);
+ $this->tiers[$i]->set($key, [0 => $effExpires, 1 => $value], $effExpires - $now);
+ }
+ return $value;
+ }
+ }
+ return $default;
+ }
+
+ public function delete($key) {
+ foreach ($this->tiers as $tier) {
+ /** @var CRM_Utils_Cache_Interface $tier */
+ $tier->delete($key);
+ }
+ return TRUE;
+ }
+
+ public function flush() {
+ return $this->clear();
+ }
+
+ public function clear() {
+ foreach ($this->tiers as $tier) {
+ /** @var CRM_Utils_Cache_Interface $tier */
+ if (!$tier->clear()) {
+ return FALSE;
+ }
+ }
+ return TRUE;
+ }
+
+ public function has($key) {
+ $nack = CRM_Utils_Cache::nack();
+ foreach ($this->tiers as $tier) {
+ /** @var CRM_Utils_Cache_Interface $tier */
+ $wrapped = $tier->get($key, $nack);
+ if ($wrapped !== $nack && $wrapped[0] > CRM_Utils_Time::getTimeRaw()) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+ }
+
+ protected function getEffectiveTtl($tierNum, $ttl) {
+ if ($ttl === NULL) {
+ return $this->maxTimeouts[$tierNum];
+ }
+ else {
+ return min($this->maxTimeouts[$tierNum], $ttl);
+ }
+ }
+
+}
return $messages;
}
+ /**
+ * Check for utf8mb4 support by MySQL.
+ *
+ * @return array<CRM_Utils_Check_Message> an empty array, or a list of warnings
+ */
+ public function checkMysqlUtf8mb4() {
+ $messages = array();
+
+ if (CRM_Core_DAO::getConnection()->phptype != 'mysqli') {
+ return $messages;
+ }
+
+ // Force utf8mb4 query to throw exception as the check expects.
+ $errorScope = CRM_Core_TemporaryErrorScope::useException();
+ try {
+ // Create a temporary table to avoid implicit commit.
+ CRM_Core_DAO::executeQuery('CREATE TEMPORARY TABLE civicrm_utf8mb4_test (id VARCHAR(255), PRIMARY KEY(id(255))) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC ENGINE=INNODB');
+ CRM_Core_DAO::executeQuery('DROP TEMPORARY TABLE civicrm_utf8mb4_test');
+ }
+ catch (PEAR_Exception $e) {
+ $messages[] = new CRM_Utils_Check_Message(
+ __FUNCTION__,
+ ts('Future versions of CiviCRM may require MySQL utf8mb4 support. It is recommended, though not yet required, to configure your MySQL server for utf8mb4 support. You will need the following MySQL server configuration: innodb_large_prefix=true innodb_file_format=barracuda innodb_file_per_table=true'),
+ ts('MySQL utf8mb4 Support'),
+ \Psr\Log\LogLevel::WARNING,
+ 'fa-database'
+ );
+ }
+ // Ensure that the MySQL driver supports utf8mb4 encoding.
+ $version = mysqli_get_client_info(CRM_Core_DAO::getConnection()->connection);
+ if (strpos($version, 'mysqlnd') !== FALSE) {
+ // The mysqlnd driver supports utf8mb4 starting at version 5.0.9.
+ $version = preg_replace('/^\D+([\d.]+).*/', '$1', $version);
+ if (version_compare($version, '5.0.9', '<')) {
+ $messages[] = new CRM_Utils_Check_Message(
+ __FUNCTION__ . 'mysqlnd',
+ ts('It is recommended, though not yet required, to upgrade your PHP MySQL driver (mysqlnd) to >= 5.0.9 for utf8mb4 support.'),
+ ts('PHP MySQL Driver (mysqlnd)'),
+ \Psr\Log\LogLevel::WARNING,
+ 'fa-server'
+ );
+ }
+ }
+ else {
+ // The libmysqlclient driver supports utf8mb4 starting at version 5.5.3.
+ if (version_compare($version, '5.5.3', '<')) {
+ $messages[] = new CRM_Utils_Check_Message(
+ __FUNCTION__ . 'libmysqlclient',
+ ts('It is recommended, though not yet required, to upgrade your PHP MySQL driver (libmysqlclient) to >= 5.5.3 for utf8mb4 support.'),
+ ts('PHP MySQL Driver (libmysqlclient)'),
+ \Psr\Log\LogLevel::WARNING,
+ 'fa-server'
+ );
+ }
+ }
+
+ return $messages;
+ }
+
}
else {
$path = $url = $imageURL;
}
- $mimeType = 'image/' . strtolower(pathinfo($path, PATHINFO_EXTENSION));
+ $fileExtension = strtolower(pathinfo($path, PATHINFO_EXTENSION));
+ //According to (https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types),
+ // there are some extensions that would need translating.:
+ $translateMimeTypes = [
+ 'tif' => 'tiff',
+ 'jpg' => 'jpeg',
+ 'svg' => 'svg+xml',
+ ];
+ $mimeType = 'image/' . CRM_Utils_Array::value(
+ $fileExtension,
+ $translateMimeTypes,
+ $fileExtension
+ );
return self::getFileURL($path, $mimeType, $url);
}
return $iconClasses['*'];
}
+ /**
+ * Is the filename a safe and valid filename passed in from URL
+ *
+ * @param string $fileName
+ * @return bool
+ */
+ public static function isValidFileName($fileName = NULL) {
+ if ($fileName) {
+ $check = $fileName !== basename($fileName) ? FALSE : TRUE;
+ if ($check) {
+ if (substr($fileName, 0, 1) == '/' || substr($fileName, 0, 1) == '.' || substr($fileName, 0, 1) == DIRECTORY_SEPARATOR) {
+ $check = FALSE;
+ }
+ }
+ return $check;
+ }
+ return FALSE;
+ }
+
}
if (!$currency) {
$currency = $config->defaultCurrency;
}
+
+ // ensure $currency is a valid currency code
+ // for backwards-compatibility, also accept one space instead of a currency
+ if ($currency != ' ' && !array_key_exists($currency, self::$_currencySymbols)) {
+ throw new CRM_Core_Exception("Invalid currency \"{$currency}\"");
+ }
+
$amount = self::formatNumericByFormat($amount, $valueFormat);
// If it contains tags, means that HTML was passed and the
// amount is already converted properly,
*
* @return string|void
*/
- public static function html2pdf(&$text, $fileName = 'civicrm.pdf', $output = FALSE, $pdfFormat = NULL) {
+ public static function html2pdf($text, $fileName = 'civicrm.pdf', $output = FALSE, $pdfFormat = NULL) {
if (is_array($text)) {
$pages = &$text;
}
// PDF Page Format parameters passed in
$format = array_merge($format, $pdfFormat);
}
- else {
+ elseif (!empty($pdfFormat)) {
// PDF Page Format ID passed in
$format = CRM_Core_BAO_PdfFormat::getById($pdfFormat);
}
$b = CRM_Core_BAO_PdfFormat::getValue('margin_bottom', $format);
$l = CRM_Core_BAO_PdfFormat::getValue('margin_left', $format);
- $stationery_path_partial = CRM_Core_BAO_PdfFormat::getValue('stationery', $format);
-
- $stationery_path = NULL;
- if (strlen($stationery_path_partial)) {
- $doc_root = $_SERVER['DOCUMENT_ROOT'];
- $stationery_path = $doc_root . "/" . $stationery_path_partial;
- }
-
$margins = array($metric, $t, $r, $b, $l);
- $config = CRM_Core_Config::singleton();
-
// Add a special region for the HTML header of PDF files:
$pdfHeaderRegion = CRM_Core_Region::instance('export-document-header', FALSE);
$htmlHeader = ($pdfHeaderRegion) ? $pdfHeaderRegion->render('', FALSE) : '';
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
<style>@page { margin: {$t}{$metric} {$r}{$metric} {$b}{$metric} {$l}{$metric}; }</style>
- <style type=\"text/css\">@import url({$config->userFrameworkResourceURL}css/print.css);</style>
+ <style type=\"text/css\">@import url(" . CRM_Core_Config::singleton()->userFrameworkResourceURL . "css/print.css);</style>
{$htmlHeader}
</head>
<body>
<div id=\"crm-container\">\n";
// Strip <html>, <header>, and <body> tags from each page
- $htmlElementstoStrip = array(
+ $htmlElementstoStrip = [
'@<head[^>]*?>.*?</head>@siu',
'@<script[^>]*?>.*?</script>@siu',
'@<body>@siu',
'@<html[^>]*?>@siu',
'@</html>@siu',
'@<!DOCTYPE[^>]*?>@siu',
- );
- $htmlElementsInstead = array('', '', '', '', '', '');
+ ];
+ $htmlElementsInstead = ['', '', '', '', '', ''];
foreach ($pages as & $page) {
$page = preg_replace($htmlElementstoStrip,
$htmlElementsInstead,
</div>
</body>
</html>";
- if ($config->wkhtmltopdfPath) {
+ if (CRM_Core_Config::singleton()->wkhtmltopdfPath) {
return self::_html2pdf_wkhtmltopdf($paper_size, $orientation, $margins, $html, $output, $fileName);
}
else {
return self::_html2pdf_dompdf($paper_size, $orientation, $html, $output, $fileName);
- //return self::_html2pdf_tcpdf($paper_size, $orientation, $margins, $html, $output, $fileName, $stationery_path);
}
}
require_once 'packages/recaptcha/recaptchalib.php';
}
- // See if we are using SSL
- if (CRM_Utils_System::isSSL()) {
- $useSSL = TRUE;
- }
- $html = recaptcha_get_html($config->recaptchaPublicKey, $error, $useSSL);
+ // Load the Recaptcha api.js over HTTPS
+ $useHTTPS = TRUE;
+
+ $html = recaptcha_get_html($config->recaptchaPublicKey, $error, $useHTTPS);
$form->assign('recaptchaHTML', $html);
$form->assign('recaptchaOptions', $config->recaptchaOptions);
const CATEGORY_REGEXP = ';^[a-zA-Z0-9]+$;';
const ID_LENGTH = 37; // MAX{64} - CATEGORY_LENGTH{12} - CONST_LENGHTH{15} = 37
const ID_REGEXP = ';^[a-zA-Z0-9_]+$;';
+ const INNODB = 'ENGINE=InnoDB';
+ const MEMORY = 'ENGINE=MEMORY';
/**
* @var bool
protected $autodrop;
+ protected $memory;
+
/**
* @return CRM_Utils_SQL_TempTable
*/
// I suspect it would be better to just say utf8=true, but a lot of existing queries don't do the utf8 bit.
$t->utf8 = CRM_Utils_Constant::value('CIVICRM_TEMP_FORCE_UTF8', FALSE);
$t->autodrop = FALSE;
+ $t->memory = FALSE;
return $t;
}
* @return CRM_Utils_SQL_TempTable
*/
public function createWithQuery($selectQuery) {
- $sql = sprintf('%s %s AS %s',
+ $sql = sprintf('%s %s %s AS %s',
$this->toSQL('CREATE'),
+ $this->memory ? self::MEMORY : self::INNODB,
$this->utf8 ? self::UTF8 : '',
($selectQuery instanceof CRM_Utils_SQL_Select ? $selectQuery->toSQL() : $selectQuery)
);
* @return CRM_Utils_SQL_TempTable
*/
public function createWithColumns($columns) {
- $sql = sprintf('%s (%s) %s',
+ $sql = sprintf('%s (%s) %s %s',
$this->toSQL('CREATE'),
$columns,
+ $this->memory ? self::MEMORY : self::INNODB,
$this->utf8 ? self::UTF8 : ''
);
CRM_Core_DAO::executeQuery($sql, array(), TRUE, NULL, TRUE, FALSE);
return $this->durable;
}
+ /**
+ * @return bool
+ */
+ public function isMemory() {
+ return $this->memory;
+ }
+
/**
* @return bool
*/
return $this;
}
+ /**
+ * Set table engine to MEMORY.
+ *
+ * @param bool $value
+ *
+ * @return $this
+ */
+ public function setMemory($value = TRUE) {
+ $this->memory = $value;
+ return $this;
+ }
+
/**
* Set table collation to UTF8.
*
FORTYFIVE = 45,
HUGE = 45;
+ /**
+ * Maximum size of a MySQL BLOB or TEXT column in bytes.
+ */
+ const BLOB_SIZE = 65535;
+
+ /**
+ * Maximum value of a MySQL signed INT column.
+ */
+ const INT_MAX = 2147483647;
+
/**
* Gets the string representation for a data type.
*
}
if (isset($apiRequest['params']['entity_table'])) {
+ if (!\CRM_Core_DAO_AllCoreTables::isCoreTable($apiRequest['params']['entity_table'])) {
+ throw new \API_Exception("Unrecognized target entity table {$apiRequest['params']['entity_table']}");
+ }
$this->authorizeDelegate(
$apiRequest['action'],
$apiRequest['params']['entity_table'],
* @throws \Civi\API\Exception\UnauthorizedException
*/
public function authorizeDelegate($action, $entityTable, $entityId, $apiRequest) {
+ if ($this->isTrusted($apiRequest)) {
+ return;
+ }
+
$entity = $this->getDelegatedEntityName($entityTable);
if (!$entity) {
throw new \API_Exception("Failed to run permission check: Unrecognized target entity table ($entityTable)");
throw new \Civi\API\Exception\UnauthorizedException("Authorization failed on ($entity): Missing entity_id");
}
- if ($this->isTrusted($apiRequest)) {
- return;
- }
-
/**
* @var \Exception $exception
*/
/**
* Get a single activity record by type.
+ * This function is only used by SequenceListenerTest
*
* @param string $type
* @throws \Civi\CCase\Exception\MultipleActivityException
*/
public function getSingleActivity($type) {
$idx = $this->getActivityIndex(array('activity_type_id', 'id'));
- $actTypes = array_flip(\CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name'));
+ $actTypes = array_flip(\CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'validate'));
$typeId = $actTypes[$type];
$count = isset($idx[$typeId]) ? count($idx[$typeId]) : 0;
return;
}
- $actTypes = array_flip(\CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name'));
+ $actTypes = array_flip(\CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'validate'));
$actStatuses = array_flip(\CRM_Activity_BAO_Activity::getStatusesByType(\CRM_Activity_BAO_Activity::COMPLETED));
$actIndex = $analyzer->getActivityIndex(array('activity_type_id', 'status_id'));
'checkMysqlTrigger',
'checkMysqlThreadStack',
'checkMysqlLockTables',
+ 'checkMysqlUtf8mb4',
);
/**
return $results;
}
+ /**
+ * @param $db_config
+ *
+ * @return array
+ */
+ public function checkMysqlUtf8mb4($db_config) {
+ $results = array(
+ 'title' => 'CiviCRM MySQL utf8mb4 Support',
+ 'severity' => $this::REQUIREMENT_OK,
+ 'details' => 'Your system supports the MySQL utf8mb4 character set.',
+ );
+
+ $conn = $this->connect($db_config);
+ if (!$conn) {
+ $results['severity'] = $this::REQUIREMENT_ERROR;
+ $results['details'] = 'Could not connect to database';
+ return $results;
+ }
+
+ if (!@mysqli_select_db($conn, $db_config['database'])) {
+ $results['severity'] = $this::REQUIREMENT_ERROR;
+ $results['details'] = 'Could not select the database';
+ mysqli_close($conn);
+ return $results;
+ }
+
+ $r = mysqli_query($conn, 'CREATE TABLE civicrm_utf8mb4_test (id VARCHAR(255), PRIMARY KEY(id(255))) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC ENGINE=INNODB');
+ if (!$r) {
+ $results['severity'] = $this::REQUIREMENT_WARNING;
+ $results['details'] = 'It is recommended, though not yet required, to configure your MySQL server for utf8mb4 support. You will need the following MySQL server configuration: innodb_large_prefix=true innodb_file_format=barracuda innodb_file_per_table=true';
+ mysqli_close($conn);
+ return $results;
+ }
+ mysqli_query('DROP TABLE civicrm_utf8mb4_test');
+
+ // Ensure that the MySQL driver supports utf8mb4 encoding.
+ $version = mysqli_get_client_info($conn);
+ if (strpos($version, 'mysqlnd') !== FALSE) {
+ // The mysqlnd driver supports utf8mb4 starting at version 5.0.9.
+ $version = preg_replace('/^\D+([\d.]+).*/', '$1', $version);
+ if (version_compare($version, '5.0.9', '<')) {
+ $results['severity'] = $this::REQUIREMENT_WARNING;
+ $results['details'] = 'It is recommended, though not yet required, to upgrade your PHP MySQL driver (mysqlnd) to >= 5.0.9 for utf8mb4 support.';
+ mysqli_close($conn);
+ return $results;
+ }
+ }
+ else {
+ // The libmysqlclient driver supports utf8mb4 starting at version 5.5.3.
+ if (version_compare($version, '5.5.3', '<')) {
+ $results['severity'] = $this::REQUIREMENT_WARNING;
+ $results['details'] = 'It is recommended, though not yet required, to upgrade your PHP MySQL driver (libmysqlclient) to >= 5.5.3 for utf8mb4 support.';
+ mysqli_close($conn);
+ return $results;
+ }
+ }
+
+ mysqli_close($conn);
+ return $results;
+ }
+
}
);
$result = $this->civicrm_api($entity, 'getsingle', $params);
if (!is_array($result) || !empty($result['is_error']) || isset($result['values'])) {
- throw new \Exception('Invalid getsingle result' . print_r($result, TRUE));
+ $unfilteredResult = $this->civicrm_api($entity, 'get', $params);
+ throw new \Exception(
+ 'Invalid getsingle result' . print_r($result, TRUE)
+ . "\n entity: $entity . \n params \n " . print_r($params, TRUE)
+ . "\n entities retrieved with blank params \n" . print_r($unfilteredResult, TRUE)
+ );
}
if ($checkAgainst) {
// @todo - have gone with the fn that unsets id? should we check id?
};
});
+ angular.module('crmUtil').factory('crmLoadScript', function($q) {
+ return function(url) {
+ var deferred = $q.defer();
+
+ CRM.loadScript(url).done(function() {
+ deferred.resolve(true);
+ });
+
+ return deferred.promise;
+ };
+ });
+
})(angular, CRM.$, CRM._);
'icon' => CRM_Utils_File::getIconFromMimeType($fileDao->mime_type),
'created_id' => $fileDao->created_id,
);
+ $fileHash = CRM_Core_BAO_File::generateFileHash($result['entity_id'], $result['id']);
$result['url'] = CRM_Utils_System::url(
- 'civicrm/file', 'reset=1&id=' . $result['id'] . '&eid=' . $result['entity_id'],
+ 'civicrm/file', 'reset=1&id=' . $result['id'] . '&eid=' . $result['entity_id'] . '&fcs=' . $fileHash,
TRUE,
NULL,
FALSE,
$fieldsToReturn = ['title', 'campaign_type_id', 'status_id', 'start_date', 'end_date'];
$request['params']['return'] = array_unique(array_merge($fieldsToReturn, $request['extra']));
if (empty($request['params']['id'])) {
+ $request['params']['options']['sort'] = 'start_date DESC, title';
$request['params'] += [
'is_active' => 1,
];
}
if (isset($params['group'])) {
$groups = $params['group'];
- $allGroups = CRM_Core_PseudoConstant::group();
+ $groupsByTitle = CRM_Core_PseudoConstant::group();
+ $groupsByName = CRM_Contact_BAO_GroupContact::buildOptions('group_id', 'validate');
+ $allGroups = array_merge(array_flip($groupsByTitle), array_flip($groupsByName));
if (is_array($groups) && in_array(key($groups), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
// Get the groups array.
$groupsArray = $groups[key($groups)];
foreach ($groupsArray as &$group) {
- if (!is_numeric($group) && array_search($group, $allGroups)) {
- $group = array_search($group, $allGroups);
+ if (!is_numeric($group) && !empty($allGroups[$group])) {
+ $group = $allGroups[$group];
}
}
// Now reset the $groups array with the ids not the titles.
// handle format like 'group' => array('title1', 'title2').
elseif (is_array($groups)) {
foreach ($groups as $k => &$group) {
- if (!is_numeric($group) && array_search($group, $allGroups)) {
- $group = array_search($group, $allGroups);
+ if (!is_numeric($group) && !empty($allGroups[$group])) {
+ $group = $allGroups[$group];
}
- if (!is_numeric($k) && array_search($k, $allGroups)) {
+ if (!is_numeric($k) && !empty($allGroups[$k])) {
unset($groups[$k]);
- $groups[array_search($k, $allGroups)] = $group;
+ $groups[$allGroups[$k]] = $group;
}
}
}
- elseif (!is_numeric($groups) && array_search($groups, $allGroups)) {
- $groups = array_search($groups, $allGroups);
+ elseif (!is_numeric($groups) && !empty($allGroups[$groups])) {
+ $groups = $allGroups[$groups];
}
$params['group'] = $groups;
}
$params['total_amount']['api.required'] = 1;
$params['payment_instrument_id']['api.aliases'] = array('payment_instrument');
$params['receive_date']['api.default'] = 'now';
+ $params['receive_date']['api.required'] = TRUE;
$params['payment_processor'] = array(
'name' => 'payment_processor',
'title' => 'Payment Processor ID',
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
-
/**
+ * Get a Dedupe Exception.
*
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
- * $Id$
+ * @param array $params
+ * Array per getfields metadata.
*
+ * @return array
+ * Array of all found dedupe exception object property values.
*/
-class CRM_Report_Form_Event extends CRM_Report_Form {
- // Nothing here.
- // FIXME: Do these reports really have nothing in common? Really?
-
+function civicrm_api3_exception_get($params) {
+ return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
+/**
+ * Create or update an dedupe exception.
+ *
+ * @param array $params
+ * Array per getfields metadata.
+ *
+ * @return array api result array
+ */
+function civicrm_api3_exception_create($params) {
+ return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Exception');
+}
+/**
+ * Delete an existing Exception.
+ *
+ * This method is used to delete any existing Exception given its id.
+ *
+ * @param array $params
+ * [id]
+ *
+ * @return array api result array
+ */
+function civicrm_api3_exception_delete($params) {
+ return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
$emailDetail = array();
// fetch contact_id and email id for all existing emails
while ($dao->fetch()) {
- $emailDetail[$dao->email] = array(
+ $emailDetail[strtolower($dao->email)] = array(
'contact_id' => $dao->contact_id,
'email_id' => $dao->id,
);
),
);
}
+
+/**
+ * Send a payment confirmation.
+ *
+ * @param array $params
+ * Input parameters.
+ *
+ * @return array
+ * @throws Exception
+ */
+function civicrm_api3_payment_sendconfirmation($params) {
+ $allowedParams = [
+ 'receipt_from_email',
+ 'receipt_from_name',
+ 'cc_receipt',
+ 'bcc_receipt',
+ 'receipt_text',
+ 'id',
+ ];
+ $input = array_intersect_key($params, array_flip($allowedParams));
+ // use either the contribution or membership receipt, based on whether it’s a membership-related contrib or not
+ $result = CRM_Financial_BAO_Payment::sendConfirmation($input);
+ return civicrm_api3_create_success([
+ $params['id'] => [
+ 'is_sent' => $result[0],
+ 'subject' => $result[1],
+ 'message_txt' => $result[2],
+ 'message_html' => $result[3],
+ ]]);
+}
+
+/**
+ * Adjust Metadata for sendconfirmation action.
+ *
+ * The metadata is used for setting defaults, documentation & validation.
+ *
+ * @param array $params
+ * Array of parameters determined by getfields.
+ */
+function _civicrm_api3_payment_sendconfirmation_spec(&$params) {
+ $params['id'] = array(
+ 'api.required' => 1,
+ 'title' => ts('Payment ID'),
+ 'type' => CRM_Utils_Type::T_INT,
+ );
+}
organization: Circle Interactive
jira : marshCircle
+- github : mathavanveda
+ name : Mathavan Veeramuthu
+ organization: Veda Consulting
+
- name : Matt Allard
organization: City of Winnipeg, Manitoba
jira : mattallard
padding: 0;
border-top: 1px solid #787878;
}
+body.admin.com_civicrm.task-civicrmupgrade .container-fluid.container-main {
+ padding: 10px 25px 25px;
+}
body.admin.com_civicrm #crm-nav-menu-container {
padding-bottom: 0 !important;
}
done
dm_install_files "$repo" "$to" {agpl-3.0,agpl-3.0.exception,gpl,CONTRIBUTORS}.txt
- dm_install_files "$repo" "$to" composer.json composer.lock bower.json package.json Civi.php README.md release-notes.md
+ dm_install_files "$repo" "$to" composer.json composer.lock bower.json package.json Civi.php README.md release-notes.md extension-compatibility.json
mkdir -p "$to/sql"
pushd "$repo" >> /dev/null
--- /dev/null
+{
+ "com.ixiam.modules.quicksearch": {
+ "obsolete": "5.8"
+ }
+}
ts('Unable to create triggers. This MySQL user is missing the CREATE TRIGGERS privilege.'),
)
);
+ $this->requireMySQLUtf8mb4($databaseConfig['server'],
+ $databaseConfig['username'],
+ $databaseConfig['password'],
+ $databaseConfig['database'],
+ array(
+ ts("MySQL %1 Configuration", array(1 => $dbName)),
+ ts('Is the <code>utf8mb4</code> character set supported?'),
+ ts('This MySQL server does not support the <code>utf8mb4</code> character set.'),
+ )
+ );
}
}
}
}
}
+ /**
+ * @param $server
+ * @param string $username
+ * @param $password
+ * @param $database
+ * @param $testDetails
+ */
+ public function requireMysqlUtf8mb4($server, $username, $password, $database, $testDetails) {
+ $this->testing($testDetails);
+ $conn = $this->connect($server, $username, $password);
+ if (!$conn) {
+ $testDetails[2] = ts('Could not connect to the database server.');
+ $this->error($testDetails);
+ return;
+ }
+
+ if (!@mysqli_select_db($conn, $database)) {
+ $testDetails[2] = ts('Could not select the database.');
+ $this->error($testDetails);
+ return;
+ }
+
+ $result = mysqli_query($conn, 'CREATE TABLE civicrm_utf8mb4_test (id VARCHAR(255), PRIMARY KEY(id(255))) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC ENGINE=INNODB');
+ if (!$result) {
+ $testDetails[2] = ts('It is recommended, though not yet required, to configure your MySQL server for utf8mb4 support. You will need the following MySQL server configuration: innodb_large_prefix=true innodb_file_format=barracuda innodb_file_per_table=true');
+ $this->warning($testDetails);
+ return;
+ }
+ $result = mysqli_query($conn, 'DROP TABLE civicrm_utf8mb4_test');
+
+ // Ensure that the MySQL driver supports utf8mb4 encoding.
+ $version = mysqli_get_client_info($conn);
+ if (strpos($version, 'mysqlnd') !== FALSE) {
+ // The mysqlnd driver supports utf8mb4 starting at version 5.0.9.
+ $version = preg_replace('/^\D+([\d.]+).*/', '$1', $version);
+ if (version_compare($version, '5.0.9', '<')) {
+ $testDetails[2] = 'It is recommended, though not yet required, to upgrade your PHP MySQL driver (mysqlnd) to >= 5.0.9 for utf8mb4 support.';
+ $this->warning($testDetails);
+ return;
+ }
+ }
+ else {
+ // The libmysqlclient driver supports utf8mb4 starting at version 5.5.3.
+ if (version_compare($version, '5.5.3', '<')) {
+ $testDetails[2] = 'It is recommended, though not yet required, to upgrade your PHP MySQL driver (libmysqlclient) to >= 5.5.3 for utf8mb4 support.';
+ $this->warning($testDetails);
+ return;
+ }
+ }
+ }
+
/**
* @param $testDetails
*
CRM.CMSjQuery = window.jQuery;
window.jQuery = CRM.$;
}
- script.src = url;
+ script.src = url + (_.includes(url, '?') ? '&r=' : '?r=') + CRM.config.resourceCacheCode;
document.getElementsByTagName("head")[0].appendChild(script);
}
return scriptsLoaded[url];
var entity = $(this).data('api-entity') || '';
$(this)
.off('.crmEntity')
- .removeClass('crm-form-entityref crm-' + entity.toLowerCase() + '-ref')
+ .removeClass('crm-form-entityref crm-' + _.kebabCase(entity) + '-ref')
.crmSelect2('destroy');
});
}
return $(this).each(function() {
var
$el = $(this).off('.crmEntity'),
- entity = options.entity || $el.data('api-entity') || 'contact',
+ entity = options.entity || $el.data('api-entity') || 'Contact',
selectParams = {};
+ // Legacy: fix entity name if passed in as snake case
+ if (entity.charAt(0).toUpperCase() !== entity.charAt(0)) {
+ entity = _.capitalize(_.camelCase(entity));
+ }
$el.data('api-entity', entity);
$el.data('select-params', $.extend({}, $el.data('select-params') || {}, options.select));
$el.data('api-params', $.extend(true, {}, $el.data('api-params') || {}, options.api));
$el.data('create-links', options.create || $el.data('create-links'));
- $el.addClass('crm-form-entityref crm-' + entity.toLowerCase() + '-ref');
+ $el.addClass('crm-form-entityref crm-' + _.kebabCase(entity) + '-ref');
var settings = {
// Use select2 ajax helper instead of CRM.api3 because it provides more value
ajax: {
}
};
// Create new items inline - works for tags
- if ($el.data('create-links') && entity.toLowerCase() === 'tag') {
+ if ($el.data('create-links') && entity === 'Tag') {
selectParams.createSearchChoice = function(term, data) {
if (!_.findKey(data, {label: term})) {
return {id: "0", term: term, label: term + ' (' + ts('new tag') + ')'};
var
createLinks = $el.data('create-links'),
params = getEntityRefApiParams($el).params,
+ entity = $el.data('api-entity'),
markup = '<div class="crm-entityref-links">';
- if (!createLinks || (createLinks === true && $el.data('api-entity').toLowerCase() !== 'contact')) {
+ if (!createLinks || (createLinks === true && !CRM.config.entityRef.links[entity])) {
return '';
}
if (createLinks === true) {
- createLinks = params.contact_type ? _.where(CRM.config.entityRef.contactCreate, {type: params.contact_type}) : CRM.config.entityRef.contactCreate;
+ createLinks = params.contact_type ? _.where(CRM.config.entityRef.links[entity], {type: params.contact_type}) : CRM.config.entityRef.links[entity];
}
_.each(createLinks, function(link) {
markup += ' <a class="crm-add-entity crm-hover-button" href="' + link.url + '">' +
function getEntityRefFilters($el) {
var
- entity = $el.data('api-entity').toLowerCase(),
+ entity = $el.data('api-entity'),
filters = CRM.config.entityRef.filters[entity] || [],
params = $.extend({params: {}}, $el.data('api-params') || {}).params,
result = [];
- $.each(filters, function() {
- var filter = $.extend({type: 'select', 'attributes': {}, entity: entity}, this);
- $.extend(this, filter);
+ _.each(filters, function(filter) {
+ _.defaults(filter, {type: 'select', 'attributes': {}, entity: entity});
if (!params[filter.key]) {
// Filter out options if params don't match its condition
if (filter.condition && !_.isMatch(params, _.pick(filter.condition, _.keys(params)))) {
*/
function renderEntityRefFilterValue($el) {
var
- entity = $el.data('api-entity').toLowerCase(),
filter = $el.data('user-filter') || {},
filterSpec = filter.key ? _.find(getEntityRefFilters($el), {key: filter.key}) : null,
$keyField = $('.crm-entityref-filter-key', '#select2-drop'),
// Determine if a user has a given permission.
// @see CRM_Core_Resources::addPermissions
CRM.checkPerm = function(perm) {
- return CRM.permissions[perm];
+ return CRM.permissions && CRM.permissions[perm];
};
// Round while preserving sigfigs
return (yiq >= 128) ? 'black' : 'white';
};
+ // CVE-2015-9251 - Prevent auto-execution of scripts when no explicit dataType was provided
+ $.ajaxPrefilter(function(s) {
+ if (s.crossDomain) {
+ s.contents.script = false;
+ }
+ });
+
})(jQuery, _);
// https://civicrm.org/licensing
CRM.$(function($) {
- var $form = $('form.CRM_Core_Form_ShortCode');
-
- function changeComponent() {
- var component = $(this).val(),
- entities = $(this).data('entities');
-
- $('.shortcode-param[data-components]', $form).each(function() {
- $(this).toggle($.inArray(component, $(this).data('components')) > -1);
-
- if (entities[component]) {
- $('input[name=entity]')
- .val('')
- .data('key', entities[component].key)
- .data('select-params', null)
- .data('api-params', null)
- .crmEntityRef(entities[component]);
- }
- });
- }
+ $('.crm-shortcode-button').click(function(e) {
+ e.preventDefault();
+ CRM.loadPage($(this).attr('href'), {dialog: {width: '50%', height: '50%'}}).on('crmLoad', loadForm);
+ });
+
+ function loadForm() {
+ var $form = $('form.CRM_Core_Form_ShortCode');
+
+ function changeComponent() {
+ var component = $(this).val(),
+ entities = $(this).data('entities');
+
+ $('.shortcode-param[data-components]', $form).each(function() {
+ $(this).toggle($.inArray(component, $(this).data('components')) > -1);
+
+ if (entities[component]) {
+ $('input[name=entity]')
+ .val('')
+ .data('key', entities[component].key)
+ .data('select-params', null)
+ .data('api-params', null)
+ .crmEntityRef(entities[component]);
+ }
+ });
+ }
- function close() {
- $form.closest('.ui-dialog-content').dialog('close');
- }
+ function close() {
+ $form.closest('.ui-dialog-content').dialog('close');
+ }
- function insert() {
- var code = '[civicrm';
- $('.shortcode-param:visible', $form).each(function() {
- var $el = $('input:checked, select, input.crm-form-entityref', this);
- code += ' ' + $el.data('key') + '="' + $el.val() + '"';
- });
- window.send_to_editor(code + ']');
- close();
+ function insert() {
+ var code = '[civicrm';
+ $('.shortcode-param:visible', $form).each(function() {
+ var $el = $('input:checked, select, input.crm-form-entityref', this);
+ code += ' ' + $el.data('key') + '="' + $el.val() + '"';
+ });
+ window.send_to_editor(code + ']');
+ close();
+ }
+
+ $('select[name=component]', $form).each(changeComponent).change(changeComponent);
+
+ $(this).dialog('option', 'buttons', [
+ {
+ text: ts("Insert"),
+ icons: {primary: "fa-check"},
+ click: insert
+ },
+ {
+ text: ts("Cancel"),
+ icons: {primary: "fa-times"},
+ click: close
+ }
+ ]);
}
- $('select[name=component]', $form).each(changeComponent).change(changeComponent);
-
- $form.closest('.ui-dialog-content').dialog('option', 'buttons', [
- {
- text: ts("Insert"),
- icons: {primary: "fa-check"},
- click: insert
- },
- {
- text: ts("Cancel"),
- icons: {primary: "fa-times"},
- click: close
- }
- ]);
});
* https://github.com/civicrm/civicrm-joomla
* https://github.com/civicrm/civicrm-wordpress
-# CiviCRM 5.9.0
+# CiviCRM 5.10.0
+
+Released February 6, 2019
+
+- **[Synopsis](release-notes/5.10.0.md#synopsis)**
+- **[Features](release-notes/5.10.0.md#features)**
+- **[Bugs resolved](release-notes/5.10.0.md#bugs)**
+- **[Miscellany](release-notes/5.10.0.md#misc)**
+- **[Credits](release-notes/5.10.0.md#credits)**
+- **[Feedback](release-notes/5.10.0.md#feedback)**
+
+## CiviCRM 5.9.1
+
+Released January 16, 2018
+
+- **[Synopsis](release-notes/5.9.1.md#synopsis)**
+- **[Bugs resolved](release-notes/5.9.1.md#bugs)**
+- **[Credits](release-notes/5.9.1.md#credits)**
+- **[Feedback](release-notes/5.9.1.md#feedback)**
+
+## CiviCRM 5.9.0
Released January 2, 2019
- **[Credits](release-notes/5.9.0.md#credits)**
- **[Feedback](release-notes/5.9.0.md#feedback)**
+## CiviCRM 5.8.2
+
+Released December 17, 2018
+
+- **[Synopsis](release-notes/5.8.2.md#synopsis)**
+- **[Bugs resolved](release-notes/5.8.2.md#bugs)**
+- **[Credits](release-notes/5.8.2.md#credits)**
+- **[Feedback](release-notes/5.8.2.md#feedback)**
+
+## CiviCRM 5.8.1
+
+Released December 12, 2018
+
+- **[Synopsis](release-notes/5.8.1.md#synopsis)**
+- **[Bugs resolved](release-notes/5.8.1.md#bugs)**
+- **[Credits](release-notes/5.8.1.md#credits)**
+- **[Feedback](release-notes/5.8.1.md#feedback)**
+
## CiviCRM 5.8.0
Released December 5, 2018
- **[Credits](release-notes/5.8.0.md#credits)**
- **[Feedback](release-notes/5.8.0.md#feedback)**
-# CiviCRM 5.7.2
+## CiviCRM 5.7.2
Released November 20, 2018
--- /dev/null
+# CiviCRM 5.10.0
+
+Released February 6, 2019
+
+- **[Synopsis](#synopsis)**
+- **[Features](#features)**
+- **[Bugs resolved](#bugs)**
+- **[Miscellany](#misc)**
+- **[Credits](#credits)**
+- **[Feedback](#feedback)**
+
+## <a name="synopsis"></a>Synopsis
+
+| *Does this version...?* | |
+|:--------------------------------------------------------------- |:-------:|
+| Fix security vulnerabilities? | no |
+| Change the database schema? | no |
+| **Alter the API?** | **yes** |
+| Require attention to configuration options? | no |
+| **Fix problems installing or upgrading to a previous version?** | **yes** |
+| **Introduce features?** | **yes** |
+| **Fix bugs?** | **yes** |
+
+## <a name="features"></a>Features
+
+### Core CiviCRM
+
+- **Support custom-data sub-type on entity-form (for activity/relationship types)
+ ([13311](https://github.com/civicrm/civicrm-core/pull/13311))**
+
+ This change makes it so that users can see and edit custom data for entity
+ sub-types (like activity types and relationship types).
+
+- **[dev/translation#13](https://lab.civicrm.org/dev/translation/issues/13)
+ Language switcher for all
+ ([13240](https://github.com/civicrm/civicrm-core/pull/13240))**
+
+ This change introduces a new setting to the settings page for Localization "UI
+ Languages" for users in monolingual mode (not using multilingual). Configuring
+ this setting results in the Language Switcher block being shown (same as in
+ multilingual mode).
+
+- **[dev/core#561](https://lab.civicrm.org/dev/core/issues/561) Replace
+ jcalendar instances with datepicker
+ ([13241](https://github.com/civicrm/civicrm-core/pull/13241) and
+ [13299](https://github.com/civicrm/civicrm-core/pull/13299)) -- CONTINUED
+ WORK**
+
+ These changes update the Scheduled Reminders Form and the Activity date and
+ case start date fields to use the new datepicker widget.
+
+- **Improved support for case variability in UF API calls.
+ ([13343](https://github.com/civicrm/civicrm-core/pull/13343))**
+
+ This change makes it so that the API will accept "UFgroup" and "ufgroup" as
+ the entity.
+
+- **Optimize CRM_Utils_String::ellipsify() method
+ ([13347](https://github.com/civicrm/civicrm-core/pull/13347))**
+
+ This change improves performance for the function that truncates a string and
+ adds an ellipsis on the end.
+
+### CiviCase
+
+- **[dev-core#564](https://lab.civicrm.org/dev/core/issues/564) Differentiate
+ case relationships in Contact Summary page
+ ([13189](https://github.com/civicrm/civicrm-core/pull/13189))**
+
+ On the Relationship tab of a contact, this change adds a case icon for each
+ case relationship to denote that the relationship is related to a case. This
+ icon is linked to the case so one can easily access the case from the
+ relationship.
+
+- **Cache case count when getting list of cases so query is executed once
+ instead of three times
+ ([13368](https://github.com/civicrm/civicrm-core/pull/13368))**
+
+ This change improves performance on the Case Dashboard when listing cases.
+
+### CiviContribute
+
+- **Add default of TRUE for is_active on PaymentProcessor.create api.
+ ([13291](https://github.com/civicrm/civicrm-core/pull/13291))**
+
+ This change makes it so that when using the API with the entity Payment
+ Processor and the action create, the parameter "is_active" defaults to TRUE
+ like the UFGroup, CustomGroup, ComtributionPage entities do.
+
+## <a name="bugs"></a>Bugs resolved
+
+### Core CiviCRM
+
+- **[dev/core#695](https://lab.civicrm.org/dev/core/issues/695) Custom Search
+ results selection failure and
+ [dev/core#679](https://lab.civicrm.org/dev/core/issues/679) Groups and Tags
+ affect search results when using Search Builder
+ ([13533](https://github.com/civicrm/civicrm-core/pull/13533))**
+
+ This resolves some search regressions introduced in 5.9.0 relating to caching
+ and custom searches.
+
+- **[dev/core#192](https://lab.civicrm.org/dev/core/issues/192) - Search builder
+ fails for != smart group filter
+ ([12344](https://github.com/civicrm/civicrm-core/pull/12344))**
+
+ This change makes it so that when using the Search Builder with a filter
+ "Contacts -> Group -> !- -> Smart group" the != operator is respected.
+
+- **[dev/core#485](https://lab.civicrm.org/dev/core/issues/485) New
+ Organization's profile: From time to time data in the field "Website" is
+ deleted if nothing choose in the drop-down "Website Type"
+ ([13170](https://github.com/civicrm/civicrm-core/pull/13170))**
+
+ This change fixes a bug when editing a contact where if a user enters a
+ Website but no Website Type, the Website was not saved, so that the website is
+ saved.
+
+- **[dev/core#491](https://lab.civicrm.org/dev/core/issues/491) Report results
+ don't show inactive campaigns
+ ([13380](https://github.com/civicrm/civicrm-core/pull/13380),
+ [13321](https://github.com/civicrm/civicrm-core/pull/13321),
+ [13341](https://github.com/civicrm/civicrm-core/pull/13341),
+ [13281](https://github.com/civicrm/civicrm-core/pull/13281),
+ [13231](https://github.com/civicrm/civicrm-core/pull/13231),
+ [13243](https://github.com/civicrm/civicrm-core/pull/13243),
+ [13358](https://github.com/civicrm/civicrm-core/pull/13358),
+ [13379](https://github.com/civicrm/civicrm-core/pull/13379),
+ [13376](https://github.com/civicrm/civicrm-core/pull/13376),
+ [13356](https://github.com/civicrm/civicrm-core/pull/13356),
+ [13348](https://github.com/civicrm/civicrm-core/pull/13348) and
+ [13351](https://github.com/civicrm/civicrm-core/pull/13351))**
+
+ This change updates the following reports: Member Summary, Pledged but not
+ Paid, SYBUNT, Member Detail, Participant Listing, Pledge Detail, Contribution
+ (org), Household Summary, and Soft Credit to include a filter for active vs
+ disabled campaigns and generally simplifies the campaign related code on these
+ reports.
+
+- **[dev/core#592](https://lab.civicrm.org/dev/core/issues/592)
+ ArgumentCountError: Too few arguments to function CiviCRM_API3_Exception...
+ ([13263](https://github.com/civicrm/civicrm-core/pull/13263))**
+
+ This change fixes a bug where an "ArgumntCountError" was being thrown whenever
+ an error was thrown so that only the error is thrown.
+
+- **[dev/core#610](https://lab.civicrm.org/dev/core/issues/610) Page title
+ displays twice if the activity type is set in Activity form
+ ([13339](https://github.com/civicrm/civicrm-core/pull/13339))**
+
+ This change ensures that on the new or edit activity form the title is only
+ shown once. Before this change if the Activity Type was set the title would
+ show up twice.
+
+- **[dev/core#622](https://lab.civicrm.org/dev/core/issues/622) User Dashboard
+ doesn't show Edit Contact Information link
+ ([13375](https://github.com/civicrm/civicrm-core/pull/13375))**
+
+ This change makes it so that the Edit Contact information link displays on the
+ User Dashboard.
+
+- **[dev/core#660](https://lab.civicrm.org/dev/core/issues/660) Fatal DB Error:
+ already exists on event registration/contribution pages when profile has user
+ creation ([13451](https://github.com/civicrm/civicrm-core/pull/13451))**
+
+ This change fixes a bug where if Anonymous users have ACLs to see a contact
+ they cannot register for an event so that Anonymous users with ACLs to se a
+ contact can register for events.
+
+- **Fix PHP 7.2 countable warning
+ ([13414](https://github.com/civicrm/civicrm-core/pull/13414))**
+
+- **Bump Minimum Required PHP to be 5.6
+ ([13309](https://github.com/civicrm/civicrm-core/pull/13309))**
+
+- **Fix PHP 7 strict warnings CRM_Core_DAO::getContactIDsFromComponent passed by
+ reference ([13295](https://github.com/civicrm/civicrm-core/pull/13295))**
+
+- **Generalise the UsersTableName Setting name to support Backdrop
+ ([13292](https://github.com/civicrm/civicrm-core/pull/13292))**
+
+- **Fix duplicate merge to not disregard zero values.
+ ([12669](https://github.com/civicrm/civicrm-core/pull/12669))**
+
+- **Search Builder fails with an error when searching for State if the location
+ type differs from the display name.
+ ([13313](https://github.com/civicrm/civicrm-core/pull/13313))**
+
+- **Installer: PHP 7.2 compatibility fixes
+ ([13326](https://github.com/civicrm/civicrm-core/pull/13326))**
+
+ This change fixes some php countable warnings thrown for users installing
+ using PHP 7.2.
+
+- **Export merge to household - fix DB error relating to fields too long for
+ table. ([13338](https://github.com/civicrm/civicrm-core/pull/13338))**
+
+ This change fixes a fatal error when trying to combine/merge households and
+ 'primary fields' on some mysql configs
+
+- **Fix notice on first loading activity search form
+ ([13378](https://github.com/civicrm/civicrm-core/pull/13378))**
+
+- **Fix verbiage for Edit Contact Information title
+ ([13352](https://github.com/civicrm/civicrm-core/pull/13352))**
+
+ On the User Dashboard this changes updates the link to edit a users contact
+ from "Edit Relationship" to "Edit Contact Information".
+
+- **Fix verbiage for Dashboard title
+ ([13349](https://github.com/civicrm/civicrm-core/pull/13349))**
+
+ This change updates the "User Dashboard" "Relationships" section Dashboard
+ links to use the title "Dashboard" instead of "Edit Relationship".
+
+### CiviCase
+
+- **[dev/core#454](https://lab.civicrm.org/dev/core/issues/454) CiviCase access
+ to activities permission discrepancy
+ ([12995](https://github.com/civicrm/civicrm-core/pull/12995))**
+
+ This change standardizes the permissioning of CiviCase so that users with the
+ permission "access my cases and activities" or "access all cases and
+ activities" can view appropriate case activities. Before this change the
+ permissions needed to view case activities were inconsistent.
+
+- **[dev/core#603](https://lab.civicrm.org/dev/core/issues/603) DB error on Case
+ Summary report ([13296](https://github.com/civicrm/civicrm-core/pull/13296))**
+
+ This fixes a bug where running the Case Summary Report with no changes to the
+ default settigns would result in a warning message so that the default
+ settings for the Case Summary Report result in the report running as expected.
+
+- **[dev/core#625](https://lab.civicrm.org/dev/core/issues/625) DB error on Case
+ Summary report ([13359](https://github.com/civicrm/civicrm-core/pull/13359))**
+
+ This change fixes a bug in the Case Summary Report where running the report
+ without the Columns "Staff Member" and "Relationship" but with a filter on
+ "Active Relationships?" resulted in a DB Error so that one can run this report
+ with this configuration.
+
+- **Fix broken case activity date filter
+ ([13449](https://github.com/civicrm/civicrm-core/pull/13449))**
+
+ This change fixes a bug on the Case Summary Screen where searching activities
+ using the Activity Date filters (From or To) would result in a database error.
+
+- **Standardize letter case
+ ([13245](https://github.com/civicrm/civicrm-core/pull/13245))**
+
+ This change updates the text for the Case Task "Print/merge Document" to
+ "Print/merge document".
+
+- **Revert to showing overdue activities on a case first
+ ([13360](https://github.com/civicrm/civicrm-core/pull/13360))**
+
+- **Don't crash with missing class if action is not defined when opening new
+ case ([13336](https://github.com/civicrm/civicrm-core/pull/13336))**
+
+### CiviContribute
+
+- **[dev/core#680](https://lab.civicrm.org/dev/core/issues/680) "Date Received"
+ for contributions no longer mandatory, also breaks financial transactions
+ ([13537](https://github.com/civicrm/civicrm-core/pull/13537))**
+
+- **[dev/core#651](https://lab.civicrm.org/dev/core/issues/651) Error exporting
+ contributions with soft credits
+ ([13536](https://github.com/civicrm/civicrm-core/pull/13536))**
+
+- **[dev/core#620](https://lab.civicrm.org/dev/core/issues/620) Unable to show
+ custom fields on Repeat Contributions Report
+ ([13350](https://github.com/civicrm/civicrm-core/pull/13350))**
+
+ This change fixes a bug where selecting a custom field column on a Repeat
+ Contributions report would result in an error so that one can use a custom
+ field as a column in a Repeat Contributions report.
+
+- **[dev/core#621](https://lab.civicrm.org/dev/core/issues/621) Price field
+ option 9 Decimal Places in GUI
+ ([13355](https://github.com/civicrm/civicrm-core/pull/13355))**
+
+ This change makes it so that the "Option Amount" field on the "Edit Price
+ Option" form shows only two decimal places, before this change it showed 9
+ decimal places.
+
+- **Unable to mark price set field as inactive
+ ([13257](https://github.com/civicrm/civicrm-core/pull/13257))**
+
+ This change ensures that when on the "Edit Price Field" form one can save
+ changes to the "Active?" field.
+
+- **Display self-service links in email receipts based on payment processor
+ capabilities ([13215](https://github.com/civicrm/civicrm-core/pull/13215))**
+
+- **On the Contribution Detail Report link the Amount field to the contribution
+ ([13316](https://github.com/civicrm/civicrm-core/pull/13316))**
+
+- **Declare 'amount' as required on ContributionRecur api
+ ([13290](https://github.com/civicrm/civicrm-core/pull/13290))**
+
+### CiviEvent
+
+- **[dev/core#653](https://lab.civicrm.org/dev/core/issues/653) New Events
+ defaulting to event template after first page
+ ([13478](https://github.com/civicrm/civicrm-core/pull/13478))**
+
+ This resolves a regression introduced in 5.9.0 where creating a new event would
+ instead create a new event template.
+
+### CiviMail
+
+- **[dev/report#5](CANNOT FIND THIS GITLAB ISSUE) - Fix mailing report unique
+ count issue ([13322](https://github.com/civicrm/civicrm-core/pull/13322))**
+
+ This fixes the count when viewing the report of Unique Opens for a Mailing.
+
+- **[dev/mail#35](https://lab.civicrm.org/dev/mail/issues/35) Public View link
+ does not show from Scheduled and Sent screen
+ ([13354](https://github.com/civicrm/civicrm-core/pull/13354))**
+
+ This change makes it so that one can click the Public View url on the
+ Scheduled and Sent mailing screen.
+
+- **[dev/core#623](https://lab.civicrm.org/dev/core/issues/623)
+ civicrm_mailing_bounce_type.threshold = 30 for 'Away' is that correct?
+ ([13366](https://github.com/civicrm/civicrm-core/pull/13366) and
+ [13362](https://github.com/civicrm/civicrm-core/pull/13362))**
+
+ This change ensures that the CiviMail mailing bounce threshold for bounces of
+ the type "Away" is set to be 30, prior to this change some instances had the
+ threshold set to 3.
+
+### Joomla Integration
+
+- **[dev/joomla#3](https://lab.civicrm.org/dev/joomla/issues/3) Recipients are
+ not shown when creating / editing mailings
+ ([13294](https://github.com/civicrm/civicrm-core/pull/13294))**
+
+### Wordpress Integration
+
+- **[dev/wordpress#16](https://lab.civicrm.org/dev/wordpress/issues/16) Fatal
+ error with some versions of PHP
+ ([143](https://github.com/civicrm/civicrm-wordpress/pull/143))**
+
+ This fixes a bug where installing the CiviCRM plugin on a Wordpress
+ site using PHP 7.2.12 would result in a fatal error.
+
+## <a name="misc"></a>Miscellany
+
+- **(NFC) Fix PHP7.2 Count error on test testImportParserWtihEmployeeOfRelation…
+ ([13247](https://github.com/civicrm/civicrm-core/pull/13247))**
+
+- **(NFC) Update Copyright in FiveTen upgrade file to be 2019
+ ([13268](https://github.com/civicrm/civicrm-core/pull/13268))**
+
+- **(NFC) Just some additional package metadata
+ ([13293](https://github.com/civicrm/civicrm-core/pull/13293))**
+
+- **(NFC) Improved documentation of crmPageTitle directive.
+ ([13337](https://github.com/civicrm/civicrm-core/pull/13337))**
+
+- **(NFC) Minor tweaks to docblocks on opencase form
+ ([13335](https://github.com/civicrm/civicrm-core/pull/13335))**
+
+- **Unit test for PR#12699
+ ([13323](https://github.com/civicrm/civicrm-core/pull/13323))**
+
+- **Add in unit test to support changes in UF API in PR 13343
+ ([13344](https://github.com/civicrm/civicrm-core/pull/13344))**
+
+- **(NFC) Tidy up comments, remove unused variables in customfield classes
+ ([13367](https://github.com/civicrm/civicrm-core/pull/13367))**
+
+- **Simplify handling for case checking.
+ ([13372](https://github.com/civicrm/civicrm-core/pull/13372))**
+
+- **[REF] Extract internals of Payment.create into function on BAO class.
+ ([13370](https://github.com/civicrm/civicrm-core/pull/13370))**
+
+- **[REF] Simplify CRM_Activity_BAO_Activity function by using early returns
+ ([13371](https://github.com/civicrm/civicrm-core/pull/13371))**
+
+- **[REF] Genericise function to add pseudoconstant data to fields to process
+ ([13328](https://github.com/civicrm/civicrm-core/pull/13328))**
+
+- **[REF] Add caching to function to determine if activity type is permitted.
+ ([13329](https://github.com/civicrm/civicrm-core/pull/13329))**
+
+- **[REF] Export add test for phone details, fix phone_type_id
+ ([13275](https://github.com/civicrm/civicrm-core/pull/13275))**
+
+- **[REF] Minor test clean up
+ ([13269](https://github.com/civicrm/civicrm-core/pull/13269))**
+
+- **[REF] Export cleanup - filter at point of query on postal exports
+ ([13216](https://github.com/civicrm/civicrm-core/pull/13216))**
+
+- **[REF] Build single array of information about output specifications when
+ exporting ([13213](https://github.com/civicrm/civicrm-core/pull/13213))**
+
+## <a name="credits"></a>Credits
+
+This release was developed by the following code authors:
+
+AGH Strategies - Alice Frumin, Andrew Hunt, Eli Lisseck; Andrew Thompson;
+Australian Greens - Seamus Lee; Christian Wach; CiviCoop - Klaas Eikelboom;
+CiviCRM - Coleman Watts, Tim Otten; CiviDesk - Sunil Pawar, Yashodha Chaku;
+CompuCorp - Davi Alexandre, Vinu Varshith Sekar; Coop SymbioTIC - Mathieu Lutfy;
+Electronic Frontier Foundation - Mark Burdett; Francesc Bassas i Bullich; Fuzion -
+Jitendra Purohit; Ginkgo Street Labs - Frank Gómez; iXiam - Luciano Spiegel;
+JMA Consulting - Monish Deb; MillerTech - Chamil Wijesooriya; MJW Consulting -
+Matthew Wire; Ray Wright; Squiffle Consulting - Aidan Saunders; Tadpole
+Collective - Kevin Cristiano; Veda Consulting - Mathavan Veeramuthu; Wikimedia
+Foundation - Eileen McNaughton
+
+Most authors also reviewed code for this release; in addition, the following
+reviewers contributed their comments:
+
+Blackfly Solutions - Alan Dixon; Circle Interactive - Dave Jenkins; Fuzion -
+Peter Davis; JMA Consulting - Joe Murray; John Kingsnorth; Joinery - Allen Shaw;
+Lighthouse Design and Consulting - Brian Shaughnessy; Megaphone Technology
+Consulting - Jon Goldberg; Nicol Wistreich; Richard van Oosterhout; Skvare -
+Mark Hanna; Systopia - Björn Endres
+
+## <a name="feedback"></a>Feedback
+
+These release notes are edited by Alice Frumin and Andrew Hunt. If you'd like
+to provide feedback on them, please log in to https://chat.civicrm.org/civicrm
+and contact `@agh1`.
--- /dev/null
+# CiviCRM 5.10.1
+
+Released February 12, 2019
+
+- **[Synopsis](#synopsis)**
+- **[Bugs resolved](#bugs)**
+- **[Credits](#credits)**
+- **[Feedback](#feedback)**
+
+## <a name="synopsis"></a>Synopsis
+
+| *Does this version...?* | |
+|:--------------------------------------------------------------- |:-------:|
+| Fix security vulnerabilities? | no |
+| Change the database schema? | no |
+| Alter the API? | no |
+| Require attention to configuration options? | no |
+| Fix problems installing or upgrading to a previous version? | no |
+| Introduce features? | no |
+| **Fix bugs?** | **yes** |
+
+## <a name="bugs"></a>Bugs resolved
+
+- **[13570](https://github.com/civicrm/civicrm-core/pull/13570) Fix Regression
+ where recieve date field being required broke backend credit card contribution
+ form**
+
+ To fix another problem the receive date field was made a required field, this
+ subsequently broke the back office credit card form as the receive date isn't
+ exposed on that form.
+
+## <a name="credits"></a>Credits
+
+This release was developed by the following authors and reviewers:
+
+Wikimedia Foundation - Eileen McNaughton; CiviCRM - Tim
+Otten; Australian Greens - Seamus Lee
+
+## <a name="feedback"></a>Feedback
+
+These release notes are edited by Tim Otten and Andrew Hunt. If you'd like to
+provide feedback on them, please login to https://chat.civicrm.org/civicrm and
+contact `@agh1`.
--- /dev/null
+# CiviCRM 5.10.2
+
+Released February 14, 2019
+
+- **[Synopsis](#synopsis)**
+- **[Bugs resolved](#bugs)**
+- **[Credits](#credits)**
+- **[Feedback](#feedback)**
+
+## <a name="synopsis"></a>Synopsis
+
+| *Does this version...?* | |
+|:--------------------------------------------------------------- |:-------:|
+| Fix security vulnerabilities? | no |
+| Change the database schema? | no |
+| Alter the API? | no |
+| Require attention to configuration options? | no |
+| Fix problems installing or upgrading to a previous version? | no |
+| Introduce features? | no |
+| **Fix bugs?** | **yes** |
+
+## <a name="bugs"></a>Bugs resolved
+
+- **([dev/core#681](https://lab.civicrm.org/dev/core/issues/681)) CiviCase - Fatal error
+ submitting "Change Case Status" form
+ ([13595](https://github.com/civicrm/civicrm-core/pull/13595))**
+
+ There was a fatal error generated when submitting the change case status form
+ because the end_date was not properly converted to MySQL date format.
+
+- **([dev/core#721](https://lab.civicrm.org/dev/core/issues/721)) ACLs - Fix regression
+ on rebuilding smart group caches when ACLs are used
+ ([13597](https://github.com/civicrm/civicrm-core/pull/13597))**
+
+ Fixed a recent regression whereby ability to see contacts permissioned by an
+ ACL over a smart group depended on the freshness of the group cache.
+
+- **([dev/core#715](https://lab.civicrm.org/dev/core/issues/715)) Relationships - Fix regression
+ preventing deletion of relationship types in UI.
+ ([13590](https://github.com/civicrm/civicrm-core/pull/13590))**
+
+ Fixed a recent regression whereby ability to delete a relationship type
+ from the user interface was broken.
+
+## <a name="credits"></a>Credits
+
+This release was developed by the following authors and reviewers:
+
+Wikimedia Foundation - Eileen McNaughton; MJW Consulting - Matthew Wire; Fuzion - Jitendra Purohit;
+CiviCRM - Mathieu Luffy and Coleman Watts; Australian Greens - Seamus Lee
+
+## <a name="feedback"></a>Feedback
+
+These release notes are edited by Tim Otten and Andrew Hunt. If you'd like to
+provide feedback on them, please login to https://chat.civicrm.org/civicrm and
+contact `@agh1`.
--- /dev/null
+# CiviCRM 5.10.3
+
+Released February 20, 2019
+
+- **[Synopsis](#synopsis)**
+- **[Security advisories](#security)**
+- **[Bugs resolved](#bugs)**
+- **[Feedback](#feedback)**
+
+## <a name="synopsis"></a>Synopsis
+
+| *Does this version...?* | |
+|:--------------------------------------------------------------- |:-------:|
+| **Fix security vulnerabilities?** | **yes** |
+| Change the database schema? | no |
+| Alter the API? | no |
+| Require attention to configuration options? | no |
+| Fix problems installing or upgrading to a previous version? | no |
+| Introduce features? | no |
+| **Fix bugs?** | **yes** |
+
+## <a name="security"></a>Security advisories
+- **[CIVI-SA-2019-01](https://civicrm.org/advisory/civi-sa-2019-01-weak-access-control-for-file-attachments)**:
+ Weak access-control for file attachments
+- **[CIVI-SA-2019-02](https://civicrm.org/advisory/civi-sa-2019-02-sqli-in-prevnext-cache)**:
+ SQL Injection in "PrevNext" Cache
+- **[CIVI-SA-2019-03](https://civicrm.org/advisory/civi-sa-2019-03-xss-in-logging-details-report)**:
+ Cross-Site Scripting in "Logging Details" Report
+- **[CIVI-SA-2019-04](https://civicrm.org/advisory/civi-sa-2019-04-sqli-in-group-tag-filters)**:
+ SQL Injection in Group and Tag Filters
+- **[CIVI-SA-2019-05](https://civicrm.org/advisory/civi-sa-2019-05-xss-in-new-pledge-form)**:
+ Cross-Site Scripting in "New Pledge" Form
+- **[CIVI-SA-2019-06](https://civicrm.org/advisory/civi-sa-2019-06-xss-in-contact-entity-reference-fields)**:
+ Cross-Site Scripting in Contact Reference Fields
+- **[CIVI-SA-2019-07](https://civicrm.org/advisory/civi-sa-2019-07-limit-cross-domain-execution-by-jquery)**:
+ Limit Cross-Domain Execution by jQuery
+
+## <a name="bugs"></a>Bugs resolved
+
+### Core CiviCRM
+
+- **[dev/core#695](https://lab.civicrm.org/dev/core/issues/695) Custom Search
+ results selection failure and
+ [dev/core#679](https://lab.civicrm.org/dev/core/issues/679) Groups and Tags
+ affect search results when using Search Builder
+ ([13533](https://github.com/civicrm/civicrm-core/pull/13533))**
+
+ This resolves some search regressions introduced in 5.9.0 relating to caching
+ and custom searches.
+
+- **[dev/core#737](https://lab.civicrm.org/dev/core/issues/737) Mass SMS not
+ sent when send time is set to immediately
+ ([13641](https://github.com/civicrm/civicrm-core/pull/13641))**
+
+ This resolves an issue where if you selected to send a Bulk SMS immediately
+ it would not be sent because the scheduled date was set to NULL rather than
+ the current date and time.
+
+## <a name="feedback"></a>Feedback
+
+Security release notes are edited by Seamus Lee and Tim Otten, and release
+notes generally are edited by Andrew Hunt. If you'd like to provide
+feedback on them, please login to https://chat.civicrm.org/civicrm and
+contact `@agh1`.
--- /dev/null
+# CiviCRM 5.10.4
+
+Released February 22, 2019
+
+- **[Synopsis](#synopsis)**
+- **[Bugs resolved](#bugs)**
+- **[Credits](#credits)**
+- **[Feedback](#feedback)**
+
+## <a name="synopsis"></a>Synopsis
+
+| *Does this version...?* | |
+|:--------------------------------------------------------------- |:-------:|
+| Fix security vulnerabilities? | no |
+| Change the database schema? | no |
+| Alter the API? | no |
+| Require attention to configuration options? | no |
+| Fix problems installing or upgrading to a previous version? | no |
+| Introduce features? | no |
+| **Fix bugs?** | **yes** |
+
+## <a name="bugs"></a>Bugs resolved
+
+- **([dev/core#747](https://lab.civicrm.org/dev/core/issues/747)) Cannot
+ load contact images on contact screen following security release
+ ([13679](https://github.com/civicrm/civicrm-core/pull/13679))**
+
+ Following the security release, loading of images on the contact summary
+ screen broke due to the removal of handling of the filename url parameter
+
+- **([dev/report#10](https://lab.civicrm.org/dev/report/issues/10)) Pagination
+ doesn't work on the contribution detail report
+ ([13677](https://github.com/civicrm/civicrm-core/pull/13677))**
+
+ Fixed a recent regression where the pagination on the contribution detail report
+ broke.
+
+- **([dev/core#746](https://lab.civicrm.org/dev/core/issues/746)) Search Builder - Fix
+ regression when > 1 smart group where clauses were used
+ ([13667](https://github.com/civicrm/civicrm-core/pull/13667))**
+
+ Fixed a recent regression whereby if you had > 1 where clauses involving groups
+ and the groups were smart groups it wouldn't return the correct results
+
+
+## <a name="credits"></a>Credits
+
+This release was developed by the following authors and reviewers:
+
+Wikimedia Foundation - Eileen McNaughton; Fuzion - Jitendra Purohit;
+Semper IT - Karin Gerritsen; CiviCRM - Tim Otten;
+Australian Greens - Seamus Lee; Blackfly Solutions - Alan Dixon;
+Megaphone Technology Consulting - Jon Goldberg;
+
+## <a name="feedback"></a>Feedback
+
+These release notes are edited by Tim Otten and Andrew Hunt. If you'd like to
+provide feedback on them, please login to https://chat.civicrm.org/civicrm and
+contact `@agh1`.
--- /dev/null
+# CiviCRM 5.9.1
+
+Released January 16, 2018
+
+- **[Synopsis](#synopsis)**
+- **[Bugs resolved](#bugs)**
+- **[Credits](#credits)**
+- **[Feedback](#feedback)**
+
+## <a name="synopsis"></a>Synopsis
+
+| *Does this version...?* | |
+|:--------------------------------------------------------------- |:-------:|
+| Fix security vulnerabilities? | no |
+| **Change the database schema?** | **yes** |
+| Alter the API? | no |
+| Require attention to configuration options? | no |
+| Fix problems installing or upgrading to a previous version? | no |
+| Introduce features? | no |
+| **Fix bugs?** | **yes** |
+
+## <a name="bugs"></a>Bugs resolved
+
+- **[dev/core#660](https://lab.civicrm.org/dev/core/issues/660) Fatal DB Error:
+ already exists on event registration/contribution pages when profile has user
+ creation ([Backport
+ 13451](https://github.com/civicrm/civicrm-core/pull/13451))**
+
+ In CiviContribute and CiviEvent, this fixes a crash on the payment page
+ affecting anonymous users in certain ACL configurations. The change relaxes a
+ foreign-key constraint.
+
+- **Fix broken case activity date filter #13449
+ ([Backport 13449](https://github.com/civicrm/civicrm-core/pull/13449))**
+
+## <a name="credits"></a>Credits
+
+This release was developed by the following authors and reviewers:
+
+Wikimedia Foundation - Eileen McNaughton; Nicol Wistreich; CiviCRM - Tim
+Otten, Coleman Watts; Circle Interactive - Dave Jenkins; Australian Greens -
+Seamus Lee
+
+## <a name="feedback"></a>Feedback
+
+These release notes are edited by Tim Otten and Andrew Hunt. If you'd like to
+provide feedback on them, please login to https://chat.civicrm.org/civicrm and
+contact `@agh1`.
'html_attributes' => array(
//'class' => 'crm-select2',
),
- 'default' => '1228',
'add' => '4.4',
'title' => 'Default Country',
'is_domain' => 1,
'is_contact' => 0,
+ 'is_required' => FALSE,
'description' => 'This value is selected by default when adding a new contact address.',
'help_text' => NULL,
'pseudoconstant' => array(
'title' => ts('Multisite Domain Group'),
'type' => 'Integer',
'html_type' => 'entity_reference',
- 'entity_reference_options' => ['entity' => 'group', 'select' => array('minimumInputLength' => 0)],
+ 'entity_reference_options' => ['entity' => 'Group', 'select' => array('minimumInputLength' => 0)],
'default' => '0',
'add' => '4.1',
'is_domain' => 1,
LOCK TABLES `civicrm_domain` WRITE;
/*!40000 ALTER TABLE `civicrm_domain` DISABLE KEYS */;
-INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `config_backend`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES (1,'Default Domain Name',NULL,NULL,'5.11.alpha1',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}');
+INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `config_backend`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES (1,'Default Domain Name',NULL,NULL,'5.12.alpha1',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}');
/*!40000 ALTER TABLE `civicrm_domain` ENABLE KEYS */;
UNLOCK TABLES;
{/if}
<div class="crm-block crm-form-block crm-activity-form-block">
{/if}
- {* added onload javascript for source contact*}
- {include file="CRM/Activity/Form/ActivityJs.tpl" tokenContext="activity"}
{if !$action or ( $action eq 1 ) or ( $action eq 2 ) }
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
{/if}
{/if}
<tr class="crm-activity-form-block-subject">
- <td class="label">{$form.subject.label}</td><td class="view-value">{$form.subject.html|crmAddClass:huge}</td>
+ <td class="label">{$form.subject.label}</td><td class="view-value">{$form.subject.html}</td>
</tr>
{* CRM-7362 --add campaign to activities *}
{if $action neq 8 and $action neq 32768 }
{* Include form buttons on top for new and edit modes. *}
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
-
- {* added onload javascript for source contact*}
- {include file="CRM/Activity/Form/ActivityJs.tpl" tokenContext="case_activity"}
-
{/if}
{if $action eq 8 or $action eq 32768 }
call_user_func(array('CRM_Core_Permission','check'), 'add cases') ) AND
$allowToAddNewCase}
<div class="action-link">
- <a accesskey="N" href="{$newCaseURL}" class="button"><span><i class="crm-i fa-plus-circle"></i> {ts}Add Case{/ts}</span></a>
+ <a accesskey="N" href="{$newCaseURL}" class="button no-popup"><span><i class="crm-i fa-plus-circle"></i> {ts}Add Case{/ts}</span></a>
</div>
{/if}
<p>{ts}Upload a photo or icon that you want to be displayed when viewing this contact.{/ts}</p>
{/htxt}
-{htxt id="id-internal-id-title"}
+{htxt id="id-contact-id-title"}
{ts}Contact ID{/ts}
{/htxt}
-{htxt id="id-internal-id"}
+{htxt id="id-contact-id"}
<p>{ts}Every contact in CiviCRM has a unique ID number. This number will never change and is the most accurate way of identifying a contact.{/ts}</p>
{/htxt}
</td>
{if $contactId}
<td>
- <label for="internal_identifier_display">{ts}Contact ID{/ts} {help id="id-internal-id"}</label><br />
+ <label for="internal_identifier_display">{ts}Contact ID{/ts} {help id="id-contact-id"}</label><br />
<input id="internal_identifier_display" type="text" class="crm-form-text six" size="6" readonly="readonly" value="{$contactId}">
</td>
{/if}
<td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`"}">{$row.sort_name}</a></td>
{/if}
<td class="crm-contribution-amount">
- {if !$row.contribution_soft_credit_amount}
<a class="nowrap bold crm-expand-row" title="{ts}view payments{/ts}" href="{crmURL p='civicrm/payment' q="view=transaction&component=contribution&action=browse&cid=`$row.contact_id`&id=`$row.contribution_id`&selector=1"}">
{$row.total_amount|crmMoney:$row.currency}
</a>
- {/if}
{if $row.amount_level }<br/>({$row.amount_level}){/if}
{if $row.contribution_recur_id}<br/>{ts}(Recurring){/ts}{/if}
</td>
- {if $softCreditColumns}
- <td class="right bold crm-contribution-soft_credit_amount">
- <span class="nowrap">{$row.contribution_soft_credit_amount|crmMoney:$row.currency}</span>
- </td>
- {/if}
{foreach from=$columnHeaders item=column}
{assign var='columnName' value=$column.field_name}
{if !$columnName}{* if field_name has not been set skip, this helps with not changing anything not specifically edited *}
{if $contributionSummary }
<tr>
{if $contributionSummary.total.amount}
- {if $contributionSummary.total.currencyCount gt 1}
- <th class="contriTotalLeft right">{ts}Total{/ts} – {$contributionSummary.total.amount}</th>
- <th class="left contriTotalRight"> {ts}# Completed{/ts} – {$contributionSummary.total.count}</th>
- </tr><tr>
- <th class="contriTotalLeft">{ts}Avg{/ts} – {$contributionSummary.total.avg}</th>
- <th class="right"> {ts}Median{/ts} – {$contributionSummary.total.median}</th>
- <th class="right contriTotalRight"> {ts}Mode{/ts} – {$contributionSummary.total.mode}</th>
- {else}
- <th class="contriTotalLeft right">{ts}Total{/ts} – {$contributionSummary.total.amount}</th>
- <th class="right"> {ts}# Completed{/ts} – {$contributionSummary.total.count}</th>
- <th class="right"> {ts}Avg{/ts} – {$contributionSummary.total.avg}</th>
- <th class="right"> {ts}Median{/ts} – {$contributionSummary.total.median}</th>
- <th class="right contriTotalRight"> {ts}Mode{/ts} – {$contributionSummary.total.mode}</th>
- {/if}
+ <th class="contriTotalLeft right">{ts}Total{/ts} – {$contributionSummary.total.amount}</th>
+ <th class="right"> {ts}# Completed{/ts} – {$contributionSummary.total.count}</th>
+ <th class="right contriTotalRight"> {ts}Avg{/ts} – {$contributionSummary.total.avg}</th>
{/if}
{if $contributionSummary.cancel.amount}
<th class="disabled right contriTotalRight"> {ts}Cancelled/Refunded{/ts} – {$contributionSummary.cancel.amount}</th>
<td>{$row.contribution_status}</td>
{if $invoicing && $invoices}
<td>
+ {* @todo Instead of this tpl handling assign actions as an array attached the row, iterate through - will better accomodate extension overrides and competition for scarce real estate on this page*}
{assign var='id' value=$row.contribution_id}
{assign var='contact_id' value=$row.contact_id}
{assign var='urlParams' value="reset=1&id=$id&cid=$contact_id"}
</td>
{/if}
{if $defaultInvoicePage && $row.contribution_status_name == 'Pending' }
+ {* @todo Instead of this tpl handling assign actions as an array attached the row, iterate through - will better accomodate extension overrides and competition for scarce real estate on this page*}
<td>
{assign var='checksum_url' value=""}
{if $userChecksum}
{/capture}{help id=$help.id file=$help.file}{/if}
{if $action == 2 && $fieldSpec.is_add_translate_dialog}{include file='CRM/Core/I18n/Dialog.tpl' table=$entityTable field=$fieldName id=$entityID}{/if}
</td>
- <td>{$fieldSpec.pre_html_text}{if $form.$fieldName.html}{if $fieldSpec.formatter === 'crmMoney'}{$form.$fieldName.html|crmMoney}{else}{$form.$fieldName.html}{/if}{else}{$fieldSpec.place_holder}{/if}{$fieldSpec.post_html_text}<br />
+ <td>{$fieldSpec.pre_html_text}{if $form.$fieldName.html}{if $fieldSpec.formatter === 'crmMoney'}{$form.$fieldName.html|crmMoney:$fieldSpec.formatterParam}{else}{$form.$fieldName.html}{/if}{else}{$fieldSpec.place_holder}{/if}{$fieldSpec.post_html_text}<br />
{if $fieldSpec.description}<span class="description">{$fieldSpec.description}</span>{/if}
{if $fieldSpec.documentation_link}{docURL page=$fieldSpec.documentation_link.page resource=$fieldSpec.documentation_link.resource}{/if}
</td>
<div class="css_right">
<a class="crm-hover-button action-item" href="{crmURL q="reset=1&update_smart_groups=1"}">{ts}Update Smart Group Counts{/ts}</a> {help id="update_smart_groups"}
</div>
+{if call_user_func(array('CRM_Core_Permission','check'), 'edit groups')}
+ {assign var='editableClass' value='crm-editable'}
+{/if}
<table class="crm-group-selector crm-ajax-table" data-order='[[0,"asc"]]'>
<thead>
<tr>
- <th data-data="title" cell-class="crm-group-name crm-editable crmf-title" class='crm-group-name'>{ts}Name{/ts}</th>
+ <th data-data="title" cell-class="crm-group-name {$editableClass} crmf-title" class='crm-group-name'>{ts}Name{/ts}</th>
<th data-data="count" cell-class="crm-group-count right" class='crm-group-count'>{ts}Count{/ts}</th>
<th data-data="created_by" cell-class="crm-group-created_by" class='crm-group-created_by'>{ts}Created By{/ts}</th>
- <th data-data="description" data-orderable="false" cell-class="crm-group-description crmf-description crm-editable" class='crm-group-description'>{ts}Description{/ts}</th>
+ <th data-data="description" data-orderable="false" cell-class="crm-group-description crmf-description {$editableClass}" class='crm-group-description'>{ts}Description{/ts}</th>
<th data-data="group_type" cell-class="crm-group-group_type" class='crm-group-group_type'>{ts}Group Type{/ts}</th>
- <th data-data="visibility" cell-class="crm-group-visibility crmf-visibility crm-editable" cell-data-type="select" class='crm-group-visibility'>{ts}Visibility{/ts}</th>
+ <th data-data="visibility" cell-class="crm-group-visibility crmf-visibility {$editableClass}" cell-data-type="select" class='crm-group-visibility'>{ts}Visibility{/ts}</th>
{if $showOrgInfo}
<th data-data="org_info" data-orderable="false" cell-class="crm-group-org_info" class='crm-group-org_info'>{ts}Organization{/ts}</th>
{/if}
$.each( response.data, function( i, val ) {
appendHTML += '<tr id="row_'+val.group_id+'_'+parent_id+'" data-entity="group" data-id="'+val.group_id+'" class="crm-entity parent_is_'+parent_id+' crm-row-child">';
if ( val.is_parent ) {
- appendHTML += '<td class="crm-group-name crmf-title ' + levelClass + '">' + '{/literal}<span class="collapsed show-children" title="{ts}show child groups{/ts}"/></span><div class="crmf-title crm-editable" style="display:inline">{literal}' + val.title + '</div></td>';
+ appendHTML += '<td class="crm-group-name crmf-title ' + levelClass + '">' + '{/literal}<span class="collapsed show-children" title="{ts}show child groups{/ts}"/></span><div class="crmf-title {$editableClass}" style="display:inline">{literal}' + val.title + '</div></td>';
}
else {
- appendHTML += '<td class="crm-group-name crmf-title crm-editable ' + levelClass + '"><span class="crm-no-children"></span>' + val.title + '</td>';
+ appendHTML += '<td class="crm-group-name crmf-title {/literal}{$editableClass}{literal} ' + levelClass + '"><span class="crm-no-children"></span>' + val.title + '</td>';
}
appendHTML += '<td class="right">' + val.count + "</td>";
appendHTML += "<td>" + val.created_by + "</td>";
- appendHTML += '<td class="crm-editable crmf-description">' + (val.description || '') + "</td>";
+ appendHTML += '<td class="{/literal}{$editableClass}{literal} crmf-description">' + (val.description || '') + "</td>";
appendHTML += "<td>" + val.group_type + "</td>";
- appendHTML += '<td class="crm-editable crmf-visibility" data-type="select">' + val.visibility + "</td>";
+ appendHTML += '<td class="{/literal}{$editableClass}{literal} crmf-visibility" data-type="select">' + val.visibility + "</td>";
if (showOrgInfo) {
appendHTML += "<td>" + val.org_info + "</td>";
}
</dl>
</div>
{/if}
- <p>{ts 1=$whom_url 2=$whom_name 3=$who_url 4=$who_name 5=$log_date}Change to <a href='%1'>%2</a> made by <a href='%3'>%4</a> on %5:{/ts}</p>
+ <p>{ts 1=$whom_url 2=$whom_name|escape 3=$who_url 4=$who_name|escape 5=$log_date}Change to <a href='%1'>%2</a> made by <a href='%3'>%4</a> on %5:{/ts}</p>
{if $layout eq 'overlay'}
{include file="CRM/Report/Form/Layout/Overlay.tpl"}
{else}
// define('CIVICRM_MYSQL_STRICT', TRUE );
// }
+/**
+ * Specify whether the CRM_Core_BAO_Cache should use the legacy
+ * direct-to-SQL-mode or the interim PSR-16 adapter.
+ */
+// define('CIVICRM_BAO_CACHE_ADAPTER', 'CRM_Core_BAO_Cache_Psr16');
+
if (CIVICRM_UF === 'UnitTests') {
if (!defined('CIVICRM_CONTAINER_CACHE')) define('CIVICRM_CONTAINER_CACHE', 'auto');
if (!defined('CIVICRM_MYSQL_STRICT')) define('CIVICRM_MYSQL_STRICT', true);
foreach (array($activitiesDep, CRM_Activity_BAO_Activity::getActivities($params)) as $activities) {
//verify target count
$this->assertEquals($targetCount, $activities[1]['target_contact_counter']);
+ $this->assertEquals([$targetContactIDs[0] => 'Anderson, Anthony'], $activities[1]['target_contact_name']);
}
}
CRM_Core_ManagedEntities::singleton(TRUE)->reconcile();
}
+ /**
+ * Test Manager contact is correctly assigned via case type def.
+ */
+ public function testManagerContact() {
+ $caseTypeId = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseType', 'ForkableCaseType', 'id', 'name');
+ $this->assertTrue(is_numeric($caseTypeId) && $caseTypeId > 0);
+
+ $this->callAPISuccess('CaseType', 'create', [
+ 'id' => $caseTypeId,
+ 'definition' => [
+ 'caseRoles' => [
+ ['name' => 'First role', 'manager' => 0],
+ ['name' => 'Second role', 'creator' => 1, 'manager' => 1],
+ ],
+ ],
+ ]);
+ $relTypeID = $this->callAPISuccessGetValue('RelationshipType', [
+ 'return' => "id",
+ 'name_b_a' => "Second role",
+ ]);
+ //Check if manager is correctly retrieved from xml processor.
+ $xmlProcessor = new CRM_Case_XMLProcessor_Process();
+ $this->assertEquals($relTypeID, $xmlProcessor->getCaseManagerRoleId('ForkableCaseType'));
+ }
+
/**
* Edit the definition of ForkableCaseType.
FALSE, FALSE, FALSE,
TRUE, FALSE
);
- $expectedWhere = "civicrm_group_contact_cache.group_id IN (\"{$group2->id}\")";
+ $key = $query->getGroupCacheTableKeys()[0];
+ $expectedWhere = "civicrm_group_contact_cache_{$key}.group_id IN (\"{$group2->id}\")";
$this->assertContains($expectedWhere, $query->_whereClause);
$this->_assertContactIds($query, "group_id = {$group2->id}");
FALSE,
FALSE, FALSE
);
+ $key = $query->getGroupCacheTableKeys()[0];
//Assert if proper where clause is present.
- $expectedWhere = "civicrm_group_contact.group_id != {$group->id} AND civicrm_group_contact_cache.group_id IS NULL OR ( civicrm_group_contact_cache.contact_id NOT IN (SELECT contact_id FROM civicrm_group_contact_cache cgcc WHERE cgcc.group_id IN ( {$group->id} ) ) )";
+ $expectedWhere = "civicrm_group_contact_{$key}.group_id != {$group->id} AND civicrm_group_contact_cache_{$key}.group_id IS NULL OR ( civicrm_group_contact_cache_{$key}.contact_id NOT IN (SELECT contact_id FROM civicrm_group_contact_cache cgcc WHERE cgcc.group_id IN ( {$group->id} ) ) )";
$this->assertContains($expectedWhere, $query->_whereClause);
$this->_assertContactIds($query, "group_id != {$group->id}");
FALSE,
FALSE, FALSE
);
- $expectedWhere = "civicrm_group_contact_cache.group_id IN (\"{$group->id}\", \"{$group2->id}\")";
+ $key = $query->getGroupCacheTableKeys()[0];
+ $expectedWhere = "civicrm_group_contact_cache_{$key}.group_id IN (\"{$group->id}\", \"{$group2->id}\")";
$this->assertContains($expectedWhere, $query->_whereClause);
$this->_assertContactIds($query, "group_id IN ({$group->id}, {$group2->id})");
FALSE,
FALSE, FALSE
);
- $expectedWhere = "civicrm_group_contact.group_id NOT IN ( {$group->id} ) AND civicrm_group_contact_cache.group_id IS NULL OR ( civicrm_group_contact_cache.contact_id NOT IN (SELECT contact_id FROM civicrm_group_contact_cache cgcc WHERE cgcc.group_id IN ( {$group->id} ) ) )";
+ $key = $query->getGroupCacheTableKeys()[0];
+ $expectedWhere = "civicrm_group_contact_{$key}.group_id NOT IN ( {$group->id} ) AND civicrm_group_contact_cache_{$key}.group_id IS NULL OR ( civicrm_group_contact_cache_{$key}.contact_id NOT IN (SELECT contact_id FROM civicrm_group_contact_cache cgcc WHERE cgcc.group_id IN ( {$group->id} ) ) )";
$this->assertContains($expectedWhere, $query->_whereClause);
$this->_assertContactIds($query, "group_id NOT IN ({$group->id})");
+ $this->callAPISuccess('group', 'delete', ['id' => $group->id]);
+ $this->callAPISuccess('group', 'delete', ['id' => $group2->id]);
+ }
+
+
+ public function testMultipleGroupWhereClause() {
+ $returnProperties = array(
+ 'contact_type' => 1,
+ 'contact_sub_type' => 1,
+ 'sort_name' => 1,
+ 'group' => 1,
+ );
+ list($group, $living, $deceased) = $this->setupSmartGroup();
+
+ $params = array(
+ 'name' => 'Living Contacts',
+ 'title' => 'Living Contacts',
+ 'is_active' => 1,
+ 'formValues' => array('is_deceased' => 0),
+ );
+ $group2 = CRM_Contact_BAO_Group::createSmartGroup($params);
+
+ //Filter on smart group with =, !=, IN and NOT IN operator.
+ $params = array(array('group', '=', $group2->id, 1, 0), array('group', '=', $group->id, 1, 0));
+ $query = new CRM_Contact_BAO_Query(
+ $params, $returnProperties,
+ NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_CONTACTS,
+ FALSE,
+ FALSE, FALSE
+ );
+ $ids = $query->searchQuery(0, 0, NULL,
+ FALSE, FALSE, FALSE,
+ TRUE, FALSE
+ );
+ $key1 = $query->getGroupCacheTableKeys()[0];
+ $key2 = $query->getGroupCacheTableKeys()[1];
+ $expectedWhere = 'civicrm_group_contact_cache_' . $key1 . '.group_id IN ("' . $group2->id . '") ) ) AND ( ( civicrm_group_contact_cache_' . $key2 . '.group_id IN ("' . $group->id . '")';
+ $this->assertContains($expectedWhere, $query->_whereClause);
+ // Check that we have 3 joins to the group contact cache 1 for each of the group where clauses and 1 for the fact we are returning groups in the select.
+ $expectedFrom1 = 'LEFT JOIN civicrm_group_contact_cache civicrm_group_contact_cache_' . $key1 . ' ON contact_a.id = civicrm_group_contact_cache_' . $key1 . '.contact_id';
+ $this->assertContains($expectedFrom1, $query->_fromClause);
+ $expectedFrom2 = 'LEFT JOIN civicrm_group_contact_cache civicrm_group_contact_cache_' . $key2 . ' ON contact_a.id = civicrm_group_contact_cache_' . $key2 . '.contact_id';
+ $this->assertContains($expectedFrom2, $query->_fromClause);
+ $expectedFrom3 = 'LEFT JOIN civicrm_group_contact_cache ON contact_a.id = civicrm_group_contact_cache.contact_id';
+ $this->assertContains($expectedFrom3, $query->_fromClause);
}
/**
$contactID = $this->individualCreate(['custom_' . $customFieldID => 'abc']);
- $formValues = ['custom_' . $customFieldID => ['LIKE' => '%a%']];
-
$hiddenSmartParams = [
'group_type' => ['2' => 1],
- 'form_values' => CRM_Contact_BAO_Query::convertFormValues($formValues),
+ 'form_values' => ['custom_' . $customFieldID => ['LIKE' => '%a%']],
'saved_search_id' => NULL,
'search_custom_id' => NULL,
'search_context' => 'advanced',
*/
class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase {
use CRMTraits_Financial_FinancialACLTrait;
+ use CRMTraits_Financial_PriceSetTrait;
/**
* @return CRM_Contact_BAO_QueryTestDataProvider
}
public function tearDown() {
+ $this->quickCleanUpFinancialEntities();
$tablesToTruncate = array(
'civicrm_group_contact',
'civicrm_group',
* Test the summary query does not add an acl clause when acls not enabled..
*/
public function testGetSummaryQueryWithFinancialACLDisabled() {
+ $this->createContributionsForSummaryQueryTests();
+
+ // Test the function directly
$where = $from = NULL;
$queryObject = new CRM_Contact_BAO_Query();
- $query = $queryObject->appendFinancialTypeWhereAndFromToQueryStrings($where,
+ $queryObject->appendFinancialTypeWhereAndFromToQueryStrings($where,
$from);
- $this->assertEquals($where, $query[0]);
- $this->assertEquals($from, $query[1]);
+ $this->assertEquals(NULL, $where);
+ $this->assertEquals(NULL, $from);
+
+ // Test the function in action
+ $queryObject = new CRM_Contact_BAO_Query([['contribution_source', '=', 'SSF', '', '']]);
+ $summary = $queryObject->summaryContribution();
+ $this->assertEquals([
+ 'total' => [
+ 'avg' => '$ 233.33',
+ 'amount' => '$ 1,400.00',
+ 'count' => 6,
+ ],
+ 'cancel' => [
+ 'count' => 2,
+ 'amount' => '$ 100.00',
+ 'avg' => '$ 50.00',
+ ],
+ ], $summary);
}
/**
*/
public function testGetSummaryQueryWithFinancialACLEnabled() {
$where = $from = NULL;
+ $this->createContributionsForSummaryQueryTests();
$this->enableFinancialACLs();
$this->createLoggedInUserWithFinancialACL();
+
+ // Test the function directly
$queryObject = new CRM_Contact_BAO_Query();
- $query = $queryObject->appendFinancialTypeWhereAndFromToQueryStrings($where,
+ $queryObject->appendFinancialTypeWhereAndFromToQueryStrings($where,
$from);
$donationTypeID = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'financial_type_id', 'Donation');
$this->assertEquals(
" LEFT JOIN civicrm_line_item li
ON civicrm_contribution.id = li.contribution_id AND
li.entity_table = 'civicrm_contribution' AND li.financial_type_id NOT IN ({$donationTypeID}) ", $from);
+
+ // Test the function in action
+ $queryObject = new CRM_Contact_BAO_Query([['contribution_source', '=', 'SSF', '', '']]);
+ $summary = $queryObject->summaryContribution();
+ $this->assertEquals([
+ 'total' => [
+ 'avg' => '$ 200.00',
+ 'amount' => '$ 400.00',
+ 'count' => 2,
+ ],
+ 'cancel' => [
+ 'count' => 1,
+ 'amount' => '$ 50.00',
+ 'avg' => '$ 50.00',
+ ],
+ ], $summary);
$this->disableFinancialACLs();
}
$this->assertEquals($modparams['member_is_primary'][2], $fv_orig['member_is_primary']);
}
+ /**
+ * Create contributions to test summary calculations.
+ *
+ * financial type | cancel_date |total_amount| source | line_item_financial_types |number_line_items| line_amounts
+ * Donation |NULL | 100.00 |SSF | Donation | 1 | 100.00
+ * Member Dues |NULL | 100.00 |SSF | Member Dues | 1 | 100.00
+ * Donation |NULL | 300.00 |SSF | Event Fee,Event Fee | 2 | 200.00,100.00
+ * Donation |NULL | 300.00 |SSF | Event Fee,Donation | 2 | 200.00,100.00
+ * Donation |NULL | 300.00 |SSF | Donation,Donation | 2 | 200.00,100.00
+ * Donation |2019-02-13 00:00:00 | 50.00 |SSF | Donation | 1 | 50.00
+ * Member Dues |2019-02-13 00:00:00 | 50.00 |SSF | Member Dues | 1 | 50.00
+ */
+ protected function createContributionsForSummaryQueryTests() {
+ $contactID = $this->individualCreate();
+ $this->contributionCreate(['contact_id' => $contactID]);
+ $this->contributionCreate([
+ 'contact_id' => $contactID,
+ 'total_amount' => 100,
+ 'financial_type_id' => 'Member Dues',
+ ]);
+ $eventFeeType = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'financial_type_id', 'Event Fee');
+ $this->createContributionWithTwoLineItemsAgainstPriceSet(['contact_id' => $contactID, 'source' => 'SSF']);
+ $this->createContributionWithTwoLineItemsAgainstPriceSet(['contact_id' => $contactID, 'source' => 'SSF'], [
+ CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'financial_type_id', 'Donation'),
+ $eventFeeType,
+ ]);
+ $this->createContributionWithTwoLineItemsAgainstPriceSet(['contact_id' => $contactID, 'source' => 'SSF'], [
+ CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'financial_type_id', 'Donation'),
+ CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'financial_type_id', 'Donation'),
+ ]);
+ $this->createContributionWithTwoLineItemsAgainstPriceSet(['contact_id' => $contactID, 'source' => 'SSF', 'financial_type_id' => $eventFeeType], [
+ CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'financial_type_id', 'Donation'),
+ CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'financial_type_id', 'Donation'),
+ ]);
+ $this->contributionCreate([
+ 'contact_id' => $contactID,
+ 'total_amount' => 50,
+ 'contribution_status_id' => 'Cancelled',
+ 'cancel_date' => 'yesterday',
+ ]);
+ $this->contributionCreate([
+ 'contact_id' => $contactID,
+ 'total_amount' => 50,
+ 'contribution_status_id' => 'Cancelled',
+ 'cancel_date' => 'yesterday',
+ 'financial_type_id' => 'Member Dues',
+ ]);
+ }
+
}
* CRM-19888 default country should be used if ambigous.
*/
public function testImportAmbiguousStateCountry() {
+ $this->callAPISuccess('Setting', 'create', ['defaultContactCountry' => 1228]);
$countries = CRM_Core_PseudoConstant::country(FALSE, FALSE);
$this->callAPISuccess('Setting', 'create', array('countryLimit' => array(array_search('United States', $countries), array_search('Guyana', $countries), array_search('Netherlands', $countries))));
$this->callAPISuccess('Setting', 'create', array('provinceLimit' => array(array_search('United States', $countries), array_search('Guyana', $countries), array_search('Netherlands', $countries))));
'receive_date' => '2018-11-21 00:00:00',
'contribution_status' => 'Completed',
'currency' => 'USD',
- //'receipt_date' => '2018-11-22 00:00:00',
+ 'receipt_date' => '2018-11-22 00:00:00',
]);
}
class CRM_Contribute_BAO_ContributionTest extends CiviUnitTestCase {
use CRMTraits_Financial_FinancialACLTrait;
+ use CRMTraits_Financial_PriceSetTrait;
/**
* Clean up after tests.
$this->disableFinancialACLs();
}
+ /**
+ * Test the annual query returns a correct result when multiple line items are present.
+ */
+ public function testAnnualWithMultipleLineItems() {
+ $contactID = $this->createLoggedInUserWithFinancialACL();
+ $this->createContributionWithTwoLineItemsAgainstPriceSet([
+ 'contact_id' => $contactID]
+ );
+ $this->enableFinancialACLs();
+ $sql = CRM_Contribute_BAO_Contribution::getAnnualQuery([$contactID]);
+ $result = CRM_Core_DAO::executeQuery($sql);
+ $result->fetch();
+ $this->assertEquals(300, $result->amount);
+ $this->assertEquals(1, $result->count);
+ $this->disableFinancialACLs();
+ }
+
/**
* Test that financial type data is not added to the annual query if acls not enabled.
*/
CRM_Core_DAO::executeQuery($sql);
}
+ /**
+ * Test that financial type data is not added to the annual query if acls not enabled.
+ */
+ public function testAnnualQueryWithFinancialHook() {
+ $this->hookClass->setHook('civicrm_selectWhereClause', array($this, 'aclIdNoZero'));
+ $sql = CRM_Contribute_BAO_Contribution::getAnnualQuery([1, 2, 3]);
+ $this->assertContains('SUM(total_amount) as amount,', $sql);
+ $this->assertContains('WHERE b.contact_id IN (1,2,3)', $sql);
+ $this->assertContains('b.id NOT IN (0)', $sql);
+ $this->assertNotContains('b.financial_type_id', $sql);
+ CRM_Core_DAO::executeQuery($sql);
+ }
+
+ /**
+ * Add ACL denying values LIKE '0'.
+ *
+ * @param string $entity
+ * @param string $clauses
+ */
+ public function aclIdNoZero($entity, &$clauses) {
+ if ($entity != 'Contribution') {
+ return;
+ }
+ $clauses['id'] = "NOT IN (0)";
+ }
+
/**
* Display sort name during.
* Update multiple contributions
*/
public function tearDown() {
$this->quickCleanUpFinancialEntities();
+ CRM_Core_DAO::executeQuery('DELETE FROM civicrm_mailing_spool ORDER BY id DESC');
parent::tearDown();
}
$this->checkResults(array(30, 70), 2);
$mut->assertSubjects(['Payment Receipt -']);
$mut->checkMailLog([
- 'Dear Anthony Anderson',
+ 'Dear Anthony,',
'Payment Details',
'Total Fees: $ 100.00',
'This Payment Amount: $ 70.00',
'Balance Owed: $ 0.00 ',
+ 'Billing Name and Address',
+ 'Vancouver, AE 1321312',
+ 'Visa',
+ '***********1111',
+ 'Expires: May 2025',
]);
$mut->stop();
+ $mut->clearMessages();
}
/**
* Test the submit function that completes the partially paid Contribution with multiple payments.
*/
public function testMultiplePaymentForPartiallyPaidContributionWithOneCreditCardPayment() {
+ $mut = new CiviMailUtils($this, TRUE);
$this->createContribution('Partially paid');
+ // In general when there is tpl leakage we try to fix. At the moment, however,
+ // the tpl leakage on credit card related things is kind of 'by-design' - or
+ // at least we haven't found a way to replace the way in with Payment.send_confirmation
+ // picks them up from the form process so we will just clear templates here to stop leakage
+ // from previous tests causing a fail.
+ // The reason this is hard to fix is that we save a billing address per contribution not
+ // per payment so it's a problem with the data model
+ CRM_Core_Smarty::singleton()->clearTemplateVars();
// pay additional amount
- $this->submitPayment(50);
+ $this->submitPayment(50, NULL, TRUE);
$contribution = $this->callAPISuccessGetSingle('Contribution', array('id' => $this->_contributionId));
$this->assertEquals('Partially paid', $contribution['contribution_status']);
// pay additional amount by using credit card
$this->submitPayment(20, 'live');
$this->checkResults(array(30, 50, 20), 3);
+ $mut->assertSubjects(array('Payment Receipt -'));
+ $mut->checkMailLog([
+ 'Dear Anthony,',
+ 'A payment has been received',
+ 'Total Fees: $ 100.00',
+ 'This Payment Amount: $ 50.00',
+ 'Balance Owed: $ 20.00 ',
+ 'Paid By: Check',
+ 'Check Number: check-12345',
+ ],
+ [
+ 'Billing Name and Address',
+ 'Visa',
+ ]);
+ $mut->stop();
+ $mut->clearMessages();
}
/**
class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase {
protected $_individual;
- protected $_tablesToTruncate = array('civicrm_contribution', 'civicrm_line_item');
+ protected $_tablesToTruncate = ['civicrm_contribution', 'civicrm_line_item'];
public function setUp() {
parent::setUp();
*/
public function testBatchFilter() {
$this->quickCleanup($this->_tablesToTruncate);
- $contactID1 = $this->individualCreate(array(), 1);
- $contactID2 = $this->individualCreate(array(), 2);
+ $contactID1 = $this->individualCreate([], 1);
+ $contactID2 = $this->individualCreate([], 2);
$batchTitle = CRM_Batch_BAO_Batch::generateBatchName();
// create batch
- $batch = $this->callAPISuccess('Batch', 'create', array(
+ $batch = $this->callAPISuccess('Batch', 'create', [
'created_id' => $this->_individual,
'created_date' => CRM_Utils_Date::processDate(date("Y-m-d"), date("H:i:s")),
'status_id' => CRM_Core_Pseudoconstant::getKey('CRM_Batch_BAO_Batch', 'status_id', 'Data Entry'),
'item_count' => 2,
'total' => 100,
'type_id' => array_search('Contribution', CRM_Batch_BAO_Batch::buildOptions('type_id')),
- ));
+ ]);
$batchID = $batch['id'];
- $batchEntry = array(
- 'primary_profiles' => array(1 => NULL, 2 => NULL, 3 => NULL),
- 'primary_contact_id' => array(
+ $batchEntry = [
+ 'primary_profiles' => [1 => NULL, 2 => NULL, 3 => NULL],
+ 'primary_contact_id' => [
1 => $contactID1,
2 => $contactID2,
- ),
- 'field' => array(
- 1 => array(
+ ],
+ 'field' => [
+ 1 => [
'financial_type' => 1,
'total_amount' => 70,
'receive_date' => '2013-07-24',
'payment_instrument' => 1,
'check_number' => NULL,
'contribution_status_id' => 1,
- ),
- 2 => array(
+ ],
+ 2 => [
'financial_type' => 1,
'total_amount' => 30,
'receive_date' => '2014-07-24',
'payment_instrument' => 1,
'check_number' => NULL,
'contribution_status_id' => 1,
- ),
- ),
+ ],
+ ],
'actualBatchTotal' => 100,
- );
+ ];
// create random contribution to check IS NULL filter more precisely
- $nonBatchContri = $this->callAPISuccess('Contribution', 'create', array(
+ $nonBatchContri = $this->callAPISuccess('Contribution', 'create', [
'financial_type_id' => 1,
'total_amount' => 123,
'receive_date' => '2014-07-24',
'check_number' => NULL,
'contribution_status_id' => 1,
'contact_id' => $this->_individual,
- ));
+ ]);
$nonBatchContriID = $nonBatchContri['id'];
// process batch entries
// fetch created contributions
$entities = $this->callAPISuccess('EntityBatch', 'get', array('batch_id' => $batchID));
- $ids = array();
+ $ids = [];
foreach ($entities['values'] as $value) {
$ids[] = $value['entity_id'];
}
list($batchContriID1, $batchContriID2) = $ids;
- $useCases = array(
+ $useCases = [
// Case 1: Search for ONLY those contributions which are created from batch
- array(
+ [
'form_value' => array('contribution_batch_id' => 'IS NOT NULL'),
'expected_count' => 2,
'expected_contribution' => array($batchContriID1, $batchContriID2),
'expected_qill' => 'Batch Name Not Null',
- ),
+ ],
// Case 2: Search for ONLY those contributions which are NOT created from batch
- array(
+ [
'form_value' => array('contribution_batch_id' => 'IS NULL'),
'expected_count' => 1,
'expected_contribution' => array($nonBatchContriID),
'expected_qill' => 'Batch Name Is Null',
- ),
+ ],
// Case 3: Search for ONLY those contributions which are created from batch ID - $batchID
- array(
+ [
'form_value' => array('contribution_batch_id' => $batchID),
'expected_count' => 2,
'expected_contribution' => array($batchContriID1, $batchContriID2),
'expected_qill' => 'Batch Name = ' . $batchTitle,
- ),
- );
+ ],
+ ];
foreach ($useCases as $case) {
$fv = $case['form_value'];
CRM_Contact_BAO_Query::processSpecialFormValue($fv, array('contribution_batch_id'));
$query = new CRM_Contact_BAO_Query(CRM_Contact_BAO_Query::convertFormValues($fv));
- list($select, $from, $where, $having) = $query->query();
+ list($select, $from, $where) = $query->query();
// get and assert contribution count
$contributions = CRM_Core_DAO::executeQuery(sprintf('SELECT DISTINCT civicrm_contribution.id %s %s AND civicrm_contribution.id IS NOT NULL', $from, $where))->fetchAll();
'total_amount' => 100,
);
CRM_Core_BAO_FinancialTrxn::create($params);
- $Contribution2 = $this->callAPISuccess('Contribution', 'create', array(
+ $this->callAPISuccess('Contribution', 'create', array(
'financial_type_id' => 1,
'total_amount' => 150,
'receive_date' => date('Ymd'),
$fv = $case['form_value'];
CRM_Contact_BAO_Query::processSpecialFormValue($fv, array('financial_trxn_card_type_id'));
$query = new CRM_Contact_BAO_Query(CRM_Contact_BAO_Query::convertFormValues($fv));
- list($select, $from, $where, $having) = $query->query();
+ list($select, $from, $where) = $query->query();
// get and assert contribution count
$contributions = CRM_Core_DAO::executeQuery(sprintf('SELECT DISTINCT civicrm_contribution.id %s %s AND civicrm_contribution.id IS NOT NULL', $from, $where))->fetchAll();
'pan_truncation' => 1234,
);
CRM_Core_BAO_FinancialTrxn::create($params);
- $Contribution2 = $this->callAPISuccess('Contribution', 'create', array(
+ $this->callAPISuccess('Contribution', 'create', array(
'financial_type_id' => 1,
'total_amount' => 150,
'receive_date' => date('Ymd'),
$fv = $case['form_value'];
CRM_Contact_BAO_Query::processSpecialFormValue($fv, array('financial_trxn_pan_truncation'));
$query = new CRM_Contact_BAO_Query(CRM_Contact_BAO_Query::convertFormValues($fv));
- list($select, $from, $where, $having) = $query->query();
+ list($select, $from, $where) = $query->query();
// get and assert contribution count
$contributions = CRM_Core_DAO::executeQuery(sprintf('SELECT DISTINCT civicrm_contribution.id %s %s AND civicrm_contribution.id IS NOT NULL', $from, $where))->fetchAll();
*/
public function testContributionRecurStatusFilter() {
$this->quickCleanup($this->_tablesToTruncate);
- $contactID1 = $this->individualCreate(array(), 1);
- $contactID2 = $this->individualCreate(array(), 2);
+ $contactID1 = $this->individualCreate([], 1);
+ $contactID2 = $this->individualCreate([], 2);
// "In Progress" recurring contribution for contactID1
- $ContributionRecur1 = $this->callAPISuccess('ContributionRecur', 'create', array(
+ $ContributionRecur1 = $this->callAPISuccess('ContributionRecur', 'create', [
'sequential' => 1,
'contact_id' => $contactID1,
'frequency_interval' => 1,
'payment_instrument_id' => 1,
'contribution_status_id' => 5,
'financial_type_id' => "Donation",
- ));
- $Contribution1 = $this->callAPISuccess('Contribution', 'create', array(
- 'financial_type_id' => 1,
+ ]);
+ $Contribution1 = $this->callAPISuccess('Contribution', 'create', [
+ 'financial_type_id' => 'Donation',
'total_amount' => 11,
'receive_date' => date('Ymd'),
'receive_date_time' => NULL,
'contribution_status_id' => 1,
'contact_id' => $contactID1,
'contribution_recur_id' => $ContributionRecur1['id'],
- 'financial_type_id' => "Donation",
- ));
- $params = array(
+ ]);
+ $params = [
'to_financial_account_id' => 1,
'status_id' => 1,
'contribution_id' => $Contribution1['id'],
'payment_instrument_id' => 1,
'card_type_id' => 1,
'total_amount' => 11,
- );
+ ];
CRM_Core_BAO_FinancialTrxn::create($params);
// "Completed" recurring contribution for contactID2
- $ContributionRecur2 = $this->callAPISuccess('ContributionRecur', 'create', array(
+ $ContributionRecur2 = $this->callAPISuccess('ContributionRecur', 'create', [
'sequential' => 1,
'contact_id' => $contactID2,
'frequency_interval' => 1,
'payment_instrument_id' => 1,
'contribution_status_id' => 1,
'financial_type_id' => "Donation",
- ));
- $Contribution2 = $this->callAPISuccess('Contribution', 'create', array(
- 'financial_type_id' => 1,
+ ]);
+ $Contribution2 = $this->callAPISuccess('Contribution', 'create', [
+ 'financial_type_id' => 'Donation',
'total_amount' => 22,
'receive_date' => date('Ymd'),
'receive_date_time' => NULL,
'contribution_status_id' => 1,
'contact_id' => $contactID2,
'contribution_recur_id' => $ContributionRecur2['id'],
- 'financial_type_id' => "Donation",
- ));
- $params = array(
+ ]);
+ $params = [
'to_financial_account_id' => 1,
'status_id' => 1,
'contribution_id' => $Contribution2['id'],
'payment_instrument_id' => 1,
'card_type_id' => 1,
'total_amount' => 22,
- );
+ ];
CRM_Core_BAO_FinancialTrxn::create($params);
- $useCases = array(
+ $useCases = [
// Case 1: Search for ONLY those recurring contributions with status "In Progress"
- array(
- 'form_value' => array('contribution_recur_contribution_status_id' => 5),
+ [
+ 'form_value' => ['contribution_recur_contribution_status_id' => 5],
'expected_count' => 1,
- 'expected_contact' => array($contactID1),
+ 'expected_contact' => [$contactID1],
'expected_qill' => "Recurring Contribution Status = 'In Progress'",
- ),
+ ],
// Case 2: Search for ONLY those recurring contributions with status "Completed"
- array(
- 'form_value' => array('contribution_recur_contribution_status_id' => 1),
+ [
+ 'form_value' => ['contribution_recur_contribution_status_id' => 1],
'expected_count' => 1,
- 'expected_contact' => array($contactID2),
+ 'expected_contact' => [$contactID2],
'expected_qill' => "Recurring Contribution Status = 'Completed'",
- ),
+ ],
// Case 3: Search for ONLY those recurring contributions with status "Cancelled"
- array(
- 'form_value' => array('contribution_recur_contribution_status_id' => 3),
+ [
+ 'form_value' => ['contribution_recur_contribution_status_id' => 3],
'expected_count' => 0,
- 'expected_contact' => array(),
+ 'expected_contact' => [],
'expected_qill' => "Recurring Contribution Status = 'Cancelled'",
- ),
- );
+ ],
+ ];
foreach ($useCases as $case) {
$fv = $case['form_value'];
*/
public function testCancelledFilter() {
$this->quickCleanup($this->_tablesToTruncate);
- $contactID1 = $this->individualCreate(array(), 1);
- $contactID2 = $this->individualCreate(array(), 2);
- $Contribution1 = $this->callAPISuccess('Contribution', 'create', array(
+ $contactID1 = $this->individualCreate([], 1);
+ $contactID2 = $this->individualCreate([], 2);
+ $Contribution1 = $this->callAPISuccess('Contribution', 'create', [
'financial_type_id' => 1,
'total_amount' => 100,
'receive_date' => date('Ymd'),
'cancel_date' => date('Ymd'),
'cancel_reason' => 'Insufficient funds',
'contact_id' => $contactID1,
- ));
- $Contribution2 = $this->callAPISuccess('Contribution', 'create', array(
+ ]);
+ $this->callAPISuccess('Contribution', 'create', [
'financial_type_id' => 1,
'total_amount' => 150,
'receive_date' => date('Ymd', strtotime(date('Y-m-d') . ' - 1 days')),
'cancel_date' => date('Ymd', strtotime(date('Y-m-d') . ' - 1 days')),
'cancel_reason' => 'Insufficient funds',
'contact_id' => $contactID2,
- ));
- $Contribution3 = $this->callAPISuccess('Contribution', 'create', array(
+ ]);
+ $Contribution3 = $this->callAPISuccess('Contribution', 'create', [
'financial_type_id' => 1,
'total_amount' => 200,
'receive_date' => date('Ymd'),
'cancel_date' => date('Ymd'),
'cancel_reason' => 'Invalid Credit Card Number',
'contact_id' => $contactID1,
- ));
+ ]);
- $useCases = array(
+ $useCases = [
// Case 1: Search for Cancelled Date
- array(
- 'form_value' => array('cancel_date' => date('Y-m-d')),
+ [
+ 'form_value' => ['cancel_date' => date('Y-m-d')],
'expected_count' => 2,
- 'expected_contribution' => array($Contribution1['id'], $Contribution3['id']),
+ 'expected_contribution' => [$Contribution1['id'], $Contribution3['id']],
'expected_qill' => "Cancel Date Like '%" . date('Y-m-d') . "%'",
- ),
+ ],
// Case 2: Search for Cancelled Reason
- array(
- 'form_value' => array('cancel_reason' => 'Invalid Credit Card Number'),
+ [
+ 'form_value' => ['cancel_reason' => 'Invalid Credit Card Number'],
'expected_count' => 1,
- 'expected_contribution' => array($Contribution3['id']),
+ 'expected_contribution' => [$Contribution3['id']],
'expected_qill' => "Cancellation / Refund Reason Like '%Invalid Credit Card Number%'",
- ),
+ ],
// Case 3: Search for Cancelled Date and Cancelled Reason
- array(
- 'form_value' => array('cancel_date' => date('Y-m-d'), 'cancel_reason' => 'Insufficient funds'),
+ [
+ 'form_value' => ['cancel_date' => date('Y-m-d'), 'cancel_reason' => 'Insufficient funds'],
'expected_count' => 1,
- 'expected_contribution' => array($Contribution1['id']),
+ 'expected_contribution' => [$Contribution1['id']],
'expected_qill' => "Cancel Date Like '%" . date('Y-m-d') . "%'ANDCancellation / Refund Reason Like '%Insufficient funds%'",
- ),
- );
+ ],
+ ];
foreach ($useCases as $case) {
$fv = $case['form_value'];
- CRM_Contact_BAO_Query::processSpecialFormValue($fv, array('cancel_date', 'cancel_reason'));
+ CRM_Contact_BAO_Query::processSpecialFormValue($fv, ['cancel_date', 'cancel_reason']);
$query = new CRM_Contact_BAO_Query(CRM_Contact_BAO_Query::convertFormValues($fv));
- list($select, $from, $where, $having) = $query->query();
+ list($select, $from, $where) = $query->query();
// get and assert contribution count
$contributions = CRM_Core_DAO::executeQuery(sprintf('SELECT DISTINCT civicrm_contribution.id %s %s AND civicrm_contribution.id IS NOT NULL AND civicrm_contribution.contribution_status_id = 3', $from, $where))->fetchAll();
$this->assertEquals($parsedStreetAddress['street_number'], '54');
$this->assertEquals($parsedStreetAddress['street_number_suffix'], 'A');
+ // Out-of-range street number to be parsed.
+ $street_address = "505050505050 Main St";
+ $parsedStreetAddress = CRM_Core_BAO_Address::parseStreetAddress($street_address);
+ $this->assertEquals($parsedStreetAddress['street_name'], '');
+ $this->assertEquals($parsedStreetAddress['street_unit'], '');
+ $this->assertEquals($parsedStreetAddress['street_number'], '');
+ $this->assertEquals($parsedStreetAddress['street_number_suffix'], '');
+
// valid Street address to be parsed ( $locale = 'en_US' )
$street_address = "54A Excelsior Ave. Apt 1C";
$locale = 'en_US';
$this->assertEquals($newIndices, $expectedIndices);
}
+ /**
+ * Test CRM_Core_DAO_AllCoreTables::isCoreTable
+ */
+ public function testIsCoreTable() {
+ $this->assertTrue(CRM_Core_DAO_AllCoreTables::isCoreTable('civicrm_contact'), 'civicrm_contact should be a core table');
+ $this->assertFalse(CRM_Core_DAO_AllCoreTables::isCoreTable('civicrm_invalid_table'), 'civicrm_invalid_table should NOT be a core table');
+ }
+
}
'cvv2' => 123,
'credit_card_exp_date' => array(
'M' => 11,
- 'Y' => 2019,
+ 'Y' => 2022,
),
'credit_card_type' => 'Visa',
'is_recur' => 1,
'state_province-5' => 'IL',
'billing_country-5' => 'US',
'country-5' => 'US',
- 'year' => 2019,
+ 'year' => 2022,
'month' => 10,
'ip_address' => '127.0.0.1',
'amount' => 70,
'first_name' => $firstName,
'middle_name' => 'bob',
'last_name' => $lastName,
- 'street_address' => '8 Hobbiton Road',
+ 'street_address' => '8 Hobbiton Road' . uniqid(),
'city' => 'The Shire',
'state_province' => 'IL',
'postal_code' => 5010,
'country' => 'US',
- 'contributionType_name' => 'My precious',
- 'contributionType_accounting_code' => '',
'contributionPageID' => '',
'email' => "{$firstName}.{$lastName}@example.com",
'contactID' => $contactId,
'contributionID' => $contribution['id'],
- 'contributionTypeID' => $this->_financialTypeId,
'contributionRecurID' => $recur->id,
);
);
}
+ /**
+ * return array
+ */
+ public function urlsToCheckIfFullyFormed() {
+ return [
+ ['civicrm/test/page', FALSE],
+ ['#', FALSE],
+ ['', FALSE],
+ ['/civicrm/test/page', TRUE],
+ ['http://test.com/civicrm/test/page', TRUE],
+ ['https://test.com/civicrm/test/page', TRUE],
+ ];
+ }
+
+ /**
+ * @param string $url
+ * @param string $expected
+ *
+ * @dataProvider urlsToCheckIfFullyFormed
+ */
+ public function testIsFullyFormedUrl($url, $expected) {
+ $this->assertEquals($expected, CRM_Core_Resources::isFullyFormedUrl($url));
+ }
+
}
--- /dev/null
+<?php
+
+/**
+ * Class CRM_Core_Smarty_plugins_CrmMoneyTest
+ * @group headless
+ */
+class CRM_Core_Smarty_plugins_CrmMoneyTest extends CiviUnitTestCase {
+ public function setUp() {
+ parent::setUp();
+ require_once 'CRM/Core/Smarty.php';
+
+ // Templates should normally be file names, but for unit-testing it's handy to use "string:" notation
+ require_once 'CRM/Core/Smarty/resources/String.php';
+ civicrm_smarty_register_string_resource();
+ }
+
+ /**
+ * @return array
+ */
+ public function moneyCases() {
+ $cases = [];
+ $cases[] = ['$ 4.00', '{assign var="amount" value="4.00"}{$amount|crmMoney:USD}'];
+ $cases[] = ['€ 1,234.00', '{assign var="amount" value="1234.00"}{$amount|crmMoney:EUR}'];
+ $cases[] = [
+ '$ <input size="10" style="background-color:#EBECE4" readonly="readonly" name="eachPaymentAmount" type="text" id="eachPaymentAmount" class="crm-form-text">',
+ '{assign var="amount" value=\'<input size="10" style="background-color:#EBECE4" readonly="readonly" name="eachPaymentAmount" type="text" id="eachPaymentAmount" class="crm-form-text">\'}{$amount|crmMoney:USD}'
+ ];
+ return $cases;
+ }
+
+ /**
+ * @dataProvider moneyCases
+ * @param $expected
+ * @param $input
+ */
+ public function testMoney($expected, $input) {
+ $smarty = CRM_Core_Smarty::singleton();
+ $actual = $smarty->fetch('string:' . $input);
+ $this->assertEquals($expected, $actual, "Process input=[$input]");
+ }
+
+}
}
$foundDupes = CRM_Dedupe_Finder::dupesInGroup($ruleGroup['id'], $this->groupID);
$this->assertEquals(count($foundDupes), 4);
- $this->markTestIncomplete('This currenctly fails - see https://lab.civicrm.org/dev/core/issues/397');
CRM_Dedupe_Finder::dupes($ruleGroup['id']);
}
), $pairs);
}
+ /**
+ * Test migration of Membership.
+ */
+ public function testMergeMembership() {
+ // Contacts setup
+ $this->setupMatchData();
+ $originalContactID = $this->contacts[0]['id'];
+ $duplicateContactID = $this->contacts[1]['id'];
+
+ //Add Membership for the duplicate contact.
+ $memTypeId = $this->membershipTypeCreate();
+ $membership = $this->callAPISuccess('Membership', 'create', [
+ 'membership_type_id' => $memTypeId,
+ 'contact_id' => $duplicateContactID,
+ ]);
+ //Assert if 'add new' checkbox is enabled on the merge form.
+ $rowsElementsAndInfo = CRM_Dedupe_Merger::getRowsElementsAndInfo($originalContactID, $duplicateContactID);
+ foreach ($rowsElementsAndInfo['elements'] as $element) {
+ if (!empty($element[3]) && $element[3] == 'add new') {
+ $checkedAttr = ['checked' => 'checked'];
+ $this->checkArrayEquals($element[4], $checkedAttr);
+ }
+ }
+
+ //Merge and move the mem to the main contact.
+ $this->mergeContacts($originalContactID, $duplicateContactID, [
+ 'move_rel_table_memberships' => 1,
+ 'operation' => ['move_rel_table_memberships' => ['add' => 1]]
+ ]);
+
+ //Check if membership is correctly transferred to original contact.
+ $originalContactMembership = $this->callAPISuccess('Membership', 'get', [
+ 'membership_type_id' => $memTypeId,
+ 'contact_id' => $originalContactID,
+ ]);
+ $this->assertEquals(1, $originalContactMembership['count']);
+ }
+
/**
* CRM-19653 : Test that custom field data should/shouldn't be overriden on
* selecting/not selecting option to migrate data respectively
public function tearDown() {
$this->eventDelete($this->_eventId);
- $this->quickCleanup(
- array(
- 'civicrm_contact',
- 'civicrm_contribution',
- 'civicrm_participant',
- 'civicrm_participant_payment',
- 'civicrm_line_item',
- 'civicrm_financial_item',
- 'civicrm_financial_trxn',
- 'civicrm_price_set',
- 'civicrm_entity_financial_trxn',
- ),
- TRUE
- );
+ $this->quickCleanUpFinancialEntities();
}
/**
]
);
$contributionID = $result['contribution']['id'];
- extract($result);
// check payment info
- $paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($participant['id'], 'event');
+ $paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($result['participant']['id'], 'event');
$this->assertEquals(round($paymentInfo['total']), $feeAmt, 'Total amount recorded is not proper');
$this->assertEquals(round($paymentInfo['paid']), $amtPaid, 'Amount paid is not proper');
$this->assertEquals(round($paymentInfo['balance']), $feeAmt, 'Balance amount is not proper');
$form->testSubmit($submitParams);
// check payment info again and see if the payment is completed
- $paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($participant['id'], 'event');
+ $paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($result['participant']['id'], 'event');
$this->assertEquals(round($paymentInfo['total']), $feeAmt, 'Total amount recorded is not proper');
$this->assertEquals(round($paymentInfo['paid']), $feeAmt, 'Amount paid is not proper');
$this->assertEquals(round($paymentInfo['balance']), 0, 'Balance amount is not proper');
$amtPaid = 80;
$result = $this->addParticipantWithPayment($feeAmt, $amtPaid);
$contributionID = $result['contribution']['id'];
- extract($result);
//Complete the partial payment.
$submittedValues = array(
'total_amount' => 20,
'payment_instrument_id' => 3,
);
- CRM_Contribute_BAO_Contribution::recordAdditionalPayment($contributionID, $submittedValues, 'owed', $participant['id']);
+ CRM_Contribute_BAO_Contribution::recordAdditionalPayment($contributionID, $submittedValues, 'owed', $result['participant']['id']);
//Change selection to a lower amount.
$params['price_2'] = 50;
- CRM_Price_BAO_LineItem::changeFeeSelections($params, $participant['id'], 'participant', $contributionID, $feeBlock, $lineItem, $feeAmt);
+ CRM_Price_BAO_LineItem::changeFeeSelections($params, $result['participant']['id'], 'participant', $contributionID, $result['feeBlock'], $result['lineItem']);
//Record a refund of the remaining amount.
$submittedValues['total_amount'] = 50;
- CRM_Contribute_BAO_Contribution::recordAdditionalPayment($contributionID, $submittedValues, 'refund', $participant['id']);
- $paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($participant['id'], 'event', TRUE);
+ CRM_Contribute_BAO_Contribution::recordAdditionalPayment($contributionID, $submittedValues, 'refund', $result['participant']['id']);
+ $paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($result['participant']['id'], 'event', TRUE);
$transaction = $paymentInfo['transaction'];
//Assert all transaction(owed and refund) are listed on view payments.
*/
protected $priceSetFieldID;
+ /**
+ * @var int
+ */
+ private $_contactId;
+
+ /**
+ * @var int
+ */
+ private $_eventId;
+
+ /**
+ * @var array
+ */
+ private $_feeBlock;
+
/**
* Set up for test.
*/
$lineItemVal[$this->_priceSetID] = $lineItems;
CRM_Price_BAO_LineItem::processPriceSet($participant['id'], $lineItemVal, $this->getContributionObject($contribution['id']), 'civicrm_participant');
$this->balanceCheck($this->_expensiveFee);
+ $this->assertEquals(($this->_expensiveFee - $actualPaidAmt), CRM_Contribute_BAO_Contribution::getContributionBalance($this->_contributionId));
+
}
public function testCRM19273() {
*/
public function testCRM20611() {
$this->registerParticipantAndPay();
+ $actualPaidAmount = 100;
$priceSetParams['price_' . $this->priceSetFieldID] = $this->expensiveFeeValueID;
$lineItem = CRM_Price_BAO_LineItem::getLineItems($this->participantID, 'participant');
CRM_Price_BAO_LineItem::changeFeeSelections($priceSetParams, $this->_participantId, 'participant', $this->_contributionId, $this->_feeBlock, $lineItem);
$this->balanceCheck($this->_expensiveFee);
+ $contributionBalance = ($this->_expensiveFee - $actualPaidAmount);
+ $this->assertEquals($contributionBalance, CRM_Contribute_BAO_Contribution::getContributionBalance($this->_contributionId));
$priceSetParams['price_' . $this->priceSetFieldID] = $this->cheapFeeValueID;
$lineItem = CRM_Price_BAO_LineItem::getLineItems($this->participantID, 'participant');
CRM_Price_BAO_LineItem::changeFeeSelections($priceSetParams, $this->_participantId, 'participant', $this->_contributionId, $this->_feeBlock, $lineItem);
$this->balanceCheck($this->_cheapFee);
+ $contributionBalance = ($this->_cheapFee - $actualPaidAmount);
+ $this->assertEquals($contributionBalance, CRM_Contribute_BAO_Contribution::getContributionBalance($this->_contributionId));
//Complete the refund payment.
$submittedValues = array(
'payment_instrument_id' => 3,
);
CRM_Contribute_BAO_Contribution::recordAdditionalPayment($this->_contributionId, $submittedValues, 'refund', $this->_participantId);
+ $contributionBalance += 120;
+ $this->assertEquals($contributionBalance, CRM_Contribute_BAO_Contribution::getContributionBalance($this->_contributionId));
// retrieve the cancelled line-item information
$cancelledLineItem = $this->callAPISuccessGetSingle('LineItem', array(
$this->assertTrue(is_object($exc));
}
+ public function test_requirements() {
+ // Quicksearch requirement should get filtered out per extension-compatibility.json
+ $data = "<extension key='test.foo' type='module'><file>foo</file><requires><ext>example.test</ext><ext>com.ixiam.modules.quicksearch</ext></requires></extension>";
+
+ $info = CRM_Extension_Info::loadFromString($data);
+ $this->assertEquals(['example.test'], $info->requires);
+ }
+
}
'source' => 'SSF',
'contribution_status_id' => 1,
));
- $balance = CRM_Core_BAO_FinancialTrxn::getPartialPaymentWithType($contribution['id'], 'contribution', FALSE, $totalAmount);
+ $balance = CRM_Contribute_BAO_Contribution::getContributionBalance($contribution['id'], $totalAmount);
$this->assertEquals(0.0, $balance);
Civi::settings()->revert('contribution_invoice_settings');
}
}
}
+ public function testEditAllGroupsACL() {
+ $this->setupEditAllGroupsACL();
+ $params = $this->_params;
+ $groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
+ $this->assertNotEmpty($groups, 'If Edit All Groups is granted, at least one group should be visible');
+ }
+
+ /**
+ * Set up an acl allowing Authenticated contacts to Edit All Groups
+ *
+ * You need to have pre-created these groups & created the user e.g
+ * $this->createLoggedInUser();
+ *
+ */
+ public function setupEditAllGroupsACL() {
+ global $_REQUEST;
+ $_REQUEST = $this->_params;
+
+ CRM_Core_Config::singleton()->userPermissionClass->permissions = array('access CiviCRM');
+ $optionGroupID = $this->callAPISuccessGetValue('option_group', array('return' => 'id', 'name' => 'acl_role'));
+ $ov = new CRM_Core_DAO_OptionValue();
+ $ov->option_group_id = $optionGroupID;
+ $ov->value = 55;
+ if ($ov->find(TRUE)) {
+ CRM_Core_DAO::executeQuery("DELETE FROM civicrm_option_value WHERE id = {$ov->id}");
+ }
+ $optionValue = $this->callAPISuccess('option_value', 'create', array(
+ 'option_group_id' => $optionGroupID,
+ 'label' => 'groupmaster',
+ 'value' => 55,
+ ));
+ $groupId = $this->groupCreate(['name' => 'groupmaster group']);
+ // Assign groupmaster to groupmaster group in civicrm_acl_entity_role
+ CRM_Core_DAO::executeQuery("
+ INSERT INTO civicrm_acl_entity_role (
+ `acl_role_id`, `entity_table`, `entity_id`, `is_active`
+ ) VALUES (55, 'civicrm_group', $groupId, 1);
+ ");
+ // Put the user into this group
+ $this->_loggedInUser = CRM_Core_Session::singleton()->get('userID');
+ $this->callAPISuccess('group_contact', 'create', array(
+ 'group_id' => $groupId,
+ 'contact_id' => $this->_loggedInUser,
+ ));
+ // Add the ACL
+ CRM_Core_DAO::executeQuery("
+ INSERT INTO civicrm_acl (
+ `name`, `entity_table`, `entity_id`, `operation`, `object_table`, `object_id`, `is_active`
+ )
+ VALUES (
+ 'core-580', 'civicrm_acl_role', 55, 'Edit', 'civicrm_saved_search', 0, 1
+ );
+ ");
+
+ }
+
}
$schema->disableLogging();
$schema->dropAllLogTables();
CRM_Core_DAO::executeQuery("DROP TABLE IF EXISTS civicrm_test_table");
+ CRM_Core_DAO::executeQuery("DROP TABLE IF EXISTS civicrm_test_column_info");
+ CRM_Core_DAO::executeQuery("DROP TABLE IF EXISTS civicrm_test_length_change");
+ CRM_Core_DAO::executeQuery("DROP TABLE IF EXISTS civicrm_test_enum_change");
}
public function queryExamples() {
$this->assertTrue(empty($diffs['OBSOLETE']));
}
+ /**
+ * Test logging trigger definition
+ */
+ public function testTriggerInfo() {
+ $info = [];
+ $schema = new CRM_Logging_Schema();
+ $schema->enableLogging();
+ $schema->triggerInfo($info, 'civicrm_group');
+ // should have 3 triggers (insert/update/delete)
+ $this->assertCount(3, $info);
+ foreach ($info as $trigger) {
+ // table for trigger should be civicrm_group
+ $this->assertEquals('civicrm_group', $trigger['table'][0]);
+ if ($trigger['event'][0] == 'UPDATE') {
+ // civicrm_group.cache_date should be an exception, i.e. not logged
+ $this->assertNotContains(
+ "IFNULL(OLD.`cache_date`,'') <> IFNULL(NEW.`cache_date`,'')",
+ $trigger['sql']
+ );
+ }
+ }
+ }
+
+ public function testColumnInfo() {
+ CRM_Core_DAO::executeQuery("CREATE TABLE `civicrm_test_column_info` (
+ test_id int(10) unsigned NOT NULL AUTO_INCREMENT,
+ test_varchar varchar(42) NOT NULL,
+ test_integer int(8) NULL,
+ test_decimal decimal(20,2),
+ test_enum enum('A','B','C'),
+ test_integer_default int(8) DEFAULT 42,
+ test_date date DEFAULT NULL,
+ PRIMARY KEY (`test_id`)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
+ $schema = new CRM_Logging_Schema();
+ $schema->enableLogging();
+ $schema->updateLogTableSchema();
+ $ci = \Civi::$statics['CRM_Logging_Schema']['columnSpecs']['civicrm_test_column_info'];
+
+ $this->assertEquals('test_id', $ci['test_id']['COLUMN_NAME']);
+ $this->assertEquals('int', $ci['test_id']['DATA_TYPE']);
+ $this->assertEquals('NO', $ci['test_id']['IS_NULLABLE']);
+ $this->assertEquals('auto_increment', $ci['test_id']['EXTRA']);
+ $this->assertEquals('10', $ci['test_id']['LENGTH']);
+
+ $this->assertEquals('varchar', $ci['test_varchar']['DATA_TYPE']);
+ $this->assertEquals('42', $ci['test_varchar']['LENGTH']);
+
+ $this->assertEquals('int', $ci['test_integer']['DATA_TYPE']);
+ $this->assertEquals('8', $ci['test_integer']['LENGTH']);
+ $this->assertEquals('YES', $ci['test_integer']['IS_NULLABLE']);
+
+ $this->assertEquals('decimal', $ci['test_decimal']['DATA_TYPE']);
+ $this->assertEquals('20,2', $ci['test_decimal']['LENGTH']);
+
+ $this->assertEquals('enum', $ci['test_enum']['DATA_TYPE']);
+ $this->assertEquals("'A','B','C'", $ci['test_enum']['ENUM_VALUES']);
+ $this->assertArrayNotHasKey('LENGTH', $ci['test_enum']);
+
+ $this->assertEquals('42', $ci['test_integer_default']['COLUMN_DEFAULT']);
+
+ $this->assertEquals('date', $ci['test_date']['DATA_TYPE']);
+ }
+
+ public function testIndexes() {
+ $schema = new CRM_Logging_Schema();
+ $indexes = $schema->getIndexesForTable('civicrm_contact');
+ $this->assertContains('PRIMARY', $indexes);
+ $this->assertContains('UI_external_identifier', $indexes);
+ $this->assertContains('FK_civicrm_contact_employer_id', $indexes);
+ $this->assertContains('index_sort_name', $indexes);
+ }
+
+ public function testLengthChange() {
+ CRM_Core_DAO::executeQuery("CREATE TABLE `civicrm_test_length_change` (
+ test_id int(10) unsigned NOT NULL AUTO_INCREMENT,
+ test_integer int(4) NULL,
+ test_decimal decimal(20,2) NULL,
+ PRIMARY KEY (`test_id`)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
+ $schema = new CRM_Logging_Schema();
+ $schema->enableLogging();
+ CRM_Core_DAO::executeQuery(
+ "ALTER TABLE civicrm_test_length_change
+ CHANGE COLUMN test_integer test_integer int(6) NULL,
+ CHANGE COLUMN test_decimal test_decimal decimal(22,2) NULL"
+ );
+ \Civi::$statics['CRM_Logging_Schema']['columnSpecs'] = [];
+ $schema->fixSchemaDifferences();
+ // need to do it twice so the columnSpecs static is refreshed
+ \Civi::$statics['CRM_Logging_Schema']['columnSpecs'] = [];
+ $schema->fixSchemaDifferences();
+ $ci = \Civi::$statics['CRM_Logging_Schema']['columnSpecs'];
+ // length should increase
+ $this->assertEquals(6, $ci['log_civicrm_test_length_change']['test_integer']['LENGTH']);
+ $this->assertEquals('22,2', $ci['log_civicrm_test_length_change']['test_decimal']['LENGTH']);
+ CRM_Core_DAO::executeQuery(
+ "ALTER TABLE civicrm_test_length_change
+ CHANGE COLUMN test_integer test_integer int(4) NULL,
+ CHANGE COLUMN test_decimal test_decimal decimal(20,2) NULL"
+ );
+ \Civi::$statics['CRM_Logging_Schema']['columnSpecs'] = [];
+ $schema->fixSchemaDifferences();
+ \Civi::$statics['CRM_Logging_Schema']['columnSpecs'] = [];
+ $schema->fixSchemaDifferences();
+ $ci = \Civi::$statics['CRM_Logging_Schema']['columnSpecs'];
+ // length should not decrease
+ $this->assertEquals(6, $ci['log_civicrm_test_length_change']['test_integer']['LENGTH']);
+ $this->assertEquals('22,2', $ci['log_civicrm_test_length_change']['test_decimal']['LENGTH']);
+ }
+
+ public function testEnumChange() {
+ CRM_Core_DAO::executeQuery("CREATE TABLE `civicrm_test_enum_change` (
+ test_id int(10) unsigned NOT NULL AUTO_INCREMENT,
+ test_enum enum('A','B','C') NULL,
+ PRIMARY KEY (`test_id`)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
+ $schema = new CRM_Logging_Schema();
+ $schema->enableLogging();
+ CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_test_enum_change CHANGE COLUMN test_enum test_enum enum('A','B','C','D') NULL");
+ \Civi::$statics['CRM_Logging_Schema']['columnSpecs'] = [];
+ $schema->fixSchemaDifferences();
+ // need to do it twice so the columnSpecs static is refreshed
+ \Civi::$statics['CRM_Logging_Schema']['columnSpecs'] = [];
+ $schema->fixSchemaDifferences();
+ $ci = \Civi::$statics['CRM_Logging_Schema']['columnSpecs'];
+ // new enum value should be included
+ $this->assertEquals("'A','B','C','D'", $ci['civicrm_test_enum_change']['test_enum']['ENUM_VALUES']);
+ }
+
}
$this->callAPISuccess('relationship_type', 'delete', array('id' => 20));
}
- /**
- * Test CRM_Member_Form_Membership::buildQuickForm()
- */
- //function testCRMMemberFormMembershipBuildQuickForm()
- //{
- // throw new PHPUnit_Framework_IncompleteTestError( "not implemented" );
- //}
-
/**
* Test CRM_Member_Form_Membership::formRule() with a parameter
* that has an empty contact_select_id value
* @return \CRM_Member_Form_Membership
*/
protected function getForm() {
+ if (isset($_REQUEST['cid'])) {
+ unset($_REQUEST['cid']);
+ }
$form = new CRM_Member_Form_Membership();
$_SERVER['REQUEST_METHOD'] = 'GET';
$form->controller = new CRM_Core_Controller();
$this->assertCsvArraysEqual($expectedOutputCsvArray, $reportCsvArray);
}
+ /**
+ * Test that the pagination widget is present.
+ *
+ * @dataProvider dataProvider
+ * @param $reportClass
+ * @param $inputParams
+ * @throws \Exception
+ */
+ public function testPager($reportClass, $inputParams) {
+ $contactID = $this->individualCreate();
+ for ($i = 1; $i <= 51; $i++) {
+ $this->contributionCreate(['contact_id' => $contactID, 'total_amount' => 50 + $i]);
+ }
+ $reportObj = $this->getReportObject($reportClass, $inputParams);
+ $pager = $reportObj->getTemplate()->_tpl_vars['pager'];
+ $this->assertEquals($pager->_response['numPages'], 2, "Pages in Pager");
+ }
+
/**
* @return array
*/
--- /dev/null
+<?php
+
+/**
+ * Class CRM_Utils_CacheTest
+ * @group headless
+ */
+class CRM_Utils_CacheTest extends CiviUnitTestCase {
+
+ public function testNack() {
+ $values = [];
+ for ($i = 0; $i < 5; $i++) {
+ $nack = CRM_Utils_Cache::nack();
+ $this->assertRegExp('/^NACK:[a-z0-9]+$/', $nack);
+ $values[] = $nack;
+ }
+ sort($values);
+ $this->assertEquals($values, array_unique($values));
+
+ // The random token should at the start should same -- because we don't
+ // the overhead of re-generating it frequently.
+ $this->assertEquals(substr($values[0], 0, 37), substr($values[1], 0, 37));
+ }
+
+}
unlink($newFile);
}
+ public function fileNames() {
+ $cases = [];
+ $cases[] = ['helloworld.txt', TRUE];
+ $cases[] = ['../helloworld.txt', FALSE];
+ // Test case seems to be failing for a strange reason
+ // $cases[] = ['\helloworld.txt', FALSE];
+ $cases[] = ['.helloworld', FALSE];
+ $cases[] = ['smartwatch_1736683_1280_9af3657015e8660cc234eb1601da871.jpg', TRUE];
+ return $cases;
+ }
+
+ /**
+ * Test if the fileName is valid or not
+ * @dataProvider fileNames
+ * @param string $fileName
+ * @param bool $expectedResult
+ */
+ public function testFileNameValid($fileName, $expectedResult) {
+ $this->assertEquals($expectedResult, CRM_Utils_File::isValidFileName($fileName));
+ }
+
}
+++ /dev/null
-<?php
-/**
- * Class CRM_Utils_GeocodeTest
- * @group headless
- */
-class CRM_Utils_GeocodeTest extends CiviUnitTestCase {
-
- public function setUp() {
- parent::setUp();
- }
-
- public function tearDown() {
- parent::tearDown();
- }
-
- /**
- * Test the format returned by Google GeoCoding
- * @group ornery
- */
- public function testStateProvinceFormat() {
- $params = array('state_province_id' => 1022, 'country' => 'U.S.A');
- $formatted = CRM_Utils_Geocode_Google::format($params);
- if (isset($params['geo_code_error']) && $params['geo_code_error'] == 'OVER_QUERY_LIMIT') {
- $this->markTestIncomplete('geo_code_error: OVER_QUERY_LIMIT');
- }
- $this->assertTrue($formatted);
- $this->assertApproxEquals('46.72', $params['geo_code_1'], 1);
- $this->assertApproxEquals('-94.68', $params['geo_code_2'], 1);
- }
-
- /**
- * Test Geoging Method off
- * @group ornery
- */
- public function testGeocodeMethodOff() {
- // Set a geocoding provider.
- $result = civicrm_api3('Setting', 'create', array(
- 'geoProvider' => "Google",
- ));
-
- CRM_Utils_GeocodeProvider::disableForSession();
-
- // Save a contact with geo coding disabled.
- $params = array(
- 'first_name' => 'Abraham',
- 'last_name' => 'Lincoln',
- 'contact_type' => 'Individual',
- 'api.Address.create' => array(
- 'street_address' => '1600 Pennsylvania Avenue',
- 'city' => 'Washington',
- 'state_province' => 'DC',
- 'location_type_id' => 1,
- ),
- );
- $result = civicrm_api3('Contact', 'create', $params);
- $contact_values = array_pop($result['values']);
- $address_values = array_pop($contact_values['api.Address.create']['values']);
-
- $this->assertArrayNotHasKey('geo_code_1', $address_values, 'No geocoding when geocodeMethod is empty');
-
- // Run the geocode job on that specific contact
- CRM_Utils_GeocodeProvider::reset();
- try {
- $params_geocode = array(
- 'start' => $contact_values['id'],
- 'end' => $contact_values['id'] + 1,
- 'geocoding' => 1,
- 'parse' => 0,
- );
- $result_geocode = civicrm_api3('Job', 'geocode', $params_geocode);
- }
- catch (CiviCRM_API3_Exception $e) {
- if ($e->getMessage() == 'Aborting batch geocoding. Hit the over query limit on geocoder.') {
- $this->markTestIncomplete('Job.geocode error_message: A fatal error was triggered: Aborting batch geocoding. Hit the over query limit on geocoder.');
- }
- else {
- throw $e;
- }
- }
- $params_address_getsingle = array(
- 'contact_id' => $contact_values['id'],
- );
- $result_address_getsingle = civicrm_api3('Address', 'getsingle', $params_address_getsingle);
-
- // We should get a geo code setting.
- $this->assertApproxEquals('38.89', CRM_Utils_Array::value('geo_code_1', $result_address_getsingle), 1);
- }
-
-}
$this->setCurrencySeparators(',');
}
+ /**
+ * Test that using the space character as a currency works
+ */
+ public function testSpaceCurrency() {
+ $this->assertEquals(' 8,950.37', CRM_Utils_Money::format(8950.37, ' '));
+ }
+
+ /**
+ * Test that passing an invalid currency throws an error
+ */
+ public function testInvalidCurrency() {
+ $this->setExpectedException(CRM_Core_Exception::class, 'Invalid currency "NOT_A_CURRENCY"');
+ CRM_Utils_Money::format(4.00, 'NOT_A_CURRENCY');
+ }
+
}
* @param array $aclPermissions
* Array of ACL permissions in the format
* [[$action, $financialType], [$action, $financialType])
+ *
+ * @return int Contact ID
*/
protected function createLoggedInUserWithFinancialACL($aclPermissions = [['view', 'Donation']]) {
- CRM_Core_Config::singleton()->userPermissionClass->permissions = ['access CiviCRM'];
- $this->createLoggedInUser();
+ CRM_Core_Config::singleton()->userPermissionClass->permissions = ['access CiviCRM', 'view all contacts'];
+ $contactID = $this->createLoggedInUser();
$this->addFinancialAclPermissions($aclPermissions);
+ return $contactID;
}
/**
-{*
+<?php
+/*
+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*}
-{* added onload javascript for source contact*}
-{literal}
-<script type="text/javascript">
+ */
+
+/**
+ * Trait PriceSetTrait
+ *
+ * Trait for working with Price Sets in tests
+ */
+trait CRMTraits_Financial_PriceSetTrait {
+
/**
- * Function to check activity status in relavent to activity date
+ * Create a contribution with 2 line items.
+ *
+ * This also involves creating t
*
- * @param message JSON object.
+ * @param $params
+ * @param array $lineItemFinancialTypes
+ * Financial Types, if an override is intended.
*/
- function activityStatus(message) {
- var activityDate = cj("#activity_date_time_display").datepicker('getDate');
- if (activityDate) {
- var
- // Ignore time, only compare dates
- today = new Date().setHours(0,0,0,0),
- activityStatusId = cj('#status_id').val();
- if (activityStatusId == 2 && today < activityDate) {
- return confirm(message.completed);
- }
- else if (activityStatusId == 1 && today > activityDate) {
- return confirm(message.scheduled);
- }
+ protected function createContributionWithTwoLineItemsAgainstPriceSet($params, $lineItemFinancialTypes = []) {
+ $params = array_merge(['total_amount' => 300, 'financial_type_id' => 'Donation'], $params);
+ $priceFields = $this->createPriceSet('contribution');
+ foreach ($priceFields['values'] as $key => $priceField) {
+ $financialTypeID = (!empty($lineItemFinancialTypes) ? array_shift($lineItemFinancialTypes) : $priceField['financial_type_id']);
+ $params['line_items'][]['line_item'][$key] = [
+ 'price_field_id' => $priceField['price_field_id'],
+ 'price_field_value_id' => $priceField['id'],
+ 'label' => $priceField['label'],
+ 'field_title' => $priceField['label'],
+ 'qty' => 1,
+ 'unit_price' => $priceField['amount'],
+ 'line_total' => $priceField['amount'],
+ 'financial_type_id' => $financialTypeID,
+ 'entity_table' => 'civicrm_contribution',
+ ];
}
+ $this->callAPISuccess('order', 'create', $params);
}
-</script>
-{/literal}
+}
const FILE_FORBIDDEN_ID = 11;
+ const FILE_UNDELEGATED_ENTITY = 12;
+
const WIDGET_ID = 20;
const FORBIDDEN_ID = 30;
$this->assertRegExp($expectedError, $result['error_message']);
}
+ /**
+ * Test whether trusted API calls bypass the permission check
+ *
+ */
+ public function testNotDelegated() {
+ $entity = 'FakeFile';
+ $action = 'create';
+ $params = [
+ 'entity_id' => self::FILE_UNDELEGATED_ENTITY,
+ 'entity_table' => 'civicrm_membership',
+ 'version' => 3,
+ 'debug' => 1,
+ 'check_permissions' => 1,
+ ];
+ // run with permission check
+ $result = $this->kernel->run('FakeFile', 'create', $params);
+ $this->assertTrue((bool) $result['is_error'], 'Undelegated entity with check_permissions = 1 should fail');
+ $this->assertRegExp('/Unrecognized target entity table \(civicrm_membership\)/', $result['error_message']);
+ // repeat without permission check
+ $params['check_permissions'] = 0;
+ $result = $this->kernel->run('FakeFile', 'create', $params);
+ $this->assertFalse((bool) $result['is_error'], 'Undelegated entity with check_permissions = 0 should succeed');
+ }
+
}
'defaultValue' => 'Default Value',
'lowercasevalue' => 'Lowercase Value',
1 => 'Integer Value',
+ 'NULL' => 'NULL',
];
$custom_field_params = ['sequential' => 1, 'id' => $customField['id']];
$custom_field_api_result = $this->callAPISuccess('custom_field', 'get', $custom_field_params);
$paramsSet['title'] = 'Price Set' . substr(sha1(rand()), 0, 7);
$paramsSet['name'] = CRM_Utils_String::titleToVar($paramsSet['title']);
$paramsSet['is_active'] = TRUE;
- $paramsSet['financial_type_id'] = 4;
+ $paramsSet['financial_type_id'] = 'Event Fee';
$paramsSet['extends'] = 1;
$priceSet = $this->callAPISuccess('price_set', 'create', $paramsSet);
$priceSetId = $priceSet['id'];
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 5 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2019 |
+ +--------------------------------------------------------------------+
+ | 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 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 |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ * Verify that CRM_Utils_Cache_ArrayDecorator complies with PSR-16.
+ *
+ * @group e2e
+ */
+class E2E_Cache_ArrayDecoratorTest extends E2E_Cache_CacheTestCase {
+
+ /**
+ * @var CRM_Utils_Cache_Interface
+ */
+ protected $a;
+
+ public function createSimpleCache() {
+ return new CRM_Utils_Cache_ArrayDecorator(
+ $this->a = CRM_Utils_Cache::create([
+ 'name' => 'e2e array-dec test',
+ 'type' => ['ArrayCache'],
+ ])
+ );
+ }
+
+ public function testDoubleLifeWithDelete() {
+ $this->assertFalse($this->a->has('foo'));
+ $this->assertEquals('dfl-1', $this->a->get('foo', 'dfl-1'));
+
+ $this->cache->set('foo', 100);
+
+ $this->assertTrue($this->a->has('foo'));
+ $this->assertEquals(100, $this->a->get('foo', 'dfl-1')[1]);
+
+ $this->cache->set('foo', 200);
+
+ $this->assertTrue($this->a->has('foo'));
+ $this->assertEquals(200, $this->a->get('foo', 'dfl-1')[1]);
+
+ $this->cache->delete('foo');
+
+ $this->assertFalse($this->a->has('foo'));
+ $this->assertEquals('dfl-1', $this->a->get('foo', 'dfl-1'));
+ }
+
+ public function testDoubleLifeWithClear() {
+ $this->assertFalse($this->a->has('foo'));
+ $this->assertEquals('dfl-1', $this->a->get('foo', 'dfl-1'));
+
+ $this->cache->set('foo', 100);
+
+ $this->assertTrue($this->a->has('foo'));
+ $this->assertEquals(100, $this->a->get('foo', 'dfl-1')[1]);
+
+ $this->cache->clear();
+
+ $this->assertFalse($this->a->has('foo'));
+ $this->assertEquals('dfl-1', $this->a->get('foo', 'dfl-1'));
+ }
+
+}
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 5 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2019 |
+ +--------------------------------------------------------------------+
+ | 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 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 |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ * Verify that CRM_Utils_Cache_FastArrayDecorator complies with PSR-16.
+ *
+ * @group e2e
+ */
+class E2E_Cache_FastArrayDecoratorTest extends E2E_Cache_ArrayDecoratorTest {
+
+ /**
+ * @var CRM_Utils_Cache_Interface
+ */
+ protected $a;
+
+ public function createSimpleCache() {
+ return new CRM_Utils_Cache_FastArrayDecorator(
+ $this->a = CRM_Utils_Cache::create([
+ 'name' => 'e2e fast-arr-dec test',
+ 'type' => ['ArrayCache'],
+ ])
+ );
+ }
+
+ public function testSetTtl() {
+ $this->markTestSkipped('FastArrayDecorator breaks convention: Does not track TTL locally. However, TTL is passed along to delegate.');
+ }
+
+ public function testSetMultipleTtl() {
+ $this->markTestSkipped('FastArrayDecorator breaks convention: Does not track TTL locally. However, TTL is passed along to delegate.');
+ }
+
+ public function testDoubleLifeWithDelete() {
+ $this->markTestSkipped('FastArrayDecorator breaks convention: Does not track TTL locally. However, TTL is passed along to delegate.');
+ }
+
+ public function testDoubleLifeWithClear() {
+ $this->markTestSkipped('FastArrayDecorator breaks convention: Does not track TTL locally. However, TTL is passed along to delegate.');
+ }
+
+ public function testObjectDoesNotChangeInCache() {
+ $this->markTestSkipped('FastArrayDecorator breaks convention: No deep-copying cache content');
+ }
+
+}
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 5 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2019 |
+ +--------------------------------------------------------------------+
+ | 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 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 |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ * Verify that CRM_Utils_Cache_Tiered complies with PSR-16.
+ *
+ * @group e2e
+ */
+class E2E_Cache_TieredTest extends E2E_Cache_CacheTestCase {
+ const TOLERANCE = 5;
+
+ /**
+ * @var CRM_Utils_Cache_ArrayCache
+ */
+ protected $a, $b;
+
+ protected function tearDown() {
+ if (function_exists('timecop_return')) {
+ timecop_return();
+ }
+ parent::tearDown();
+ }
+
+ public function createSimpleCache($maxTimeouts = [86400]) {
+ return new CRM_Utils_Cache_Tiered([
+ $this->a = CRM_Utils_Cache::create([
+ 'name' => 'e2e tiered test a',
+ 'type' => ['ArrayCache'],
+ ]),
+ $this->b = CRM_Utils_Cache::create([
+ 'name' => 'e2e tiered test b',
+ 'type' => ['ArrayCache'],
+ ])
+ ], $maxTimeouts);
+ }
+
+ public function testDoubleLifeWithDelete() {
+ $this->assertFalse($this->a->has('foo'));
+ $this->assertFalse($this->b->has('foo'));
+ $this->assertEquals('dfl-1', $this->a->get('foo', 'dfl-1'));
+ $this->assertEquals('dfl-2', $this->b->get('foo', 'dfl-2'));
+
+ $this->cache->set('foo', 100);
+
+ $this->assertTrue($this->a->has('foo'));
+ $this->assertTrue($this->b->has('foo'));
+ $this->assertEquals(100, $this->a->get('foo', 'dfl-1')[1]);
+ $this->assertEquals(100, $this->b->get('foo', 'dfl-2')[1]);
+ $this->assertEquals($this->a->get('foo'), $this->b->get('foo'));
+
+ $this->cache->set('foo', 200);
+
+ $this->assertTrue($this->a->has('foo'));
+ $this->assertTrue($this->b->has('foo'));
+ $this->assertEquals(200, $this->a->get('foo', 'dfl-1')[1]);
+ $this->assertEquals(200, $this->b->get('foo', 'dfl-2')[1]);
+ $this->assertEquals($this->a->get('foo'), $this->b->get('foo'));
+
+ $this->cache->delete('foo');
+
+ $this->assertFalse($this->a->has('foo'));
+ $this->assertFalse($this->b->has('foo'));
+ $this->assertEquals('dfl-1', $this->a->get('foo', 'dfl-1'));
+ $this->assertEquals('dfl-2', $this->b->get('foo', 'dfl-2'));
+ }
+
+ public function testDoubleLifeWithClear() {
+ $this->assertFalse($this->a->has('foo'));
+ $this->assertFalse($this->b->has('foo'));
+ $this->assertEquals('dfl-1', $this->a->get('foo', 'dfl-1'));
+ $this->assertEquals('dfl-2', $this->b->get('foo', 'dfl-2'));
+
+ $this->cache->set('foo', 100);
+
+ $this->assertTrue($this->a->has('foo'));
+ $this->assertTrue($this->b->has('foo'));
+ $this->assertEquals(100, $this->a->get('foo', 'dfl-1')[1]);
+ $this->assertEquals(100, $this->b->get('foo', 'dfl-2')[1]);
+ $this->assertEquals($this->a->get('foo'), $this->b->get('foo'));
+
+ $this->cache->clear();
+
+ $this->assertFalse($this->a->has('foo'));
+ $this->assertFalse($this->b->has('foo'));
+ $this->assertEquals('dfl-1', $this->a->get('foo', 'dfl-1'));
+ $this->assertEquals('dfl-2', $this->b->get('foo', 'dfl-2'));
+ }
+
+ public function testTieredTimeout_default() {
+ $start = CRM_Utils_Time::getTimeRaw();
+ $this->cache = $this->createSimpleCache([100, 1000]);
+
+ $this->cache->set('foo', 'bar');
+ $this->assertApproxEquals($start + 100, $this->a->getExpires('foo'), self::TOLERANCE);
+ $this->assertApproxEquals($start + 1000, $this->b->getExpires('foo'), self::TOLERANCE);
+
+ // Simulate expiration & repopulation in nearest tier.
+
+ $this->a->clear();
+ $this->assertApproxEquals(NULL, $this->a->getExpires('foo'), self::TOLERANCE);
+ $this->assertApproxEquals($start + 1000, $this->b->getExpires('foo'), self::TOLERANCE);
+
+ $this->assertEquals('bar', $this->cache->get('foo'));
+ $this->assertApproxEquals($start + 100, $this->a->getExpires('foo'), self::TOLERANCE);
+ $this->assertApproxEquals($start + 1000, $this->b->getExpires('foo'), self::TOLERANCE);
+ }
+
+ public function testTieredTimeout_explicitLow() {
+ $start = CRM_Utils_Time::getTimeRaw();
+ $this->cache = $this->createSimpleCache([100, 1000]);
+
+ $this->cache->set('foo', 'bar', 50);
+ $this->assertApproxEquals($start + 50, $this->a->getExpires('foo'), self::TOLERANCE);
+ $this->assertApproxEquals($start + 50, $this->b->getExpires('foo'), self::TOLERANCE);
+
+ // Simulate expiration & repopulation in nearest tier.
+
+ $this->a->clear();
+ $this->assertApproxEquals(NULL, $this->a->getExpires('foo'), self::TOLERANCE);
+ $this->assertApproxEquals($start + 50, $this->b->getExpires('foo'), self::TOLERANCE);
+
+ $this->assertEquals('bar', $this->cache->get('foo'));
+ $this->assertApproxEquals($start + 50, $this->a->getExpires('foo'), self::TOLERANCE);
+ $this->assertApproxEquals($start + 50, $this->b->getExpires('foo'), self::TOLERANCE);
+ }
+
+ public function testTieredTimeout_explicitMedium() {
+ $start = CRM_Utils_Time::getTimeRaw();
+ $this->cache = $this->createSimpleCache([100, 1000]);
+
+ $this->cache->set('foo', 'bar', 500);
+ $this->assertApproxEquals($start + 100, $this->a->getExpires('foo'), self::TOLERANCE);
+ $this->assertApproxEquals($start + 500, $this->b->getExpires('foo'), self::TOLERANCE);
+
+ // Simulate expiration & repopulation in nearest tier.
+
+ $this->a->clear();
+ $this->assertApproxEquals(NULL, $this->a->getExpires('foo'), self::TOLERANCE);
+ $this->assertApproxEquals($start + 500, $this->b->getExpires('foo'), self::TOLERANCE);
+
+ $this->assertEquals('bar', $this->cache->get('foo'));
+ $this->assertApproxEquals($start + 100, $this->a->getExpires('foo'), self::TOLERANCE);
+ $this->assertApproxEquals($start + 500, $this->b->getExpires('foo'), self::TOLERANCE);
+ }
+
+ public function testTieredTimeout_explicitHigh_lateReoad() {
+ $start = CRM_Utils_Time::getTimeRaw();
+ $this->cache = $this->createSimpleCache([100, 1000]);
+
+ $this->cache->set('foo', 'bar', 5000);
+ $this->assertApproxEquals($start + 100, $this->a->getExpires('foo'), self::TOLERANCE);
+ $this->assertApproxEquals($start + 1000, $this->b->getExpires('foo'), self::TOLERANCE);
+
+ // Simulate expiration & repopulation in nearest tier.
+
+ $this->a->clear();
+ $this->assertApproxEquals(NULL, $this->a->getExpires('foo'), self::TOLERANCE);
+ $this->assertApproxEquals($start + 1000, $this->b->getExpires('foo'), self::TOLERANCE);
+
+ function_exists('timecop_return') ? timecop_travel(time() + self::TOLERANCE) : sleep(self::TOLERANCE);
+
+ $this->assertEquals('bar', $this->cache->get('foo'));
+ $this->assertApproxEquals($start + 100 + self::TOLERANCE, $this->a->getExpires('foo'), self::TOLERANCE);
+ $this->assertApproxEquals($start + 1000, $this->b->getExpires('foo'), self::TOLERANCE);
+ }
+
+ /**
+ * Assert that two numbers are approximately equal.
+ *
+ * @param int|float $expected
+ * @param int|float $actual
+ * @param int|float $tolerance
+ * @param string $message
+ */
+ public function assertApproxEquals($expected, $actual, $tolerance, $message = NULL) {
+ if ($message === NULL) {
+ $message = sprintf("approx-equals: expected=[%.3f] actual=[%.3f] tolerance=[%.3f]", $expected, $actual, $tolerance);
+ }
+ $this->assertTrue(abs($actual - $expected) < $tolerance, $message);
+ }
+
+}
$query = new \CRM_Contact_BAO_Query(array(), NULL, NULL, FALSE, FALSE, 1, FALSE, TRUE, FALSE, NULL, 'AND');
$sql = $query->searchQuery($start, $prefillLimit, $sort, FALSE, $query->_includeContactIds,
FALSE, TRUE, TRUE);
- $selectSQL = "SELECT DISTINCT '$this->cacheKey', contact_a.id, contact_a.sort_name";
+ $selectSQL = "SELECT DISTINCT %1, contact_a.id, contact_a.sort_name";
$sql = str_replace(array("SELECT contact_a.id as contact_id", "SELECT contact_a.id as id"), $selectSQL, $sql);
$this->assertTrue(
- $this->prevNext->fillWithSql($this->cacheKey, $sql),
+ $this->prevNext->fillWithSql($this->cacheKey, $sql, [1 => [$this->cacheKey, 'String']]),
"fillWithSql should return TRUE on success"
);
'mime_type' => 'text/plain',
'description' => 'My test description',
'content' => 'My test content',
+ 'check_permissions' => 1,
),
"/Unrecognized target entity/",
);
$getResult = $this->callAPISuccess('Attachment', 'get', $getParams);
$actualNames = array_values(CRM_Utils_Array::collect('name', $getResult['values']));
+ // Verify the hash generated by the API is valid if we were to try and load the file.
+ foreach ($getResult['values'] as $result) {
+ $queryResult = [];
+ $parsedURl = parse_url($result['url']);
+ $parsedQuery = parse_str($parsedURl['query'], $queryResult);
+ $this->assertTrue(CRM_Core_BAO_File::validateFileHash($queryResult['fcs'], $queryResult['eid'], $queryResult['id']));
+ }
+
sort($actualNames);
sort($expectedNames);
$this->assertEquals($expectedNames, $actualNames);
$this->assertEquals(array('external_identifier'), $result['values']['UI_external_identifier']);
}
+ /**
+ * API test to retrieve contact from group having different group title and name.
+ */
+ public function testContactGetFromGroup() {
+ $groupId = $this->groupCreate([
+ 'name' => 'Test_Group',
+ 'domain_id' => 1,
+ 'title' => 'New Test Group Created',
+ 'description' => 'New Test Group Created',
+ 'is_active' => 1,
+ 'visibility' => 'User and User Admin Only',
+ ]);
+ $contact = $this->callAPISuccess('contact', 'create', $this->_params);
+ $groupContactCreateParams = array(
+ 'contact_id' => $contact['id'],
+ 'group_id' => $groupId,
+ 'status' => 'Pending',
+ );
+ $groupContact = $this->callAPISuccess('groupContact', 'create', $groupContactCreateParams);
+ $groupGetContact = $this->CallAPISuccess('groupContact', 'get', $groupContactCreateParams);
+ $this->CallAPISuccess('Contact', 'getcount', [
+ 'group' => "Test_Group",
+ ]);
+ }
+
public function testSmartGroupsForRelatedContacts() {
$rtype1 = $this->callAPISuccess('relationship_type', 'create', array(
"name_a_b" => uniqid() . " Child of",
$this->assertEquals($note['values'][$note['id']]['note'], "Test note created by API Call as array");
}
+ /**
+ * Verify that passing tag IDs to Contact.get works
+ *
+ * Tests the following formats
+ * - Contact.get tag='id1'
+ * - Contact.get tag='id1,id2'
+ * - Contact.get tag='id1, id2'
+ */
+ public function testContactGetWithTag() {
+ $contact = $this->callApiSuccess('Contact', 'create', [
+ 'contact_type' => 'Individual',
+ 'first_name' => 'Test',
+ 'last_name' => 'Tagged',
+ 'email' => 'test@example.org',
+ ]);
+ $tags = [];
+ foreach (['Tag A', 'Tag B'] as $name) {
+ $tags[] = $this->callApiSuccess('Tag', 'create', [
+ 'name' => $name
+ ]);
+ }
+
+ // assign contact to "Tag B"
+ $this->callApiSuccess('EntityTag', 'create', [
+ 'entity_table' => 'civicrm_contact',
+ 'entity_id' => $contact['id'],
+ 'tag_id' => $tags[1]['id'],
+ ]);
+
+ // test format Contact.get tag='id1'
+ $contact_get = $this->callAPISuccess('Contact', 'get', [
+ 'tag' => $tags[1]['id'],
+ 'return' => 'tag',
+ ]);
+ $this->assertEquals(1, $contact_get['count']);
+ $this->assertEquals($contact['id'], $contact_get['id']);
+ $this->assertEquals('Tag B', $contact_get['values'][$contact['id']]['tags']);
+
+ // test format Contact.get tag='id1,id2'
+ $contact_get = $this->callAPISuccess('Contact', 'get', [
+ 'tag' => $tags[0]['id'] . ',' . $tags[1]['id'],
+ 'return' => 'tag',
+ ]);
+ $this->assertEquals(1, $contact_get['count']);
+ $this->assertEquals($contact['id'], $contact_get['id']);
+ $this->assertEquals('Tag B', $contact_get['values'][$contact['id']]['tags']);
+
+ // test format Contact.get tag='id1, id2'
+ $contact_get = $this->callAPISuccess('Contact', 'get', [
+ 'tag' => $tags[0]['id'] . ', ' . $tags[1]['id'],
+ 'return' => 'tag',
+ ]);
+ $this->assertEquals(1, $contact_get['count']);
+ $this->assertEquals($contact['id'], $contact_get['id']);
+ $this->assertEquals('Tag B', $contact_get['values'][$contact['id']]['tags']);
+
+ foreach ($tags as $tag) {
+ $this->callAPISuccess('Tag', 'delete', ['id' => $tag['id']]);
+ }
+ $this->callAPISuccess('Contact', 'delete', [
+ 'id' => $contact['id'],
+ 'skip_undelete' => TRUE
+ ]);
+ }
+
}
// ** Pass 1: Create
$createParams = $this->_params;
- $createParams['groups']['include'] = array($groupIDs['a']);
- $createParams['groups']['exclude'] = array();
- $createParams['mailings']['include'] = array();
- $createParams['mailings']['exclude'] = array();
- $createParams['api.mailing_job.create'] = 1;
+ $createParams['groups']['include'] = [$groupIDs['a']];
+ $createParams['groups']['exclude'] = [];
+ $createParams['mailings']['include'] = [];
+ $createParams['mailings']['exclude'] = [];
+ $createParams['scheduled_date'] = 'now';
$createResult = $this->callAPISuccess('Mailing', 'create', $createParams);
$getGroup1 = $this->callAPISuccess('MailingGroup', 'get', array('mailing_id' => $createResult['id']));
$getGroup1_ids = array_values(CRM_Utils_Array::collect('entity_id', $getGroup1['values']));
$updateParams = $createParams;
$updateParams['id'] = $createResult['id'];
$updateParams['groups']['include'] = array($groupIDs['b']);
- $updateParams['api.mailing_job.create'] = 1;
+ $updateParams['scheduled_date'] = 'now';
$this->callAPISuccess('Mailing', 'create', $updateParams);
$getGroup3 = $this->callAPISuccess('MailingGroup', 'get', array('mailing_id' => $createResult['id']));
$getGroup3_ids = array_values(CRM_Utils_Array::collect('entity_id', $getGroup3['values']));
));
}
+ /**
+ * Test email receipt for partial payment.
+ */
+ public function testPaymentEmailReceipt() {
+ $mut = new CiviMailUtils($this);
+ list($lineItems, $contribution) = $this->createParticipantWithContribution();
+ $event = $this->callAPISuccess('Event', 'get', []);
+ $this->addLocationToEvent($event['id']);
+ $params = [
+ 'contribution_id' => $contribution['id'],
+ 'total_amount' => 50,
+ 'check_number' => '345',
+ 'trxn_date' => '2018-08-13 17:57:56',
+ ];
+ $payment = $this->callAPISuccess('payment', 'create', $params);
+ $this->checkPaymentResult($payment, [
+ $payment['id'] => [
+ 'from_financial_account_id' => 7,
+ 'to_financial_account_id' => 6,
+ 'total_amount' => 50,
+ 'status_id' => 1,
+ 'is_payment' => 1,
+ ],
+ ]);
+
+ $this->callAPISuccess('Payment', 'sendconfirmation', ['id' => $payment['id']]);
+ $mut->assertSubjects(['Payment Receipt - Annual CiviCRM meet']);
+ $mut->checkMailLog(array(
+ 'Dear Anthony,',
+ 'Total Fees: $ 300.00',
+ 'This Payment Amount: $ 50.00',
+ 'Balance Owed: $ 100.00', //150 was paid in the 1st payment.
+ 'Event Information and Location',
+ 'Paid By: Check',
+ 'Check Number: 345',
+ 'Transaction Date: August 13th, 2018 5:57 PM',
+ 'event place',
+ 'streety street',
+ ));
+ $mut->stop();
+ $mut->clearMessages();
+ }
+
+ /**
+ * Test email receipt for partial payment.
+ */
+ public function testPaymentEmailReceiptFullyPaid() {
+ $mut = new CiviMailUtils($this);
+ list($lineItems, $contribution) = $this->createParticipantWithContribution();
+
+ $params = [
+ 'contribution_id' => $contribution['id'],
+ 'total_amount' => 150,
+ ];
+ $payment = $this->callAPISuccess('payment', 'create', $params);
+
+ $this->callAPISuccess('Payment', 'sendconfirmation', ['id' => $payment['id']]);
+ $mut->assertSubjects(['Payment Receipt - Annual CiviCRM meet']);
+ $mut->checkMailLog(array(
+ 'Dear Anthony,',
+ 'A payment has been received.',
+ 'Total Fees: $ 300.00',
+ 'This Payment Amount: $ 150.00',
+ 'Balance Owed: $ 0.00',
+ 'Thank you for completing payment.',
+ ));
+ $mut->stop();
+ $mut->clearMessages();
+ }
+
+ /**
+ * Test email receipt for partial payment.
+ *
+ * @dataProvider getThousandSeparators
+ *
+ * @param string $thousandSeparator
+ */
+ public function testRefundEmailReceipt($thousandSeparator) {
+ $this->setCurrencySeparators($thousandSeparator);
+ $decimalSeparator = ($thousandSeparator === ',' ? '.' : ',');
+ $mut = new CiviMailUtils($this);
+ list($lineItems, $contribution) = $this->createParticipantWithContribution();
+ $this->callAPISuccess('payment', 'create', [
+ 'contribution_id' => $contribution['id'],
+ 'total_amount' => 50,
+ 'check_number' => '345',
+ 'trxn_date' => '2018-08-13 17:57:56',
+ ]);
+
+ $payment = $this->callAPISuccess('payment', 'create', [
+ 'contribution_id' => $contribution['id'],
+ 'total_amount' => -30,
+ 'trxn_date' => '2018-11-13 12:01:56',
+ ]);
+
+ $this->checkPaymentResult($payment, [
+ $payment['id'] => [
+ 'from_financial_account_id' => 7,
+ 'to_financial_account_id' => 6,
+ 'total_amount' => -30,
+ 'status_id' => 1,
+ 'is_payment' => 1,
+ ],
+ ]);
+
+ $this->callAPISuccess('Payment', 'sendconfirmation', ['id' => $payment['id']]);
+ $mut->assertSubjects(['Refund Notification - Annual CiviCRM meet']);
+ $mut->checkMailLog(array(
+ 'Dear Anthony,',
+ 'A refund has been issued based on changes in your registration selections.',
+ 'Total Fees: $ 300' . $decimalSeparator . '00',
+ 'Refund Amount: $ -30' . $decimalSeparator . '00',
+ 'Event Information and Location',
+ 'Paid By: Check',
+ 'Transaction Date: November 13th, 2018 12:01 PM',
+ 'You Paid: $ 170' . $decimalSeparator . '00',
+ ));
+ $mut->stop();
+ $mut->clearMessages();
+ }
+
/**
* Test create payment api with no line item in params
*/
));
}
+ /**
+ * Add a location to our event.
+ *
+ * @param int $eventID
+ */
+ protected function addLocationToEvent($eventID) {
+ $addressParams = [
+ 'name' => 'event place',
+ 'street_address' => 'streety street',
+ 'location_type_id' => 1,
+ 'is_primary' => 1,
+ ];
+ // api requires contact_id - perhaps incorrectly but use add to get past that.
+ $address = CRM_Core_BAO_Address::add($addressParams);
+
+ $location = $this->callAPISuccess('LocBlock', 'create', ['address_id' => $address->id]);
+ $this->callAPISuccess('Event', 'create', [
+ 'id' => $eventID,
+ 'loc_block_id' => $location['id'],
+ 'is_show_location' => TRUE,
+ ]);
+ }
+
}
* Get Billing empty contact - this will return generic defaults
*/
public function testProfileGetBillingEmptyContact() {
-
+ $this->callAPISuccess('Setting', 'create', ['defaultContactCountry' => 1228]);
$params = array(
'profile_id' => array('Billing'),
);
<dataPattern>/^\d+$/</dataPattern>
<comment>FK to Contact ID</comment>
<html>
- <type>EntityRef</type>
- </html>
+ <type>EntityRef</type>
+ </html>
<add>1.3</add>
</field>
<foreignKey>
</primaryKey>
<field>
<name>contact_id</name>
- <title>Contact ID</title>
+ <title>Contact</title>
<type>int unsigned</type>
<required>true</required>
- <comment>Foreign key to civicrm_contact.id .</comment>
+ <comment>Foreign key to civicrm_contact.id.</comment>
<add>1.6</add>
+ <html>
+ <type>EntityRef</type>
+ </html>
</field>
<foreignKey>
<name>contact_id</name>
</field>
<field>
<name>start_date</name>
- <title>Recurring Contribution Started Date</title>
+ <title>Start Date</title>
<type>datetime</type>
<required>true</required>
<comment>The date the first scheduled recurring contribution occurs.</comment>
<add>1.6</add>
<html>
<type>Select Date</type>
- <formatType>activityDate</formatType>
+ <formatType>activityDateTime</formatType>
</html>
</field>
<field>
<name>create_date</name>
- <title>Recurring Contribution Created Date</title>
+ <title>Created Date</title>
<type>datetime</type>
<required>true</required>
<comment>When this recurring contribution record was created.</comment>
<add>1.6</add>
<html>
<type>Select Date</type>
- <formatType>activityDate</formatType>
+ <formatType>activityDateTime</formatType>
</html>
</field>
<field>
<name>modified_date</name>
- <title>Recurring Contribution Modified Date</title>
+ <title>Modified Date</title>
<type>datetime</type>
<comment>Last updated date for this record. mostly the last time a payment was received</comment>
<add>1.6</add>
<html>
<type>Select Date</type>
- <formatType>activityDate</formatType>
+ <formatType>activityDateTime</formatType>
</html>
</field>
<field>
<name>cancel_date</name>
- <title>Recurring Contribution Cancel Date</title>
+ <title>Cancel Date</title>
<type>datetime</type>
<comment>Date this recurring contribution was cancelled by contributor- if we can get access to it</comment>
<add>1.6</add>
<length>255</length>
<comment>Possibly needed to store a unique identifier for this recurring payment order - if this is available from the processor??</comment>
<add>1.6</add>
+ <html>
+ <type>Text</type>
+ </html>
</field>
<field>
<name>payment_token_id</name>
<length>255</length>
<comment>unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method</comment>
<add>1.6</add>
+ <html>
+ <type>Text</type>
+ </html>
</field>
<field>
<name>invoice_id</name>
<length>255</length>
<comment>unique invoice id, system generated or passed in</comment>
<add>1.6</add>
+ <html>
+ <type>Text</type>
+ </html>
</field>
<index>
<name>UI_contrib_trxn_id</name>
</index>
<field>
<name>contribution_status_id</name>
- <title>Recurring Contribution Status</title>
+ <title>Status</title>
<type>int unsigned</type>
<default>1</default>
<import>true</import>
<pseudoconstant>
<optionGroupName>contribution_status</optionGroupName>
</pseudoconstant>
+ <html>
+ <type>Select</type>
+ </html>
</field>
<index>
<name>index_contribution_status</name>
</field>
<field>
<name>cycle_day</name>
- <title>Number of Cycle Day</title>
+ <title>Cycle Day</title>
<type>int unsigned</type>
<default>1</default>
<required>true</required>
<type>int unsigned</type>
<comment>Foreign key to civicrm_payment_processor.id</comment>
<add>3.3</add>
+ <html>
+ <type>Select</type>
+ </html>
</field>
<foreignKey>
<name>payment_processor_id</name>
<keyColumn>id</keyColumn>
<labelColumn>name</labelColumn>
</pseudoconstant>
+ <html>
+ <type>Select</type>
+ </html>
</field>
<foreignKey>
<name>financial_type_id</name>
<labelColumn>title</labelColumn>
</pseudoconstant>
<add>4.1</add>
+ <html>
+ <type>Select</type>
+ </html>
</field>
<foreignKey>
<name>campaign_id</name>
<length>255</length>
<comment>Foreign Key to Note Privacy Level (which is an option value pair and hence an implicit FK)</comment>
<add>3.3</add>
+ <html>
+ <type>Select</type>
+ </html>
<pseudoconstant>
<optionGroupName>note_privacy</optionGroupName>
</pseudoconstant>
<type>int unsigned</type>
<comment>FK to Contact ID</comment>
<add>3.3</add>
+ <required>TRUE</required>
</field>
<foreignKey>
<name>contact_id1</name>
<type>int unsigned</type>
<comment>FK to Contact ID</comment>
<add>3.3</add>
+ <required>TRUE</required>
</field>
<foreignKey>
<name>contact_id2</name>
{capture assign=emptyBlockStyle }style="padding: 10px; border-bottom: 1px solid #999;background-color: #f7f7f7;"{/capture}
{capture assign=emptyBlockValueStyle }style="padding: 10px; border-bottom: 1px solid #999;"{/capture}
-<p>Dear {$contactDisplayName}</p>
<center>
<table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
<!-- END HEADER -->
<!-- BEGIN CONTENT -->
-
+ {if $emailGreeting}<tr><td>{$emailGreeting},</td></tr>{/if}
<tr>
<td>
{if $isRefund}
{else}
<p>{ts}A payment has been received.{/ts}</p>
{/if}
- <p>{ts}Please print this confirmation for your records.{/ts}</p>
</td>
</tr>
<tr>
<tr>
<td>
<table style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse; width:100%;">
- {if $contributeMode eq 'direct' and !$isAmountzero}
+ {if $billingName || $address}
<tr>
<th {$headerStyle}>
{ts}Billing Name and Address{/ts}
</td>
</tr>
{/if}
- {if $contributeMode eq'direct' and !$isAmountzero}
+ {if $credit_card_number}
<tr>
<th {$headerStyle}>
{ts}Credit Card Information{/ts}
-Dear {$contactDisplayName}
-{if $isRefund}
+{if $emailGreeting}{$emailGreeting},
+{/if}{if $isRefund}
{ts}A refund has been issued based on changes in your registration selections.{/ts}
{else}
{ts}A payment has been received.{/ts}
{/if}
-{ts}Please print this confirmation for your records.{/ts}
-
{if $isRefund}
===============================================================================
{if $checkNumber}
{ts}Check Number{/ts}: {$checkNumber}
{/if}
-{if $contributeMode eq 'direct' and !$isAmountzero}
+{if $billingName || $address}
===============================================================================
{$address}
{/if}
-{if $contributeMode eq 'direct' and !$isAmountzero}
+{if $credit_card_number}
===========================================================
{ts}Credit Card Information{/ts}
<?xml version="1.0" encoding="iso-8859-1" ?>
<version>
- <version_no>5.11.alpha1</version_no>
+ <version_no>5.12.alpha1</version_no>
</version>