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