Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
232624b1 | 3 | | CiviCRM version 4.4 | |
6a488035 TO |
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"} |
eadfd545 | 32 | {if ($editOwnCustomData and $showEdit) or ($showEdit and $editCustomData and $groupId)} |
fe06c0fb KJ |
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} | |
ebb9197b C |
80 | <td class="html-adjust"> |
81 | <a href="{$element.field_value.displayURL}" class='crm-image-popup'> | |
82 | <img src="{$element.field_value.displayURL}" height="100" width="100"> | |
83 | </a> | |
84 | </td> | |
fe06c0fb | 85 | {else} |
ebb9197b C |
86 | <td class="html-adjust"> |
87 | <a href="{$element.field_value.fileURL}">{$element.field_value.fileName}</a> | |
88 | </td> | |
fe06c0fb KJ |
89 | {/if} |
90 | {else} | |
91 | {if $element.field_data_type == 'Money'} | |
92 | {if $element.field_type == 'Text'} | |
93 | <td class="html-adjust">{$element.field_value|crmMoney}</td> | |
94 | {else} | |
95 | <td class="html-adjust">{$element.field_value}</td> | |
96 | {/if} | |
97 | {else} | |
98 | <td class="html-adjust"> | |
99 | {if $element.contact_ref_id} | |
100 | <a href='{crmURL p="civicrm/contact/view" q="reset=1&cid=`$element.contact_ref_id`"}'> | |
101 | {/if} | |
102 | {if $element.field_data_type == 'Memo'} | |
103 | {$element.field_value|nl2br} | |
104 | {else} | |
105 | {$element.field_value} | |
106 | {/if} | |
107 | {if $element.contact_ref_id} | |
108 | </a> | |
109 | {/if} | |
110 | </td> | |
111 | {/if} | |
112 | {/if} | |
113 | {/if} | |
114 | </tr> | |
115 | </table> | |
116 | {/foreach} | |
117 | </div> | |
118 | <!-- end of body --> | |
119 | <div class="clear"></div> | |
120 | </div> | |
121 | <!-- end of main accordian --> | |
122 | </td> | |
6a488035 | 123 | </tr> |
fe06c0fb KJ |
124 | </table> |
125 | {/foreach} | |
6a488035 | 126 | {/foreach} |
fe06c0fb | 127 | {literal} |
6a488035 | 128 | <script type="text/javascript"> |
fe06c0fb KJ |
129 | cj(function () { |
130 | cj().crmAccordions(); | |
131 | }); | |
6a488035 | 132 | </script> |
fe06c0fb | 133 | {/literal} |
6a488035 TO |
134 | {*currently delete is available only for tab custom data*} |
135 | {if $groupId} | |
fe06c0fb | 136 | <script type="text/javascript"> |
6a488035 | 137 | {literal} |
fe06c0fb KJ |
138 | function hideStatus(valueID, groupID) { |
139 | cj('#statusmessg_' + groupID + '_' + valueID).hide(); | |
6a488035 | 140 | } |
fe06c0fb KJ |
141 | function showDelete(valueID, elementID, groupID, contactID) { |
142 | var confirmMsg = '{/literal}{ts escape='js'}Are you sure you want to delete this record?{/ts}{literal} <a href="#" onclick="deleteCustomValue( ' + valueID + ',\'' + elementID + '\',' + groupID + ',' + contactID + ' ); return false;" style="text-decoration: underline;">{/literal}{ts escape='js'}Yes{/ts}{literal}</a> <a href="#" onclick="hideStatus( ' + valueID + ', ' + groupID + ' ); return false;" style="text-decoration: underline;">{/literal}{ts escape='js'}No{/ts}{literal}</a>'; | |
143 | cj('tr#statusmessg_' + groupID + '_' + valueID).show().children().find('span').html(confirmMsg); | |
6a488035 | 144 | } |
fe06c0fb KJ |
145 | function deleteCustomValue(valueID, elementID, groupID, contactID) { |
146 | var postUrl = {/literal}"{crmURL p='civicrm/ajax/customvalue' h=0 }"{literal}; | |
147 | cj.ajax({ | |
148 | type: "POST", | |
149 | data: "valueID=" + valueID + "&groupID=" + groupID + "&contactId=" + contactID + "&key={/literal}{crmKey name='civicrm/ajax/customvalue'}{literal}", | |
150 | url: postUrl, | |
151 | success: function (html) { | |
152 | cj('#' + elementID).hide(); | |
153 | hideStatus(valueID, groupID); | |
154 | CRM.alert('', '{/literal}{ts escape="js"}Record Deleted{/ts}{literal}', 'success'); | |
155 | var element = cj('.ui-tabs-nav #tab_custom_' + groupID + ' a'); | |
156 | cj(element).html(cj(element).attr('title') + ' (' + html + ') '); | |
157 | } | |
158 | }); | |
6a488035 TO |
159 | } |
160 | {/literal} | |
fe06c0fb | 161 | </script> |
6a488035 TO |
162 | {/if} |
163 |