CRM-13992 : handling multi-custom data listing, edit, add, view actions. reused profi...
[civicrm-core.git] / templates / CRM / Profile / Page / MultipleRecordFieldsListing.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.4 |
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 {if $showListing}
27 {if $dontShowTitle neq 1}<h1>{ts}{$customGroupTitle}{/ts}</h1>{/if}
28 {if $pageViewType eq 'customDataView'}
29 {assign var='dialogId' value='custom-record-dialog'}
30 {else}
31 {assign var='dialogId' value='profile-dialog'}
32 {/if}
33 {if $records and $headers}
34 {include file="CRM/common/jsortable.tpl"}
35 <div id="browseValues">
36 <div>
37 {strip}
38 <table id="records" class="display">
39 <thead>
40 <tr>
41 {foreach from=$headers key=recId item=head}
42 <th>{ts}{$head}{/ts}</th>
43 {/foreach}
44 <th></th>
45 </tr>
46 </thead>
47 {foreach from=$records key=recId item=rows}
48 <tr class="{cycle values="odd-row,even-row"}">
49 {foreach from=$headers key=hrecId item=head}
50 <td>{$rows.$hrecId}</td>
51 {/foreach}
52 <td>{$rows.action}</td>
53 </tr>
54 {/foreach}
55 </table>
56 {/strip}
57 </div>
58 </div>
59 <div id='{$dialogId}' class="hiddenElement"></div>
60 {elseif !$records}
61 <div class="messages status no-popup">
62 <div class="icon inform-icon"></div>
63 &nbsp;
64 {ts 1=$customGroupTitle}No records of type '%1' found.{/ts}
65 </div>
66 <div id='{$dialogId}' class="hiddenElement"></div>
67 {/if}
68
69 {if !$reachedMax}
70 {if $pageViewType eq 'customDataView'}
71 <a accesskey="N" href="{crmURL p='civicrm/contact/view/cd/edit' q="reset=1&snippet=1&type=$ctype&groupID=$customGroupId&entityID=$contactId&cgcount=$cgcount&multiRecordDisplay=single"}"
72 class="button action-item"><span><div class="icon add-icon"></div>{ts 1=$customGroupTitle}Add %1 Record{/ts}</span></a>
73 {else}
74 <a accesskey="N" href="{crmURL p='civicrm/profile/edit' q="reset=1&id=`$contactId`&multiRecord=add&gid=`$gid`&snippet=1&context=multiProfileDialog&onPopupClose=`$onPopupClose`"}"
75 class="button action-item"><span><div class="icon add-icon"></div>{ts}Add New Record{/ts}</span></a>
76 {/if}
77 {/if}
78 {/if}
79 {literal}
80 <script type='text/javascript'>
81 cj(function () {
82 var dialogId = '{/literal}{$dialogId}{literal}';
83 var pageViewType = '{/literal}{$pageViewType}{literal}';
84 // NOTE: Triggers two events, "profile-dialog:FOO:open" and "profile-dialog:FOO:close",
85 // where "FOO" is the internal name of a profile form
86 function formDialog(dialogName, dataURL, dialogTitle) {
87 cj.ajax({
88 url: dataURL,
89 success: function (content) {
90 cj('#' + dialogId).show().html(content).dialog({
91 title: dialogTitle,
92 modal: true,
93 width: 680,
94 overlay: {
95 opacity: 0.5,
96 background: "black"
97 },
98 open: function(event, ui) {
99 cj('#' + dialogId).trigger({
100 type: "crmFormLoad",
101 profileName: dialogName
102 });
103 },
104 close: function (event, ui) {
105 cj('#' + dialogId).trigger({
106 type: "crmFormClose",
107 profileName: dialogName
108 });
109 cj('#' + dialogId).html('');
110 }
111 });
112 cj('.action-link').hide();
113 if (pageViewType != 'customDataView') {
114 cj('#profile-dialog #crm-profile-block .edit-value label').css('display', 'inline');
115 }
116 }
117 });
118 }
119
120 var profileName = {/literal}"{$ufGroupName}"{literal};
121 cj('.action-item').each(function () {
122 if (!cj(this).attr('jshref')) {
123 cj(this).attr('jshref', cj(this).attr('href'));
124 cj(this).attr('href', '#browseValues');
125 }
126 });
127
128 if (pageViewType == 'customDataView') {
129 var actionItemHeirarchy = '.action-item';
130 profileName = 'customRecordView';
131 }
132 else {
133 var actionItemHeirarchy = '.crm-profile-name-' + profileName + ' .action-item';
134 }
135
136 cj(actionItemHeirarchy).click(function () {
137 dataURL = cj(this).attr('jshref');
138 dialogTitle = cj(this).attr('title');
139 formDialog(profileName, dataURL, dialogTitle);
140 });
141 });
142 </script>
143 {/literal}