2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.4 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2013 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
26 {* CiviCase - view case screen*}
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>
38 {foreach from=$relatedCases item=row key=caseId}
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>
49 <h3>{ts}Summary{/ts}</h3>
50 <table class="report">
52 <tr class="crm-case-caseview-client">
53 <td colspan="5" class="label">
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}, {/if}
58 <a href="#" title="{ts}add new client to the case{/ts}" onclick="addClient( );return false;">
59 <span class="icon edit-icon"></span>
62 <div class="crm-block relatedCases-link"><a href='#' onClick='viewRelatedCases( {$caseID}, {$contactID} ); return false;'>{ts}Related Cases{/ts}</a></div>
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>
76 <tr class="crm-case-caseview-phone">
77 <td class="label-left description" style="padding: 1px">{$client.phone}</td>
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>
88 <div class="crm-block relatedCases-link"><a href='#' onClick='viewRelatedCases( {$caseID}, {$contactID} ); return false;'>{ts}Related Cases{/ts}</a></div>
92 <td class="crm-case-caseview-case_subject label">
93 <span class="crm-case-summary-label">{ts}Subject{/ts}:</span> {$caseDetails.case_subject}
95 <td class="crm-case-caseview-case_type label">
96 <span class="crm-case-summary-label">{ts}Type{/ts}:</span> {$caseDetails.case_type} <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>
98 <td class="crm-case-caseview-case_status label">
99 <span class="crm-case-summary-label">{ts}Status{/ts}:</span> {$caseDetails.case_status} <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>
101 <td class="crm-case-caseview-case_start_date label">
102 <span class="crm-case-summary-label">{ts}Open Date{/ts}:</span> {$caseDetails.case_start_date|crmDate} <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>
104 <td class="crm-case-caseview-{$caseID} label">
105 <span class="crm-case-summary-label">{ts}ID{/ts}:</span> {$caseID}
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>
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} <input type="button" accesskey="N" value="{ts}Go{/ts}" name="new_activity" onclick="checkSelection( this );"/></td>
120 {if $hasAccessToAllCases}
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>
126 <td class="crm-case-caseview-form-block-timeline_id">{$form.timeline_id.label}<br />{$form.timeline_id.html} {$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} <input type="button" accesskey="R" value="Go" name="case_report" onclick="checkSelection( this );"/></td>
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} {$form._qf_CaseView_next_merge_case.html}
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} {$form._qf_CaseView_next_edit_client.html}
154 <div id="view-related-cases">
155 <div id="related-cases-content"></div>
158 <div class="clear"></div>
159 {include file="CRM/Case/Page/CustomDataView.tpl"}
161 <div class="crm-accordion-wrapper collapsed crm-case-roles-block">
162 <div class="crm-accordion-header">
164 </div><!-- /.crm-accordion-header -->
165 <div class="crm-accordion-body">
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>
173 <table id="caseRoles-selector" class="report-layout">
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>
186 <script type="text/javascript">
190 cj().crmAccordions();
191 buildCaseRoles(false);
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');
199 CRM.confirm(function() {
200 var postUrl = {/literal}"{crmURL p='civicrm/ajax/delcaserole' h=0 }"{literal};
202 rel_type: relType, case_id: caseID, key: {/literal}"{crmKey name='civicrm/ajax/delcaserole'}"{literal}},
204 // reloading datatable
205 var oTable = cj('#' + caseselector).dataTable();
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}'
218 function buildCaseRoles(filterSearch) {
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}';
228 cj('#caseRoles-selector th').each( function( ) {
229 if ( cj(this).attr('id') != 'nosort' ) {
230 columns += '{"sClass": "' + cj(this).attr('class') +'"},';
233 columns += '{ "bSortable": false },';
238 columns = columns.substring(0, columns.length - 1 );
239 eval('columns =[' + columns + ']');
241 oTable = cj('#caseRoles-selector').dataTable({
243 "bAutoWidth" : false,
245 "aoColumns" : columns,
248 "asStripClasses" : [ "odd-row", "even-row" ],
249 "sPaginationType": "full_numbers",
250 "sDom" : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
252 "sAjaxSource": sourceUrl,
253 "iDisplayLength": 10,
254 "fnDrawCallback": function() { setCaseRolesSelectorClass(); },
255 "fnServerData": function ( sSource, aoData, fnCallback ) {
261 "success": fnCallback
267 function setCaseRolesSelectorClass( ) {
268 cj("#caseRoles-selector td:last-child").each( function( ) {
269 cj(this).parent().addClass(cj(this).text() );
272 // also bind delete action once rows are rendered
273 deleteCaseRoles('caseRoles-selector');
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}';
283 window.location = dataUrl;
287 </div><!-- /.crm-accordion-body -->
288 </div><!-- /.crm-accordion-wrapper -->
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="">
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(''); });
304 cj("#dialog").hide( );
306 function addClient( ) {
307 cj("#dialog").show( );
309 cj("#dialog").dialog({
310 title: "Add Client to the Case",
313 close : function(event, ui) { cj("#rel_contact").unautocomplete( ); },
314 overlay: { opacity: 0.5, background: "black" },
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, {
324 cj("#rel_contact").focus();
325 cj("#rel_contact").result(function(event, data, formatted) {
326 cj("input[id=rel_contact_id]").val(data[1]);
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( );
336 if ( !cj("#rel_contact").val( ) || !contactID ) {
337 cj("#rel_contact").crmError('{/literal}{ts escape="js"}Select valid contact from the list{/ts}{literal}.');
340 cj.post( postUrl, {contactID: contactID,caseID: caseID,
341 key: {/literal}"{crmKey name='civicrm/case/ajax/addclient'}"{literal} },
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};
350 "Cancel": function() {
351 cj(this).dialog("close");
352 cj(this).dialog("destroy");
358 function createRelationship( relType, contactID, relID, rowNumber, relTypeName ) {
359 cj("#dialog").show( );
361 cj("#dialog").dialog({
362 title: "Assign Case Role",
365 close: function(event, ui) { cj("#rel_contact").unautocomplete( ); },
372 /* set defaults if editing */
373 cj("#rel_contact").val("");
374 cj("#rel_contact_id").val(null);
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);
381 var contactUrl = {/literal}"{crmURL p='civicrm/ajax/rest' q='className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=caseview' h=0 }"{literal};
383 cj("#rel_contact").autocomplete( contactUrl, {
389 cj("#rel_contact").focus();
390 cj("#rel_contact").result(function(event, data, formatted) {
391 cj("input[id=rel_contact_id]").val(data[1]);
398 var sourceContact = {/literal}"{$contactID}"{literal};
399 var caseID = {/literal}"{$caseID}"{literal};
401 var v1 = cj("#rel_contact_id").val( );
403 if ( !cj("#rel_contact").val( ) || !v1 ) {
404 cj("#rel_contact").crmError('{/literal}{ts escape="js"}Select valid contact from the list{/ts}{literal}.');
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} },
412 if ( data.status == 'process-relationship-success' ) {
413 // reloading datatable
414 var oTable = cj('#caseRoles-selector').dataTable();
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.
421 {capture assign=relTypeAdminLink}{crmURL p='civicrm/admin/reltype' q='reset=1' h=0 }{/capture}
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}';
425 //display error message.
426 cj().crmError(errorMsg);
431 cj(this).dialog("close");
432 cj(this).dialog("destroy");
435 "Cancel": function() {
436 cj(this).dialog("close");
437 cj(this).dialog("destroy");
443 function viewRelatedCases( mainCaseID, contactID ) {
444 cj("#view-related-cases").show( );
445 cj("#view-related-cases").dialog({
446 title: "Related Cases",
457 beforeclose: function(event, ui) {
458 cj(this).dialog("destroy");
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';
468 success : function(html){
469 cj("#related-cases-content" ).html( html );
476 cj(this).dialog("close");
477 cj(this).dialog("destroy");
484 cj("#view-activity").hide( );
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">
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>
501 <table id="clientRelationships-selector" class="report-layout">
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>
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}
517 <script type="text/javascript">
519 buildCaseClientRelationships(false);
522 function buildCaseClientRelationships(filterSearch) {
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}';
532 cj('#clientRelationships-selector th').each( function( ) {
533 if ( cj(this).attr('id') != 'nosort' ) {
534 columns += '{"sClass": "' + cj(this).attr('class') +'"},';
537 columns += '{ "bSortable": false },';
542 columns = columns.substring(0, columns.length - 1 );
543 eval('columns =[' + columns + ']');
545 oTable = cj('#clientRelationships-selector').dataTable({
547 "bAutoWidth" : false,
549 "aoColumns" : columns,
552 "asStripClasses" : [ "odd-row", "even-row" ],
553 "sPaginationType": "full_numbers",
554 "sDom" : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
556 "sAjaxSource": sourceUrl,
557 "iDisplayLength": 10,
558 "fnDrawCallback": function() { setClientRelationshipsSelectorClass(); },
559 "fnServerData": function (sSource, aoData, fnCallback) {
565 "success": fnCallback
571 function setClientRelationshipsSelectorClass( ) {
572 cj("#clientRelationships-selector td:last-child").each(function() {
573 cj(this).parent().addClass(cj(this).text());
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>
585 <table id="globalRelationships-selector" class="report-layout">
587 <th>{$globalGroupInfo.title}</th>
588 <th>{ts}Phone{/ts}</th>
589 <th>{ts}Email{/ts}</th>
592 {elseif $globalGroupInfo.id}
593 <div class="messages status no-popup">
594 <div class="icon inform-icon"></div>
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}
601 <script type="text/javascript">
604 buildCaseGlobalRelationships(false);
607 function buildCaseGlobalRelationships(filterSearch) {
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}';
617 cj('#globalRelationships-selector th').each( function( ) {
618 if (cj(this).attr('id') != 'nosort') {
619 columns += '{"sClass": "' + cj(this).attr('class') +'"},';
622 columns += '{ "bSortable": false },';
627 columns = columns.substring(0, columns.length - 1 );
628 eval('columns =[' + columns + ']');
630 oTable = cj('#globalRelationships-selector').dataTable({
632 "bAutoWidth" : false,
634 "aoColumns" : columns,
637 "asStripClasses" : [ "odd-row", "even-row" ],
638 "sPaginationType": "full_numbers",
639 "sDom" : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
641 "sAjaxSource": sourceUrl,
642 "iDisplayLength": 10,
643 "fnDrawCallback": function() { setGlobalRelationshipsSelectorClass(); },
644 "fnServerData": function ( sSource, aoData, fnCallback ) {
650 "success": fnCallback
656 function setGlobalRelationshipsSelectorClass( ) {
657 cj("#globalRelationships-selector td:last-child").each( function( ) {
658 cj(this).parent().addClass(cj(this).text() );
663 </div><!-- /.crm-accordion-body -->
664 </div><!-- /.crm-accordion-wrapper -->
666 {/if} {* other relationship section ends *}
668 <div id="addRoleDialog">
669 {$form.role_type.label}<br />
670 {$form.role_type.html}
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="">
678 <script type="text/javascript">
680 cj("#addRoleDialog").hide( );
682 cj("#addRoleDialog").show( );
684 cj("#addRoleDialog").dialog({
688 close: function(event, ui) { cj("#role_contact").unautocomplete( ); },
695 /* set defaults if editing */
696 cj("#role_contact").val( "" );
697 cj("#role_contact_id").val( null );
699 var contactUrl = {/literal}"{crmURL p='civicrm/ajax/rest' q='className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=caseview' h=0 }"{literal};
701 cj("#role_contact").autocomplete( contactUrl, {
707 cj("#role_contact").focus();
708 cj("#role_contact").result(function(event, data, formatted) {
709 cj("input[id=role_contact_id]").val(data[1]);
715 var sourceContact = {/literal}"{$contactID}"{literal};
716 var caseID = {/literal}"{$caseID}"{literal};
719 var v2 = cj("#role_type").val();
721 cj("#role_type").crmError('{/literal}{ts escape="js"}Select valid type from the list{/ts}{literal}.');
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}.');
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}";
741 success : function(values) {
742 if (values.status == 'process-relationship-success') {
743 // reloading datatable
744 var oTable = cj('#caseRoles-selector').dataTable();
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}.';
752 //display error message.
753 cj().crmError(errorMsg);
758 cj(this).dialog("close");
759 cj(this).dialog("destroy");
762 "Cancel": function() {
763 cj(this).dialog("close");
764 cj(this).dialog("destroy");
772 {include file="CRM/Case/Form/ActivityToCase.tpl"}
774 {* pane to display / edit regular tags or tagsets for cases *}
775 {if $showTags OR $showTagsets}
777 <div id="casetags" class="crm-accordion-wrapper crm-case-tags-block">
778 <div class="crm-accordion-header">
780 </div><!-- /.crm-accordion-header -->
781 <div class="crm-accordion-body">
782 {assign var="tagExits" value=0}
784 <div class="crm-block crm-content-block crm-case-caseview-display-tags">{$tags}</div>
785 {assign var="tagExits" value=1}
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 {$displayTagset.parentName}:
792 {foreach from=$displayTagset.entityTagsArray item=val name="tagsetList"}
793 {$val.name}{if !$smarty.foreach.tagsetList.last},{/if}
796 {assign var="tagExits" value=1}
802 {ts}There are no tags currently assigned to this case.{/ts}
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>
808 </div><!-- /.crm-accordion-body -->
809 </div><!-- /.crm-accordion-wrapper -->
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>
815 <div style="text-align:left;">{include file="CRM/common/Tag.tpl" tagsetType='case'}</div>
817 <div class="clear"></div>
822 <script type="text/javascript">
823 cj("#manageTags select[multiple]").crmasmSelect({
824 addItemTarget: 'bottom',
831 cj("#manageTags").hide( );
833 cj("#manageTags").show( );
835 cj("#manageTags").dialog({
836 title: "{/literal}{ts escape='js'}Change Case Tags{/ts}{literal}",
842 var tagsChecked = '';
843 var caseID = {/literal}{$caseID}{literal};
845 cj("#manageTags #tags option").each( function() {
846 if (cj(this).prop('selected')) {
848 tagsChecked = cj(this).val() + '';
851 tagsChecked = tagsChecked + ',' + cj(this).val();
857 cj("#manageTags input[name^=case_taglist]").each(function( ) {
859 tagsChecked = cj(this).val() + '';
862 tagsChecked = tagsChecked + ',' + cj(this).val();
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};
869 cj.ajax({ type: "POST", url: postUrl, data: data, async: false });
870 cj(this).dialog("close");
871 cj(this).dialog("destroy");
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();
879 while(curDate-sdate < 2000) {
880 curDate = (new Date()).getTime();
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};
887 "Cancel": function() {
888 cj(this).dialog("close");
889 cj(this).dialog("destroy");
898 {/if} {* end of tag block*}
900 {*include activity view js file*}
901 {include file="CRM/common/activityView.tpl"}
903 <div class="crm-accordion-wrapper crm-case_activities-accordion crm-case-activities-block">
904 <div class="crm-accordion-header">
907 <div id="activities" class="crm-accordion-body">
908 <div id="view-activity">
909 <div id="activity-content"></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">
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}
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}
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>
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}
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}
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}
942 {if $form.activity_deleted}
943 <tr class="crm-case-caseview-form-block-activity_deleted">
945 {$form.activity_deleted.html}{$form.activity_deleted.label}
950 </div><!-- /.crm-accordion-body -->
951 </div><!-- /.crm-accordion-wrapper -->
953 <table id="activities-selector" class="nestedActivitySelector">
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"> </th>
962 <th class='hiddenElement'> </th>
966 </div><!-- /.crm-accordion-body -->
967 </div><!-- /.crm-accordion-wrapper -->
970 <script type="text/javascript">
973 function checkSelection( field ) {
974 var validationMessage = '';
975 var validationField = '';
976 var successAction = '';
977 var forceValidation = false;
979 var clientName = new Array( );
980 clientName = selectedContact.split('::');
981 var fName = field.name;
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}');";
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";
997 successAction = "window.location='{/literal}{$newActivityUrl}{literal}' + document.getElementById('activity_type_id').value";
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";
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';
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}';
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}' )";
1023 if ( forceValidation || ( document.getElementById( validationField ).value == '' ) ) {
1024 cj('#'+validationField).crmError(validationMessage);
1027 else if ( successAction ) {
1028 return eval( successAction );
1033 buildCaseActivities(false);
1036 function buildCaseActivities(filterSearch) {
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}';
1046 cj('#activities-selector th').each(function( ) {
1047 if (cj(this).attr('id') != 'nosort') {
1048 columns += '{"sClass": "' + cj(this).attr('class') +'"},';
1051 columns += '{ "bSortable": false },';
1056 columns = columns.substring(0, columns.length - 1 );
1057 eval('columns =[' + columns + ']');
1059 oTable = cj('#activities-selector').dataTable({
1061 "bAutoWidth" : false,
1063 "aoColumns" : columns,
1064 "bProcessing": 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 ) {
1075 if ( filterSearch ) {
1076 var activity_deleted = 0;
1077 if ( cj("#activity_deleted:checked").val() == 1 ) {
1078 activity_deleted = 1;
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 }
1093 "success": fnCallback
1099 function setSelectorClass( ) {
1100 cj("#activities-selector td:last-child").each( function( ) {
1101 cj(this).parent().addClass(cj(this).text() );
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}';
1112 window.location = dataUrl;
1118 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
1121 <script type="text/javascript">
1123 cj().crmAccordions();
1128 {/if} {* view related cases if end *}