Merge pull request #12834 from pradpnayak/preRelHook
[civicrm-core.git] / templates / CRM / Contact / Page / View / CustomData.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 5 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2019 |
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 {* template for custom data *}
27 {assign var="customDataGroupName" value=$customDataGroup.name}
28 {strip}
29 {if $displayStyle neq 'tableOriented' and ($action eq 16 or $action eq 4)} {* Browse or View actions *}
30 {assign var="customGroupDisplayDone" value=1}
31 <div class="form-item">
32 {include file="CRM/Custom/Page/CustomDataView.tpl"}
33 </div>
34 {/if}
35 {/strip}
36 {if $displayStyle eq 'tableOriented'}
37 {include file='CRM/Profile/Page/MultipleRecordFieldsListing.tpl' showListing=1 dontShowTitle=1 pageViewType='customDataView'}
38 {literal}
39 <script type="text/javascript">
40 CRM.$(function($) {
41 var $table = $("#{/literal}custom-{$customGroupId}-table-wrapper{literal}");
42 $('a.delete-custom-row', $table).on('click', function(e) {
43 deleteRow($(this));
44 e.preventDefault();
45 });
46 $(".crm-multifield-selector").on('click', '.delete-custom-row', function (e) {
47 deleteRow($(this));
48 e.preventDefault();
49 });
50
51 function deleteRow($el) {
52 CRM.confirm({
53 message: '{/literal}{ts escape='js'}Are you sure you want to delete this record?{/ts}{literal}'
54 }).on('crmConfirm:yes', function() {
55 var postUrl = {/literal}"{crmURL p='civicrm/ajax/customvalue' h=0 }"{literal};
56 var request = $.post(postUrl, $el.data('delete_params'));
57 CRM.status({/literal}"{ts escape='js'}Record Deleted{/ts}"{literal}, request);
58 request.done(function() {
59 CRM.refreshParent($el);
60 });
61 })
62 }
63 });
64 </script>
65 {/literal}
66 {/if}
67
68 {* Todo: Comment on which part custom data gets displayed from the below code. *}
69 {foreach from=$viewCustomData item=customGroupWrapper}
70 {foreach from=$customGroupWrapper item=customGroup key=customGroupId}
71 {assign var="customRegion" value='contact-custom-data-'|cat:$customGroup.name}
72 {crmRegion name=$customRegion}
73 {if $customGroup.help_pre and !$customGroupDisplayDone}
74 <div class="messages help">{$customGroup.help_pre}</div>
75 {/if}
76 {if $action eq 0 or $action eq 1 or $action eq 2 or $recordActivity}
77 {include file="CRM/Contact/Form/CustomData.tpl" mainEdit=$mainEditForm}
78 {/if}
79 {if $mainEditForm}
80 <script type="text/javascript">
81 var showBlocks1 = new Array({$showBlocks1});
82 var hideBlocks1 = new Array({$hideBlocks1});
83
84 on_load_init_blocks(showBlocks1, hideBlocks1);
85 </script>
86 {else}
87 <script type="text/javascript">
88 var showBlocks = new Array({$showBlocks});
89 var hideBlocks = new Array({$hideBlocks});
90
91 {* hide and display the appropriate blocks as directed by the php code *}
92 on_load_init_blocks(showBlocks, hideBlocks);
93 </script>
94 {/if}
95 {if $customGroup.help_post and !$customGroupDisplayDone}
96 <div class="messages help">{$customGroup.help_post}</div>
97 {/if}
98 {/crmRegion}
99 {/foreach}
100 {/foreach}