[REF] Move handling of form elements back to the Form
[civicrm-core.git] / templates / CRM / Profile / Page / MultipleRecordFieldsListing.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | Copyright CiviCRM LLC. All rights reserved. |
4 | |
5 | This work is published under the GNU AGPLv3 license with some |
6 | permitted exceptions and without any warranty. For full license |
7 | and copyright information, see https://civicrm.org/licensing |
8 +--------------------------------------------------------------------+
9 *}
10 {if $showListing}
11 {if $dontShowTitle neq 1}<h1>{ts}{$customGroupTitle}{/ts}</h1>{/if}
12 {if $pageViewType eq 'customDataView'}
13 {assign var='dialogId' value='custom-record-dialog'}
14 {else}
15 {assign var='dialogId' value='profile-dialog'}
16 {/if}
17 {if ($records and $headers) or ($pageViewType eq 'customDataView')}
18 {include file="CRM/common/jsortable.tpl"}
19 <div id="custom-{$customGroupId}-table-wrapper" {if $pageViewType eq 'customDataView'}class="crm-entity" data-entity="contact" data-id="{$contactId}"{/if}>
20 <div>
21 {strip}
22 <table id="records-{$customGroupId}" class={if $pageViewType eq 'customDataView'}"crm-multifield-selector crm-ajax-table"{else}'display'{/if}>
23 <thead>
24 {if $pageViewType eq 'customDataView'}
25 {foreach from=$headers key=recId item=head}
26 <th data-data={ts}'{$headerAttr.$recId.columnName}'{/ts}
27 {if !empty($headerAttr.$recId.dataType)}cell-data-type="{$headerAttr.$recId.dataType}"{/if}
28 {if !empty($headerAttr.$recId.dataEmptyOption)}cell-data-empty-option="{$headerAttr.$recId.dataEmptyOption}"{/if}>{ts}{$head}{/ts}
29 </th>
30 {/foreach}
31 <th data-data="action" data-orderable="false">&nbsp;</th>
32 </thead>
33 {literal}
34 <script type="text/javascript">
35 (function($) {
36 var ZeroRecordText = {/literal}'{ts 1=$customGroupTitle|escape}No records of type \'%1\' found.{/ts}'{literal};
37 var $table = $('#records-' + {/literal}'{$customGroupId}'{literal});
38 $('table.crm-multifield-selector').data({
39 "ajax": {
40 "url": {/literal}'{crmURL p="civicrm/ajax/multirecordfieldlist" h=0 q="snippet=4&cid=$contactId&cgid=$customGroupId"}'{literal},
41 },
42 "language": {
43 "emptyTable": ZeroRecordText,
44 },
45 //Add class attributes to cells
46 "rowCallback": function(row, data) {
47 $('thead th', $table).each(function(index) {
48 var fName = $(this).attr('data-data');
49 var cell = $('td:eq(' + index + ')', row);
50 if (typeof data[fName] == 'object') {
51 if (typeof data[fName].data != 'undefined') {
52 $(cell).html(data[fName].data);
53 }
54 if (typeof data[fName].cellClass != 'undefined') {
55 $(cell).attr('class', data[fName].cellClass);
56 }
57 }
58 });
59 }
60 })
61 })(CRM.$);
62 </script>
63 {/literal}
64
65 {else}
66 {foreach from=$headers key=recId item=head}
67 <th>{ts}{$head}{/ts}</th>
68 {/foreach}
69
70 {foreach from=$dateFields key=fieldId item=v}
71 <th class='hiddenElement'></th>
72 {/foreach}
73 <th>&nbsp;</th>
74 </thead>
75 {foreach from=$records key=recId item=rows}
76 <tr class="{cycle values="odd-row,even-row"}">
77 {foreach from=$headers key=hrecId item=head}
78 <td {crmAttributes a=$attributes.$hrecId.$recId}>{$rows.$hrecId}</td>
79 {/foreach}
80 <td>{$rows.action}</td>
81 {foreach from=$dateFieldsVals key=fid item=rec}
82 <td class='crm-field-{$fid}_date hiddenElement'>{$rec.$recId}</td>
83 {/foreach}
84 </tr>
85 {/foreach}
86 {/if}
87 </table>
88 {/strip}
89 </div>
90 </div>
91 <div id='{$dialogId}' class="hiddenElement"></div>
92 {elseif !$records}
93 <div class="messages status no-popup">
94 <div class="icon inform-icon"></div>
95 &nbsp;
96 {ts 1=$customGroupTitle}No records of type '%1' found.{/ts}
97 </div>
98 <div id='{$dialogId}' class="hiddenElement"></div>
99 {/if}
100
101 {if !$reachedMax}
102 <div class="action-link">
103 {if $pageViewType eq 'customDataView'}
104 <br/><a accesskey="N" title="{ts 1=$customGroupTitle}Add %1 Record{/ts}" href="{crmURL p='civicrm/contact/view/cd/edit' q="reset=1&type=$ctype&groupID=$customGroupId&entityID=$contactId&cgcount=$newCgCount&multiRecordDisplay=single&mode=add"}"
105 class="button action-item"><span><i class="crm-i fa-plus-circle" aria-hidden="true"></i> {ts 1=$customGroupTitle}Add %1 Record{/ts}</span></a>
106 {else}
107 <a accesskey="N" href="{crmURL p='civicrm/profile/edit' q="reset=1&id=`$contactId`&multiRecord=add&gid=`$gid`&context=multiProfileDialog&onPopupClose=`$onPopupClose`"}"
108 class="button action-item"><span><i class="crm-i fa-plus-circle" aria-hidden="true"></i> {ts}Add New Record{/ts}</span></a>
109 {/if}
110 </div>
111 <br />
112 {/if}
113 {/if}