Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
3 | | CiviCRM version 4.3 | | |
4 | +--------------------------------------------------------------------+ | |
5 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
6 | +--------------------------------------------------------------------+ | |
7 | | This file is a part of CiviCRM. | | |
8 | | | | |
9 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
10 | | under the terms of the GNU Affero General Public License | | |
11 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
12 | | | | |
13 | | CiviCRM is distributed in the hope that it will be useful, but | | |
14 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
15 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
16 | | See the GNU Affero General Public License for more details. | | |
17 | | | | |
18 | | You should have received a copy of the GNU Affero General Public | | |
19 | | License and the CiviCRM Licensing Exception along | | |
20 | | with this program; if not, contact CiviCRM LLC | | |
21 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
22 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
23 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
24 | +--------------------------------------------------------------------+ | |
25 | *} | |
26 | {* CiviCase - view case screen*} | |
27 | ||
28 | {* here we are showing related cases w/ jquery dialog *} | |
29 | <div class="crm-block crm-form-block crm-case-caseview-form-block"> | |
30 | {if $showRelatedCases} | |
31 | <table class="report"> | |
32 | <tr class="columnheader"> | |
33 | <th>{ts}Client Name{/ts}</th> | |
34 | <th>{ts}Case Type{/ts}</th> | |
35 | <th></th> | |
36 | </tr> | |
37 | ||
38 | {foreach from=$relatedCases item=row key=caseId} | |
39 | <tr> | |
40 | <td class="crm-case-caseview-client_name label">{$row.client_name}</td> | |
41 | <td class="crm-case-caseview-case_type label">{$row.case_type}</td> | |
42 | <td class="label">{$row.links}</td> | |
43 | </tr> | |
44 | {/foreach} | |
45 | </table> | |
46 | ||
47 | {else} | |
48 | ||
49 | <h3>{ts}Case Summary{/ts}</h3> | |
50 | <table class="report"> | |
51 | {if $multiClient} | |
52 | <tr class="crm-case-caseview-client"> | |
ad5d70b5 | 53 | <td colspan="5" class="label"> |
6a488035 TO |
54 | {ts}Clients:{/ts} |
55 | {foreach from=$caseRoles.client item=client name=clients} | |
56 | <a href="{crmURL p='civicrm/contact/view' q="action=view&reset=1&cid=`$client.contact_id`"}" title="{ts}view contact record{/ts}">{$client.display_name}</a>{if not $smarty.foreach.clients.last}, {/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} | |
0cc50002 | 92 | <td class="crm-case-caseview-case_subject label"> |
6a488035 TO |
93 | <span class="crm-case-summary-label">{ts}Case Subject{/ts}:</span> {$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> {$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> | |
97 | </td> | |
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> | |
100 | </td> | |
101 | <td class="crm-case-caseview-case_start_date label"> | |
102 | <span class="crm-case-summary-label">{ts}Start 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> | |
103 | </td> | |
104 | <td class="crm-case-caseview-{$caseID} label"> | |
105 | <span class="crm-case-summary-label">{ts}Case ID{/ts}:</span> {$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} <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} {$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> | |
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} {$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} {$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() { | |
4cd35744 | 190 | cj().crmAccordions(); |
6a488035 TO |
191 | buildCaseRoles(false); |
192 | }); | |
193 | ||
4cd35744 KJ |
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: ts('Delete case role'), | |
212 | message: ts('Are you sure you want to delete this case role.') | |
213 | }); | |
214 | return false; | |
215 | }); | |
216 | } | |
217 | ||
6a488035 TO |
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 | }); | |
4cd35744 KJ |
271 | |
272 | // also bind delete action once rows are rendered | |
273 | deleteCaseRoles('caseRoles-selector'); | |
6a488035 TO |
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 | } | |
6a488035 TO |
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 ) { | |
b5547cb6 KJ |
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}; | |
6a488035 TO |
345 | }, |
346 | 'json' | |
347 | ); | |
6a488035 TO |
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> | |
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 | {include file="CRM/Case/Form/ActivityChangeStatus.tpl"} | |
770 | ||
771 | {* pane to display / edit regular tags or tagsets for cases *} | |
772 | {if $showTags OR $showTagsets} | |
773 | ||
774 | <div id="casetags" class="crm-accordion-wrapper crm-case-tags-block"> | |
775 | <div class="crm-accordion-header"> | |
776 | {ts}Case Tags{/ts} | |
777 | </div><!-- /.crm-accordion-header --> | |
778 | <div class="crm-accordion-body"> | |
779 | {assign var="tagExits" value=0} | |
780 | {if $tags} | |
781 | <div class="crm-block crm-content-block crm-case-caseview-display-tags">{$tags}</div> | |
782 | {assign var="tagExits" value=1} | |
783 | {/if} | |
784 | ||
785 | {foreach from=$tagsetInfo_case item=displayTagset} | |
786 | {if $displayTagset.entityTagsArray} | |
787 | <div class="crm-block crm-content-block crm-case-caseview-display-tagset"> | |
788 | {$displayTagset.parentName}: | |
789 | {foreach from=$displayTagset.entityTagsArray item=val name="tagsetList"} | |
790 | {$val.name}{if !$smarty.foreach.tagsetList.last},{/if} | |
791 | {/foreach} | |
792 | </div> | |
793 | {assign var="tagExits" value=1} | |
794 | {/if} | |
795 | {/foreach} | |
796 | ||
797 | {if !$tagExits } | |
798 | <div class="status"> | |
799 | {ts}There are no tags currently assigned to this case.{/ts} | |
800 | </div> | |
801 | {/if} | |
802 | ||
803 | <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> | |
804 | ||
805 | </div><!-- /.crm-accordion-body --> | |
806 | </div><!-- /.crm-accordion-wrapper --> | |
807 | ||
808 | <div id="manageTags"> | |
809 | <div class="label">{$form.case_tag.label}</div> | |
810 | <div class="view-value"><div class="crm-select-container">{$form.case_tag.html}</div> | |
811 | <br/> | |
812 | <div style="text-align:left;">{include file="CRM/common/Tag.tpl" tagsetType='case'}</div> | |
813 | <br/> | |
814 | <div class="clear"></div> | |
815 | </div> | |
816 | </div> | |
817 | ||
818 | {literal} | |
819 | <script type="text/javascript"> | |
820 | cj("#manageTags select[multiple]").crmasmSelect({ | |
821 | addItemTarget: 'bottom', | |
822 | animate: true, | |
823 | highlight: true, | |
824 | sortable: true, | |
825 | respectParents: true | |
826 | }); | |
827 | ||
828 | cj("#manageTags").hide( ); | |
829 | function addTags() { | |
830 | cj("#manageTags").show( ); | |
831 | ||
832 | cj("#manageTags").dialog({ | |
833 | title: "{/literal}{ts escape='js'}Change Case Tags{/ts}{literal}", | |
834 | modal: true, | |
835 | height: 'auto', | |
836 | width: 'auto', | |
837 | buttons: { | |
838 | "Save": function() { | |
839 | var tagsChecked = ''; | |
840 | var caseID = {/literal}{$caseID}{literal}; | |
841 | ||
842 | cj("#manageTags #tags option").each( function() { | |
843 | if (cj(this).prop('selected')) { | |
844 | if (!tagsChecked) { | |
845 | tagsChecked = cj(this).val() + ''; | |
846 | } | |
847 | else { | |
848 | tagsChecked = tagsChecked + ',' + cj(this).val(); | |
849 | } | |
850 | } | |
851 | }); | |
852 | ||
853 | var tagList = ''; | |
854 | cj("#manageTags input[name^=case_taglist]").each(function( ) { | |
855 | if (!tagsChecked) { | |
856 | tagsChecked = cj(this).val() + ''; | |
857 | } | |
858 | else { | |
859 | tagsChecked = tagsChecked + ',' + cj(this).val(); | |
860 | } | |
861 | }); | |
862 | ||
863 | var postUrl = {/literal}"{crmURL p='civicrm/case/ajax/processtags' h=0 }"{literal}; | |
864 | var data = 'case_id=' + caseID + '&tag=' + tagsChecked + '&key=' + {/literal}"{crmKey name='civicrm/case/ajax/processtags'}"{literal}; | |
865 | ||
866 | cj.ajax({ type: "POST", url: postUrl, data: data, async: false }); | |
867 | cj(this).dialog("close"); | |
868 | cj(this).dialog("destroy"); | |
869 | ||
870 | // Temporary workaround for problems with SSL connections being too | |
871 | // slow. The relationship doesn't get created because the page reload | |
872 | // happens before the ajax call. | |
873 | // In general this reload needs improvement, which is already on the list for phase 2. | |
874 | var sdate = (new Date()).getTime(); | |
875 | var curDate = sdate; | |
876 | while(curDate-sdate < 2000) { | |
877 | curDate = (new Date()).getTime(); | |
878 | } | |
879 | ||
880 | //due to caching issues we use redirection rather than reload | |
881 | document.location = {/literal}'{crmURL q="action=view&reset=1&id=$caseID&cid=$contactID&context=$context" h=0 }'{literal}; | |
882 | }, | |
883 | ||
884 | "Cancel": function() { | |
885 | cj(this).dialog("close"); | |
886 | cj(this).dialog("destroy"); | |
887 | } | |
888 | } | |
889 | }); | |
890 | } | |
891 | ||
892 | </script> | |
893 | {/literal} | |
894 | ||
895 | {/if} {* end of tag block*} | |
896 | ||
897 | {*include activity view js file*} | |
898 | {include file="CRM/common/activityView.tpl"} | |
899 | ||
900 | <div class="crm-accordion-wrapper crm-case_activities-accordion crm-case-activities-block"> | |
901 | <div class="crm-accordion-header"> | |
902 | {ts}Case Activities{/ts} | |
903 | </div> | |
904 | <div id="activities" class="crm-accordion-body"> | |
905 | <div id="view-activity"> | |
906 | <div id="activity-content"></div> | |
907 | </div> | |
908 | <div class="crm-accordion-wrapper crm-accordion-inner crm-search_filters-accordion collapsed"> | |
909 | <div class="crm-accordion-header"> | |
910 | {ts}Search Filters{/ts}</a> | |
911 | </div><!-- /.crm-accordion-header --> | |
912 | <div class="crm-accordion-body"> | |
913 | <table class="no-border form-layout-compressed" id="searchOptions"> | |
914 | <tr> | |
915 | <td class="crm-case-caseview-form-block-repoter_id"colspan="2"><label for="reporter_id">{ts}Reporter/Role{/ts}</label><br /> | |
916 | {$form.reporter_id.html|crmAddClass:twenty} | |
917 | </td> | |
918 | <td class="crm-case-caseview-form-block-status_id"><label for="status_id">{$form.status_id.label}</label><br /> | |
919 | {$form.status_id.html} | |
920 | </td> | |
921 | <td style="vertical-align: bottom;"> | |
922 | <span class="crm-button"><input class="form-submit default" name="_qf_Basic_refresh" value="Search" type="button" onclick="buildCaseActivities( true )"; /></span> | |
923 | </td> | |
924 | </tr> | |
925 | <tr> | |
926 | <td class="crm-case-caseview-form-block-activity_date_low"> | |
927 | {$form.activity_date_low.label}<br /> | |
928 | {include file="CRM/common/jcalendar.tpl" elementName=activity_date_low} | |
929 | </td> | |
930 | <td class="crm-case-caseview-form-block-activity_date_high"> | |
931 | {$form.activity_date_high.label}<br /> | |
932 | {include file="CRM/common/jcalendar.tpl" elementName=activity_date_high} | |
933 | </td> | |
934 | <td class="crm-case-caseview-form-block-activity_type_filter_id"> | |
935 | {$form.activity_type_filter_id.label}<br /> | |
936 | {$form.activity_type_filter_id.html} | |
937 | </td> | |
938 | </tr> | |
939 | {if $form.activity_deleted} | |
940 | <tr class="crm-case-caseview-form-block-activity_deleted"> | |
941 | <td> | |
942 | {$form.activity_deleted.html}{$form.activity_deleted.label} | |
943 | </td> | |
944 | </tr> | |
945 | {/if} | |
946 | </table> | |
947 | </div><!-- /.crm-accordion-body --> | |
948 | </div><!-- /.crm-accordion-wrapper --> | |
949 | ||
950 | <table id="activities-selector" class="nestedActivitySelector"> | |
951 | <thead><tr> | |
952 | <th class='crm-case-activities-date'>{ts}Date{/ts}</th> | |
953 | <th class='crm-case-activities-subject'>{ts}Subject{/ts}</th> | |
954 | <th class='crm-case-activities-type'>{ts}Type{/ts}</th> | |
955 | <th class='crm-case-activities-with'>{ts}With{/ts}</th> | |
956 | <th class='crm-case-activities-assignee'>{ts}Reporter / Assignee{/ts}</th> | |
957 | <th class='crm-case-activities-status'>{ts}Status{/ts}</th> | |
958 | <th class='crm-case-activities-status' id="nosort"> </th> | |
959 | <th class='hiddenElement'> </th> | |
960 | </tr></thead> | |
961 | </table> | |
962 | ||
963 | </div><!-- /.crm-accordion-body --> | |
964 | </div><!-- /.crm-accordion-wrapper --> | |
965 | ||
966 | {literal} | |
967 | <script type="text/javascript"> | |
968 | var oTable; | |
969 | ||
970 | function checkSelection( field ) { | |
971 | var validationMessage = ''; | |
972 | var validationField = ''; | |
973 | var successAction = ''; | |
974 | var forceValidation = false; | |
975 | ||
976 | var clientName = new Array( ); | |
977 | clientName = selectedContact.split('::'); | |
978 | var fName = field.name; | |
979 | ||
980 | switch ( fName ) { | |
981 | case '_qf_CaseView_next' : | |
982 | validationMessage = '{/literal}{ts escape="js"}Please select an activity set from the list.{/ts}{literal}'; | |
983 | validationField = 'timeline_id'; | |
984 | successAction = "confirm('{/literal}{ts escape='js'}Are you sure you want to add a set of scheduled activities to this case?{/ts}{literal}');"; | |
985 | break; | |
986 | ||
987 | case 'new_activity' : | |
988 | validationMessage = '{/literal}{ts escape="js"}Please select an activity type from the list.{/ts}{literal}'; | |
989 | validationField = 'activity_type_id'; | |
990 | if ( document.getElementById('activity_type_id').value == 3 ) { | |
991 | successAction = "window.location='{/literal}{$newActivityEmailUrl}{literal}' + document.getElementById('activity_type_id').value"; | |
992 | } | |
993 | else { | |
994 | successAction = "window.location='{/literal}{$newActivityUrl}{literal}' + document.getElementById('activity_type_id').value"; | |
995 | } | |
996 | break; | |
997 | ||
998 | case 'case_report' : | |
999 | validationMessage = '{/literal}{ts escape="js"}Please select a report from the list.{/ts}{literal}'; | |
1000 | validationField = 'report_id'; | |
1001 | successAction = "window.location='{/literal}{$reportUrl}{literal}' + document.getElementById('report_id').value"; | |
1002 | break; | |
1003 | ||
1004 | case '_qf_CaseView_next_merge_case' : | |
1005 | validationMessage = '{/literal}{ts escape="js"}Please select a case from the list to merge with.{/ts}{literal}'; | |
1006 | validationField = 'merge_case_id'; | |
1007 | break; | |
1008 | ||
1009 | case '_qf_CaseView_next_edit_client' : | |
1010 | validationMessage = '{/literal}{ts escape="js"}Please select a client for this case.{/ts}{literal}'; | |
1011 | if ( cj('#contact_id').val( ) == '{/literal}{$contactID}{literal}' ) { | |
1012 | forceValidation = true; | |
1013 | validationMessage = '{/literal}{ts 1="'+clientName[0]+'"}%1 is already assigned to this case. Please select some other client for this case.{/ts}{literal}'; | |
1014 | } | |
1015 | validationField = 'change_client_id'; | |
1016 | 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}' )"; | |
1017 | break; | |
1018 | } | |
1019 | ||
1020 | if ( forceValidation || ( document.getElementById( validationField ).value == '' ) ) { | |
1021 | cj('#'+validationField).crmError(validationMessage); | |
1022 | return false; | |
1023 | } | |
1024 | else if ( successAction ) { | |
1025 | return eval( successAction ); | |
1026 | } | |
1027 | } | |
1028 | ||
1029 | cj(function( ) { | |
1030 | buildCaseActivities(false); | |
1031 | }); | |
1032 | ||
1033 | function buildCaseActivities(filterSearch) { | |
1034 | if (filterSearch) { | |
1035 | oTable.fnDestroy(); | |
1036 | } | |
1037 | var count = 0; | |
1038 | var columns = ''; | |
1039 | var sourceUrl = {/literal}"{crmURL p='civicrm/ajax/activity' h=0 q='snippet=4&caseID='}{$caseID}"{literal}; | |
1040 | sourceUrl = sourceUrl + '&cid={/literal}{$contactID}{literal}'; | |
1041 | sourceUrl = sourceUrl + '&userID={/literal}{$userID}{literal}'; | |
1042 | ||
1043 | cj('#activities-selector th').each(function( ) { | |
1044 | if (cj(this).attr('id') != 'nosort') { | |
1045 | columns += '{"sClass": "' + cj(this).attr('class') +'"},'; | |
1046 | } | |
1047 | else { | |
1048 | columns += '{ "bSortable": false },'; | |
1049 | } | |
1050 | count++; | |
1051 | }); | |
1052 | ||
1053 | columns = columns.substring(0, columns.length - 1 ); | |
1054 | eval('columns =[' + columns + ']'); | |
1055 | ||
1056 | oTable = cj('#activities-selector').dataTable({ | |
1057 | "bFilter" : false, | |
1058 | "bAutoWidth" : false, | |
1059 | "aaSorting" : [], | |
1060 | "aoColumns" : columns, | |
1061 | "bProcessing": true, | |
1062 | "bJQueryUI": true, | |
1063 | "asStripClasses" : [ "odd-row", "even-row" ], | |
1064 | "sPaginationType": "full_numbers", | |
1065 | "sDom" : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>', | |
1066 | "bServerSide": true, | |
1067 | "sAjaxSource": sourceUrl, | |
1068 | "iDisplayLength": 10, | |
1069 | "fnDrawCallback": function() { setSelectorClass(); }, | |
1070 | "fnServerData": function ( sSource, aoData, fnCallback ) { | |
1071 | ||
1072 | if ( filterSearch ) { | |
1073 | var activity_deleted = 0; | |
1074 | if ( cj("#activity_deleted:checked").val() == 1 ) { | |
1075 | activity_deleted = 1; | |
1076 | } | |
1077 | aoData.push( | |
1078 | {name:'status_id', value: cj("select#status_id").val()}, | |
1079 | {name:'activity_type_id', value: cj("select#activity_type_filter_id").val()}, | |
1080 | {name:'activity_date_low', value: cj("#activity_date_low").val()}, | |
1081 | {name:'activity_date_high', value: cj("#activity_date_high").val() }, | |
1082 | {name:'activity_deleted', value: activity_deleted } | |
1083 | ); | |
1084 | } | |
1085 | cj.ajax( { | |
1086 | "dataType": 'json', | |
1087 | "type": "POST", | |
1088 | "url": sSource, | |
1089 | "data": aoData, | |
1090 | "success": fnCallback | |
1091 | } ); | |
1092 | } | |
1093 | }); | |
1094 | } | |
1095 | ||
1096 | function setSelectorClass( ) { | |
1097 | cj("#activities-selector td:last-child").each( function( ) { | |
1098 | cj(this).parent().addClass(cj(this).text() ); | |
1099 | }); | |
1100 | } | |
1101 | ||
1102 | function printCaseReport( ) { | |
1103 | var asn = 'standard_timeline'; | |
1104 | var dataUrl = {/literal}"{crmURL p='civicrm/case/report/print' q='all=1&redact=0' h='0'}"{literal}; | |
1105 | dataUrl = dataUrl + '&cid={/literal}{$contactID}{literal}' | |
1106 | + '&caseID={/literal}{$caseID}{literal}' | |
1107 | + '&asn={/literal}' + asn + '{literal}'; | |
1108 | ||
1109 | window.location = dataUrl; | |
1110 | } | |
1111 | ||
1112 | </script> | |
1113 | {/literal} | |
1114 | ||
1115 | <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div> | |
1116 | ||
1117 | {literal} | |
1118 | <script type="text/javascript"> | |
1119 | cj(function() { | |
1120 | cj().crmAccordions(); | |
1121 | }); | |
1122 | </script> | |
1123 | {/literal} | |
1124 | ||
1125 | {/if} {* view related cases if end *} | |
1126 | </div> |