From a4aea74571b86baaaf2287bb6ebfb4e09cbd85e8 Mon Sep 17 00:00:00 2001 From: Ruben Rodriguez Date: Thu, 10 Sep 2015 18:24:23 -0400 Subject: [PATCH] Added the current uncommited changes to production code, and rebased to 4.6.8 --- CRM/Activity/BAO/Activity.php | 3 +- CRM/Contact/BAO/Contact/Utils.php | 2 +- CRM/Contact/BAO/GroupContact.php | 6 ++- CRM/Contact/Form/Task/PDFLatexCommon.php | 9 ++-- CRM/Event/BAO/Participant.php | 4 +- CRM/Member/BAO/Membership.php | 3 +- CRM/Member/Import/Form/DataSource.php | 19 +++++++++ CRM/Price/BAO/PriceSet.php | 28 +++++++++++++ CRM/Utils/PDF/Utils.php | 41 +++++++++++++++---- .../Form/Contribution/PremiumBlock.tpl | 9 ++++ 10 files changed, 106 insertions(+), 18 deletions(-) diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index 965e91d291..3e28ab6901 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -519,7 +519,8 @@ class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity { } } - CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush(); + // reset the group contact cache since smart groups might be affected due to this + // CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush(); // if the subject contains a ‘[case #…]’ string, file that activity on the related case (CRM-5916) $matches = []; diff --git a/CRM/Contact/BAO/Contact/Utils.php b/CRM/Contact/BAO/Contact/Utils.php index da904c31b8..6f4b97664e 100644 --- a/CRM/Contact/BAO/Contact/Utils.php +++ b/CRM/Contact/BAO/Contact/Utils.php @@ -968,7 +968,7 @@ INNER JOIN civicrm_contact contact_target ON ( contact_target.id = act.contact_i FROM civicrm_contact WHERE contact_type = %1 AND ({$idFldName} IS NULL - OR ( {$idFldName} IS NOT NULL AND ({$displayFldName} IS NULL OR {$displayFldName} = '')) )"; + OR ( {$idFldName} IS NOT NULL AND ({$displayFldName} IS NULL OR {$displayFldName} = '')) ) LIMIT 800"; } if ($limit) { diff --git a/CRM/Contact/BAO/GroupContact.php b/CRM/Contact/BAO/GroupContact.php index 8580a787d3..aae14931b4 100644 --- a/CRM/Contact/BAO/GroupContact.php +++ b/CRM/Contact/BAO/GroupContact.php @@ -130,7 +130,11 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact implemen $result = self::bulkAddContactsToGroup($contactIds, $groupId, $method, $status, $tracking); CRM_Contact_BAO_GroupContactCache::invalidateGroupContactCache($groupId); - CRM_Contact_BAO_Contact_Utils::clearContactCaches(); + + // reset the group contact cache for all group(s) + // if this group is being used as a smart group + // HACK: Dave had to disable an earlier version of this, but no longer is upstream! + //CRM_Contact_BAO_Contact_Utils::clearContactCaches(); CRM_Utils_Hook::post('create', 'GroupContact', $groupId, $contactIds); diff --git a/CRM/Contact/Form/Task/PDFLatexCommon.php b/CRM/Contact/Form/Task/PDFLatexCommon.php index a0ca45339c..4dbdb1806b 100644 --- a/CRM/Contact/Form/Task/PDFLatexCommon.php +++ b/CRM/Contact/Form/Task/PDFLatexCommon.php @@ -48,7 +48,7 @@ class CRM_Contact_Form_Task_PDFLatexCommon { static function preProcess(&$form) { $messageText = array(); $messageSubject = array(); - $dao = new CRM_Core_BAO_MessageTemplates(); + $dao = new CRM_Core_BAO_MessageTemplate(); $dao->is_active = 1; $dao->find(); while ($dao->fetch()) { @@ -254,14 +254,14 @@ class CRM_Contact_Form_Task_PDFLatexCommon { } if (CRM_Utils_Array::value('saveTemplate', $formValues) && $formValues['saveTemplate']) { $messageTemplate['msg_title'] = $formValues['saveTemplateName']; - CRM_Core_BAO_MessageTemplates::add($messageTemplate); + CRM_Core_BAO_MessageTemplate::add($messageTemplate); } if (CRM_Utils_Array::value('updateTemplate', $formValues) && $formValues['template'] && $formValues['updateTemplate']) { $messageTemplate['id'] = $formValues['template']; unset($messageTemplate['msg_title']); - CRM_Core_BAO_MessageTemplates::add($messageTemplate); + CRM_Core_BAO_MessageTemplate::add($messageTemplate); } } elseif (CRM_Utils_Array::value('template', $formValues) > 0) { @@ -384,10 +384,11 @@ class CRM_Contact_Form_Task_PDFLatexCommon { foreach ($form->_contactIds as $contactId) { $activityTargetParams = array( + 'contact_id' => $contactId, 'activity_id' => empty($activity->id) ? $activityIds[$contactId] : $activity->id, 'target_contact_id' => $contactId, ); - CRM_Activity_BAO_Activity::createActivityTarget($activityTargetParams); + CRM_Activity_BAO_ActivityTarget::create($activityTargetParams); } } diff --git a/CRM/Event/BAO/Participant.php b/CRM/Event/BAO/Participant.php index 9ab5ab46e4..ec0abfa4a1 100644 --- a/CRM/Event/BAO/Participant.php +++ b/CRM/Event/BAO/Participant.php @@ -110,7 +110,9 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant { $participantBAO->save(); - CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush(); + // reset the group contact cache for this group + // HACK: by davet + // CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush(); if (!empty($params['id'])) { CRM_Utils_Hook::post('edit', 'Participant', $participantBAO->id, $participantBAO); diff --git a/CRM/Member/BAO/Membership.php b/CRM/Member/BAO/Membership.php index 7daf555876..891f4cbcf7 100644 --- a/CRM/Member/BAO/Membership.php +++ b/CRM/Member/BAO/Membership.php @@ -113,7 +113,8 @@ class CRM_Member_BAO_Membership extends CRM_Member_DAO_Membership { CRM_Member_BAO_MembershipLog::add($membershipLog); // reset the group contact cache since smart groups might be affected due to this - CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush(); + // HACK: a new fragrance by davet + // CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush(); $allStatus = CRM_Member_BAO_Membership::buildOptions('status_id', 'get'); $activityParams = [ diff --git a/CRM/Member/Import/Form/DataSource.php b/CRM/Member/Import/Form/DataSource.php index 8eaabae047..5112077761 100644 --- a/CRM/Member/Import/Form/DataSource.php +++ b/CRM/Member/Import/Form/DataSource.php @@ -41,6 +41,25 @@ class CRM_Member_Import_Form_DataSource extends CRM_Import_Form_DataSource { public function buildQuickForm() { parent::buildQuickForm(); + //Setting Upload File Size + $config = CRM_Core_Config::singleton(); + + $uploadFileSize = CRM_Core_Config_Defaults::formatUnitSize($config->maxFileSize . 'm', TRUE); + $uploadSize = round(($uploadFileSize / (1024 * 1024)), 2); + + $this->assign('uploadSize', $uploadSize); + + $this->add('File', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=255', TRUE); + $this->setMaxFileSize($uploadFileSize); + $this->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array( + 1 => $uploadSize, + 2 => $uploadFileSize, + )), 'maxfilesize', $uploadFileSize); + $this->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile'); + $this->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File'); + + $this->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers')); + $this->addRadio('onDuplicate', ts('Import mode'), [ CRM_Import_Parser::DUPLICATE_SKIP => ts('Insert new Membership'), CRM_Import_Parser::DUPLICATE_UPDATE => ts('Update existing Membership'), diff --git a/CRM/Price/BAO/PriceSet.php b/CRM/Price/BAO/PriceSet.php index a0aeb3bc09..e55b4933f5 100644 --- a/CRM/Price/BAO/PriceSet.php +++ b/CRM/Price/BAO/PriceSet.php @@ -732,6 +732,7 @@ WHERE id = %1"; $priceSetID = $params['priceSetId']; $priceFieldSelection = self::filterPriceFieldsFromParams($priceSetID, $params); $priceFieldMetadata = self::getCachedPriceSetDetail($priceSetID); + $displayParticipantCount = NULL; $amount_level = []; foreach ($priceFieldMetadata['fields'] as $field) { @@ -1194,6 +1195,11 @@ GROUP BY mt.member_of_contact_id "; * $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 DISTINCT mt.auto_renew, mt.duration_interval, mt.duration_unit, pf.html_type, pf.id as price_field_id FROM civicrm_price_field_value pfv @@ -1242,6 +1248,28 @@ GROUP BY mt.member_of_contact_id "; return $autoRenewOption; } + /** + * 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 = [1 => [$priceSetId, 'Integer']]; + $dao = CRM_Core_DAO::executeQuery($query, $params); + $dao->fetch(); + return [$dao->duration_interval, $dao->duration_unit]; + } + /** * @return object */ diff --git a/CRM/Utils/PDF/Utils.php b/CRM/Utils/PDF/Utils.php index b0ea305bec..49a054c8ad 100644 --- a/CRM/Utils/PDF/Utils.php +++ b/CRM/Utils/PDF/Utils.php @@ -21,6 +21,15 @@ use Dompdf\Options; class CRM_Utils_PDF_Utils { + public static function enqueuePDF($pdf) { + + $fname = time().'_lp.pdf'; + file_put_contents('/tmp/'.$fname, $pdf); + header('Location: /civicrm/lp-setup?file='.$fname); + exit; + + } + public static function latex2pdf(&$text, $fileName = 'civicrm.pdf', $output = FALSE, $pdfFormat = NULL) { /* FIXME: get $paper_size, $orientation, $margins */ @@ -31,13 +40,22 @@ class CRM_Utils_PDF_Utils { $pages = array($text); } - - $head='\documentclass[11pt]{letter} + $head='\documentclass[12pt]{letter} \usepackage{url} \usepackage{ucs} \usepackage{graphicx} \usepackage[T1]{fontenc} \usepackage{fullpage} +\usepackage{fontspec,xunicode} +%% VERY IMPORTANT. Configures supported languages and fonts to use for each one. +\usepackage[Latin, Hebrew, Arabics, CJK, Diacritics]{ucharclasses} +\setDefaultTransitions{\fontspec{CMU Serif}}{} +\setTransitionsForLatin{\fontspec{CMU Serif}}{} +\setTransitionsForArabics{\fontspec{Droid Sans Arabic}}{} +\setTransitionsForCJK{\fontspec{WenQuanYi Zen Hei}}{} +\setTransitionsForDiacritics{\fontspec{Droid Sans Arabic}}{} +\setTransitionTo{Hebrew}{\fontspec{David CLM}} +\setmainfont{CMU Serif} \newcommand{\fsfclosing}[1]{\par\nobreak\vspace{\parskip} \stopbreaks @@ -46,7 +64,7 @@ class CRM_Utils_PDF_Utils { \hspace*{\longindentation}\fi \parbox{\indentedwidth}{\raggedright \ignorespaces #1\\\\[1\medskipamount] - \hspace*{-0.25in}\includegraphics[scale=1.0]{sigjohns.pdf} + \hspace*{-0.25in}\includegraphics[scale=1.0]{/var/www/drupal-7.27/sites/all/modules/civicrm/sigjohns.pdf} \\\\ \ifx\@empty\fromsig @@ -57,16 +75,16 @@ class CRM_Utils_PDF_Utils { %% This line might be necessary, but it was not able to find utf8.def on my %% machine. -\usepackage[utf8x]{inputenc} +%% \usepackage[utf8x]{inputenc} \pagestyle{empty} \tolerance=8000 \address{\vspace{0.05in}} \signature{John Sullivan \\\\ Executive Director} \usepackage[ -top = 0.4in, -bottom = 0.9in, -left = 0.8in, -right = 0.8in]{geometry} +top = 1.5in, +bottom = 1.25in, +left = 1.0in, +right = 1.0in]{geometry} \begin{document} '; $footer=' @@ -105,8 +123,10 @@ right = 0.8in]{geometry} header('Content-Type: application/pdf'); header('Content-Disposition: attachment; filename="' . $fileName . '"'); echo $pdf; +// CRM_Utils_PDF_Utils::enqueuePDF($pdf); + } - } + } /** * @param array $text @@ -309,6 +329,7 @@ right = 0.8in]{geometry} $snappy->setOption("margin-right", $margins[2] . $margins[0]); $snappy->setOption("margin-bottom", $margins[3] . $margins[0]); $snappy->setOption("margin-left", $margins[4] . $margins[0]); + $html = preg_replace('/{ }/', ' ', $html); $pdf = $snappy->getOutputFromHtml($html); if ($output) { return $pdf; @@ -317,6 +338,8 @@ right = 0.8in]{geometry} CRM_Utils_System::setHttpHeader('Content-Type', 'application/pdf'); CRM_Utils_System::setHttpHeader('Content-Disposition', 'attachment; filename="' . $fileName . '"'); echo $pdf; + //CRM_Utils_PDF_Utils::enqueuePDF($pdf); + } } diff --git a/templates/CRM/Contribute/Form/Contribution/PremiumBlock.tpl b/templates/CRM/Contribute/Form/Contribution/PremiumBlock.tpl index 286cee5a67..60ab57cdc8 100644 --- a/templates/CRM/Contribute/Form/Contribution/PremiumBlock.tpl +++ b/templates/CRM/Contribute/Form/Contribution/PremiumBlock.tpl @@ -179,6 +179,14 @@ amount = 0; } + // next, check for contribution amount price sets + check_price_set('.contribution_amount-content input[type="radio"]'); + + // next, check for membership level price set + check_price_set('.membership_amount-content input[type="radio"]'); + + check_price_set(cj('.price-set-option-content input[type="radio"]')); + // make sure amount is a number at this point if(!amount) amount = 0; @@ -196,6 +204,7 @@ // update premiums function update_premiums() { var amount = get_amount(); + console.log('amount:', amount); $('.premium').each(function(){ var min_contribution = $(this).attr('min_contribution'); -- 2.25.1