summaryrefslogtreecommitdiff
path: root/www/crm/wp-content/uploads/civicrm/templates_c/es_ES/%%9C/9C5/9C5362F2%%additionalBlocks.tpl.php
blob: 672d17d5287fe6d2b99c0607ed4a795f6c5be2ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?php /* Smarty version 2.6.31, created on 2019-08-30 19:47:35
         compiled from CRM/common/additionalBlocks.tpl */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('block', 'crmScope', 'CRM/common/additionalBlocks.tpl', 1, false),array('function', 'crmURL', 'CRM/common/additionalBlocks.tpl', 59, false),)), $this); ?>
<?php $this->_tag_stack[] = array('crmScope', array('extensionKey' => "")); $_block_repeat=true;smarty_block_crmScope($this->_tag_stack[count($this->_tag_stack)-1][1], null, $this, $_block_repeat);while ($_block_repeat) { ob_start(); ?><?php echo '
<script type="text/javascript" >
CRM.$(function($) {
    '; ?>

    <?php if ($this->_tpl_vars['generateAjaxRequest']): ?>
        <?php $_from = $this->_tpl_vars['ajaxRequestBlocks']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['blockName'] => $this->_tpl_vars['instances']):
?>
            <?php $_from = $this->_tpl_vars['instances']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['instance'] => $this->_tpl_vars['active']):
?>
                buildAdditionalBlocks( '<?php echo $this->_tpl_vars['blockName']; ?>
', '<?php echo $this->_tpl_vars['className']; ?>
' );
            <?php endforeach; endif; unset($_from); ?>
        <?php endforeach; endif; unset($_from); ?>
    <?php endif; ?>

    <?php if ($this->_tpl_vars['loadShowHideAddressFields']): ?>
        <?php $_from = $this->_tpl_vars['showHideAddressFields']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['blockId'] => $this->_tpl_vars['fieldName']):
?>
           processAddressFields( '<?php echo $this->_tpl_vars['fieldName']; ?>
', '<?php echo $this->_tpl_vars['blockId']; ?>
', 0 );
        <?php endforeach; endif; unset($_from); ?>
    <?php endif; ?>
    <?php echo '
});

