8dde0645e662253afa8e661a03525de7b72623c1
[civicrm-core.git] / templates / CRM / Event / Form / ManageEvent / Location.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.5 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2014 |
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 template used to build location block *}
27 {if !$addBlock}
28 <div id="help">
29 {ts}Use this form to configure the location and optional contact information for the event. This information will be displayed on the Event Information page. It will also be included in online registration pages and confirmation emails if these features are enabled.{/ts}
30 </div>
31 {/if}
32 <div class="crm-block crm-form-block crm-event-manage-location-form-block">
33 {if $addBlock}
34 {include file="CRM/Contact/Form/Edit/$blockName.tpl"}
35 {else}
36 <div class="crm-submit-buttons">
37 {include file="CRM/common/formButtons.tpl" location="top"}
38 </div>
39 {if $locEvents}
40 <table class="form-layout-compressed">
41 <tr id="optionType" class="crm-event-manage-location-form-block-location_option">
42 <td class="labels">
43 {$form.location_option.label}
44 </td>
45 {foreach from=$form.location_option key=key item =item}
46 {if $key|is_numeric}
47 <td class="value"><strong>{$item.html}</strong></td>
48 {/if}
49 {/foreach}
50 </tr>
51 <tr id="existingLoc" class="crm-event-manage-location-form-block-loc_event_id">
52 <td class="labels">
53 {$form.loc_event_id.label}
54 </td>
55 <td class="value" colspan="2">
56 {$form.loc_event_id.html|crmAddClass:huge}
57 </td>
58 </tr>
59 <tr>
60 <td id="locUsedMsg" colspan="3">
61 {assign var=locUsedMsgTxt value="<strong>Note:</strong> This location is used by multiple events. Modifying location information will change values for all events."}
62 </td>
63 </tr>
64
65 </table>
66 {/if}
67
68
69
70 <div id="newLocation">
71 <h3>Address</h3>
72 {* Display the address block *}
73 {include file="CRM/Contact/Form/Edit/Address.tpl"}
74 <table class="form-layout-compressed">
75 {* Display the email block(s) *}
76 {include file="CRM/Contact/Form/Edit/Email.tpl"}
77
78 {* Display the phone block(s) *}
79 {include file="CRM/Contact/Form/Edit/Phone.tpl"}
80 </table>
81 <table class="form-layout-compressed">
82 <tr class="crm-event-is_show_location">
83 <td colspan="2">{$form.is_show_location.label}</td>
84 <td colspan="2">
85 {$form.is_show_location.html}<br />
86 <span class="description">{ts}Uncheck this box if you want to HIDE the event Address on Event Information and Registration pages as well as on email confirmations.{/ts}
87 </td>
88 </tr>
89 </table>
90 <div class="crm-submit-buttons">
91 {include file="CRM/common/formButtons.tpl" location="bottom"}
92 </div>
93 </div>
94
95 {* Include Javascript to hide and display the appropriate blocks as directed by the php code *}
96 {*include file="CRM/common/showHide.tpl"*}
97 {if $locEvents}
98 <script type="text/javascript">
99 {literal}
100 var locUsedMsgTxt = {/literal}"{$locUsedMsgTxt}"{literal};
101 var locBlockId = {/literal}"{$form.loc_event_id.value.0}"{literal};
102
103 if ( {/literal}"{$locUsed}"{literal} ) {
104 displayMessage( true );
105 }
106
107 cj(document).ready(function() {
108 cj('#loc_event_id').change(function() {
109 cj.ajax({
110 url: CRM.url('civicrm/ajax/locBlock', 'reset=1'),
111 type: 'POST',
112 data: {'lbid': cj(this).val()},
113 dataType: 'json',
114 success: function(data) {
115 var selectLocBlockId = cj('#loc_event_id').val();
116 for(i in data) {
117 if ( i == 'count_loc_used' ) {
118 if ( ((selectLocBlockId == locBlockId) && data['count_loc_used'] > 1) ||
119 ((selectLocBlockId != locBlockId) && data['count_loc_used'] > 0) ) {
120 displayMessage( true );
121 } else {
122 displayMessage( false );
123 }
124 } else {
125 cj('#'+i).val(data[i]);
126 }
127 }
128 }
129 });
130 return false;
131 });
132 });
133
134 function displayMessage( set ) {
135 cj(document).ready(function() {
136 if ( set ) {
137 cj('#locUsedMsg').html( locUsedMsgTxt ).addClass('status');
138 } else {
139 cj('#locUsedMsg').html( ' ' ).removeClass('status');
140 }
141 });
142 }
143
144 function showLocFields( ) {
145 var createNew = document.getElementsByName("location_option")[0].checked;
146 var useExisting = document.getElementsByName("location_option")[1].checked;
147 if ( createNew ) {
148 cj('#existingLoc').hide();
149 //clear all location fields values.
150 cj("input[id *= 'address_1_']").val("");
151 cj("input[id *= 'email_1_']").val("");
152 cj("input[id *= 'phone_1_']").val("");
153 //reset country/state.
154 cj("select[id *= 'address_1_']").val("");
155 displayMessage(false);
156 } else if ( useExisting ) {
157 cj('#existingLoc').show();
158 }
159 }
160
161 showLocFields( );
162 {/literal}
163 </script>
164 {/if}
165
166 {* include common additional blocks tpl *}
167 {include file="CRM/common/additionalBlocks.tpl"}
168
169 {/if} {* add block if end*}