From 1314eb8000e5454e18cea21c6fe7668c791e612b Mon Sep 17 00:00:00 2001 From: Edsel Lopez <edsel.lopez@jmaconsulting.biz> Date: Tue, 7 Jul 2020 17:38:01 +0530 Subject: [PATCH 1/5] Removed code for zero price events --- aoeventtemplates.php | 54 ------------------------------ templates/CRM/AO/EventTemplate.tpl | 8 ----- 2 files changed, 62 deletions(-) diff --git a/aoeventtemplates.php b/aoeventtemplates.php index 5fb3157..2f1b6c8 100755 --- a/aoeventtemplates.php +++ b/aoeventtemplates.php @@ -111,55 +111,6 @@ function aoeventtemplates_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) _aoeventtemplates_civix_civicrm_alterSettingsFolders($metaDataFolders); } -function aoeventtemplates_civicrm_buildAmount($pageType, &$form, &$amount) { - $zeroTemplates = [ - 'Community Awareness', - 'SLO Evidence Based Programs', - 'SLO Health & Fitness', - 'SLO Recreation', - 'SLO Skill Building', - 'SLO Support Groups - Facilitated', - 'SLO Support Groups - Meetup', - 'Workshop - Community Training', - 'Webinar - Live', - ]; - if (get_class($form) == "CRM_Event_Form_Registration_Register") { - $templateId = civicrm_api3('Event', 'get', [ - 'id' => $form->_eventId, - 'return.custom_' . TEMPLATE_ID => 1, - ])['values'][$form->_eventId]['custom_' . TEMPLATE_ID]; - if ($templateId) { - $template = getEventTemplates($templateId); - if (in_array($template, $zeroTemplates)) { - foreach ($amount as $key => &$val) { - $val['is_display_amounts'] = 0; - foreach ($val['options'] as $pid => &$pf) { - $pf['amount'] = 0.00; - } - } - } - } - } - if (in_array(get_class($form), ["CRM_Event_Form_Participant", "CRM_Event_Form_ParticipantFeeSelection"]) && $pageType == 'event') { - $eventTypes = CRM_Core_OptionGroup::values('event_type'); - $eventType = CRM_Core_DAO::singleValueQuery("SELECT event_type_id FROM civicrm_event WHERE id = {$form->_eventId}"); - $templateId = civicrm_api3('Event', 'get', [ - 'id' => $form->_eventId, - 'return.custom_' . TEMPLATE_ID => 1, - ])['values'][$form->_eventId]['custom_' . TEMPLATE_ID]; - if (!in_array($templateId, [SLOZOOEVENT, SLOVAREVENT]) && in_array($eventTypes[$eventType], $zeroTemplates) && !empty($amount)) { - $form->assign('zeroPrice', TRUE); - foreach ($amount as $key => &$val) { - $val['is_display_amounts'] = 0; - foreach ($val['options'] as $pid => &$pf) { - $pf['amount'] = 0.00; - } - } - - } - } -} - function aoeventtemplates_civicrm_links($op, $objectName, $objectId, &$links, &$mask, &$values) { if (CRM_Core_Config::singleton()->userSystem->is_wordpress) { return; @@ -385,11 +336,6 @@ function aoeventtemplates_civicrm_buildForm($formName, &$form) { ); } } - if ($formName == "CRM_Event_Form_Participant") { - CRM_Core_Region::instance('page-body')->add(array( - 'template' => 'CRM/AO/Price.tpl', - )); - } } function aoeventtemplates_civicrm_validateForm($formName, &$fields, &$files, &$form, &$errors) { diff --git a/templates/CRM/AO/EventTemplate.tpl b/templates/CRM/AO/EventTemplate.tpl index da2d6c2..ed04fc7 100755 --- a/templates/CRM/AO/EventTemplate.tpl +++ b/templates/CRM/AO/EventTemplate.tpl @@ -4,16 +4,8 @@ CRM.$(function($) { var currentTemplate = '{/literal}{$currentTemplate}{literal}'; var waiver = '{/literal}{$smarty.const.WAIVER_5}{literal}'; - var zeroprice = '{/literal}{$zeroPrice}{literal}'; $('fieldset.crm-profile-name-Waivers_35 div.label').hide(); - if (zeroprice) { - $('._of_children_with_asd_attending-content').append('$ 0.00'); - $('._of_parents_guardians_caregivers-content').append('$ 0.00'); - $('._siblings-content span.price-field-amount').html('$ 0.00'); - $('._of_professionals-content span.price-field-amount').html('$ 0.00'); - $('._of_volunteers-content span.price-field-amount').html('$ 0.00'); - } switch (currentTemplate) { case 'SLO Evidence Based Programs': case 'SLO Health & Fitness': -- GitLab From 2f50e24218606217f53b84c54fb16c6430400f5b Mon Sep 17 00:00:00 2001 From: Edsel Lopez <edsel.lopez@jmaconsulting.biz> Date: Mon, 13 Jul 2020 12:28:12 +0530 Subject: [PATCH 2/5] Fixed start date creation error --- aoeventtemplates.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aoeventtemplates.php b/aoeventtemplates.php index 2f1b6c8..cf20085 100755 --- a/aoeventtemplates.php +++ b/aoeventtemplates.php @@ -193,7 +193,7 @@ function aoeventtemplates_civicrm_buildForm($formName, &$form) { )); } } - if ($formName == "CRM_Event_Form_ManageEvent_EventInfo" && ($form->_action & CRM_Core_Action::ADD)) { + if ($formName == "CRM_Event_Form_ManageEvent_EventInfo" && ($form->_action & CRM_Core_Action::ADD) && !$form->getVar('_isTemplate')) { $defaults = [ 'start_date' => date('m/d/Y'), ]; -- GitLab From 9614560a27a465565da6ebc52d39c01101863c80 Mon Sep 17 00:00:00 2001 From: Edsel Lopez <edsel.lopez@jmaconsulting.biz> Date: Tue, 21 Jul 2020 16:06:15 +0530 Subject: [PATCH 3/5] Added validation for title of template --- aoeventtemplates.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/aoeventtemplates.php b/aoeventtemplates.php index cf20085..86ed563 100755 --- a/aoeventtemplates.php +++ b/aoeventtemplates.php @@ -393,6 +393,15 @@ function aoeventtemplates_civicrm_validateForm($formName, &$fields, &$files, &$f } } } + if ($formName == "CRM_Event_Form_ManageEvent_EventInfo" && !empty($form->getVar('_templateId'))) { + if (!empty($fields['template_title'])) { + // Check if title already exists, else throw error. + $title = CRM_Core_DAO::singleValueQuery("SELECT template_title FROM civicrm_event WHERE template_title = 1 AND id = %1", ['1' => [$fields['template_title'], 'String']]); + if (!empty($title)) { + $errors['template_title'] = ts('An event template already exists with this title.'); + } + } + } } function getEventTemplates($id) { -- GitLab From 9e52411532ddbc5d199b95ffcabd7c8d2088bd55 Mon Sep 17 00:00:00 2001 From: Edsel Lopez <edsel.lopez@jmaconsulting.biz> Date: Thu, 23 Jul 2020 12:39:04 +0530 Subject: [PATCH 4/5] Bug fix --- aoeventtemplates.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aoeventtemplates.php b/aoeventtemplates.php index 86ed563..0b5957e 100755 --- a/aoeventtemplates.php +++ b/aoeventtemplates.php @@ -393,10 +393,10 @@ function aoeventtemplates_civicrm_validateForm($formName, &$fields, &$files, &$f } } } - if ($formName == "CRM_Event_Form_ManageEvent_EventInfo" && !empty($form->getVar('_templateId'))) { + if ($formName == "CRM_Event_Form_ManageEvent_EventInfo" && !empty($fields['template_title'])) { if (!empty($fields['template_title'])) { // Check if title already exists, else throw error. - $title = CRM_Core_DAO::singleValueQuery("SELECT template_title FROM civicrm_event WHERE template_title = 1 AND id = %1", ['1' => [$fields['template_title'], 'String']]); + $title = CRM_Core_DAO::singleValueQuery("SELECT template_title FROM civicrm_event WHERE template_title = %1", ['1' => [$fields['template_title'], 'String']]); if (!empty($title)) { $errors['template_title'] = ts('An event template already exists with this title.'); } -- GitLab From 4971a568f0afb75acc319dd2711492ea6e02be0a Mon Sep 17 00:00:00 2001 From: Edsel Lopez <edsel.lopez@jmaconsulting.biz> Date: Fri, 24 Jul 2020 16:43:02 +0530 Subject: [PATCH 5/5] Removed unused file --- templates/CRM/AO/Price.tpl | 46 -------------------------------------- 1 file changed, 46 deletions(-) delete mode 100755 templates/CRM/AO/Price.tpl diff --git a/templates/CRM/AO/Price.tpl b/templates/CRM/AO/Price.tpl deleted file mode 100755 index e7cc3e4..0000000 --- a/templates/CRM/AO/Price.tpl +++ /dev/null @@ -1,46 +0,0 @@ -{literal} -<script type="text/javascript"> -CRM.$( function($) { - var eventType = '{/literal}{$eventTypeID}{literal}'; - var eventId = '{/literal}{$eventID}{literal}'; - if (eventId) { - CRM.api3('Event', 'get', { - "id": eventId, - "return.custom_327": 1, - }).done(function(result) { - if (result.values[eventId]['custom_327'] != 1509 || result.values[eventId]['custom_327'] != 1510) { - hidePriceSet(eventType); - } - }); - } - - $('#event_id').change(function() { - var eventid = $(this).val(); - if (eventid) { - CRM.api3('Event', 'get', { - "id": eventid, - "return.custom_327": 1, - }).then(function(result) { - if (result.values[eventid]['custom_327'] != 1509 || result.values[eventid]['custom_327'] != 1510) { - CRM.api3('Event', 'getvalue', { - "return": "event_type_id", - "id": eventid - }).done(function(result) { - hidePriceSet(result.result); - }); - } - }); - } - }); - - function hidePriceSet(type) { - var validtypes = ['8','18','9','10','19','20','21','22', '17']; - if ($.inArray(type, validtypes) !='-1') { - $( document ).ajaxComplete(function( event, xhr, settings ) { - $('.price-field-amount').html('$ 0.00'); - }); - } - } -}); -</script> -{/literal} -- GitLab