function buildAdditionalBlocks( blockName, className ) {
    var element = blockName + \'_Block_\';

    //get blockcount of last element of relevant blockName
    var previousInstance = cj( \'[id^="\'+ element +\'"]:last\' ).attr(\'id\').slice( element.length );
    var currentInstance  = parseInt( previousInstance ) + 1;

    //show primary option if block count = 2
    if ( currentInstance == 2) {
        cj("#" + blockName + \'-Primary\').show( );
        cj("#" + blockName + \'-Primary-html\').show( );
    }

    var dataUrl = '; ?>
"<?php echo CRM_Utils_System::crmURL(array('h' => 0,'q' => 'snippet=4'), $this);?>
"<?php echo ' + \'&block=\' + blockName + \'&count=\' + currentInstance;;

    if ( className == \'CRM_Event_Form_ManageEvent_Location\' ) {
        dataUrl = ( currentInstance <= 2 ) ? dataUrl + \'&subPage=Location\' : \'\';
    }

    '; ?>

    <?php if ($this->_tpl_vars['qfKey']): ?>
        dataUrl += "&qfKey=<?php echo $this->_tpl_vars['qfKey']; ?>
";
    <?php endif; ?>
    <?php echo '

    if ( !dataUrl ) {
        return;
    }

    var fname = \'#\' + blockName + \'_Block_\'+ previousInstance;

    cj(\'#addMore\' + blockName + previousInstance ).hide( );
    cj.ajax({
        url     : dataUrl,
        async   : false,
        success : function(html){
            cj(fname).after(html);
            cj(fname).nextAll().trigger(\'crmLoad\');
        }
    });

    if ( blockName == \'Address\' ) {
        checkLocation(\'address_\' + currentInstance + \'_location_type_id\', true );
        /* FIX: for IE, To get the focus after adding new address block on first element */
        cj(\'#address_\' + currentInstance + \'_location_type_id\').focus();
    }
}

//select single for is_bulk & is_primary
function singleSelect( object ) {
    var element = object.split( \'_\', 3 );

    var block = (element[\'0\'] == \'Address\') ? \'Primary\' : element[\'2\'].slice(\'2\');
    var execBlock  = \'#\' + element[\'0\'] + \'-\' + block + \'-html Input[id*="\' + element[\'2\'] + \'"]\';

    //element to check for checkbox
    var elementChecked =  cj( \'#\' + object ).prop(\'checked\');
    if ( elementChecked ) {
        cj( execBlock ).each( function() {
            if ( cj(this).attr(\'id\') != object ) {
                cj(this).prop(\'checked\', false );
            }
        });
    } else {
        cj( \'#\' + object ).prop(\'checked\', false );
    }

  //check if non of elements is set Primary / Allowed to Login.
  if( cj.inArray( element[\'2\'].slice(\'2\'), [ \'Primary\', \'Login\' ] ) != -1 ) {
    primary = false;
    cj( execBlock ).each( function( ) {
      if ( cj(this).prop(\'checked\' ) ) {
        primary = true;
      }
    });
    if( ! primary ) {
      cj(\'#\' + object).prop(\'checked\', true );
    }
  }
}

function removeBlock( blockName, blockId ) {
    var element = cj("#addressBlock > div").size();
    if ( ( blockName == \'Address\' ) && element == 1 ) {
      return clearFirstBlock(blockName , blockId);
    }

    if ( cj( "#"+ blockName + "_" + blockId + "_IsPrimary").prop(\'checked\') ) {
         var primaryBlockId = 1;
        // consider next block as a primary,
        // when user delete first block
        if ( blockId >= 1 ) {
           var blockIds = getAddressBlock(\'next\');
           for ( var i = 0; i <= blockIds.length; i++) {
               var curBlockId = blockIds[i];
             if ( curBlockId != blockId ) {
                 primaryBlockId = curBlockId;
                 break;
             }
            }
        }

        // finally sets the primary address
        cj( \'#\'+ blockName + \'_\' + primaryBlockId + \'_IsPrimary\').prop(\'checked\', true);
    }

    //remove the spacer for address block only.
    if ( blockName == \'Address\' && cj( "#"+ blockName + "_Block_" + blockId ).prev().attr(\'class\') == \'spacer\' ){
        cj( "#"+ blockName + "_Block_" + blockId ).prev().remove();
    }

    //unset block from html
    cj( "#"+ blockName + "_Block_" + blockId ).empty().remove();

    //show the link \'add address\' to last element of Address Block
    if ( blockName == \'Address\' ) {
        var lastAddressBlock = cj(\'div[id^=Address_Block_]\').last().attr(\'id\');
        var lastBlockId = lastAddressBlock.split( \'_\' );
        if ( lastBlockId[2] ) {
            cj( \'#addMoreAddress\' + lastBlockId[2] ).show();
        }
    }
}

function clearFirstBlock( blockName , blockId ) {
    var element =  blockName + \'_Block_\' + blockId;
    cj("#" + element +" input, " + "#" + element + " select").each(function () {
        cj(this).val(\'\');
    });
    cj("#addressBlockId:not(.collapsed)").crmAccordionToggle();
    cj("#addressBlockId .active").removeClass(\'active\');
}

function getAddressBlock( position ) {
   var addressBlockIds = [];
   var i = 0;
   switch ( position ) {
        case \'last\':
              var lastBlockInfo = cj("#addressBlockId > div").children(\':last\').attr(\'id\').split( \'_\', 3);
              addressBlockIds[i] = lastBlockInfo[\'2\'];
              break;
        case \'next\':
              cj("#addressBlockId > div").children().each( function() {
                  if ( cj(this).attr(\'id\') ) {
                     var blockInfo = cj(this).attr(\'id\').split( \'_\', 3);
                     addressBlockIds[i] = blockInfo[\'2\'];
                     i++;
                  }
              });
              break;
   }
   return addressBlockIds;
}
</script>
'; ?>

<?php $_block_content = ob_get_contents(); ob_end_clean(); $_block_repeat=false;echo smarty_block_crmScope($this->_tag_stack[count($this->_tag_stack)-1][1], $_block_content, $this, $_block_repeat); }  array_pop($this->_tag_stack); ?>