CRM-14383 - Update cj closures
[civicrm-core.git] / templates / CRM / Custom / Page / CustomDataView.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 {* Custom Data view mode*}
27 {assign var="showEdit" value=1}
28 {foreach from=$viewCustomData item=customValues key=customGroupId}
29 {foreach from=$customValues item=cd_edit key=cvID}
30 {if $multiRecordDisplay neq 'single'}
31 <table class="no-border">
32 {assign var='index' value=$groupId|cat:"_$cvID"}
33 {if ($editOwnCustomData and $showEdit) or ($showEdit and $editCustomData and $groupId)}
34 <tr>
35 <td>
36 <a
37 href="{crmURL p="civicrm/contact/view/cd/edit" q="tableId=`$contactId`&cid=`$contactId`&groupID=`$groupId`&action=update&reset=1"}"
38 class="button" style="margin-left: 6px;"><span><div
39 class="icon edit-icon"></div>{ts 1=$cd_edit.title}Edit %1{/ts}</span></a><br/><br/>
40 </td>
41 </tr>
42 {/if}
43 {assign var="showEdit" value=0}
44 <tr id="statusmessg_{$index}" class="hiddenElement">
45 <td><span class="success-status"></span></td>
46 </tr>
47 <tr>
48 <td id="{$cd_edit.name}_{$index}" class="section-shown form-item">
49 <div class="crm-accordion-wrapper {if $cd_edit.collapse_display eq 0 or $skipTitle} {else}collapsed{/if}">
50 {if !$skipTitle}
51 <div class="crm-accordion-header">
52 {$cd_edit.title}
53 </div>
54 {/if}
55 <div class="crm-accordion-body">
56 {if $groupId and $cvID and $editCustomData}
57 <div class="crm-submit-buttons">
58 <a href="#"
59 onclick="showDelete( {$cvID}, '{$cd_edit.name}_{$index}', {$customGroupId}, {$contactId} ); return false;"
60 class="button delete-button" title="{ts 1=$cd_edit.title}Delete this %1 record{/ts}">
61 <span><div class="icon delete-icon"></div>{ts}Delete{/ts}</span>
62 </a>
63 </div>
64 {/if}
65 {foreach from=$cd_edit.fields item=element key=field_id}
66 <table class="crm-info-panel">
67 <tr>
68 {if $element.options_per_line != 0}
69 <td class="label">{$element.field_title}</td>
70 <td class="html-adjust">
71 {* sort by fails for option per line. Added a variable to iterate through the element array*}
72 {foreach from=$element.field_value item=val}
73 {$val}
74 <br/>
75 {/foreach}
76 </td>
77 {else}
78 <td class="label">{$element.field_title}</td>
79 {if $element.field_type == 'File'}
80 {if $element.field_value.displayURL}
81 <td class="html-adjust">
82 <a href="{$element.field_value.displayURL}" class='crm-image-popup'>
83 <img src="{$element.field_value.displayURL}" height="100" width="100">
84 </a>
85 </td>
86 {else}
87 <td class="html-adjust">
88 <a href="{$element.field_value.fileURL}">{$element.field_value.fileName}</a>
89 </td>
90 {/if}
91 {else}
92 {if $element.field_data_type == 'Money'}
93 {if $element.field_type == 'Text'}
94 <td class="html-adjust">{$element.field_value|crmMoney}</td>
95 {else}
96 <td class="html-adjust">{$element.field_value}</td>
97 {/if}
98 {else}
99 <td class="html-adjust">
100 {if $element.contact_ref_id}
101 <a href='{crmURL p="civicrm/contact/view" q="reset=1&cid=`$element.contact_ref_id`"}'>
102 {/if}
103 {if $element.field_data_type == 'Memo'}
104 {$element.field_value|nl2br}
105 {else}
106 {$element.field_value}
107 {/if}
108 {if $element.contact_ref_id}
109 </a>
110 {/if}
111 </td>
112 {/if}
113 {/if}
114 {/if}
115 </tr>
116 </table>
117 {/foreach}
118 </div>
119 <!-- end of body -->
120 <div class="clear"></div>
121 </div>
122 <!-- end of main accordian -->
123 </td>
124 </tr>
125 </table>
126 {else}
127 {foreach from=$cd_edit.fields item=element key=field_id}
128 <div class="crm-section">
129 {if $element.options_per_line != 0}
130 <div class="label">{$element.field_title}</div>
131 <div class="content">
132 {* sort by fails for option per line. Added a variable to iterate through the element array*}
133 {foreach from=$element.field_value item=val}
134 {$val}
135 <br/>
136 {/foreach}
137 </div>
138 {else}
139 <div class="label">{$element.field_title}</div>
140 {if $element.field_type == 'File'}
141 {if $element.field_value.displayURL}
142 <div class="content">
143 <a href="{$element.field_value.displayURL}" class='crm-image-popup'>
144 <img src="{$element.field_value.displayURL}" height="100" width="100">
145 </a>
146 </div>
147 {else}
148 <div class="content">
149 {if $element.field_value}
150 <a href="{$element.field_value.fileURL}">{$element.field_value.fileName}</a>
151 {else}
152 <br/>
153 {/if}
154 </div>
155 {/if}
156 {else}
157 {if $element.field_data_type == 'Money'}
158 {if $element.field_type == 'Text'}
159 <div class="content">{if $element.field_value}{$element.field_value|crmMoney}{else}<br/>{/if}</div>
160 {else}
161 <div class="content">{if $element.field_value}{$element.field_value}{else}<br/>{/if}</div>
162 {/if}
163 {else}
164 <div class="content">
165 {if $element.contact_ref_id}
166 <a href='{crmURL p="civicrm/contact/view" q="reset=1&cid=`$element.contact_ref_id`"}'>
167 {/if}
168 {if $element.field_data_type == 'Memo'}
169 {$element.field_value|nl2br}
170 {else}
171 {if $element.field_value}{$element.field_value} {else}<br/>{/if}
172 {/if}
173 {if $element.contact_ref_id}
174 </a>
175 {/if}
176 </div>
177 {/if}
178 {/if}
179 {/if}
180 </div>
181 {/foreach}
182 {/if}
183 {/foreach}
184 {/foreach}
185 {literal}
186 <script type="text/javascript">
187 CRM.$(function($) {
188 cj().crmAccordions();
189 });
190 </script>
191 {/literal}
192 {*currently delete is available only for tab custom data*}
193 {if $groupId}
194 <script type="text/javascript">
195 {literal}
196 function hideStatus(valueID, groupID) {
197 cj('#statusmessg_' + groupID + '_' + valueID).hide();
198 }
199 function showDelete(valueID, elementID, groupID, contactID) {
200 var confirmMsg = '{/literal}{ts escape='js'}Are you sure you want to delete this record?{/ts}{literal} &nbsp; <a href="#" onclick="deleteCustomValue( ' + valueID + ',\'' + elementID + '\',' + groupID + ',' + contactID + ' ); return false;" style="text-decoration: underline;">{/literal}{ts escape='js'}Yes{/ts}{literal}</a>&nbsp;&nbsp;&nbsp;<a href="#" onclick="hideStatus( ' + valueID + ', ' + groupID + ' ); return false;" style="text-decoration: underline;">{/literal}{ts escape='js'}No{/ts}{literal}</a>';
201 cj('tr#statusmessg_' + groupID + '_' + valueID).show().children().find('span').html(confirmMsg);
202 }
203 function deleteCustomValue(valueID, elementID, groupID, contactID) {
204 var postUrl = {/literal}"{crmURL p='civicrm/ajax/customvalue' h=0 }"{literal},
205 request = cj.ajax({
206 type: "POST",
207 data: "valueID=" + valueID + "&groupID=" + groupID + "&contactId=" + contactID + "&key={/literal}{crmKey name='civicrm/ajax/customvalue'}{literal}",
208 url: postUrl,
209 success: function (html) {
210 cj('#' + elementID).hide();
211 hideStatus(valueID, groupID);
212 var element = cj('.ui-tabs-nav #tab_custom_' + groupID + ' a');
213 cj(element).html(cj(element).attr('title') + ' (' + html + ') ');
214 }
215 });
216 CRM.status({success: '{/literal}{ts escape="js"}Record Deleted{/ts}{literal}'}, request);
217 }
218 {/literal}
219 </script>
220 {/if}
221