Skip to content
Snippets Groups Projects
Source.tpl 4 KiB
Newer Older
  • Learn to ignore specific revisions
  • jaapjansma's avatar
    jaapjansma committed
    {crmScope extensionKey='dataprocessor'}
    
    {if $action eq 8}
        {* Are you sure to delete form *}
    
    jaapjansma's avatar
    jaapjansma committed
        <h3>{ts}Delete Data Source{/ts}</h3>
    
    jaapjansma's avatar
    jaapjansma committed
        <div class="crm-block crm-form-block crm-data-processor_label-block">
    
            <div class="crm-section">{ts 1=$source.title}Are you sure to delete data processor source '%1'?{/ts}</div>
    
    jaapjansma's avatar
    jaapjansma committed
        </div>
    
    jaapjansma's avatar
    jaapjansma committed
    
        <div class="crm-submit-buttons">
            {include file="CRM/common/formButtons.tpl" location="bottom"}
        </div>
    {elseif (!$snippet)}
    
    jaapjansma's avatar
    jaapjansma committed
    
        {* block for rule data *}
        <h3>{ts}Data Processor Source{/ts}</h3>
        <div class="crm-block crm-form-block crm-data-processor_source-block">
            <div class="crm-section">
                <div class="label">{$form.type.label}</div>
                <div class="content">{$form.type.html}</div>
                <div class="clear"></div>
            </div>
            <div class="crm-section">
                <div class="label">{$form.title.label}</div>
    
    jaapjansma's avatar
    jaapjansma committed
                <div class="content">
                    {$form.title.html}
                    <span class="">
                    {ts}System name:{/ts}&nbsp;
                    <span id="systemName" style="font-style: italic;">{if ($source)}{$source.name}{/if}</span>
                    <a href="javascript:void(0);" onclick="jQuery('#nameSection').removeClass('hiddenElement'); jQuery(this).parent().addClass('hiddenElement'); return false;">
                      {ts}Change{/ts}
                    </a>
                    </span>
                </div>
    
    jaapjansma's avatar
    jaapjansma committed
                <div class="clear"></div>
            </div>
    
    jaapjansma's avatar
    jaapjansma committed
            <div id="nameSection" class="crm-section hiddenElement">
    
    jaapjansma's avatar
    jaapjansma committed
                <div class="label">{$form.name.label}</div>
                <div class="content">{$form.name.html}</div>
                <div class="clear"></div>
            </div>
    
    jaapjansma's avatar
    jaapjansma committed
    
            <div id="type_configuration">
                {if ($configuration_template)}
                    {include file=$configuration_template}
                {/if}
    
    jaapjansma's avatar
    jaapjansma committed
    
                {include file="CRM/Dataprocessor/Form/Source/Join.tpl"}
    
    jaapjansma's avatar
    jaapjansma committed
            </div>
        </div>
    
        <div class="crm-submit-buttons">
            {include file="CRM/common/formButtons.tpl" location="bottom"}
        </div>
    
        <script type="text/javascript">
            {literal}
    
    
    jaapjansma's avatar
    jaapjansma committed
            CRM.$(function($) {
    
    jaapjansma's avatar
    jaapjansma committed
              $('#type').on('change', function() {
    
                {/literal}{if $action eq 1}{literal}
    
                  var titlepreset = $.trim($('#type option:selected').text().split("::").pop());
                  $('#title').val(titlepreset).trigger('blur');
                {/literal}{/if}{literal};
    
    jaapjansma's avatar
    jaapjansma committed
                var type = $('#type').val();
    
    jaapjansma's avatar
    jaapjansma committed
                var join_type = $('#join_type').val();
                var id = {/literal}{if ($source)}{$source.id}{else}false{/if}{literal};
                var data_processor_id = {/literal}{$data_processor_id}{literal};
    
    jaapjansma's avatar
    jaapjansma committed
                if (type) {
    
    jaapjansma's avatar
    jaapjansma committed
                  var dataUrl = CRM.url('civicrm/dataprocessor/form/source', {type: type, 'data_processor_id': data_processor_id, 'id': id, 'join_type': join_type});
    
    jaapjansma's avatar
    jaapjansma committed
                  CRM.loadPage(dataUrl, {'target': '#type_configuration'});
                }
              });
    
              $('#title').on('blur', function() {
                var title = $('#title').val();
    
    jaapjansma's avatar
    jaapjansma committed
                var id = {/literal}{if ($source)}{$source.id}{else}false{/if}{literal};
                var data_processor_id = {/literal}{$data_processor_id}{literal};
    
    jaapjansma's avatar
    jaapjansma committed
                if ($('#nameSection').hasClass('hiddenElement') && !id) {
                  CRM.api3('DataProcessorSource', 'check_name', {
                    'title': title,
                    'data_processor_id': data_processor_id
                  }).done(function (result) {
                    $('#systemName').html(result.name);
                    $('#name').val(result.name);
                  });
                }
              });
    
              $('#type').change();
            });
            {/literal}
        </script>
    
    
    jaapjansma's avatar
    jaapjansma committed
    {elseif ($block == 'joinOnly')}
        {include file="CRM/Dataprocessor/Form/Source/Join.tpl"}
    {elseif ($block == 'configuration')}
    
    jaapjansma's avatar
    jaapjansma committed
        <div id="type_configuration">
            {if ($configuration_template)}
                {include file=$configuration_template}
            {/if}
    
    jaapjansma's avatar
    jaapjansma committed
    
            {include file="CRM/Dataprocessor/Form/Source/Join.tpl"}
    
    jaapjansma's avatar
    jaapjansma committed
        </div>
    {/if}
    
    {/crmScope}