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