Merge pull request #2033 from JoeMurray/master
[civicrm-core.git] / templates / CRM / Case / Form / CaseView.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.4 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2013 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
8 | |
9 | CiviCRM is free software; you can copy, modify, and distribute it |
10 | under the terms of the GNU Affero General Public License |
11 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
12 | |
13 | CiviCRM is distributed in the hope that it will be useful, but |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16 | See the GNU Affero General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU Affero General Public |
19 | License and the CiviCRM Licensing Exception along |
20 | with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
25 *}
26 {* 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}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}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}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}Open 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}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 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 Contact{/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}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 // This is an awkward mix of smarty and javascript: the relTypeName variable is
419 // not available in smarty, could not find an i18n-correct way of doing this.
420 {/literal}
421 {capture assign=relTypeAdminLink}{crmURL p='civicrm/admin/reltype' q='reset=1' h=0 }{/capture}
422 {literal}
423 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}';
424
425 //display error message.
426 cj().crmError(errorMsg);
427 }
428 }, 'json'
429 );
430
431 cj(this).dialog("close");
432 cj(this).dialog("destroy");
433 },
434
435 "Cancel": function() {
436 cj(this).dialog("close");
437 cj(this).dialog("destroy");
438 }
439 }
440 });
441 }
442
443 function viewRelatedCases( mainCaseID, contactID ) {
444 cj("#view-related-cases").show( );
445 cj("#view-related-cases").dialog({
446 title: "Related Cases",
447 modal: true,
448 width : "680px",
449 height: 'auto',
450 resizable: true,
451 bgiframe: true,
452 overlay: {
453 opacity: 0.5,
454 background: "black"
455 },
456
457 beforeclose: function(event, ui) {
458 cj(this).dialog("destroy");
459 },
460
461 open:function() {
462 var dataUrl = {/literal}"{crmURL p='civicrm/contact/view/case' h=0 q="snippet=4" }"{literal};
463 dataUrl = dataUrl + '&id=' + mainCaseID + '&cid=' +contactID + '&relatedCases=true&action=view&context=case&selectedChild=case';
464
465 cj.ajax({
466 url : dataUrl,
467 async : false,
468 success : function(html){
469 cj("#related-cases-content" ).html( html );
470 }
471 });
472 },
473
474 buttons: {
475 "Done": function() {
476 cj(this).dialog("close");
477 cj(this).dialog("destroy");
478 }
479 }
480 });
481 }
482
483 cj(function(){
484 cj("#view-activity").hide( );
485 });
486 </script>
487 {/literal}
488
489 {if $hasAccessToAllCases}
490 <div class="crm-accordion-wrapper collapsed crm-case-other-relationships-block">
491 <div class="crm-accordion-header">
492 {ts}Other Relationships{/ts}
493 </div><!-- /.crm-accordion-header -->
494 <div class="crm-accordion-body">
495
496 {if $clientRelationships}
497 <div class="crm-submit-buttons">
498 <a class="button" href="#" onClick="window.location='{crmURL p='civicrm/contact/view/rel' q="action=add&reset=1&cid=`$contactId`&caseID=`$caseID`"}'; return false;">
499 <span><div class="icon add-icon"></div>{ts}Add client relationship{/ts}</a></span>
500 </div>
501 <table id="clientRelationships-selector" class="report-layout">
502 <thead><tr>
503 <th>{ts}Client Relationship{/ts}</th>
504 <th>{ts}Name{/ts}</th>
505 <th>{ts}Phone{/ts}</th>
506 <th>{ts}Email{/ts}</th>
507 </tr></thead>
508 </table>
509 {else}
510 <div class="messages status no-popup">
511 <div class="icon inform-icon"></div>
512 {capture assign=crmURL}{crmURL p='civicrm/contact/view/rel' q="action=add&reset=1&cid=`$contactId`&caseID=`$caseID`"}{/capture}
513 {ts 1=$crmURL}There are no Relationships entered for this client. You can <a accesskey="N" href='%1'>add one</a>.{/ts}
514 </div>
515 {/if}
516 {literal}
517 <script type="text/javascript">
518 cj(function( ) {
519 buildCaseClientRelationships(false);
520 });
521
522 function buildCaseClientRelationships(filterSearch) {
523 if (filterSearch) {
524 oTable.fnDestroy();
525 }
526 var count = 0;
527 var columns = '';
528 var sourceUrl = {/literal}"{crmURL p='civicrm/ajax/clientrelationships' h=0 q='snippet=4&caseID='}{$caseID}"{literal};
529 sourceUrl = sourceUrl + '&cid={/literal}{$contactID}{literal}';
530 sourceUrl = sourceUrl + '&userID={/literal}{$userID}{literal}';
531
532 cj('#clientRelationships-selector th').each( function( ) {
533 if ( cj(this).attr('id') != 'nosort' ) {
534 columns += '{"sClass": "' + cj(this).attr('class') +'"},';
535 }
536 else {
537 columns += '{ "bSortable": false },';
538 }
539 count++;
540 });
541
542 columns = columns.substring(0, columns.length - 1 );
543 eval('columns =[' + columns + ']');
544
545 oTable = cj('#clientRelationships-selector').dataTable({
546 "bFilter" : false,
547 "bAutoWidth" : false,
548 "aaSorting" : [],
549 "aoColumns" : columns,
550 "bProcessing": true,
551 "bJQueryUI": true,
552 "asStripClasses" : [ "odd-row", "even-row" ],
553 "sPaginationType": "full_numbers",
554 "sDom" : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
555 "bServerSide": true,
556 "sAjaxSource": sourceUrl,
557 "iDisplayLength": 10,
558 "fnDrawCallback": function() { setClientRelationshipsSelectorClass(); },
559 "fnServerData": function (sSource, aoData, fnCallback) {
560 cj.ajax( {
561 "dataType": 'json',
562 "type": "POST",
563 "url": sSource,
564 "data": aoData,
565 "success": fnCallback
566 } );
567 }
568 });
569 }
570
571 function setClientRelationshipsSelectorClass( ) {
572 cj("#clientRelationships-selector td:last-child").each(function() {
573 cj(this).parent().addClass(cj(this).text());
574 });
575 }
576 </script>
577 {/literal}
578 <br />
579
580 {if $globalRelationships}
581 <div class="crm-submit-buttons">
582 <a class="button" href="#" onClick="window.location='{crmURL p='civicrm/group/search' q="reset=1&context=amtg&amtgID=`$globalGroupInfo.id`"}'; return false;">
583 <span><div class="icon add-icon"></div>{ts 1=$globalGroupInfo.title}Add members to %1{/ts}</a></span>
584 </div>
585 <table id="globalRelationships-selector" class="report-layout">
586 <thead><tr>
587 <th>{$globalGroupInfo.title}</th>
588 <th>{ts}Phone{/ts}</th>
589 <th>{ts}Email{/ts}</th>
590 </tr></thead>
591 </table>
592 {elseif $globalGroupInfo.id}
593 <div class="messages status no-popup">
594 <div class="icon inform-icon"></div>&nbsp;
595 {capture assign=crmURL}{crmURL p='civicrm/group/search' q="reset=1&context=amtg&amtgID=`$globalGroupInfo.id`"}{/capture}
596 {ts 1=$crmURL 2=$globalGroupInfo.title}The group %2 has no members. You can <a href='%1'>add one</a>.{/ts}
597 </div>
598 {/if}
599
600 {literal}
601 <script type="text/javascript">
602
603 cj(function() {
604 buildCaseGlobalRelationships(false);
605 });
606
607 function buildCaseGlobalRelationships(filterSearch) {
608 if (filterSearch) {
609 oTable.fnDestroy();
610 }
611 var count = 0;
612 var columns = '';
613 var sourceUrl = {/literal}"{crmURL p='civicrm/ajax/globalrelationships' h=0 q='snippet=4&caseID='}{$caseID}"{literal};
614 sourceUrl = sourceUrl + '&cid={/literal}{$contactID}{literal}';
615 sourceUrl = sourceUrl + '&userID={/literal}{$userID}{literal}';
616
617 cj('#globalRelationships-selector th').each( function( ) {
618 if (cj(this).attr('id') != 'nosort') {
619 columns += '{"sClass": "' + cj(this).attr('class') +'"},';
620 }
621 else {
622 columns += '{ "bSortable": false },';
623 }
624 count++;
625 });
626
627 columns = columns.substring(0, columns.length - 1 );
628 eval('columns =[' + columns + ']');
629
630 oTable = cj('#globalRelationships-selector').dataTable({
631 "bFilter" : false,
632 "bAutoWidth" : false,
633 "aaSorting" : [],
634 "aoColumns" : columns,
635 "bProcessing": true,
636 "bJQueryUI": true,
637 "asStripClasses" : [ "odd-row", "even-row" ],
638 "sPaginationType": "full_numbers",
639 "sDom" : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
640 "bServerSide": true,
641 "sAjaxSource": sourceUrl,
642 "iDisplayLength": 10,
643 "fnDrawCallback": function() { setGlobalRelationshipsSelectorClass(); },
644 "fnServerData": function ( sSource, aoData, fnCallback ) {
645 cj.ajax( {
646 "dataType": 'json',
647 "type": "POST",
648 "url": sSource,
649 "data": aoData,
650 "success": fnCallback
651 } );
652 }
653 });
654 }
655
656 function setGlobalRelationshipsSelectorClass( ) {
657 cj("#globalRelationships-selector td:last-child").each( function( ) {
658 cj(this).parent().addClass(cj(this).text() );
659 });
660 }
661 </script>
662 {/literal}
663 </div><!-- /.crm-accordion-body -->
664 </div><!-- /.crm-accordion-wrapper -->
665
666 {/if} {* other relationship section ends *}
667
668 <div id="addRoleDialog">
669 {$form.role_type.label}<br />
670 {$form.role_type.html}
671 <br /><br />
672 {ts}Begin typing last name of contact.{/ts}<br/>
673 <input type="text" id="role_contact"/>
674 <input type="hidden" id="role_contact_id" value="">
675 </div>
676
677 {literal}
678 <script type="text/javascript">
679
680 cj("#addRoleDialog").hide( );
681 function addRole() {
682 cj("#addRoleDialog").show( );
683
684 cj("#addRoleDialog").dialog({
685 title: "Add Role",
686 modal: true,
687 bgiframe: true,
688 close: function(event, ui) { cj("#role_contact").unautocomplete( ); },
689 overlay: {
690 opacity: 0.5,
691 background: "black"
692 },
693
694 open:function() {
695 /* set defaults if editing */
696 cj("#role_contact").val( "" );
697 cj("#role_contact_id").val( null );
698
699 var contactUrl = {/literal}"{crmURL p='civicrm/ajax/rest' q='className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=caseview' h=0 }"{literal};
700
701 cj("#role_contact").autocomplete( contactUrl, {
702 width: 260,
703 selectFirst: false,
704 matchContains: true
705 });
706
707 cj("#role_contact").focus();
708 cj("#role_contact").result(function(event, data, formatted) {
709 cj("input[id=role_contact_id]").val(data[1]);
710 });
711 },
712
713 buttons: {
714 "Ok": function() {
715 var sourceContact = {/literal}"{$contactID}"{literal};
716 var caseID = {/literal}"{$caseID}"{literal};
717 var relID = null;
718
719 var v2 = cj("#role_type").val();
720 if (!v2) {
721 cj("#role_type").crmError('{/literal}{ts escape="js"}Select valid type from the list{/ts}{literal}.');
722 return false;
723 }
724
725 var v1 = cj("#role_contact_id").val( );
726 if (!cj("#role_contact").val( ) || !v1) {
727 cj("#role_contact").crmError('{/literal}{ts escape="js"}Select valid contact from the list{/ts}{literal}.');
728 return false;
729 }
730
731 /* send synchronous request so that disabling any actions for slow servers*/
732 var postUrl = {/literal}"{crmURL p='civicrm/ajax/relation' h=0 }"{literal};
733 var data = 'rel_contact='+ v1 + '&rel_type='+ v2 + '&contact_id='+sourceContact + '&rel_id='+ relID
734 + '&case_id=' + caseID + "&key={/literal}{crmKey name='civicrm/ajax/relation'}{literal}";
735 cj.ajax({
736 type : "POST",
737 url : postUrl,
738 data : data,
739 async : false,
740 dataType : "json",
741 success : function(values) {
742 if (values.status == 'process-relationship-success') {
743 // reloading datatable
744 var oTable = cj('#caseRoles-selector').dataTable();
745 oTable.fnDraw();
746 }
747 else {
748 var relTypeName = cj("#role_type :selected").text();
749 var relTypeAdminLink = {/literal}"{crmURL p='civicrm/admin/reltype' q='reset=1' h=0 }"{literal};
750 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}.';
751
752 //display error message.
753 cj().crmError(errorMsg);
754 }
755 }
756 });
757
758 cj(this).dialog("close");
759 cj(this).dialog("destroy");
760 },
761
762 "Cancel": function() {
763 cj(this).dialog("close");
764 cj(this).dialog("destroy");
765 }
766 }
767 });
768 }
769
770 </script>
771 {/literal}
772 {include file="CRM/Case/Form/ActivityToCase.tpl"}
773
774 {* pane to display / edit regular tags or tagsets for cases *}
775 {if $showTags OR $showTagsets}
776
777 <div id="casetags" class="crm-accordion-wrapper crm-case-tags-block">
778 <div class="crm-accordion-header">
779 {ts}Case Tags{/ts}
780 </div><!-- /.crm-accordion-header -->
781 <div class="crm-accordion-body">
782 {assign var="tagExits" value=0}
783 {if $tags}
784 <div class="crm-block crm-content-block crm-case-caseview-display-tags">{$tags}</div>
785 {assign var="tagExits" value=1}
786 {/if}
787
788 {foreach from=$tagsetInfo_case item=displayTagset}
789 {if $displayTagset.entityTagsArray}
790 <div class="crm-block crm-content-block crm-case-caseview-display-tagset">
791 &nbsp;&nbsp;{$displayTagset.parentName}:
792 {foreach from=$displayTagset.entityTagsArray item=val name="tagsetList"}
793 &nbsp;{$val.name}{if !$smarty.foreach.tagsetList.last},{/if}
794 {/foreach}
795 </div>
796 {assign var="tagExits" value=1}
797 {/if}
798 {/foreach}
799
800 {if !$tagExits }
801 <div class="status">
802 {ts}There are no tags currently assigned to this case.{/ts}
803 </div>
804 {/if}
805
806 <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>
807
808 </div><!-- /.crm-accordion-body -->
809 </div><!-- /.crm-accordion-wrapper -->
810
811 <div id="manageTags">
812 <div class="label">{$form.case_tag.label}</div>
813 <div class="view-value"><div class="crm-select-container">{$form.case_tag.html}</div>
814 <br/>
815 <div style="text-align:left;">{include file="CRM/common/Tag.tpl" tagsetType='case'}</div>
816 <br/>
817 <div class="clear"></div>
818 </div>
819 </div>
820
821 {literal}
822 <script type="text/javascript">
823 cj("#manageTags select[multiple]").crmasmSelect({
824 addItemTarget: 'bottom',
825 animate: true,
826 highlight: true,
827 sortable: true,
828 respectParents: true
829 });
830
831 cj("#manageTags").hide( );
832 function addTags() {
833 cj("#manageTags").show( );
834
835 cj("#manageTags").dialog({
836 title: "{/literal}{ts escape='js'}Change Case Tags{/ts}{literal}",
837 modal: true,
838 height: 'auto',
839 width: 'auto',
840 buttons: {
841 "Save": function() {
842 var tagsChecked = '';
843 var caseID = {/literal}{$caseID}{literal};
844
845 cj("#manageTags #tags option").each( function() {
846 if (cj(this).prop('selected')) {
847 if (!tagsChecked) {
848 tagsChecked = cj(this).val() + '';
849 }
850 else {
851 tagsChecked = tagsChecked + ',' + cj(this).val();
852 }
853 }
854 });
855
856 var tagList = '';
857 cj("#manageTags input[name^=case_taglist]").each(function( ) {
858 if (!tagsChecked) {
859 tagsChecked = cj(this).val() + '';
860 }
861 else {
862 tagsChecked = tagsChecked + ',' + cj(this).val();
863 }
864 });
865
866 var postUrl = {/literal}"{crmURL p='civicrm/case/ajax/processtags' h=0 }"{literal};
867 var data = 'case_id=' + caseID + '&tag=' + tagsChecked + '&key=' + {/literal}"{crmKey name='civicrm/case/ajax/processtags'}"{literal};
868
869 cj.ajax({ type: "POST", url: postUrl, data: data, async: false });
870 cj(this).dialog("close");
871 cj(this).dialog("destroy");
872
873 // Temporary workaround for problems with SSL connections being too
874 // slow. The relationship doesn't get created because the page reload
875 // happens before the ajax call.
876 // In general this reload needs improvement, which is already on the list for phase 2.
877 var sdate = (new Date()).getTime();
878 var curDate = sdate;
879 while(curDate-sdate < 2000) {
880 curDate = (new Date()).getTime();
881 }
882
883 //due to caching issues we use redirection rather than reload
884 document.location = {/literal}'{crmURL q="action=view&reset=1&id=$caseID&cid=$contactID&context=$context" h=0 }'{literal};
885 },
886
887 "Cancel": function() {
888 cj(this).dialog("close");
889 cj(this).dialog("destroy");
890 }
891 }
892 });
893 }
894
895 </script>
896 {/literal}
897
898 {/if} {* end of tag block*}
899
900 {*include activity view js file*}
901 {include file="CRM/common/activityView.tpl"}
902
903 <div class="crm-accordion-wrapper crm-case_activities-accordion crm-case-activities-block">
904 <div class="crm-accordion-header">
905 {ts}Activities{/ts}
906 </div>
907 <div id="activities" class="crm-accordion-body">
908 <div id="view-activity">
909 <div id="activity-content"></div>
910 </div>
911 <div class="crm-accordion-wrapper crm-accordion-inner crm-search_filters-accordion collapsed">
912 <div class="crm-accordion-header">
913 {ts}Search Filters{/ts}</a>
914 </div><!-- /.crm-accordion-header -->
915 <div class="crm-accordion-body">
916 <table class="no-border form-layout-compressed" id="searchOptions">
917 <tr>
918 <td class="crm-case-caseview-form-block-repoter_id"colspan="2"><label for="reporter_id">{ts}Reporter/Role{/ts}</label><br />
919 {$form.reporter_id.html|crmAddClass:twenty}
920 </td>
921 <td class="crm-case-caseview-form-block-status_id"><label for="status_id">{$form.status_id.label}</label><br />
922 {$form.status_id.html}
923 </td>
924 <td style="vertical-align: bottom;">
925 <span class="crm-button"><input class="form-submit default" name="_qf_Basic_refresh" value="Search" type="button" onclick="buildCaseActivities( true )"; /></span>
926 </td>
927 </tr>
928 <tr>
929 <td class="crm-case-caseview-form-block-activity_date_low">
930 {$form.activity_date_low.label}<br />
931 {include file="CRM/common/jcalendar.tpl" elementName=activity_date_low}
932 </td>
933 <td class="crm-case-caseview-form-block-activity_date_high">
934 {$form.activity_date_high.label}<br />
935 {include file="CRM/common/jcalendar.tpl" elementName=activity_date_high}
936 </td>
937 <td class="crm-case-caseview-form-block-activity_type_filter_id">
938 {$form.activity_type_filter_id.label}<br />
939 {$form.activity_type_filter_id.html}
940 </td>
941 </tr>
942 {if $form.activity_deleted}
943 <tr class="crm-case-caseview-form-block-activity_deleted">
944 <td>
945 {$form.activity_deleted.html}{$form.activity_deleted.label}
946 </td>
947 </tr>
948 {/if}
949 </table>
950 </div><!-- /.crm-accordion-body -->
951 </div><!-- /.crm-accordion-wrapper -->
952
953 <table id="activities-selector" class="nestedActivitySelector">
954 <thead><tr>
955 <th class='crm-case-activities-date'>{ts}Date{/ts}</th>
956 <th class='crm-case-activities-subject'>{ts}Subject{/ts}</th>
957 <th class='crm-case-activities-type'>{ts}Type{/ts}</th>
958 <th class='crm-case-activities-with'>{ts}With{/ts}</th>
959 <th class='crm-case-activities-assignee'>{ts}Reporter / Assignee{/ts}</th>
960 <th class='crm-case-activities-status'>{ts}Status{/ts}</th>
961 <th class='crm-case-activities-status' id="nosort">&nbsp;</th>
962 <th class='hiddenElement'>&nbsp;</th>
963 </tr></thead>
964 </table>
965
966 </div><!-- /.crm-accordion-body -->
967 </div><!-- /.crm-accordion-wrapper -->
968
969 {literal}
970 <script type="text/javascript">
971 var oTable;
972
973 function checkSelection( field ) {
974 var validationMessage = '';
975 var validationField = '';
976 var successAction = '';
977 var forceValidation = false;
978
979 var clientName = new Array( );
980 clientName = selectedContact.split('::');
981 var fName = field.name;
982
983 switch ( fName ) {
984 case '_qf_CaseView_next' :
985 validationMessage = '{/literal}{ts escape="js"}Please select an activity set from the list.{/ts}{literal}';
986 validationField = 'timeline_id';
987 successAction = "confirm('{/literal}{ts escape='js'}Are you sure you want to add a set of scheduled activities to this case?{/ts}{literal}');";
988 break;
989
990 case 'new_activity' :
991 validationMessage = '{/literal}{ts escape="js"}Please select an activity type from the list.{/ts}{literal}';
992 validationField = 'activity_type_id';
993 if ( document.getElementById('activity_type_id').value == 3 ) {
994 successAction = "window.location='{/literal}{$newActivityEmailUrl}{literal}' + document.getElementById('activity_type_id').value";
995 }
996 else {
997 successAction = "window.location='{/literal}{$newActivityUrl}{literal}' + document.getElementById('activity_type_id').value";
998 }
999 break;
1000
1001 case 'case_report' :
1002 validationMessage = '{/literal}{ts escape="js"}Please select a report from the list.{/ts}{literal}';
1003 validationField = 'report_id';
1004 successAction = "window.location='{/literal}{$reportUrl}{literal}' + document.getElementById('report_id').value";
1005 break;
1006
1007 case '_qf_CaseView_next_merge_case' :
1008 validationMessage = '{/literal}{ts escape="js"}Please select a case from the list to merge with.{/ts}{literal}';
1009 validationField = 'merge_case_id';
1010 break;
1011
1012 case '_qf_CaseView_next_edit_client' :
1013 validationMessage = '{/literal}{ts escape="js"}Please select a client for this case.{/ts}{literal}';
1014 if ( cj('#contact_id').val( ) == '{/literal}{$contactID}{literal}' ) {
1015 forceValidation = true;
1016 validationMessage = '{/literal}{ts 1="'+clientName[0]+'"}%1 is already assigned to this case. Please select some other client for this case.{/ts}{literal}';
1017 }
1018 validationField = 'change_client_id';
1019 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}' )";
1020 break;
1021 }
1022
1023 if ( forceValidation || ( document.getElementById( validationField ).value == '' ) ) {
1024 cj('#'+validationField).crmError(validationMessage);
1025 return false;
1026 }
1027 else if ( successAction ) {
1028 return eval( successAction );
1029 }
1030 }
1031
1032 cj(function( ) {
1033 buildCaseActivities(false);
1034 });
1035
1036 function buildCaseActivities(filterSearch) {
1037 if (filterSearch) {
1038 oTable.fnDestroy();
1039 }
1040 var count = 0;
1041 var columns = '';
1042 var sourceUrl = {/literal}"{crmURL p='civicrm/ajax/activity' h=0 q='snippet=4&caseID='}{$caseID}"{literal};
1043 sourceUrl = sourceUrl + '&cid={/literal}{$contactID}{literal}';
1044 sourceUrl = sourceUrl + '&userID={/literal}{$userID}{literal}';
1045
1046 cj('#activities-selector th').each(function( ) {
1047 if (cj(this).attr('id') != 'nosort') {
1048 columns += '{"sClass": "' + cj(this).attr('class') +'"},';
1049 }
1050 else {
1051 columns += '{ "bSortable": false },';
1052 }
1053 count++;
1054 });
1055
1056 columns = columns.substring(0, columns.length - 1 );
1057 eval('columns =[' + columns + ']');
1058
1059 oTable = cj('#activities-selector').dataTable({
1060 "bFilter" : false,
1061 "bAutoWidth" : false,
1062 "aaSorting" : [],
1063 "aoColumns" : columns,
1064 "bProcessing": true,
1065 "bJQueryUI": true,
1066 "asStripClasses" : [ "odd-row", "even-row" ],
1067 "sPaginationType": "full_numbers",
1068 "sDom" : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
1069 "bServerSide": true,
1070 "sAjaxSource": sourceUrl,
1071 "iDisplayLength": 10,
1072 "fnDrawCallback": function() { setSelectorClass(); },
1073 "fnServerData": function ( sSource, aoData, fnCallback ) {
1074
1075 if ( filterSearch ) {
1076 var activity_deleted = 0;
1077 if ( cj("#activity_deleted:checked").val() == 1 ) {
1078 activity_deleted = 1;
1079 }
1080 aoData.push(
1081 {name:'status_id', value: cj("select#status_id").val()},
1082 {name:'activity_type_id', value: cj("select#activity_type_filter_id").val()},
1083 {name:'activity_date_low', value: cj("#activity_date_low").val()},
1084 {name:'activity_date_high', value: cj("#activity_date_high").val() },
1085 {name:'activity_deleted', value: activity_deleted }
1086 );
1087 }
1088 cj.ajax( {
1089 "dataType": 'json',
1090 "type": "POST",
1091 "url": sSource,
1092 "data": aoData,
1093 "success": fnCallback
1094 } );
1095 }
1096 });
1097 }
1098
1099 function setSelectorClass( ) {
1100 cj("#activities-selector td:last-child").each( function( ) {
1101 cj(this).parent().addClass(cj(this).text() );
1102 });
1103 }
1104
1105 function printCaseReport( ) {
1106 var asn = 'standard_timeline';
1107 var dataUrl = {/literal}"{crmURL p='civicrm/case/report/print' q='all=1&redact=0' h='0'}"{literal};
1108 dataUrl = dataUrl + '&cid={/literal}{$contactID}{literal}'
1109 + '&caseID={/literal}{$caseID}{literal}'
1110 + '&asn={/literal}' + asn + '{literal}';
1111
1112 window.location = dataUrl;
1113 }
1114
1115 </script>
1116 {/literal}
1117
1118 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
1119
1120 {literal}
1121 <script type="text/javascript">
1122 cj(function() {
1123 cj().crmAccordions();
1124 });
1125 </script>
1126 {/literal}
1127
1128 {/if} {* view related cases if end *}
1129 </div>