$this->addElement('checkbox', 'record_activity', $recordActivity);
$this->addElement('checkbox', 'is_repeat', ts('Repeat'),
- NULL, array('onclick' => "return showHideByValue('is_repeat',true,'repeatFields','table-row','radio',false);")
+ NULL, array('onchange' => "return showHideByValue('is_repeat',true,'repeatFields','table-row','radio',false);")
);
$this->add('select', 'repetition_frequency_unit', ts('every'), $freqUnitsDisplay);
$this->add('select', 'limit_to', ts('Limit Options'), $limitOptions);
$this->add('select', 'recipient', ts('Recipients'), $sel5[$recipient],
- FALSE, array('onClick' => "showHideByValue('recipient','manual','recipientManual','table-row','select',false); showHideByValue('recipient','group','recipientGroup','table-row','select',false);")
+ FALSE, array('onchange' => "showHideByValue('recipient','manual','recipientManual','table-row','select',false); showHideByValue('recipient','group','recipientGroup','table-row','select',false);")
);
if (!empty($_POST['is_recipient_listing'])) {
elseif (!empty($this->_values['recipient_listing'])) {
$recipientListingOptions = CRM_Core_BAO_ActionSchedule::getRecipientListing($this->_values['mapping_id'], $this->_values['recipient']);
}
- $recipientListing = $this->add('select', 'recipient_listing', ts('Recipient Listing'), $recipientListingOptions);
- $recipientListing->setMultiple(TRUE);
- $this->add('hidden', 'is_recipient_listing', empty($recipientListingOptions) ? FALSE : TRUE, array('id' => 'is_recipient_listing'));
+ $this->add('select', 'recipient_listing', ts('Recipient Roles'), $recipientListingOptions, FALSE,
+ array('multiple' => TRUE, 'class' => 'crm-select2 huge', 'placeholder' => TRUE));
+ $this->add('hidden', 'is_recipient_listing', (int) !empty($recipientListingOptions));
$this->addEntityRef('recipient_manual_id', ts('Manual Recipients'), array('multiple' => TRUE, 'create' => TRUE));
- $this->addElement(
- 'select',
- 'group_id',
- ts('Group'),
- // CRM-13577
- CRM_Core_PseudoConstant::group()
+ $this->add('select', 'group_id', ts('Group'),
+ CRM_Core_PseudoConstant::nestedGroup(), FALSE, array('class' => 'crm-select2 huge')
);
CRM_Mailing_BAO_Mailing::commonCompose($this);
$this->add('checkbox', 'is_active', $isActive);
$this->addFormRule(array('CRM_Admin_Form_ScheduleReminders', 'formRule'));
+
+ $this->setPageTitle(ts('Scheduled Reminder'));
}
/**
* global form rule
}
function mappingList() {
- $params = array('mappingID');
- foreach ($params as $param) {
- $$param = CRM_Utils_Array::value($param, $_POST);
+ if (empty($_GET['mappingID'])) {
+ CRM_Utils_JSON::output(array('status' => 'error', 'error_msg' => 'required params missing.'));
}
- if (!$mappingID) {
- CRM_Utils_JSON::output(array('error_msg' => 'required params missing.'));
- }
-
- $selectionOptions = CRM_Core_BAO_ActionSchedule::getSelection1($mappingID);
- extract($selectionOptions);
-
- $elements = array();
- foreach ($sel4 as $id => $name) {
- $elements[] = array(
- 'name' => $name,
- 'value' => $id,
- );
- }
-
- CRM_Utils_JSON::output($elements);
- }
-
- function mappingList1() {
- $params = array('mappingID');
- foreach ($params as $param) {
- $$param = CRM_Utils_Array::value($param, $_POST);
- }
-
- if (!$mappingID) {
- CRM_Utils_JSON::output(array('error_msg' => 'required params missing.'));
- }
+ $selectionOptions = CRM_Core_BAO_ActionSchedule::getSelection1($_GET['mappingID']);
- $selectionOptions = CRM_Core_BAO_ActionSchedule::getSelection1($mappingID);
- extract($selectionOptions);
-
- $elements = array();
- foreach ($sel5 as $id => $name) {
- $elements['sel5'][] = array(
- 'name' => $name,
- 'value' => $id,
- );
+ $output = array(
+ 'sel4' => array(),
+ 'sel5' => array(),
+ 'recipientMapping' => $selectionOptions['recipientMapping'],
+ );
+ foreach (array(4, 5) as $sel) {
+ foreach ($selectionOptions["sel$sel"] as $id => $name) {
+ $output["sel$sel"][] = array(
+ 'value' => $name,
+ 'key' => $id,
+ );
+ }
}
- $elements['recipientMapping'] = $recipientMapping;
- CRM_Utils_JSON::output($elements);
+ CRM_Utils_JSON::output($output);
}
static function mergeTags() {
}
function recipient() {
- $params = array('recipient');
- foreach ($params as $param) {
- $$param = CRM_Utils_Array::value($param, $_POST);
- }
-
- if (!$recipient) {
- CRM_Utils_JSON::output(array('error_msg' => 'required params missing.'));
+ if (empty($_GET['recipient'])) {
+ CRM_Utils_JSON::output(array('status' => 'error', 'error_msg' => 'required params missing.'));
}
- switch ($recipient) {
+ switch ($_GET['recipient']) {
case 'Participant Status':
$values = CRM_Event_PseudoConstant::participantStatus();
break;
$elements = array();
foreach ($values as $id => $name) {
$elements[] = array(
- 'name' => $name,
- 'value' => $id,
+ 'value' => $name,
+ 'key' => $id,
);
}
'url' => 'civicrm/admin/scheduleReminders',
'qs' => 'action=update&id=%%id%%&reset=1',
'title' => ts('Edit Schedule Reminders'),
- 'class' => 'no-popup',
),
CRM_Core_Action::ENABLE => array(
'name' => ts('Enable'),
// Update tab "disabled" css class
$this->ajaxResponse['tabValid'] = !empty($reminderList) && is_array($reminderList);
}
+ $this->setPageTitle(ts('Scheduled Reminder'));
}
/**
$this->add('select', 'recipient', ts('Recipients'), $sel5[$recipient],
FALSE, array('onchange' => "showHideByValue('recipient','manual','recipientManual','table-row','select',false); showHideByValue('recipient','group','recipientGroup','table-row','select',false);")
);
- $recipientListing = $this->add('select', 'recipient_listing', ts('Recipient Listing'),
- $sel3[$this->_mappingID][0], FALSE, array('class' => 'crm-select2 huge')
+ $recipientListing = $this->add('select', 'recipient_listing', ts('Recipient Roles'),
+ $sel3[$this->_mappingID][0], FALSE, array('multiple' => TRUE, 'class' => 'crm-select2 huge', 'placeholder' => TRUE)
);
- $recipientListing->setMultiple(TRUE);
$this->addEntityRef('recipient_manual_id', ts('Manual Recipients'), array('multiple' => true));
- $groups = CRM_Contact_BAO_Group::getGroupsHierarchy(CRM_Core_PseudoConstant::staticGroup(), NULL, ' ', TRUE);
$this->add('select', 'group_id', ts('Group'),
- $groups, FALSE, array('class' => 'crm-select2 huge')
+ CRM_Core_PseudoConstant::nestedGroup(), FALSE, array('class' => 'crm-select2 huge')
);
CRM_Mailing_BAO_Mailing::commonCompose($this);
/**
* Populate a select list, overwriting the existing options except for the placeholder.
- * @param $el jquery collection - 1 or more select elements
+ * @param select jquery selector - 1 or more select elements
* @param options array in format returned by api.getoptions
* @param placeholder string
*/
- CRM.utils.setOptions = function($el, options, placeholder) {
- $el.each(function() {
+ CRM.utils.setOptions = function(select, options, placeholder) {
+ $(select).each(function() {
var
$elect = $(this),
val = $elect.val() || [],
- multiple = $el.is('[multiple]'),
opts = placeholder || placeholder === '' ? '' : '[value!=""]',
newOptions = '',
theme = function(options) {
$elect.find('option' + opts).remove();
theme(options);
if (typeof placeholder === 'string') {
- if (multiple) {
- $el.attr('placeholder', placeholder);
+ if ($elect.is('[multiple]')) {
+ select.attr('placeholder', placeholder);
} else {
newOptions = '<option value="">' + placeholder + '</option>' + newOptions;
}
{literal}
<script type='text/javascript'>
- var entityMapping = eval({/literal}{$entityMapping}{literal});
- var recipientMapping = eval({/literal}{$recipientMapping}{literal});
-
-
CRM.$(function($) {
- $('#absolute_date_display').change(function() {
- if($('#absolute_date_display').val()) {
- $('#relativeDate').hide();
- $('#relativeDateRepeat').hide();
- $('#repeatFields').hide();
+ var $form = $('form.{/literal}{$form.formClass}{literal}'),
+ recipientMapping = eval({/literal}{$recipientMapping}{literal});
+
+ $('#absolute_date_display', $form).change(function() {
+ if($(this).val()) {
+ $('#relativeDate, #relativeDateRepeat, #repeatFields', $form).hide();
} else {
- $('#relativeDate').show();
- $('#relativeDateRepeat').show();
+ $('#relativeDate, #relativeDateRepeat', $form).show();
}
});
- if ($('#absolute_date_display').val()) {
- $('#relativeDate, #relativeDateRepeat, #repeatFields').hide();
+ if ($('#absolute_date_display', $form).val()) {
+ $('#relativeDate, #relativeDateRepeat, #repeatFields', $form).hide();
}
- $('#entity_0').change( function( ) {
- buildSelect("start_action_date");
- buildSelect("end_date");
- buildSelect1("recipient");
- showHideLimitTo();
- });
+ $('#entity_0', $form).change(buildSelects);
loadMsgBox();
- $('#mode').change(loadMsgBox);
+ $('#mode', $form).change(loadMsgBox);
showHideLimitTo();
- if ($('#is_recipient_listing').val()) {
- $('#recipientList').show();
+ $('#recipient', $form).change(populateRecipient);
+
+ var entity = $('#entity_0', $form).val();
+ if (!(entity === '2' || entity === '3') || $('#recipient', $form).val() !== '1') {
+ $('#recipientList', $form).hide();
+ }
+
+ function buildSelects() {
+ var mappingID = $('#entity_0', $form).val();
+
+ $('#is_recipient_listing').val('');
+ $.getJSON(CRM.url('civicrm/ajax/mapping'), {mappingID: mappingID},
+ function (result) {
+ CRM.utils.setOptions($('#start_action_date', $form), result.sel4);
+ CRM.utils.setOptions($('#end_date', $form), result.sel4);
+ CRM.utils.setOptions($('#recipient', $form), result.sel5);
+ recipientMapping = result.recipientMapping;
+ populateRecipient();
+ }
+ );
}
- else {
- $('#recipientList').hide();
+ function populateRecipient() {
+ var recipient = $("#recipient", $form).val();
+
+ if (recipientMapping[recipient] == 'Participant Status' || recipientMapping[recipient] == 'participant_role') {
+ $.getJSON(CRM.url('civicrm/ajax/populateRecipient'), {recipient: recipientMapping[recipient]},
+ function (result) {
+ CRM.utils.setOptions($('#recipient_listing', $form), result);
+ }
+ );
+ $("#recipientList", $form).show();
+ $('#is_recipient_listing', $form).val(1);
+ } else {
+ $("#recipientList", $form).hide();
+ $('#is_recipient_listing', $form).val('');
+ }
}
- $('#recipient').change(populateRecipient);
});
function loadMsgBox() {
}
}
- function populateRecipient( ) {
- var recipient = cj("#recipient option:selected").val();
- var entity = cj("#entity_0 option:selected").val();
- var postUrl = "{/literal}{crmURL p='civicrm/ajax/populateRecipient' h=0}{literal}";
-
- if (recipientMapping[recipient] == 'Participant Status' || recipientMapping[recipient] == 'participant_role') {
- var elementID = '#recipient_listing';
- cj( elementID ).html('');
- cj.post(postUrl, {recipient: recipientMapping[recipient]},
- function ( response ) {
- response = eval( response );
- for (i = 0; i < response.length; i++) {
- cj( elementID ).get(0).add(new Option(response[i].name, response[i].value), document.all ? i : null);
- }
- });
- cj("#recipientList").show();
- cj('#is_recipient_listing').val(1);
- } else {
- cj("#recipientList").hide();
- cj('#is_recipient_listing').val('');
- }
- }
-
- function buildSelect( selectID ) {
- var elementID = '#' + selectID;
- cj( elementID ).html('');
- var mappingID = cj('#entity_0').val();
- var postUrl = "{/literal}{crmURL p='civicrm/ajax/mapping' h=0}{literal}";
- cj.post( postUrl, { mappingID: mappingID},
- function ( response ) {
- response = eval( response );
- for (i = 0; i < response.length; i++) {
- cj( elementID ).get(0).add(new Option(response[i].name, response[i].value), document.all ? i : null);
- }
- }
- );
- }
-
- function buildSelect1( selectID ) {
- var elementID = '#' + selectID;
- cj( elementID ).html('');
- var mappingID = cj('#entity_0').val();
- var postUrl1 = "{/literal}{crmURL p='civicrm/ajax/mapping1' h=0}{literal}";
-
- cj('#is_recipient_listing').val('');
- cj.post( postUrl1, { mappingID: mappingID},
- function ( result ) {
- var responseResult = cj.parseJSON(result);
- var response = eval(responseResult.sel5);
- recipientMapping = eval(responseResult.recipientMapping);
- for (i = 0; i < response.length; i++) {
- cj( elementID ).get(0).add(new Option(response[i].name, response[i].value), document.all ? i : null);
- }
- populateRecipient();
- }
- );
- }
-
</script>
{/literal}
{if $action eq 1 or $action eq 2 or $action eq 8 or $action eq 16384}
{include file="CRM/Admin/Form/ScheduleReminders.tpl"}
{else}
-{* include wysiwyg related files*}
-{include file="CRM/common/wysiwyg.tpl" includeWysiwygEditor=true}
-{capture assign=schedRemindersDocLink}{docURL page="user/current/email/scheduled-reminders/"}{/capture}
-<div class="help">
- {ts}Scheduled reminders allow you to automatically send messages to contacts regarding their memberships, participation in events, or other activities.{/ts} {$schedRemindersDocLink}
-</div>
-{if $rows}
+ {* include wysiwyg related files*}
+ {include file="CRM/common/wysiwyg.tpl" includeWysiwygEditor=true}
+ {capture assign=schedRemindersDocLink}{docURL page="user/current/email/scheduled-reminders/"}{/capture}
+ <div class="help">
+ {ts}Scheduled reminders allow you to automatically send messages to contacts regarding their memberships, participation in events, or other activities.{/ts} {$schedRemindersDocLink}
+ </div>
+ {if $rows}
<div id="reminder">
{include file="CRM/Admin/Page/Reminders.tpl"}
- <div class="action-link">
- <a href="{crmURL q="action=add&reset=1"}" id="newScheduleReminder" class="button no-popup"><span><div class="icon add-icon"></div>{ts}Add Reminder{/ts}</span></a>
- </div>
-
</div>
-
-{else}
+ {else}
<div class="messages status no-popup">
<div class="icon inform-icon"></div>
- {capture assign=crmURL}class="no-popup" href="{crmURL p='civicrm/admin/scheduleReminders' q="action=add&reset=1"}" class="action-item"{/capture}
- {ts 1=$crmURL}There are no Scheduled Reminders configured. You can <a %1>add one</a>.{/ts}
+ {ts}None found.{/ts}
</div>
-{/if}
+ {/if}
+ <div class="action-link">
+ <a href="{crmURL q="action=add&reset=1"}" id="newScheduleReminder" class="button"><span><div class="icon add-icon"></div>{ts}Add Reminder{/ts}</span></a>
+ </div>
{/if}
{literal}
<script type='text/javascript'>
CRM.$(function($) {
+ var $form = $('form.{/literal}{$form.formClass}{literal}'),
+ recipientMapping = eval({/literal}{$recipientMapping}{literal});
+
populateRecipient();
- $('#recipient').click( function( ) {
- populateRecipient();
- });
- });
+ $('#recipient', $form).change(populateRecipient);
- function populateRecipient( ) {
- var recipientMapping = eval({/literal}{$recipientMapping}{literal});
- var recipient = cj("#recipient option:selected").val();
- var postUrl = "{/literal}{crmURL p='civicrm/ajax/populateRecipient' h=0}{literal}";
- if(recipientMapping[recipient] == 'Participant Status' || recipientMapping[recipient] == 'participant_role'){
- var elementID = '#recipient_listing';
- cj( elementID ).html('');
- cj.post(postUrl, {recipient: recipientMapping[recipient]},
- function ( response ) {
- response = eval( response );
- for (iota = 0; iota < response.length; iota++) {
- cj( elementID ).get(0).add(new Option(response[iota].name, response[iota].value), document.all ? iota : null);
+ function populateRecipient() {
+ var recipient = $("#recipient", $form).val();
+
+ if (recipientMapping[recipient] == 'Participant Status' || recipientMapping[recipient] == 'participant_role') {
+ $.getJSON(CRM.url('civicrm/ajax/populateRecipient'), {recipient: recipientMapping[recipient]},
+ function (result) {
+ CRM.utils.setOptions($('#recipient_listing', $form), result);
}
- }
- );
- cj("#recipientList").show();
- } else {
- cj("#recipientList").hide();
+ );
+ $("#recipientList", $form).show();
+ $('#is_recipient_listing', $form).val(1);
+ } else {
+ $("#recipientList", $form).hide();
+ $('#is_recipient_listing', $form).val('');
+ }
}
- }
-
- cj('#absolute_date_display').click( function( ) {
- if(cj('#absolute_date_display').val()) {
- cj('#relativeDate').hide();
- cj('#relativeDateRepeat').hide();
- cj('#repeatFields').hide();
- } else {
- cj('#relativeDate').show();
- cj('#relativeDateRepeat').show();
+
+ $('#absolute_date_display', $form).change(function() {
+ if($(this).val()) {
+ $('#relativeDate, #relativeDateRepeat, #repeatFields', $form).hide();
+ } else {
+ $('#relativeDate, #relativeDateRepeat', $form).show();
+ }
+ });
+
+ if ($('#absolute_date_display', $form).val()) {
+ $('#relativeDate, #relativeDateRepeat, #repeatFields', $form).hide();
}
+
});
</script>
{/literal}
{/if}
<div class="crm-submit-buttons">
- {include file="CRM/common/formButtons.tpl" location="bottom"}</div>
+ {include file="CRM/common/formButtons.tpl" location="bottom"}
+ </div>
</div>
{/if}