more template cleanup
[civicrm-core.git] / templates / CRM / Custom / Page / CustomDataView.tpl
CommitLineData
6a488035
TO
1{*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.3 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2013 |
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}
fe06c0fb
KJ
29 {foreach from=$customValues item=cd_edit key=cvID}
30 <table class="no-border">
6a488035 31 {assign var='index' value=$groupId|cat:"_$cvID"}
fe06c0fb
KJ
32 {if $editOwnCustomData or ($showEdit and $editCustomData and $groupId)}
33 <tr>
34 <td>
35 <a
36 href="{crmURL p="civicrm/contact/view/cd/edit" q="tableId=`$contactId`&cid=`$contactId`&groupID=`$groupId`&action=update&reset=1"}"
37 class="button" style="margin-left: 6px;"><span><div
38 class="icon edit-icon"></div>{ts 1=$cd_edit.title}Edit %1{/ts}</span></a><br/><br/>
39 </td>
40 </tr>
6a488035
TO
41 {/if}
42 {assign var="showEdit" value=0}
43 <tr id="statusmessg_{$index}" class="hiddenElement">
fe06c0fb 44 <td><span class="success-status"></span></td>
6a488035
TO
45 </tr>
46 <tr>
fe06c0fb
KJ
47 <td id="{$cd_edit.name}_{$index}" class="section-shown form-item">
48 <div class="crm-accordion-wrapper {if $cd_edit.collapse_display eq 0 or $skipTitle} {else}collapsed{/if}">
49 {if !$skipTitle}
50 <div class="crm-accordion-header">
51 {$cd_edit.title}
52 </div>
6a488035 53 {/if}
fe06c0fb
KJ
54 <div class="crm-accordion-body">
55 {if $groupId and $cvID and $editCustomData}
56 <div class="crm-submit-buttons">
57 <a href="#"
58 onclick="showDelete( {$cvID}, '{$cd_edit.name}_{$index}', {$customGroupId}, {$contactId} ); return false;"
59 class="button delete-button" title="{ts 1=$cd_edit.title}Delete this %1 record{/ts}">
60 <span><div class="icon delete-icon"></div>{ts}Delete{/ts}</span>
6a488035 61 </a>
fe06c0fb
KJ
62 </div>
63 {/if}
64 {foreach from=$cd_edit.fields item=element key=field_id}
65 <table class="crm-info-panel">
66 <tr>
67 {if $element.options_per_line != 0}
68 <td class="label">{$element.field_title}</td>
69 <td class="html-adjust">
70 {* sort by fails for option per line. Added a variable to iterate through the element array*}
71 {foreach from=$element.field_value item=val}
72 {$val}
73 <br/>
74 {/foreach}
75 </td>
76 {else}
77 <td class="label">{$element.field_title}</td>
78 {if $element.field_type == 'File'}
79 {if $element.field_value.displayURL}
80 <td class="html-adjust"><a href="#"
81 onclick="imagePopUp('{$element.field_value.imageURL}'); return false;"><img
82 src="{$element.field_value.displayURL}" height="100" width="100"></a></td>
83 {else}
84 <td class="html-adjust"><a
85 href="{$element.field_value.fileURL}">{$element.field_value.fileName}</a></td>
86 {/if}
87 {else}
88 {if $element.field_data_type == 'Money'}
89 {if $element.field_type == 'Text'}
90 <td class="html-adjust">{$element.field_value|crmMoney}</td>
91 {else}
92 <td class="html-adjust">{$element.field_value}</td>
93 {/if}
94 {else}
95 <td class="html-adjust">
96 {if $element.contact_ref_id}
97 <a href='{crmURL p="civicrm/contact/view" q="reset=1&cid=`$element.contact_ref_id`"}'>
98 {/if}
99 {if $element.field_data_type == 'Memo'}
100 {$element.field_value|nl2br}
101 {else}
102 {$element.field_value}
103 {/if}
104 {if $element.contact_ref_id}
105 </a>
106 {/if}
107 </td>
108 {/if}
109 {/if}
110 {/if}
111 </tr>
112 </table>
113 {/foreach}
114 </div>
115 <!-- end of body -->
116 <div class="clear"></div>
117 </div>
118 <!-- end of main accordian -->
119 </td>
6a488035 120 </tr>
fe06c0fb
KJ
121 </table>
122 {/foreach}
6a488035 123{/foreach}
fe06c0fb 124{literal}
6a488035 125 <script type="text/javascript">
fe06c0fb
KJ
126 cj(function () {
127 cj().crmAccordions();
128 });
6a488035 129 </script>
fe06c0fb 130{/literal}
6a488035
TO
131{*currently delete is available only for tab custom data*}
132{if $groupId}
fe06c0fb 133 <script type="text/javascript">
6a488035 134 {literal}
fe06c0fb
KJ
135 function hideStatus(valueID, groupID) {
136 cj('#statusmessg_' + groupID + '_' + valueID).hide();
6a488035 137 }
fe06c0fb
KJ
138 function showDelete(valueID, elementID, groupID, contactID) {
139 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>';
140 cj('tr#statusmessg_' + groupID + '_' + valueID).show().children().find('span').html(confirmMsg);
6a488035 141 }
fe06c0fb
KJ
142 function deleteCustomValue(valueID, elementID, groupID, contactID) {
143 var postUrl = {/literal}"{crmURL p='civicrm/ajax/customvalue' h=0 }"{literal};
144 cj.ajax({
145 type: "POST",
146 data: "valueID=" + valueID + "&groupID=" + groupID + "&contactId=" + contactID + "&key={/literal}{crmKey name='civicrm/ajax/customvalue'}{literal}",
147 url: postUrl,
148 success: function (html) {
149 cj('#' + elementID).hide();
150 hideStatus(valueID, groupID);
151 CRM.alert('', '{/literal}{ts escape="js"}Record Deleted{/ts}{literal}', 'success');
152 var element = cj('.ui-tabs-nav #tab_custom_' + groupID + ' a');
153 cj(element).html(cj(element).attr('title') + ' (' + html + ') ');
154 }
155 });
6a488035
TO
156 }
157 {/literal}
fe06c0fb 158 </script>
6a488035
TO
159{/if}
160