summaryrefslogtreecommitdiff
path: root/www/crm/wp-content/uploads/civicrm/templates_c/es_ES/%%D3/D31/D315F302%%ShareAddress.tpl.php
blob: 231f8dc2420fcfa6c9be64081ea1bd916c4a0ba8 (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
<?php /* Smarty version 2.6.31, created on 2019-08-30 19:47:35
         compiled from CRM/Contact/Form/ShareAddress.tpl */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('block', 'crmScope', 'CRM/Contact/Form/ShareAddress.tpl', 1, false),array('block', 'ts', 'CRM/Contact/Form/ShareAddress.tpl', 117, false),array('function', 'help', 'CRM/Contact/Form/ShareAddress.tpl', 29, false),array('modifier', 'json_encode', 'CRM/Contact/Form/ShareAddress.tpl', 57, 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(); ?><tr>
  <td>
    <?php echo $this->_tpl_vars['form']['address'][$this->_tpl_vars['blockId']]['use_shared_address']['html']; ?>
<?php echo $this->_tpl_vars['form']['address'][$this->_tpl_vars['blockId']]['use_shared_address']['label']; ?>
 <?php echo smarty_function_help(array('id' => "id-sharedAddress",'file' => "CRM/Contact/Form/Contact.hlp"), $this);?>

    <div id="shared-address-<?php echo $this->_tpl_vars['blockId']; ?>
" class="form-layout-compressed">
      <?php echo $this->_tpl_vars['form']['address'][$this->_tpl_vars['blockId']]['master_contact_id']['label']; ?>

      <?php echo $this->_tpl_vars['form']['address'][$this->_tpl_vars['blockId']]['master_contact_id']['html']; ?>

      <div class="shared-address-update-employer" style="display: none;">
        <?php echo $this->_tpl_vars['form']['address'][$this->_tpl_vars['blockId']]['update_current_employer']['html']; ?>

        <?php echo $this->_tpl_vars['form']['address'][$this->_tpl_vars['blockId']]['update_current_employer']['label']; ?>

        <?php echo smarty_function_help(array('id' => "id-sharedAddress-updateRelationships",'file' => "CRM/Contact/Form/Contact"), $this);?>

      </div>
      <div class="shared-address-list">
        <?php if (! empty ( $this->_tpl_vars['sharedAddresses'][$this->_tpl_vars['blockId']]['shared_address_display'] )): ?>
          <?php $_from = $this->_tpl_vars['sharedAddresses'][$this->_tpl_vars['blockId']]['shared_address_display']['options']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['sa']):
?>
            <?php $this->assign('sa_name', "selected_shared_address-".($this->_tpl_vars['blockId'])); ?>
            <?php $this->assign('sa_id', ($this->_tpl_vars['sa_name'])."-".($this->_tpl_vars['sa']['id'])); ?>
            <input type="radio" name="<?php echo $this->_tpl_vars['sa_name']; ?>
" id="<?php echo $this->_tpl_vars['sa_id']; ?>
" value="<?php echo $this->_tpl_vars['sa']['id']; ?>
" <?php if ($this->_tpl_vars['sa']['id'] == $this->_tpl_vars['sharedAddresses'][$this->_tpl_vars['blockId']]['shared_address_display']['master_id']): ?>checked="checked"<?php endif; ?>>
            <label for="<?php echo $this->_tpl_vars['sa_id']; ?>
"><?php echo $this->_tpl_vars['sa']['display_text']; ?>
</label><?php if ($this->_tpl_vars['sa']['location_type']): ?>(<?php echo $this->_tpl_vars['sa']['location_type']; ?>
)<?php endif; ?><br/>
          <?php endforeach; endif; unset($_from); ?>
        <?php endif; ?>
      </div>
    </div>
  </td>
</tr>


<?php echo '
<script type="text/javascript">
  CRM.$(function($) {
    var blockNo = '; ?>
<?php echo $this->_tpl_vars['blockId']; ?>
<?php echo ',
      contactType = '; ?>
<?php echo json_encode($this->_tpl_vars['contactType']); ?>
<?php echo ',
      $employerSection = $(\'#shared-address-\' + blockNo + \' .shared-address-update-employer\'),
      $contentArea = $(\'#shared-address-\' + blockNo + \' .shared-address-list\'),
      $masterElement = $(\'input[name="address[\' + blockNo + \'][master_id]"]\');

    function showHideSharedAddress() {
      // based on checkbox, show or hide
      var share = $(this).prop(\'checked\');
      $(\'#shared-address-\' + blockNo).toggle(!!share);
      $(\'table#address_table_\' + blockNo +\', .crm-address-custom-set-block-\' + blockNo).toggle(!share);
    }

    // "Use another contact\'s address" checkbox
    $(\'#address\\\\[\' + blockNo + \'\\\\]\\\\[use_shared_address\\\\]\').each(showHideSharedAddress).click(showHideSharedAddress);

    // When an address is selected
    $contentArea.off().on(\'click\', \'input\', function() {
      $masterElement.val($(this).val());
    });

    // When shared contact is selected/unselected
    $(\'input[name="address[\' + blockNo +\'][master_contact_id]"]\').change(function() {
      var $el = $(this),
        sharedContactId = $el.val();

      $contentArea.html(\'\');
      $masterElement.val(\'\');

      if (!sharedContactId || isNaN(sharedContactId)) {
        $employerSection.hide();
        return;
      }

      var otherContactType = $el.select2(\'data\').extra.contact_type;
      $employerSection.toggle(contactType === \'Individual\' && otherContactType === \'Organization\');

      $.post(CRM.url(\'civicrm/ajax/inline\'), {
          \'contact_id\': sharedContactId,
          \'type\': \'method\',
          \'class_name\': \'CRM_Contact_Page_AJAX\',
          \'fn_name\': \'getAddressDisplay\'
        },
        function(response) {
          // Avoid race conditions - check that value hasn\'t been changed by the user while we were waiting for response
          if (response && $el.val() === sharedContactId) {
            var selected = \' checked="checked"\',
              addressHTML = \'\';

            $.each(response, function(i, val) {
              if (addressHTML) {
                selected = \'\';
              } else {
                $(\'input[name="address[\' + blockNo + \'][master_id]"]\').val(val.id);
              }
              var name = \'selected_shared_address-\'+ blockNo,
                id = name + \'-\' + val.id;
              addressHTML += \'<input type="radio" name="\' + name + \'" id="\' + id + \'" value="\' + val.id + \'"\' + selected +\'><label for="\' + id + \'">\' + val.display_text + \'</label>(\'+val.location_type+\')<br/>\';
            });

            if (!addressHTML) {
              addressHTML = '; ?>
"<?php $this->_tag_stack[] = array('ts', array('escape' => 'js')); $_block_repeat=true;smarty_block_ts($this->_tag_stack[count($this->_tag_stack)-1][1], null, $this, $_block_repeat);while ($_block_repeat) { ob_start(); ?>Selected contact does not have an address. Please edit that contact to add an address, or select a different contact.<?php $_block_content = ob_get_contents(); ob_end_clean(); $_block_repeat=false;echo smarty_block_ts($this->_tag_stack[count($this->_tag_stack)-1][1], $_block_content, $this, $_block_repeat); }  array_pop($this->_tag_stack); ?>"<?php echo ';
            }

            $contentArea.html(addressHTML);
          }
        },\'json\');
    });
  });
</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); ?>