Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
232624b1 | 3 | | CiviCRM version 4.4 | |
6a488035 TO |
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 | {* CiviCase - view case screen*} | |
27 | ||
6a488035 | 28 | <div class="crm-block crm-form-block crm-case-caseview-form-block"> |
6a488035 | 29 | |
c1c6e20c CW |
30 | {* here we are showing related cases w/ jquery dialog *} |
31 | {if $showRelatedCases} | |
32 | {include file="CRM/Case/Form/ViewRelatedCases.tpl"} | |
6a488035 | 33 | |
c1c6e20c CW |
34 | {* Main case view *} |
35 | {else} | |
6a488035 | 36 | |
1712131c | 37 | <h3>{ts}Summary{/ts}</h3> |
6ce08914 | 38 | <table class="report crm-entity case-summary" data-entity="case" data-id="{$caseID}" data-cid="{$contactID}"> |
6a488035 TO |
39 | {if $multiClient} |
40 | <tr class="crm-case-caseview-client"> | |
ad5d70b5 | 41 | <td colspan="5" class="label"> |
6a488035 TO |
42 | {ts}Clients:{/ts} |
43 | {foreach from=$caseRoles.client item=client name=clients} | |
44 | <a href="{crmURL p='civicrm/contact/view' q="action=view&reset=1&cid=`$client.contact_id`"}" title="{ts}view contact record{/ts}">{$client.display_name}</a>{if not $smarty.foreach.clients.last}, {/if} | |
45 | {/foreach} | |
ab99c7b3 | 46 | <a href="#" class="crm-hover-button" title="{ts}add new client to the case{/ts}" onclick="addClient( );return false;"> |
6a488035 TO |
47 | <span class="icon edit-icon"></span> |
48 | </a> | |
49 | {if $hasRelatedCases} | |
6ce08914 | 50 | <div class="crm-block relatedCases-link"><a class="crm-hover-button crm-popup medium-popup" href="{$relatedCaseUrl}">{$relatedCaseLabel}</a></div> |
6a488035 TO |
51 | {/if} |
52 | </td> | |
53 | </tr> | |
54 | {/if} | |
55 | <tr> | |
56 | {if not $multiClient} | |
57 | <td> | |
58 | <table class="form-layout-compressed"> | |
59 | {foreach from=$caseRoles.client item=client} | |
60 | <tr class="crm-case-caseview-display_name"> | |
61 | <td class="label-left bold" style="padding: 0px; border: none;">{$client.display_name}</td> | |
62 | </tr> | |
63 | {if $client.phone} | |
64 | <tr class="crm-case-caseview-phone"> | |
65 | <td class="label-left description" style="padding: 1px">{$client.phone}</td> | |
66 | </tr> | |
67 | {/if} | |
68 | {if $client.birth_date} | |
69 | <tr class="crm-case-caseview-birth_date"> | |
70 | <td class="label-left description" style="padding: 1px">{ts}DOB{/ts}: {$client.birth_date|crmDate}</td> | |
71 | </tr> | |
72 | {/if} | |
73 | {/foreach} | |
74 | </table> | |
75 | {if $hasRelatedCases} | |
6ce08914 | 76 | <div class="crm-block relatedCases-link"><a class="crm-hover-button crm-popup medium-popup" href="{$relatedCaseUrl}">{$relatedCaseLabel}</a></div> |
6a488035 TO |
77 | {/if} |
78 | </td> | |
79 | {/if} | |
0cc50002 | 80 | <td class="crm-case-caseview-case_subject label"> |
41f5e946 | 81 | <span class="crm-case-summary-label">{ts}Subject{/ts}:</span> {$caseDetails.case_subject} |
6a488035 TO |
82 | </td> |
83 | <td class="crm-case-caseview-case_type label"> | |
6ce08914 | 84 | <span class="crm-case-summary-label">{ts}Type{/ts}:</span> {$caseDetails.case_type} <a class="crm-hover-button crm-popup" href="{crmURL p='civicrm/case/activity' q="action=add&reset=1&cid=`$contactId`&caseid=`$caseId`&selectedChild=activity&atype=`$changeCaseTypeId`"}" title="{ts}Change case type (creates activity record){/ts}"><span class="icon edit-icon"></span></a> |
6a488035 TO |
85 | </td> |
86 | <td class="crm-case-caseview-case_status label"> | |
6ce08914 | 87 | <span class="crm-case-summary-label">{ts}Status{/ts}:</span> {$caseDetails.case_status} <a class="crm-hover-button crm-popup" href="{crmURL p='civicrm/case/activity' q="action=add&reset=1&cid=`$contactId`&caseid=`$caseId`&selectedChild=activity&atype=`$changeCaseStatusId`"}" title="{ts}Change case status (creates activity record){/ts}"><span class="icon edit-icon"></span></a> |
6a488035 TO |
88 | </td> |
89 | <td class="crm-case-caseview-case_start_date label"> | |
6ce08914 | 90 | <span class="crm-case-summary-label">{ts}Open Date{/ts}:</span> {$caseDetails.case_start_date|crmDate} <a class="crm-hover-button crm-popup" href="{crmURL p='civicrm/case/activity' q="action=add&reset=1&cid=`$contactId`&caseid=`$caseId`&selectedChild=activity&atype=`$changeCaseStartDateId`"}" title="{ts}Change case start date (creates activity record){/ts}"><span class="icon edit-icon"></span></a> |
6a488035 TO |
91 | </td> |
92 | <td class="crm-case-caseview-{$caseID} label"> | |
41f5e946 | 93 | <span class="crm-case-summary-label">{ts}ID{/ts}:</span> {$caseID} |
6a488035 TO |
94 | </td> |
95 | </tr> | |
96 | </table> | |
97 | {if $hookCaseSummary} | |
98 | <div id="caseSummary"> | |
99 | {foreach from=$hookCaseSummary item=val key=div_id} | |
100 | <div id="{$div_id}"><label>{$val.label}</label><div class="value">{$val.value}</div></div> | |
101 | {/foreach} | |
102 | </div> | |
103 | {/if} | |
104 | ||
105 | <table class="form-layout"> | |
106 | <tr class="crm-case-caseview-form-block-activity_type_id"> | |
5ffd5a35 | 107 | <td>{$form.add_activity_type_id.html}</td> |
6a488035 TO |
108 | {if $hasAccessToAllCases} |
109 | <td> | |
5ffd5a35 | 110 | <a class="button no-popup" href="{crmURL p='civicrm/case/report/print' q="all=1&redact=0&cid=$contactID&caseID=$caseId&asn=standard_timeline"}"><div class="icon print-icon"></div> {ts}Print Report{/ts}</a> |
6a488035 TO |
111 | </td> |
112 | </tr> | |
113 | <tr> | |
114 | <td class="crm-case-caseview-form-block-timeline_id">{$form.timeline_id.label}<br />{$form.timeline_id.html} {$form._qf_CaseView_next.html}</td> | |
115 | <td class="crm-case-caseview-form-block-report_id">{$form.report_id.label}<br />{$form.report_id.html} <input type="button" accesskey="R" value="Go" name="case_report" onclick="checkSelection( this );"/></td> | |
116 | {else} | |
117 | <td></td> | |
118 | {/if} | |
119 | </tr> | |
120 | ||
121 | {if $mergeCases} | |
122 | <tr class="crm-case-caseview-form-block-merge_case_id"> | |
123 | <td colspan='2'><a href="#" onClick='cj("#merge_cases").toggle( ); return false;'>{ts}Merge Case{/ts}</a> | |
124 | <span id='merge_cases' class='hide-block'> | |
125 | {$form.merge_case_id.html} {$form._qf_CaseView_next_merge_case.html} | |
126 | </span> | |
127 | </td> | |
128 | </tr> | |
129 | {/if} | |
130 | ||
131 | {if call_user_func(array('CRM_Core_Permission','giveMeAllACLs'))} | |
132 | <tr class="crm-case-caseview-form-block-change_client_id"> | |
66adc860 | 133 | <td colspan='2'> |
5ffd5a35 | 134 | <a class="crm-popup medium-popup" href="{crmURL p='civicrm/contact/view/case/editClient' h=0 q="reset=1&action=update&id=$caseID&cid=$contactID"}"><span class="icon swap-icon"></span> {ts}Assign to Another Contact{/ts}</a> |
6a488035 TO |
135 | </td> |
136 | </tr> | |
137 | {/if} | |
138 | </table> | |
139 | ||
6a488035 TO |
140 | <div class="clear"></div> |
141 | {include file="CRM/Case/Page/CustomDataView.tpl"} | |
142 | ||
143 | <div class="crm-accordion-wrapper collapsed crm-case-roles-block"> | |
144 | <div class="crm-accordion-header"> | |
1712131c | 145 | {ts}Roles{/ts} |
6a488035 TO |
146 | </div><!-- /.crm-accordion-header --> |
147 | <div class="crm-accordion-body"> | |
148 | ||
149 | {if $hasAccessToAllCases} | |
150 | <div class="crm-submit-buttons"> | |
151 | <a class="button" href="#" onclick="addRole();return false;"><span><div class="icon add-icon"></div>{ts}Add new role{/ts}</span></a> | |
152 | </div> | |
153 | {/if} | |
154 | ||
155 | <table id="caseRoles-selector" class="report-layout"> | |
156 | <thead><tr> | |
157 | <th>{ts}Case Role{/ts}</th> | |
158 | <th>{ts}Name{/ts}</th> | |
159 | <th>{ts}Phone{/ts}</th> | |
160 | <th>{ts}Email{/ts}</th> | |
161 | {if $relId neq 'client' and $hasAccessToAllCases} | |
162 | <th id="nosort">{ts}Actions{/ts}</th> | |
163 | {/if} | |
164 | </tr></thead> | |
165 | </table> | |
166 | ||
167 | {literal} | |
168 | <script type="text/javascript"> | |
169 | var oTable; | |
170 | ||
171 | cj(function() { | |
4cd35744 | 172 | cj().crmAccordions(); |
6a488035 TO |
173 | buildCaseRoles(false); |
174 | }); | |
175 | ||
4cd35744 KJ |
176 | function deleteCaseRoles(caseselector) { |
177 | cj('.case-role-delete').click(function(){ | |
178 | var caseID = cj(this).attr('case_id'); | |
179 | var relType = cj(this).attr('rel_type'); | |
180 | ||
181 | CRM.confirm(function() { | |
182 | var postUrl = {/literal}"{crmURL p='civicrm/ajax/delcaserole' h=0 }"{literal}; | |
183 | cj.post( postUrl, { | |
184 | rel_type: relType, case_id: caseID, key: {/literal}"{crmKey name='civicrm/ajax/delcaserole'}"{literal}}, | |
185 | function(data) { | |
186 | // reloading datatable | |
187 | var oTable = cj('#' + caseselector).dataTable(); | |
188 | oTable.fnDraw(); | |
189 | } | |
190 | ); | |
191 | } | |
192 | ,{ | |
faf07ee0 CW |
193 | title: '{/literal}{ts escape="js"}Delete case role{/ts}{literal}', |
194 | message: '{/literal}{ts escape="js"}Are you sure you want to delete this case role?{/ts}{literal}' | |
4cd35744 KJ |
195 | }); |
196 | return false; | |
197 | }); | |
198 | } | |
199 | ||
6a488035 TO |
200 | function buildCaseRoles(filterSearch) { |
201 | if(filterSearch) { | |
202 | oTable.fnDestroy(); | |
203 | } | |
204 | var count = 0; | |
205 | var columns = ''; | |
206 | var sourceUrl = {/literal}"{crmURL p='civicrm/ajax/caseroles' h=0 q='snippet=4&caseID='}{$caseID}"{literal}; | |
207 | sourceUrl = sourceUrl + '&cid={/literal}{$contactID}{literal}'; | |
208 | sourceUrl = sourceUrl + '&userID={/literal}{$userID}{literal}'; | |
209 | ||
210 | cj('#caseRoles-selector th').each( function( ) { | |
211 | if ( cj(this).attr('id') != 'nosort' ) { | |
212 | columns += '{"sClass": "' + cj(this).attr('class') +'"},'; | |
213 | } | |
214 | else { | |
215 | columns += '{ "bSortable": false },'; | |
216 | } | |
217 | count++; | |
218 | }); | |
219 | ||
220 | columns = columns.substring(0, columns.length - 1 ); | |
221 | eval('columns =[' + columns + ']'); | |
222 | ||
223 | oTable = cj('#caseRoles-selector').dataTable({ | |
224 | "bFilter" : false, | |
225 | "bAutoWidth" : false, | |
226 | "aaSorting" : [], | |
227 | "aoColumns" : columns, | |
228 | "bProcessing": true, | |
229 | "bJQueryUI": true, | |
230 | "asStripClasses" : [ "odd-row", "even-row" ], | |
231 | "sPaginationType": "full_numbers", | |
232 | "sDom" : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>', | |
233 | "bServerSide": true, | |
234 | "sAjaxSource": sourceUrl, | |
235 | "iDisplayLength": 10, | |
236 | "fnDrawCallback": function() { setCaseRolesSelectorClass(); }, | |
237 | "fnServerData": function ( sSource, aoData, fnCallback ) { | |
238 | cj.ajax({ | |
239 | "dataType": 'json', | |
240 | "type": "POST", | |
241 | "url": sSource, | |
242 | "data": aoData, | |
243 | "success": fnCallback | |
244 | }); | |
245 | } | |
246 | }); | |
247 | } | |
248 | ||
249 | function setCaseRolesSelectorClass( ) { | |
250 | cj("#caseRoles-selector td:last-child").each( function( ) { | |
251 | cj(this).parent().addClass(cj(this).text() ); | |
252 | }); | |
4cd35744 KJ |
253 | |
254 | // also bind delete action once rows are rendered | |
255 | deleteCaseRoles('caseRoles-selector'); | |
6a488035 TO |
256 | } |
257 | ||
6a488035 TO |
258 | </script> |
259 | {/literal} | |
260 | </div><!-- /.crm-accordion-body --> | |
261 | </div><!-- /.crm-accordion-wrapper --> | |
262 | <div id="dialog"> | |
263 | {ts}Begin typing last name of contact.{/ts}<br/> | |
264 | <input type="text" id="rel_contact"/> | |
265 | <input type="hidden" id="rel_contact_id" value=""> | |
266 | </div> | |
267 | ||
268 | {literal} | |
269 | <script type="text/javascript"> | |
6a488035 TO |
270 | |
271 | cj("#dialog").hide( ); | |
272 | ||
273 | function addClient( ) { | |
274 | cj("#dialog").show( ); | |
275 | ||
276 | cj("#dialog").dialog({ | |
c1c6e20c | 277 | title: "{/literal}{ts escape="js"}Add Client to the Case{/ts}{literal}", |
6a488035 | 278 | modal: true, |
6ce08914 CW |
279 | close : function(event, ui) { |
280 | cj("#rel_contact").unautocomplete( ); | |
281 | cj("#dialog").hide( ); | |
282 | }, | |
6a488035 TO |
283 | overlay: { opacity: 0.5, background: "black" }, |
284 | ||
285 | open:function() { | |
286 | var contactUrl = {/literal}"{crmURL p='civicrm/ajax/rest' q='className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=caseview' h=0 }"{literal}; | |
287 | cj("#rel_contact").autocomplete( contactUrl, { | |
288 | width: 260, | |
289 | selectFirst: false, | |
290 | matchContains: true | |
291 | }); | |
292 | ||
293 | cj("#rel_contact").focus(); | |
294 | cj("#rel_contact").result(function(event, data, formatted) { | |
295 | cj("input[id=rel_contact_id]").val(data[1]); | |
296 | }); | |
297 | }, | |
298 | ||
299 | buttons: { | |
6ce08914 | 300 | "{/literal}{ts escape='js'}Done{/ts}{literal}": function() { |
6a488035 TO |
301 | var postUrl = {/literal}"{crmURL p='civicrm/case/ajax/addclient' h=0 }"{literal}; |
302 | var caseID = {/literal}"{$caseID}"{literal}; | |
303 | var contactID = cj("#rel_contact_id").val( ); | |
304 | ||
305 | if ( !cj("#rel_contact").val( ) || !contactID ) { | |
c1c6e20c | 306 | cj("#rel_contact").crmError('{/literal}{ts escape="js"}Select valid contact from the list.{/ts}{literal}'); |
6a488035 TO |
307 | return false; |
308 | } | |
309 | cj.post( postUrl, {contactID: contactID,caseID: caseID, | |
310 | key: {/literal}"{crmKey name='civicrm/case/ajax/addclient'}"{literal} }, | |
311 | function( data ) { | |
b5547cb6 KJ |
312 | //due to caching issues we use redirection rather than reload |
313 | document.location = {/literal}'{crmURL q="action=view&reset=1&id=$caseID&cid=$contactID&context=$context" h=0 }'{literal}; | |
6a488035 TO |
314 | }, |
315 | 'json' | |
316 | ); | |
6a488035 TO |
317 | }, |
318 | ||
6ce08914 | 319 | "{/literal}{ts escape='js'}Cancel{/ts}{literal}": function() { |
6a488035 TO |
320 | cj(this).dialog("close"); |
321 | cj(this).dialog("destroy"); | |
322 | } | |
323 | } | |
324 | }); | |
325 | } | |
326 | ||
327 | function createRelationship( relType, contactID, relID, rowNumber, relTypeName ) { | |
328 | cj("#dialog").show( ); | |
329 | ||
330 | cj("#dialog").dialog({ | |
331 | title: "Assign Case Role", | |
332 | modal: true, | |
6a488035 | 333 | close: function(event, ui) { cj("#rel_contact").unautocomplete( ); }, |
6a488035 TO |
334 | open:function() { |
335 | /* set defaults if editing */ | |
336 | cj("#rel_contact").val(""); | |
337 | cj("#rel_contact_id").val(null); | |
338 | if (contactID) { | |
339 | cj("#rel_contact_id").val(contactID); | |
340 | var contactName = cj('#caseRoles-selector').find('tr :eq('+ rowNumber +')').children(':eq(1)').text(); | |
341 | cj("#rel_contact").val(contactName); | |
342 | } | |
343 | ||
344 | var contactUrl = {/literal}"{crmURL p='civicrm/ajax/rest' q='className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=caseview' h=0 }"{literal}; | |
345 | ||
346 | cj("#rel_contact").autocomplete( contactUrl, { | |
347 | width: 260, | |
348 | selectFirst: false, | |
349 | matchContains: true | |
350 | }); | |
351 | ||
352 | cj("#rel_contact").focus(); | |
353 | cj("#rel_contact").result(function(event, data, formatted) { | |
354 | cj("input[id=rel_contact_id]").val(data[1]); | |
355 | }); | |
356 | }, | |
357 | ||
358 | buttons: { | |
6ce08914 | 359 | "{/literal}{ts escape='js'}Ok{/ts}{literal}": function() { |
6a488035 TO |
360 | |
361 | var sourceContact = {/literal}"{$contactID}"{literal}; | |
362 | var caseID = {/literal}"{$caseID}"{literal}; | |
363 | ||
364 | var v1 = cj("#rel_contact_id").val( ); | |
365 | ||
366 | if ( !cj("#rel_contact").val( ) || !v1 ) { | |
367 | cj("#rel_contact").crmError('{/literal}{ts escape="js"}Select valid contact from the list{/ts}{literal}.'); | |
368 | return false; | |
369 | } | |
370 | ||
371 | var postUrl = {/literal}"{crmURL p='civicrm/ajax/relation' h=0 }"{literal}; | |
372 | cj.post( postUrl, { rel_contact: v1, rel_type: relType, contact_id: sourceContact, | |
373 | rel_id: relID, case_id: caseID, key: {/literal}"{crmKey name='civicrm/ajax/relation'}"{literal} }, | |
374 | function( data ) { | |
375 | if ( data.status == 'process-relationship-success' ) { | |
376 | // reloading datatable | |
377 | var oTable = cj('#caseRoles-selector').dataTable(); | |
378 | oTable.fnDraw(); | |
379 | } | |
380 | else { | |
1ec6f372 ML |
381 | // This is an awkward mix of smarty and javascript: the relTypeName variable is |
382 | // not available in smarty, could not find an i18n-correct way of doing this. | |
383 | {/literal} | |
384 | {capture assign=relTypeAdminLink}{crmURL p='civicrm/admin/reltype' q='reset=1' h=0 }{/capture} | |
385 | {literal} | |
386 | var errorMsg = relTypeName + ': ' + '{/literal}{ts escape="js" 1="$relTypeAdminLink"}The relationship type definition for the case role is not valid for the client and / or staff contact types. You can review and edit relationship types at <a href="%1">Administer >> Option Lists >> Relationship Types</a>.{/ts}{literal}'; | |
6a488035 TO |
387 | |
388 | //display error message. | |
389 | cj().crmError(errorMsg); | |
390 | } | |
391 | }, 'json' | |
392 | ); | |
393 | ||
394 | cj(this).dialog("close"); | |
395 | cj(this).dialog("destroy"); | |
396 | }, | |
397 | ||
6ce08914 | 398 | "{/literal}{ts escape='js'}Cancel{/ts}{literal}": function() { |
6a488035 TO |
399 | cj(this).dialog("close"); |
400 | cj(this).dialog("destroy"); | |
401 | } | |
402 | } | |
403 | }); | |
404 | } | |
405 | ||
6a488035 TO |
406 | </script> |
407 | {/literal} | |
408 | ||
409 | {if $hasAccessToAllCases} | |
410 | <div class="crm-accordion-wrapper collapsed crm-case-other-relationships-block"> | |
411 | <div class="crm-accordion-header"> | |
412 | {ts}Other Relationships{/ts} | |
413 | </div><!-- /.crm-accordion-header --> | |
414 | <div class="crm-accordion-body"> | |
5ffd5a35 | 415 | {capture assign=relUrl}{crmURL p='civicrm/contact/view/rel' q="action=add&reset=1&cid=`$contactId`&caseID=`$caseID`"}{/capture} |
6a488035 TO |
416 | {if $clientRelationships} |
417 | <div class="crm-submit-buttons"> | |
5ffd5a35 CW |
418 | <a class="button" href="{$relUrl}"> |
419 | <div class="icon add-icon"></div>{ts}Add client relationship{/ts}</a> | |
6a488035 TO |
420 | </div> |
421 | <table id="clientRelationships-selector" class="report-layout"> | |
422 | <thead><tr> | |
423 | <th>{ts}Client Relationship{/ts}</th> | |
424 | <th>{ts}Name{/ts}</th> | |
425 | <th>{ts}Phone{/ts}</th> | |
426 | <th>{ts}Email{/ts}</th> | |
427 | </tr></thead> | |
428 | </table> | |
429 | {else} | |
430 | <div class="messages status no-popup"> | |
431 | <div class="icon inform-icon"></div> | |
5ffd5a35 CW |
432 | {capture assign=link}class="action-item" href="{$relUrl}"{/capture} |
433 | {ts 1=$link}There are no Relationships entered for this client. You can <a %1>add one</a>.{/ts} | |
6a488035 TO |
434 | </div> |
435 | {/if} | |
436 | {literal} | |
437 | <script type="text/javascript"> | |
438 | cj(function( ) { | |
439 | buildCaseClientRelationships(false); | |
440 | }); | |
441 | ||
442 | function buildCaseClientRelationships(filterSearch) { | |
443 | if (filterSearch) { | |
444 | oTable.fnDestroy(); | |
445 | } | |
446 | var count = 0; | |
447 | var columns = ''; | |
448 | var sourceUrl = {/literal}"{crmURL p='civicrm/ajax/clientrelationships' h=0 q='snippet=4&caseID='}{$caseID}"{literal}; | |
449 | sourceUrl = sourceUrl + '&cid={/literal}{$contactID}{literal}'; | |
450 | sourceUrl = sourceUrl + '&userID={/literal}{$userID}{literal}'; | |
451 | ||
452 | cj('#clientRelationships-selector th').each( function( ) { | |
453 | if ( cj(this).attr('id') != 'nosort' ) { | |
454 | columns += '{"sClass": "' + cj(this).attr('class') +'"},'; | |
455 | } | |
456 | else { | |
457 | columns += '{ "bSortable": false },'; | |
458 | } | |
459 | count++; | |
460 | }); | |
461 | ||
462 | columns = columns.substring(0, columns.length - 1 ); | |
463 | eval('columns =[' + columns + ']'); | |
464 | ||
465 | oTable = cj('#clientRelationships-selector').dataTable({ | |
466 | "bFilter" : false, | |
467 | "bAutoWidth" : false, | |
468 | "aaSorting" : [], | |
469 | "aoColumns" : columns, | |
470 | "bProcessing": true, | |
471 | "bJQueryUI": true, | |
472 | "asStripClasses" : [ "odd-row", "even-row" ], | |
473 | "sPaginationType": "full_numbers", | |
474 | "sDom" : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>', | |
475 | "bServerSide": true, | |
476 | "sAjaxSource": sourceUrl, | |
477 | "iDisplayLength": 10, | |
478 | "fnDrawCallback": function() { setClientRelationshipsSelectorClass(); }, | |
479 | "fnServerData": function (sSource, aoData, fnCallback) { | |
480 | cj.ajax( { | |
481 | "dataType": 'json', | |
482 | "type": "POST", | |
483 | "url": sSource, | |
484 | "data": aoData, | |
485 | "success": fnCallback | |
486 | } ); | |
487 | } | |
488 | }); | |
489 | } | |
490 | ||
491 | function setClientRelationshipsSelectorClass( ) { | |
492 | cj("#clientRelationships-selector td:last-child").each(function() { | |
493 | cj(this).parent().addClass(cj(this).text()); | |
494 | }); | |
495 | } | |
496 | </script> | |
497 | {/literal} | |
498 | <br /> | |
499 | ||
500 | {if $globalRelationships} | |
501 | <div class="crm-submit-buttons"> | |
502 | <a class="button" href="#" onClick="window.location='{crmURL p='civicrm/group/search' q="reset=1&context=amtg&amtgID=`$globalGroupInfo.id`"}'; return false;"> | |
503 | <span><div class="icon add-icon"></div>{ts 1=$globalGroupInfo.title}Add members to %1{/ts}</a></span> | |
504 | </div> | |
505 | <table id="globalRelationships-selector" class="report-layout"> | |
506 | <thead><tr> | |
507 | <th>{$globalGroupInfo.title}</th> | |
508 | <th>{ts}Phone{/ts}</th> | |
509 | <th>{ts}Email{/ts}</th> | |
510 | </tr></thead> | |
511 | </table> | |
512 | {elseif $globalGroupInfo.id} | |
513 | <div class="messages status no-popup"> | |
514 | <div class="icon inform-icon"></div> | |
515 | {capture assign=crmURL}{crmURL p='civicrm/group/search' q="reset=1&context=amtg&amtgID=`$globalGroupInfo.id`"}{/capture} | |
516 | {ts 1=$crmURL 2=$globalGroupInfo.title}The group %2 has no members. You can <a href='%1'>add one</a>.{/ts} | |
517 | </div> | |
518 | {/if} | |
519 | ||
520 | {literal} | |
521 | <script type="text/javascript"> | |
522 | ||
523 | cj(function() { | |
524 | buildCaseGlobalRelationships(false); | |
525 | }); | |
526 | ||
527 | function buildCaseGlobalRelationships(filterSearch) { | |
528 | if (filterSearch) { | |
529 | oTable.fnDestroy(); | |
530 | } | |
531 | var count = 0; | |
532 | var columns = ''; | |
533 | var sourceUrl = {/literal}"{crmURL p='civicrm/ajax/globalrelationships' h=0 q='snippet=4&caseID='}{$caseID}"{literal}; | |
534 | sourceUrl = sourceUrl + '&cid={/literal}{$contactID}{literal}'; | |
535 | sourceUrl = sourceUrl + '&userID={/literal}{$userID}{literal}'; | |
536 | ||
537 | cj('#globalRelationships-selector th').each( function( ) { | |
538 | if (cj(this).attr('id') != 'nosort') { | |
539 | columns += '{"sClass": "' + cj(this).attr('class') +'"},'; | |
540 | } | |
541 | else { | |
542 | columns += '{ "bSortable": false },'; | |
543 | } | |
544 | count++; | |
545 | }); | |
546 | ||
547 | columns = columns.substring(0, columns.length - 1 ); | |
548 | eval('columns =[' + columns + ']'); | |
549 | ||
550 | oTable = cj('#globalRelationships-selector').dataTable({ | |
551 | "bFilter" : false, | |
552 | "bAutoWidth" : false, | |
553 | "aaSorting" : [], | |
554 | "aoColumns" : columns, | |
555 | "bProcessing": true, | |
556 | "bJQueryUI": true, | |
557 | "asStripClasses" : [ "odd-row", "even-row" ], | |
558 | "sPaginationType": "full_numbers", | |
559 | "sDom" : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>', | |
560 | "bServerSide": true, | |
561 | "sAjaxSource": sourceUrl, | |
562 | "iDisplayLength": 10, | |
563 | "fnDrawCallback": function() { setGlobalRelationshipsSelectorClass(); }, | |
564 | "fnServerData": function ( sSource, aoData, fnCallback ) { | |
565 | cj.ajax( { | |
566 | "dataType": 'json', | |
567 | "type": "POST", | |
568 | "url": sSource, | |
569 | "data": aoData, | |
570 | "success": fnCallback | |
571 | } ); | |
572 | } | |
573 | }); | |
574 | } | |
575 | ||
576 | function setGlobalRelationshipsSelectorClass( ) { | |
577 | cj("#globalRelationships-selector td:last-child").each( function( ) { | |
578 | cj(this).parent().addClass(cj(this).text() ); | |
579 | }); | |
580 | } | |
581 | </script> | |
582 | {/literal} | |
583 | </div><!-- /.crm-accordion-body --> | |
584 | </div><!-- /.crm-accordion-wrapper --> | |
585 | ||
586 | {/if} {* other relationship section ends *} | |
587 | ||
588 | <div id="addRoleDialog"> | |
589 | {$form.role_type.label}<br /> | |
590 | {$form.role_type.html} | |
591 | <br /><br /> | |
592 | {ts}Begin typing last name of contact.{/ts}<br/> | |
593 | <input type="text" id="role_contact"/> | |
594 | <input type="hidden" id="role_contact_id" value=""> | |
595 | </div> | |
596 | ||
597 | {literal} | |
598 | <script type="text/javascript"> | |
599 | ||
600 | cj("#addRoleDialog").hide( ); | |
601 | function addRole() { | |
602 | cj("#addRoleDialog").show( ); | |
603 | ||
604 | cj("#addRoleDialog").dialog({ | |
605 | title: "Add Role", | |
606 | modal: true, | |
6a488035 | 607 | close: function(event, ui) { cj("#role_contact").unautocomplete( ); }, |
6a488035 TO |
608 | open:function() { |
609 | /* set defaults if editing */ | |
610 | cj("#role_contact").val( "" ); | |
611 | cj("#role_contact_id").val( null ); | |
612 | ||
613 | var contactUrl = {/literal}"{crmURL p='civicrm/ajax/rest' q='className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=caseview' h=0 }"{literal}; | |
614 | ||
615 | cj("#role_contact").autocomplete( contactUrl, { | |
616 | width: 260, | |
617 | selectFirst: false, | |
618 | matchContains: true | |
619 | }); | |
620 | ||
621 | cj("#role_contact").focus(); | |
622 | cj("#role_contact").result(function(event, data, formatted) { | |
623 | cj("input[id=role_contact_id]").val(data[1]); | |
624 | }); | |
625 | }, | |
626 | ||
627 | buttons: { | |
6ce08914 | 628 | "{/literal}{ts escape='js'}Ok{/ts}{literal}": function() { |
6a488035 TO |
629 | var sourceContact = {/literal}"{$contactID}"{literal}; |
630 | var caseID = {/literal}"{$caseID}"{literal}; | |
631 | var relID = null; | |
632 | ||
633 | var v2 = cj("#role_type").val(); | |
634 | if (!v2) { | |
635 | cj("#role_type").crmError('{/literal}{ts escape="js"}Select valid type from the list{/ts}{literal}.'); | |
636 | return false; | |
637 | } | |
638 | ||
639 | var v1 = cj("#role_contact_id").val( ); | |
640 | if (!cj("#role_contact").val( ) || !v1) { | |
641 | cj("#role_contact").crmError('{/literal}{ts escape="js"}Select valid contact from the list{/ts}{literal}.'); | |
642 | return false; | |
643 | } | |
644 | ||
645 | /* send synchronous request so that disabling any actions for slow servers*/ | |
646 | var postUrl = {/literal}"{crmURL p='civicrm/ajax/relation' h=0 }"{literal}; | |
647 | var data = 'rel_contact='+ v1 + '&rel_type='+ v2 + '&contact_id='+sourceContact + '&rel_id='+ relID | |
648 | + '&case_id=' + caseID + "&key={/literal}{crmKey name='civicrm/ajax/relation'}{literal}"; | |
649 | cj.ajax({ | |
650 | type : "POST", | |
651 | url : postUrl, | |
652 | data : data, | |
653 | async : false, | |
654 | dataType : "json", | |
655 | success : function(values) { | |
656 | if (values.status == 'process-relationship-success') { | |
657 | // reloading datatable | |
658 | var oTable = cj('#caseRoles-selector').dataTable(); | |
659 | oTable.fnDraw(); | |
660 | } | |
661 | else { | |
662 | var relTypeName = cj("#role_type :selected").text(); | |
663 | var relTypeAdminLink = {/literal}"{crmURL p='civicrm/admin/reltype' q='reset=1' h=0 }"{literal}; | |
664 | var errorMsg = '{/literal}{ts escape="js" 1="' + relTypeName + '" 2="' + relTypeAdminLink + '"}The relationship type definition for the %1 case role is not valid for the client and / or staff contact types. You can review and edit relationship types at <a href="%2">Administer >> Option Lists >> Relationship Types</a>{/ts}{literal}.'; | |
665 | ||
666 | //display error message. | |
667 | cj().crmError(errorMsg); | |
668 | } | |
669 | } | |
670 | }); | |
671 | ||
672 | cj(this).dialog("close"); | |
673 | cj(this).dialog("destroy"); | |
674 | }, | |
675 | ||
6ce08914 | 676 | "{/literal}{ts escape='js'}Cancel{/ts}{literal}": function() { |
6a488035 TO |
677 | cj(this).dialog("close"); |
678 | cj(this).dialog("destroy"); | |
679 | } | |
680 | } | |
681 | }); | |
682 | } | |
683 | ||
684 | </script> | |
685 | {/literal} | |
686 | {include file="CRM/Case/Form/ActivityToCase.tpl"} | |
6a488035 TO |
687 | |
688 | {* pane to display / edit regular tags or tagsets for cases *} | |
689 | {if $showTags OR $showTagsets} | |
690 | ||
691 | <div id="casetags" class="crm-accordion-wrapper crm-case-tags-block"> | |
692 | <div class="crm-accordion-header"> | |
693 | {ts}Case Tags{/ts} | |
694 | </div><!-- /.crm-accordion-header --> | |
695 | <div class="crm-accordion-body"> | |
696 | {assign var="tagExits" value=0} | |
697 | {if $tags} | |
6fd5424b | 698 | <div class="crm-block crm-content-block crm-case-caseview-display-tags"> {$tags}</div> |
6a488035 TO |
699 | {assign var="tagExits" value=1} |
700 | {/if} | |
701 | ||
702 | {foreach from=$tagsetInfo_case item=displayTagset} | |
703 | {if $displayTagset.entityTagsArray} | |
704 | <div class="crm-block crm-content-block crm-case-caseview-display-tagset"> | |
705 | {$displayTagset.parentName}: | |
706 | {foreach from=$displayTagset.entityTagsArray item=val name="tagsetList"} | |
707 | {$val.name}{if !$smarty.foreach.tagsetList.last},{/if} | |
708 | {/foreach} | |
709 | </div> | |
710 | {assign var="tagExits" value=1} | |
711 | {/if} | |
712 | {/foreach} | |
713 | ||
714 | {if !$tagExits } | |
715 | <div class="status"> | |
716 | {ts}There are no tags currently assigned to this case.{/ts} | |
717 | </div> | |
718 | {/if} | |
719 | ||
6ce08914 CW |
720 | <div class="crm-submit-buttons"> |
721 | <a class="button case-miniform" href="#manageTags" data-qfkey="{crmKey name='civicrm/case/ajax/processtags'}">{if $tagExits}{ts}Edit Tags{/ts}{else}{ts}Add Tags{/ts}{/if}</a> | |
722 | </div> | |
6a488035 TO |
723 | |
724 | </div><!-- /.crm-accordion-body --> | |
725 | </div><!-- /.crm-accordion-wrapper --> | |
726 | ||
727 | <div id="manageTags"> | |
728 | <div class="label">{$form.case_tag.label}</div> | |
729 | <div class="view-value"><div class="crm-select-container">{$form.case_tag.html}</div> | |
730 | <br/> | |
731 | <div style="text-align:left;">{include file="CRM/common/Tag.tpl" tagsetType='case'}</div> | |
732 | <br/> | |
733 | <div class="clear"></div> | |
734 | </div> | |
735 | </div> | |
736 | ||
6a488035 TO |
737 | {/if} {* end of tag block*} |
738 | ||
6a488035 TO |
739 | <div class="crm-accordion-wrapper crm-case_activities-accordion crm-case-activities-block"> |
740 | <div class="crm-accordion-header"> | |
1712131c | 741 | {ts}Activities{/ts} |
6a488035 TO |
742 | </div> |
743 | <div id="activities" class="crm-accordion-body"> | |
6a488035 TO |
744 | <div class="crm-accordion-wrapper crm-accordion-inner crm-search_filters-accordion collapsed"> |
745 | <div class="crm-accordion-header"> | |
746 | {ts}Search Filters{/ts}</a> | |
747 | </div><!-- /.crm-accordion-header --> | |
748 | <div class="crm-accordion-body"> | |
749 | <table class="no-border form-layout-compressed" id="searchOptions"> | |
750 | <tr> | |
751 | <td class="crm-case-caseview-form-block-repoter_id"colspan="2"><label for="reporter_id">{ts}Reporter/Role{/ts}</label><br /> | |
752 | {$form.reporter_id.html|crmAddClass:twenty} | |
753 | </td> | |
754 | <td class="crm-case-caseview-form-block-status_id"><label for="status_id">{$form.status_id.label}</label><br /> | |
755 | {$form.status_id.html} | |
756 | </td> | |
757 | <td style="vertical-align: bottom;"> | |
758 | <span class="crm-button"><input class="form-submit default" name="_qf_Basic_refresh" value="Search" type="button" onclick="buildCaseActivities( true )"; /></span> | |
759 | </td> | |
760 | </tr> | |
761 | <tr> | |
762 | <td class="crm-case-caseview-form-block-activity_date_low"> | |
763 | {$form.activity_date_low.label}<br /> | |
764 | {include file="CRM/common/jcalendar.tpl" elementName=activity_date_low} | |
765 | </td> | |
766 | <td class="crm-case-caseview-form-block-activity_date_high"> | |
767 | {$form.activity_date_high.label}<br /> | |
768 | {include file="CRM/common/jcalendar.tpl" elementName=activity_date_high} | |
769 | </td> | |
770 | <td class="crm-case-caseview-form-block-activity_type_filter_id"> | |
771 | {$form.activity_type_filter_id.label}<br /> | |
772 | {$form.activity_type_filter_id.html} | |
773 | </td> | |
774 | </tr> | |
775 | {if $form.activity_deleted} | |
776 | <tr class="crm-case-caseview-form-block-activity_deleted"> | |
777 | <td> | |
778 | {$form.activity_deleted.html}{$form.activity_deleted.label} | |
779 | </td> | |
780 | </tr> | |
781 | {/if} | |
782 | </table> | |
783 | </div><!-- /.crm-accordion-body --> | |
784 | </div><!-- /.crm-accordion-wrapper --> | |
785 | ||
786 | <table id="activities-selector" class="nestedActivitySelector"> | |
787 | <thead><tr> | |
788 | <th class='crm-case-activities-date'>{ts}Date{/ts}</th> | |
789 | <th class='crm-case-activities-subject'>{ts}Subject{/ts}</th> | |
790 | <th class='crm-case-activities-type'>{ts}Type{/ts}</th> | |
791 | <th class='crm-case-activities-with'>{ts}With{/ts}</th> | |
792 | <th class='crm-case-activities-assignee'>{ts}Reporter / Assignee{/ts}</th> | |
793 | <th class='crm-case-activities-status'>{ts}Status{/ts}</th> | |
794 | <th class='crm-case-activities-status' id="nosort"> </th> | |
795 | <th class='hiddenElement'> </th> | |
796 | </tr></thead> | |
797 | </table> | |
798 | ||
799 | </div><!-- /.crm-accordion-body --> | |
800 | </div><!-- /.crm-accordion-wrapper --> | |
801 | ||
802 | {literal} | |
803 | <script type="text/javascript"> | |
804 | var oTable; | |
805 | ||
806 | function checkSelection( field ) { | |
807 | var validationMessage = ''; | |
808 | var validationField = ''; | |
809 | var successAction = ''; | |
810 | var forceValidation = false; | |
811 | ||
6a488035 TO |
812 | var fName = field.name; |
813 | ||
814 | switch ( fName ) { | |
815 | case '_qf_CaseView_next' : | |
816 | validationMessage = '{/literal}{ts escape="js"}Please select an activity set from the list.{/ts}{literal}'; | |
817 | validationField = 'timeline_id'; | |
818 | successAction = "confirm('{/literal}{ts escape='js'}Are you sure you want to add a set of scheduled activities to this case?{/ts}{literal}');"; | |
819 | break; | |
820 | ||
6a488035 TO |
821 | case 'case_report' : |
822 | validationMessage = '{/literal}{ts escape="js"}Please select a report from the list.{/ts}{literal}'; | |
823 | validationField = 'report_id'; | |
824 | successAction = "window.location='{/literal}{$reportUrl}{literal}' + document.getElementById('report_id').value"; | |
825 | break; | |
826 | ||
827 | case '_qf_CaseView_next_merge_case' : | |
828 | validationMessage = '{/literal}{ts escape="js"}Please select a case from the list to merge with.{/ts}{literal}'; | |
829 | validationField = 'merge_case_id'; | |
830 | break; | |
6a488035 | 831 | } |
6a488035 TO |
832 | if ( forceValidation || ( document.getElementById( validationField ).value == '' ) ) { |
833 | cj('#'+validationField).crmError(validationMessage); | |
834 | return false; | |
835 | } | |
836 | else if ( successAction ) { | |
837 | return eval( successAction ); | |
838 | } | |
839 | } | |
840 | ||
841 | cj(function( ) { | |
842 | buildCaseActivities(false); | |
843 | }); | |
844 | ||
845 | function buildCaseActivities(filterSearch) { | |
846 | if (filterSearch) { | |
847 | oTable.fnDestroy(); | |
848 | } | |
849 | var count = 0; | |
850 | var columns = ''; | |
851 | var sourceUrl = {/literal}"{crmURL p='civicrm/ajax/activity' h=0 q='snippet=4&caseID='}{$caseID}"{literal}; | |
852 | sourceUrl = sourceUrl + '&cid={/literal}{$contactID}{literal}'; | |
853 | sourceUrl = sourceUrl + '&userID={/literal}{$userID}{literal}'; | |
854 | ||
855 | cj('#activities-selector th').each(function( ) { | |
856 | if (cj(this).attr('id') != 'nosort') { | |
857 | columns += '{"sClass": "' + cj(this).attr('class') +'"},'; | |
858 | } | |
859 | else { | |
860 | columns += '{ "bSortable": false },'; | |
861 | } | |
862 | count++; | |
863 | }); | |
864 | ||
865 | columns = columns.substring(0, columns.length - 1 ); | |
866 | eval('columns =[' + columns + ']'); | |
867 | ||
868 | oTable = cj('#activities-selector').dataTable({ | |
869 | "bFilter" : false, | |
870 | "bAutoWidth" : false, | |
871 | "aaSorting" : [], | |
872 | "aoColumns" : columns, | |
873 | "bProcessing": true, | |
874 | "bJQueryUI": true, | |
875 | "asStripClasses" : [ "odd-row", "even-row" ], | |
876 | "sPaginationType": "full_numbers", | |
877 | "sDom" : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>', | |
878 | "bServerSide": true, | |
879 | "sAjaxSource": sourceUrl, | |
880 | "iDisplayLength": 10, | |
881 | "fnDrawCallback": function() { setSelectorClass(); }, | |
882 | "fnServerData": function ( sSource, aoData, fnCallback ) { | |
883 | ||
884 | if ( filterSearch ) { | |
885 | var activity_deleted = 0; | |
886 | if ( cj("#activity_deleted:checked").val() == 1 ) { | |
887 | activity_deleted = 1; | |
888 | } | |
889 | aoData.push( | |
890 | {name:'status_id', value: cj("select#status_id").val()}, | |
891 | {name:'activity_type_id', value: cj("select#activity_type_filter_id").val()}, | |
892 | {name:'activity_date_low', value: cj("#activity_date_low").val()}, | |
893 | {name:'activity_date_high', value: cj("#activity_date_high").val() }, | |
894 | {name:'activity_deleted', value: activity_deleted } | |
895 | ); | |
896 | } | |
897 | cj.ajax( { | |
898 | "dataType": 'json', | |
899 | "type": "POST", | |
900 | "url": sSource, | |
901 | "data": aoData, | |
902 | "success": fnCallback | |
903 | } ); | |
904 | } | |
905 | }); | |
906 | } | |
907 | ||
908 | function setSelectorClass( ) { | |
909 | cj("#activities-selector td:last-child").each( function( ) { | |
910 | cj(this).parent().addClass(cj(this).text() ); | |
911 | }); | |
912 | } | |
913 | ||
6a488035 TO |
914 | </script> |
915 | {/literal} | |
916 | ||
917 | <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div> | |
918 | ||
919 | {literal} | |
920 | <script type="text/javascript"> | |
921 | cj(function() { | |
922 | cj().crmAccordions(); | |
923 | }); | |
924 | </script> | |
925 | {/literal} | |
926 | ||
5ffd5a35 | 927 | {include file="CRM/Case/Form/ActivityChangeStatusJs.tpl"} |
6a488035 TO |
928 | {/if} {* view related cases if end *} |
929 | </div> | |
21d5ed51 | 930 |