fix api test break
[civicrm-core.git] / templates / CRM / Profile / Page / MultipleRecordFieldsListing.tpl
CommitLineData
6a488035
TO
1{*
2 +--------------------------------------------------------------------+
2c4c49ca 3 | CiviCRM version 4.7 |
6a488035 4 +--------------------------------------------------------------------+
e7112fa7 5 | Copyright CiviCRM LLC (c) 2004-2015 |
6a488035
TO
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}
e41f4660
PJ
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}
f8c36033 33 {if $records and $headers}
6a488035 34 {include file="CRM/common/jsortable.tpl"}
4411002f 35 <div id="custom-{$customGroupId}-table-wrapper" {if $pageViewType eq 'customDataView'}class="crm-entity" data-entity="contact" data-id="{$contactId}"{/if}>
f8c36033 36 <div>
6a488035 37 {strip}
c693f065 38 <table id="records" class={if $pageViewType eq 'customDataView'}"crm-multifield-selector crm-ajax-table"{else}'display'{/if}>
f8c36033 39 <thead>
7253f198 40 <tr>
c693f065 41 {if $pageViewType eq 'customDataView'}
f8c36033 42 {foreach from=$headers key=recId item=head}
d51e02d3 43 <th data-data={ts}'{$head}'{/ts}
c693f065 44 {if !empty($headerAttr.$recId.dataType)}cell-data-type="{$headerAttr.$recId.dataType}"{/if}
45 {if !empty($headerAttr.$recId.dataEmptyOption)}cell-data-empty-option="{$headerAttr.$recId.dataEmptyOption}"{/if}>{ts}{$head}{/ts}
46 </th>
b05a0fb6 47 {/foreach}
d51e02d3 48 <th data-data="action" data-orderable="false">&nbsp;</th>
7253f198 49 </tr>
f8c36033 50 </thead>
5a2c7bb9 51 {literal}
52 <script type="text/javascript">
c693f065 53 (function($) {
d51e02d3 54 var ZeroRecordText = {/literal}'{ts 1=$customGroupTitle}No records of type \'%1\' found.{/ts}'{literal};
c693f065 55 $('table.crm-multifield-selector').data({
56 "ajax": {
57 "url": {/literal}'{crmURL p="civicrm/ajax/multirecordfieldlist" h=0 q="snippet=4&cid=$contactId&cgid=$customGroupId"}'{literal},
58 },
59 "aaSorting": [],
60 "pageLength": 10,
d51e02d3 61 "language": {
62 "zeroRecords": ZeroRecordText,
63 },
64 //Add class attributes to cells
65 "fnRowCallback": function(nRow, aData) {
66 $('thead th').each( function( index ) {
67 var fName = $(this).attr('data-data');
68 var cell = $('td:eq(' + index + ')', nRow);
69 if (typeof aData[fName]=='object'){
70 if (typeof aData[fName].data != 'undefined') {
71 $(cell).html(aData[fName].data);
72 }
73 if (typeof aData[fName].cssClass != 'undefined') {
74 $(cell).attr('class', aData[fName].cssClass);
75 }
76 }
77 });
78 return nRow;
79 },
c693f065 80 })
d51e02d3 81
c693f065 82 $(".crm-multifield-selector").on('click','.delete-custom-row', function (e) {
5a2c7bb9 83 var $el = $(this);
84 CRM.confirm({
85 message: '{/literal}{ts escape='js'}Are you sure you want to delete this record?{/ts}{literal}'
86 }).on('crmConfirm:yes', function() {
c693f065 87 var postUrl = {/literal}"{crmURL p='civicrm/ajax/customvalue' h=0 }"{literal};
88 var request = $.post(postUrl, $el.data('delete_params'));
89 CRM.status({/literal}"{ts escape='js'}Record Deleted{/ts}"{literal}, request);
90 request.done(function() {
91 CRM.refreshParent($el);
92 });
93 })
94 e.preventDefault();
95 });
96 })(CRM.$);
5a2c7bb9 97 </script>
98 {/literal}
c693f065 99
5a2c7bb9 100 {else}
c693f065 101 {foreach from=$headers key=recId item=head}
102 <th>{ts}{$head}{/ts}</th>
103 {/foreach}
104 <th></th>
105 {foreach from=$dateFields key=fieldId item=v}
106 <th class='hiddenElement'></th>
107 {/foreach}
108 <th>&nbsp;</th>
109 </tr>
110 </thead>
5a2c7bb9 111 {foreach from=$records key=recId item=rows}
112 <tr class="{cycle values="odd-row,even-row"}">
113 {foreach from=$headers key=hrecId item=head}
114 <td {crmAttributes a=$attributes.$hrecId.$recId}>{$rows.$hrecId}</td>
115 {/foreach}
116 <td>{$rows.action}</td>
117 {foreach from=$dateFieldsVals key=fid item=rec}
118 <td class='crm-field-{$fid}_date hiddenElement'>{$rec.$recId}</td>
119 {/foreach}
120 </tr>
121 {/foreach}
122 {/if}
6a488035
TO
123 </table>
124 {/strip}
6a488035 125 </div>
f8c36033 126 </div>
e41f4660 127 <div id='{$dialogId}' class="hiddenElement"></div>
f8c36033
KJ
128 {elseif !$records}
129 <div class="messages status no-popup">
130 <div class="icon inform-icon"></div>
131 &nbsp;
e5e3f1ad 132 {ts 1=$customGroupTitle}No records of type '%1' found.{/ts}
f8c36033 133 </div>
e41f4660 134 <div id='{$dialogId}' class="hiddenElement"></div>
f8c36033 135 {/if}
6a488035 136
f8c36033 137 {if !$reachedMax}
4da822ca
EM
138 <div class="action-link">
139 {if $pageViewType eq 'customDataView'}
140 <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=$cgcount&multiRecordDisplay=single&mode=add"}"
a2c70872 141 class="button action-item"><span><i class="crm-i fa-plus-circle"></i> {ts 1=$customGroupTitle}Add %1 Record{/ts}</span></a>
4da822ca
EM
142 {else}
143 <a accesskey="N" href="{crmURL p='civicrm/profile/edit' q="reset=1&id=`$contactId`&multiRecord=add&gid=`$gid`&context=multiProfileDialog&onPopupClose=`$onPopupClose`"}"
a2c70872 144 class="button action-item"><span><i class="crm-i fa-plus-circle"></i> {ts}Add New Record{/ts}</span></a>
4da822ca
EM
145 {/if}
146 </div>
147 <br />
f8c36033 148 {/if}
3cc60a06 149{/if}