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