dev/core#2774 : Sort by date column on multirecord field listing section on profile...
[civicrm-core.git] / templates / CRM / Profile / Page / MultipleRecordFieldsListing.tpl
CommitLineData
6a488035
TO
1{*
2 +--------------------------------------------------------------------+
1188c7a8 3 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 4 | |
1188c7a8
TO
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 |
6a488035
TO
8 +--------------------------------------------------------------------+
9*}
10{if $showListing}
e41f4660
PJ
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}
f5eda27f 17 {if ($records and $headers) or ($pageViewType eq 'customDataView')}
6a488035 18 {include file="CRM/common/jsortable.tpl"}
4411002f 19 <div id="custom-{$customGroupId}-table-wrapper" {if $pageViewType eq 'customDataView'}class="crm-entity" data-entity="contact" data-id="{$contactId}"{/if}>
f8c36033 20 <div>
6a488035 21 {strip}
a98d39f1 22 <table id="records-{$customGroupId}" class={if $pageViewType eq 'customDataView'}"crm-multifield-selector crm-ajax-table"{else}'display'{/if}>
f8c36033 23 <thead>
c693f065 24 {if $pageViewType eq 'customDataView'}
f8c36033 25 {foreach from=$headers key=recId item=head}
f11b68e0 26 <th data-data={ts}'{$headerAttr.$recId.columnName}'{/ts}
c693f065 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>
b05a0fb6 30 {/foreach}
d51e02d3 31 <th data-data="action" data-orderable="false">&nbsp;</th>
f8c36033 32 </thead>
5a2c7bb9 33 {literal}
34 <script type="text/javascript">
c693f065 35 (function($) {
84982014 36 var ZeroRecordText = {/literal}'{ts 1=$customGroupTitle|escape}No records of type \'%1\' found.{/ts}'{literal};
a98d39f1 37 var $table = $('#records-' + {/literal}'{$customGroupId}'{literal});
c693f065 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 },
d51e02d3 42 "language": {
f5eda27f 43 "emptyTable": ZeroRecordText,
d51e02d3 44 },
45 //Add class attributes to cells
56a7bb7c 46 "rowCallback": function(row, data) {
a98d39f1 47 $('thead th', $table).each(function(index) {
d51e02d3 48 var fName = $(this).attr('data-data');
56a7bb7c 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);
d51e02d3 53 }
56a7bb7c 54 if (typeof data[fName].cellClass != 'undefined') {
55 $(cell).attr('class', data[fName].cellClass);
d51e02d3 56 }
57 }
58 });
13f7c844 59 }
c693f065 60 })
c693f065 61 })(CRM.$);
5a2c7bb9 62 </script>
63 {/literal}
c693f065 64
5a2c7bb9 65 {else}
c693f065 66 {foreach from=$headers key=recId item=head}
67 <th>{ts}{$head}{/ts}</th>
68 {/foreach}
f1eae8d1 69
c693f065 70 {foreach from=$dateFields key=fieldId item=v}
71 <th class='hiddenElement'></th>
72 {/foreach}
73 <th>&nbsp;</th>
c693f065 74 </thead>
5a2c7bb9 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}
256db02a 78 <td {if !empty($dateFieldsVals.$hrecId)}data-order="{$dateFieldsVals.$hrecId.$recId|crmDate:'%Y-%m-%d'}"{/if} {crmAttributes a=$attributes.$hrecId.$recId}>{$rows.$hrecId}</td>
5a2c7bb9 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}
6a488035
TO
87 </table>
88 {/strip}
6a488035 89 </div>
f8c36033 90 </div>
e41f4660 91 <div id='{$dialogId}' class="hiddenElement"></div>
f8c36033
KJ
92 {elseif !$records}
93 <div class="messages status no-popup">
34d6cec4 94 {icon icon="fa-info-circle"}{/icon}
f8c36033 95 &nbsp;
e5e3f1ad 96 {ts 1=$customGroupTitle}No records of type '%1' found.{/ts}
f8c36033 97 </div>
e41f4660 98 <div id='{$dialogId}' class="hiddenElement"></div>
f8c36033 99 {/if}
6a488035 100
317103ab 101 {if empty($reachedMax) && !empty($editPermission)}
4da822ca
EM
102 <div class="action-link">
103 {if $pageViewType eq 'customDataView'}
d4c2682f 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"}"
13a3d214 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>
4da822ca
EM
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`"}"
13a3d214 108 class="button action-item"><span><i class="crm-i fa-plus-circle" aria-hidden="true"></i> {ts}Add New Record{/ts}</span></a>
4da822ca
EM
109 {/if}
110 </div>
111 <br />
f8c36033 112 {/if}
3cc60a06 113{/if}