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