Import from SVN (r45945, r596)
[civicrm-core.git] / templates / CRM / Contact / Form / Inline / Address.tpl
CommitLineData
6a488035
TO
1{*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.3 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2013 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
8 | |
9 | CiviCRM is free software; you can copy, modify, and distribute it |
10 | under the terms of the GNU Affero General Public License |
11 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
12 | |
13 | CiviCRM is distributed in the hope that it will be useful, but |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16 | See the GNU Affero General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU Affero General Public |
19 | License and the CiviCRM Licensing Exception along |
20 | with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
25*}
26{* This file builds html for address block inline edit *}
27{$form.oplock_ts.html}
28 <table class="form-layout crm-edit-address-form crm-inline-edit-form">
29 <tr>
30 <td>
31 <div class="crm-submit-buttons">
32 {include file="CRM/common/formButtons.tpl"}
33 </div>
34 </td>
35 </tr>
36 <tr>
37 <td>
38 <span class="crm-address-element location_type_id-address-element">
39 {$form.address.$blockId.location_type_id.label}&nbsp;{$form.address.$blockId.location_type_id.html}
40 </span>
41 </td>
42 </tr>
43 <tr>
44 <td>
45 <span class="crm-address-element is_primary-address-element">{$form.address.$blockId.is_primary.html}</span>
46 <span class="crm-address-element is_billing-address-element">{$form.address.$blockId.is_billing.html}</span>
47 </td>
48 </tr>
49
50 {* include shared address template *}
51 {include file="CRM/Contact/Form/ShareAddress.tpl"}
52
53 <tr>
54 <td>
55 <table id="address_table_{$blockId}" class="form-layout-compressed">
56 {* build address block w/ address sequence. *}
57 {foreach item=addressElement from=$addressSequence}
58 {include file=CRM/Contact/Form/Edit/Address/$addressElement.tpl}
59 {/foreach}
60 {include file=CRM/Contact/Form/Edit/Address/geo_code.tpl}
61 </table>
62 </td>
63 </tr>
64 </table>
65
66 <div class="crm-edit-address-custom_data crm-inline-edit-form crm-address-custom-set-block-{$blockId}">
67 {include file="CRM/Contact/Form/Edit/Address/CustomData.tpl"}
68 </div>
69{literal}
70<script type="text/javascript">
71 {/literal}{* // Enforce unique location_type_id fields *}{literal}
72 cj('#address_{/literal}{$blockId}{literal}_location_type_id').change(function() {
73 var ele = cj(this);
74 var lt = ele.val();
75 var container = ele.closest('div.crm-inline-edit.address');
76 container.data('location-type-id', '');
77 var ok = true;
78 if (lt != '') {
79 cj('.crm-inline-edit.address').each(function() {
80 if (ok && cj(this).data('location-type-id') == lt) {
81 var label = cj('option:selected', ele).text();
82 ele.val('');
83 ele.crmError(label + "{/literal} {ts escape='js'}has already been assigned to another address. Please select another location for this address.{/ts}"{literal});
84 ok = false;
85 }
86 });
87 if (ok) {
88 container.data('location-type-id', lt);
89 }
90 }
91 });
92 {/literal}{* // Enforce unique is_primary fields *}{literal}
93 cj(':checkbox[id*="[is_primary"]', 'form#Address_{/literal}{$blockId}{literal}').change(function() {
94 if (this.defaultChecked) {
95 cj(this).crmError("{/literal} {ts escape='js'}Please choose another address to be primary before changing this one.{/ts}{literal}");
96 cj(this).prop('checked', true);
97 }
98 });
99 {/literal}{* // Reset location_type_id when cancel button pressed *}{literal}
100 cj(':submit[name$=cancel]', 'form#Address_{/literal}{$blockId}{literal}').click(function() {
101 var container = cj(this).closest('div.crm-inline-edit.address');
102 var origValue = container.attr('data-location-type-id') || '';
103 container.data('location-type-id', origValue);
104 });
105 {/literal}
106 {if $masterAddress.$blockId}
107 CRM.alert('{ts escape="js" 1=$masterAddress.$blockId}This address is shared with %1 contact record(s). Modifying this address will automatically update the shared address for these contacts.{/ts}', '{ts escape="js"}Editing Master Address{/ts}', 'info', {ldelim}expires: 0{rdelim});
108 {/if}
109</script>