event recurring patch for v4.6
[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 </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 {include file="CRM/Event/Form/ConfirmSubmit.tpl"}
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 {* include common additional blocks tpl *}
100 {include file="CRM/common/additionalBlocks.tpl"}
101
102 <script type="text/javascript">
103 {literal}
104 CRM.$(function($) {
105 //FIX ME: by default load 2 blocks and hide add and delete links
106 //we should make additional block function more flexible to set max block limit
107 buildBlocks('Email');
108 buildBlocks('Phone');
109
110 var $form = $('form.{/literal}{$form.formClass}{literal}'),
111 locBlockId = {/literal}"{$form.loc_event_id.value.0}"{literal};
112
113 displayMessage({/literal}{$locUsed}{literal});
114
115 // build blocks only if it is not built
116 function buildBlocks(element) {
117 if (!$('[id='+ element +'_Block_2]').length) {
118 buildAdditionalBlocks(element, 'CRM_Event_Form_ManageEvent_Location');
119 }
120 }
121
122 hideAddDeleteLinks('Email');
123 hideAddDeleteLinks('Phone');
124 function hideAddDeleteLinks(element) {
125 $('#add'+ element, $form).hide();
126 $('[id='+ element +'_Block_2] a:last', $form).hide();
127 }
128
129 $('#loc_event_id', $form).change(function() {
130 $.ajax({
131 url: CRM.url('civicrm/ajax/locBlock', 'reset=1'),
132 data: {'lbid': $(this).val()},
133 dataType: 'json',
134 success: function(data) {
135 var selectLocBlockId = $('#loc_event_id').val();
136 // Only change state when options are loaded
137 if (data.address_1_state_province_id) {
138 var defaultState = data.address_1_state_province_id;
139 $('#address_1_state_province_id', $form).one('crmOptionsUpdated', function() {
140 $(this).val(defaultState).change();
141 });
142 delete data.address_1_state_province_id;
143 }
144 for(i in data) {
145 if ( i == 'count_loc_used' ) {
146 if ( ((selectLocBlockId == locBlockId) && data.count_loc_used > 1) ||
147 ((selectLocBlockId != locBlockId) && data.count_loc_used > 0) ) {
148 displayMessage(data.count_loc_used);
149 } else {
150 displayMessage(0);
151 }
152 } else {
153 $('#'+i, $form).val(data[i]).change();
154 }
155 }
156 }
157 });
158 return false;
159 });
160
161 function showLocFields(clear) {
162 var createNew = document.getElementsByName("location_option")[0].checked;
163 if (createNew) {
164 $('#existingLoc', $form).hide();
165 //clear all location fields values.
166 if (clear !== false) {
167 $(":input[id *= 'address_1_'], :input[id *= 'email_1_'], :input[id *= 'phone_1_']", $form).val("").change();
168 {/literal}{if $config->defaultContactCountry}
169 {if $config->defaultContactStateProvince}
170 // Set default state once options are loaded
171 var defaultState = {$config->defaultContactStateProvince}
172 {literal}
173 $('#address_1_state_province_id', $form).one('crmOptionsUpdated', function() {
174 $(this).val(defaultState).change();
175 });
176 {/literal}
177 {/if}
178 // Set default country
179 $('#address_1_country_id', $form).val({$config->defaultContactCountry}).change();
180 {/if}{literal}
181 }
182 displayMessage(0);
183 } else {
184 $('#existingLoc', $form).show();
185 if (clear !== false) {
186 $('#loc_event_id', $form).change();
187 }
188 }
189 }
190
191 $('input[name=location_option]').click(showLocFields);
192 showLocFields(false);
193
194 function displayMessage(count) {
195 if (count) {
196 var msg = {/literal}'{ts escape="js" 1="%1"}This location is used by %1 other events. Modifying location information will change values for all events.{/ts}'{literal};
197 $('#locUsedMsg', $form).text(ts(msg, {1: count})).addClass('status');
198 } else {
199 $('#locUsedMsg', $form).text(' ').removeClass('status');
200 }
201 }
202 });
203 {/literal}
204 </script>
205 {/if}
206
207 {/if} {* add block if end*}