Merge remote-tracking branch 'upstream/4.4' into 4.4-4.5-2014-09-01-22-48-29
[civicrm-core.git] / templates / CRM / Event / Form / ManageEvent / Location.tpl
CommitLineData
6a488035
TO
1{*
2 +--------------------------------------------------------------------+
819d0d41 3 | CiviCRM version 4.5 |
6a488035 4 +--------------------------------------------------------------------+
819d0d41 5 | Copyright CiviCRM LLC (c) 2004-2014 |
6a488035
TO
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}
81ba6833 32
6a488035
TO
33{if $addBlock}
34{include file="CRM/Contact/Form/Edit/$blockName.tpl"}
35{else}
81ba6833 36<div class="crm-block crm-form-block crm-event-manage-location-form-block">
6a488035
TO
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}
c720e2e2 99 {* include common additional blocks tpl *}
100 {include file="CRM/common/additionalBlocks.tpl"}
101
6a488035
TO
102<script type="text/javascript">
103{literal}
104var locUsedMsgTxt = {/literal}"{$locUsedMsgTxt}"{literal};
105var locBlockId = {/literal}"{$form.loc_event_id.value.0}"{literal};
106
107if ( {/literal}"{$locUsed}"{literal} ) {
108 displayMessage( true );
109}
110
32678ccb 111CRM.$(function($) {
c720e2e2 112 //FIX ME: by default load 2 blocks and hide add and delete links
113 //we should make additional block function more flexible to set max block limit
f16f7f75 114 buildBlocks('Email');
115 buildBlocks('Phone');
116
117 // build blocks only if it is not built
118 function buildBlocks(element) {
32678ccb 119 if (!$('[id='+ element +'_Block_2]').length) {
f16f7f75 120 buildAdditionalBlocks(element, 'CRM_Event_Form_ManageEvent_Location');
121 }
122 }
123
124 hideAddDeleteLinks('Email');
125 hideAddDeleteLinks('Phone');
126 function hideAddDeleteLinks(element) {
32678ccb
CW
127 $('#add'+ element).hide();
128 $('[id='+ element +'_Block_2] a:last').hide();
c720e2e2 129 }
130
32678ccb
CW
131 $('#loc_event_id').change(function() {
132 $.ajax({
6a488035
TO
133 url: CRM.url('civicrm/ajax/locBlock', 'reset=1'),
134 type: 'POST',
32678ccb 135 data: {'lbid': $(this).val()},
6a488035
TO
136 dataType: 'json',
137 success: function(data) {
32678ccb 138 var selectLocBlockId = $('#loc_event_id').val();
6a488035
TO
139 for(i in data) {
140 if ( i == 'count_loc_used' ) {
141 if ( ((selectLocBlockId == locBlockId) && data['count_loc_used'] > 1) ||
142 ((selectLocBlockId != locBlockId) && data['count_loc_used'] > 0) ) {
143 displayMessage( true );
144 } else {
145 displayMessage( false );
146 }
147 } else {
c720e2e2 148 if (i == 'phone_1_phone_type_id' || i == 'phone_2_phone_type_id') {
32678ccb 149 $('#'+i).select2('val', data[i]);
c720e2e2 150 }
151 else {
32678ccb 152 $('#'+i).val(data[i]);
c720e2e2 153 }
6a488035
TO
154 }
155 }
156 }
157 });
158 return false;
159 });
160});
161
162function displayMessage( set ) {
32678ccb 163 CRM.$(function($) {
6a488035 164 if ( set ) {
32678ccb 165 $('#locUsedMsg').html( locUsedMsgTxt ).addClass('status');
6a488035 166 } else {
32678ccb 167 $('#locUsedMsg').html( ' ' ).removeClass('status');
6a488035
TO
168 }
169 });
170}
171
172function showLocFields( ) {
173 var createNew = document.getElementsByName("location_option")[0].checked;
174 var useExisting = document.getElementsByName("location_option")[1].checked;
175 if ( createNew ) {
176 cj('#existingLoc').hide();
162b0ed4 177 //clear all location fields values.
178 cj("input[id *= 'address_1_']").val("");
179 cj("input[id *= 'email_1_']").val("");
180 cj("input[id *= 'phone_1_']").val("");
181 //reset country/state.
182 cj("select[id *= 'address_1_']").val("");
6a488035
TO
183 displayMessage(false);
184 } else if ( useExisting ) {
185 cj('#existingLoc').show();
186 }
187}
188
189showLocFields( );
190{/literal}
191</script>
192{/if}
193
6a488035 194{/if} {* add block if end*}