Merge pull request #2596 from eileenmcnaughton/CRM-14299
[civicrm-core.git] / templates / CRM / Contact / Form / Selector.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 {include file="CRM/common/pager.tpl" location="top"}
27
28 {include file="CRM/common/pagerAToZ.tpl"}
29 <a href="#" onclick=" return toggleContactSelection( 'resetSel', 'civicrm search {$qfKey}', 'reset' );">{ts}Reset all selections{/ts}</a>
30
31 <table summary="{ts}Search results listings.{/ts}" class="selector row-highlight">
32 <thead class="sticky">
33 <tr>
34 <th scope="col" title="Select All Rows">{$form.toggleSelect.html}</th>
35 {if $context eq 'smog'}
36 <th scope="col">
37 {ts}Status{/ts}
38 </th>
39 {/if}
40 {foreach from=$columnHeaders item=header}
41 <th scope="col">
42 {if $header.sort}
43 {assign var='key' value=$header.sort}
44 {$sort->_response.$key.link}
45 {else}
46 {$header.name}
47 {/if}
48 </th>
49 {/foreach}
50 </tr>
51 </thead>
52
53 {counter start=0 skip=1 print=false}
54
55 { if $id }
56 {foreach from=$rows item=row}
57 <tr id='rowid{$row.contact_id}' class="{cycle values='odd-row,even-row'}">
58 {assign var=cbName value=$row.checkbox}
59 <td>{$form.$cbName.html}</td>
60 {if $context eq 'smog'}
61 {if $row.status eq 'Pending'}<td class="status-pending"}>
62 {elseif $row.status eq 'Removed'}<td class="status-removed">
63 {else}<td>{/if}
64 {$row.status}</td>
65 {/if}
66 <td>{$row.contact_type}</td>
67 <td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`&key=`$qfKey`&context=`$context`"}">{$row.sort_name}</a></td>
68 {foreach from=$row item=value key=key}
69 {if ($key neq "checkbox") and ($key neq "action") and ($key neq "contact_type") and ($key neq "contact_type_orig") and ($key neq "status") and ($key neq "sort_name") and ($key neq "contact_id")and ($key neq "contact_sub_type")}
70 <td>
71 {if $key EQ "household_income_total" }
72 {$value|crmMoney}
73 {elseif strpos( $key, '_date' ) !== false }
74 {$value|crmDate}
75 {else}
76 {$value}
77 {/if}
78 &nbsp;
79 </td>
80 {/if}
81 {/foreach}
82 <td>{$row.action|replace:'xx':$row.contact_id}</td>
83 </tr>
84 {/foreach}
85 {else}
86 {foreach from=$rows item=row}
87 <tr id="rowid{$row.contact_id}" class="{cycle values='odd-row,even-row'}">
88 {assign var=cbName value=$row.checkbox}
89 <td>{$form.$cbName.html}</td>
90 {if $context eq 'smog'}
91 {if $row.status eq 'Pending'}<td class="status-pending"}>
92 {elseif $row.status eq 'Removed'}<td class="status-removed">
93 {else}<td>{/if}
94 {$row.status}</td>
95 {/if}
96 <td>{$row.contact_type}</td>
97 <td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`&key=`$qfKey`&context=`$context`"}">{if $row.is_deleted}<del>{/if}{$row.sort_name}{if $row.is_deleted}</del>{/if}</a></td>
98 {if $action eq 512 or $action eq 256}
99 {if !empty($columnHeaders.street_address)}
100 <td><span title="{$row.street_address}">{$row.street_address|mb_truncate:22:"...":true}{if $row.do_not_mail} <span class="icon privacy-flag do-not-mail"></span>{/if}</span></td>
101 {/if}
102 {if !empty($columnHeaders.city)}
103 <td>{$row.city}</td>
104 {/if}
105 {if !empty($columnHeaders.state_province)}
106 <td>{$row.state_province}</td>
107 {/if}
108 {if !empty($columnHeaders.postal_code)}
109 <td>{$row.postal_code}</td>
110 {/if}
111 {if !empty($columnHeaders.country)}
112 <td>{$row.country}</td>
113 {/if}
114 <td>
115 {if $row.email}
116 <span title="{$row.email}">
117 {$row.email|mb_truncate:17:"...":true}
118 {if $row.on_hold}
119 (On Hold)<span class="status-hold" title="{ts}This email is on hold (probably due to bouncing).{/ts}"></span>
120 {elseif $row.do_not_email}
121 <span class="icon privacy-flag do-not-email" title="{ts}Do Not Email{/ts}"></span>
122 {/if}
123 </span>
124 {/if}
125 </td>
126 <td>
127 {if $row.phone}
128 {$row.phone}
129 {if $row.do_not_phone}
130 <span class="icon privacy-flag do-not-phone" title="{ts}Do Not Phone{/ts}" ></span>
131 {/if}
132 {/if}
133 </td>
134 {else}
135 {foreach from=$row item=value key=key}
136 {if ($key neq "checkbox") and ($key neq "action") and ($key neq "contact_type") and ($key neq "contact_sub_type") and ($key neq "status") and ($key neq "sort_name") and ($key neq "contact_id") and ($key neq "contact_type_orig")}
137 <td>{$value}&nbsp;</td>
138 {/if}
139 {/foreach}
140 {/if}
141 <td style='width:125px;'>{$row.action|replace:'xx':$row.contact_id}</td>
142 </tr>
143 {/foreach}
144 {/if}
145 </table>
146
147 <script type="text/javascript">
148 {literal}
149 cj(function($) {
150 cj("#toggleSelect, input[id^=mark_x_]").prop('checked', false);
151 var cids = [];
152 var i = 0;
153 {/literal}
154 {foreach from=$selectedContactIds item=selectedContactId}
155 cids[i++] = "#mark_x_{$selectedContactId}";
156 {/foreach}
157 {literal}
158 $(cids.join(',')).prop('checked', true);
159 if (cids.length > 0) {
160 $('input[name=radio_ts][value=ts_sel]').prop('checked', true);
161 }
162 var params = {getCount: cids.length};
163 countSelections(params);
164 });
165 function countSelections(obj) {
166 var label = cj('label[for*=ts_sel]');
167 if (typeof(obj) == 'undefined') {
168 return parseInt(cj('span', label).text());
169 }
170 if (obj && typeof(obj.getCount) != 'undefined' && label.length > 0) {
171 if (cj('span', label).length < 1) {
172 label.prepend('<span>' + obj.getCount + '</span> ');
173 }
174 else {
175 cj('span', label).html(obj.getCount);
176 }
177 toggleTaskAction(obj.getCount);
178 }
179 }
180 function toggleContactSelection(name, qfKey, selection) {
181 var url = CRM.url('civicrm/ajax/markSelection');
182 var params = {qfKey: qfKey};
183 if (!(cj('#' + name).is(':checked'))) {
184 params.action = 'unselect';
185 params.state = 'unchecked';
186 }
187 if (selection == 'multiple') {
188 var rowArr = new Array( );
189 {/literal}{foreach from=$rows item=row key=keyVal}
190 {literal}rowArr[{/literal}{$keyVal}{literal}] = '{/literal}{$row.checkbox}{literal}';
191 {/literal}{/foreach}{literal}
192 params.name = rowArr.join('-');
193 params.variableType = 'multiple';
194 }
195 else if (name == 'resetSel' && selection == 'reset') {
196 params.variableType = 'multiple';
197 cj("#toggleSelect, input[id^=mark_x_]").prop('checked', false);
198 }
199 else {
200 params.name = name;
201 }
202 cj.getJSON(url, params, countSelections);
203 return false;
204 }
205 {/literal}
206 </script>
207 {include file="CRM/common/pager.tpl" location="bottom"}