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