CRM-13611 - Fix case detail report
authorColeman Watts <coleman@civicrm.org>
Tue, 9 Dec 2014 04:36:03 +0000 (23:36 -0500)
committerColeman Watts <coleman@civicrm.org>
Tue, 9 Dec 2014 04:36:03 +0000 (23:36 -0500)
CRM/Case/Page/AJAX.php
CRM/Report/Form/Case/Detail.php
templates/CRM/Report/Form/Case/Detail.tpl

index 30b5f08232045b216a1f6ab8a3eccf96e3dd0716..e685b96e185ef5ec300712accc9898db92e7be0a 100644 (file)
@@ -140,10 +140,15 @@ class CRM_Case_Page_AJAX {
                                     <tr><td>" . ts('Case Status') . "</td><td>{$cs}</td></tr>
                                     <tr><td>" . ts('Case Start Date') . "</td><td>" . CRM_Utils_Date::customFormat($dao->start_date) . "</td></tr>
                                     <tr><td>" . ts('Case End Date') . "</td><td></td></tr>" . CRM_Utils_Date::customFormat($dao->end_date) . "</table>";
-      echo $caseDetails;
+      if (CRM_Utils_Array::value('snippet', $_GET) == 'json') {
+        CRM_Core_Page_AJAX::returnJsonResponse($caseDetails);
+      }
+      else {
+        echo $caseDetails;
+      }
     }
     else {
-      echo ts('Could not find valid Case!');
+      CRM_Core_Error::fatal('Could not find valid Case.');
     }
     CRM_Utils_System::civiExit();
   }
index 0d88234558fbcfb3ee17a4f70ed6c6fc2ab81eb9..6596df1a855eac494aa7514020cd0ea7b87941e1 100644 (file)
@@ -600,9 +600,11 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form {
       }
       if (array_key_exists('civicrm_case_subject', $row)) {
         if ($value = $row['civicrm_case_subject']) {
-          $caseId = $row['civicrm_case_id'];
-          $contactId = $row['civicrm_contact_id'];
-          $rows[$rowNum]['civicrm_case_subject'] = "<a href= 'javascript:viewCase( $caseId,$contactId );'>$value</a>";
+          $url = CRM_Utils_System::url("civicrm/case/ajax/details",
+            "caseId={$row['civicrm_case_id']}&contactId={$row['civicrm_contact_id']}",
+            $this->_absoluteUrl
+          );
+          $rows[$rowNum]['civicrm_case_subject'] = "<a class=\"crm-popup\" href=\"$url\">$value</a>";
           $rows[$rowNum]['civicrm_case_subject_hover'] = ts('View Details of Case.');
 
           $entryFound = TRUE;
index 6767c16e5dcc2ac3cde86d079d31cef7139175b8..9d72b48002e49183eb3814ad8186832e53f61111 100644 (file)
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
 *}
-{if $section eq 1}
-    <div class="crm-block crm-content-block crm-report-layoutGraph-form-block">
-        {*include the graph*}
-        {include file="CRM/Report/Form/Layout/Graph.tpl"}
-    </div>
-    {elseif $section eq 2}
-    <div class="crm-block crm-content-block crm-report-layoutTable-form-block">
-        {*include the table layout*}
-        {include file="CRM/Report/Form/Layout/Table.tpl"}
-  </div>
-    {else}
-    <div class="crm-block crm-form-block crm-report-field-form-block">
-
-    {if !$printOnly} {* NO print section starts *}
-    <div {if !$criteriaForm}style="display: none;"{/if}> {* criteria section starts *}
-    <div class="crm-accordion-wrapper crm-report_criteria-accordion {if $rows}collapsed{/if}">
-    <div class="crm-accordion-header">
-    {ts}Report Criteria{/ts}
-    </div><!-- /.crm-accordion-header -->
-    <div class="crm-accordion-body">
-        <div id="id_{$formTpl}"> {* search section starts *}
-
-    {if $colGroups}
-        {if $componentName eq 'Grant'}
-            <h3>{ts}Include these Statistics{/ts}</h3>
-        {else}
-      <h3>Display Columns</h3>
-        {/if}
-        {foreach from=$colGroups item=grpFields key=dnc}
-            {assign  var="count" value="0"}
-            {* Wrap custom field sets in collapsed accordion pane. *}
-            {if $grpFields.group_title}
-                <div class="crm-accordion-wrapper crm-accordion collapsed">
-                    <div class="crm-accordion-header">
-                                    {$grpFields.group_title}
-                    </div><!-- /.crm-accordion-header -->
-                    <div class="crm-accordion-body">
-            {/if}
-            <table class="criteria-group">
-                <tr class="crm-report crm-report-criteria-field crm-report-criteria-field-{$dnc}">
-                    {foreach from=$grpFields.fields item=title key=field}
-                        {assign var="count" value=`$count+1`}
-                        <td width="25%">{$form.fields.$field.html}</td>
-                        {if $count is div by 4}
-                            </tr><tr class="crm-report crm-report-criteria-field crm-report-criteria-field_{$dnc}">
-                        {/if}
-                    {/foreach}
-                    {if $count is not div by 4}
-                        <td colspan="4 - ($count % 4)"></td>
-                    {/if}
-                </tr>
-            </table>
-            {if $grpFields.group_title}
-                    </div><!-- /.crm-accordion-body -->
-                </div><!-- /.crm-accordion-wrapper -->
-            {/if}
-        {/foreach}
-
-  <table class="criteria-group">
-  {foreach from=$caseDetailExtra key=field item=fieldDetail}
-      <tr class="crm-report crm-report-criteria-field crm-report-criteria-field-{$field}">
-          <td width="25%">{$fieldDetail.title}</td><td> {$form.case_detail_extra.$field.html}</td>
-      </tr>
-        {/foreach}
-  </table>
-    {/if}
-
-    {if $groupByElements}
-        <h3>Group by Columns</h3>
-        {assign  var="count" value="0"}
-        <table class="report-layout">
-            <tr class="crm-report crm-report-criteria-groupby">
-                {foreach from=$groupByElements item=gbElem key=dnc}
-                    {assign var="count" value=`$count+1`}
-                    <td width="25%" {if $form.fields.$gbElem} onClick="selectGroupByFields('{$gbElem}');"{/if}>
-                        {$form.group_bys[$gbElem].html}
-                        {if $form.group_bys_freq[$gbElem].html}:<br>
-                            &nbsp;&nbsp;{$form.group_bys_freq[$gbElem].label}&nbsp;{$form.group_bys_freq[$gbElem].html}
-                        {/if}
-                    </td>
-                    {if $count is div by 4}
-                        </tr><tr class="crm-report crm-report-criteria-groupby">
-                    {/if}
-                {/foreach}
-                {if $count is not div by 4}
-                    <td colspan="4 - ($count % 4)"></td>
-                {/if}
-            </tr>
-        </table>
-    {/if}
-
-    {if $form.options.html || $form.options.html}
-        <h3>Other Options</h3>
-        <table class="report-layout">
-            <tr class="crm-report crm-report-criteria-groupby">
-          <td>{$form.options.html}</td>
-          {if $form.blank_column_end}
-              <td>{$form.blank_column_end.label}&nbsp;&nbsp;{$form.blank_column_end.html}</td>
-                {/if}
-            </tr>
-        </table>
-    {/if}
-
-    {if $filters}
-        <h3>Set Filters</h3>
-        <table class="report-layout">
-      {assign var="counter" value=1}
-            {foreach from=$filters     item=table key=tableName}
-           {assign  var="filterCount" value=$table|@count}
-            {* Wrap custom field sets in collapsed accordion pane. *}
-          {if $colGroups.$tableName.group_title and $filterCount gte 1}
-        {* we should close table that contains other filter elements before we start building custom group accordian  *}
-        {if $counter eq 1}
-                </table>
-      {assign var="counter" value=0}
-        {/if}
-                    <div class="crm-accordion-wrapper crm-accordion collapsed">
-                    <div class="crm-accordion-header">
-                                    {$colGroups.$tableName.group_title}
-                    </div><!-- /.crm-accordion-header -->
-                    <div class="crm-accordion-body">
-                    <table class="report-layout">
-               {/if}
-                {foreach from=$table       item=field key=fieldName}
-                    {assign var=fieldOp     value=$fieldName|cat:"_op"}
-                    {assign var=filterVal   value=$fieldName|cat:"_value"}
-                    {assign var=filterMin   value=$fieldName|cat:"_min"}
-                    {assign var=filterMax   value=$fieldName|cat:"_max"}
-                    {if $field.operatorType & 4}
-                        <tr class="report-contents crm-report crm-report-criteria-filter crm-report-criteria-filter-{$tableName}">
-                            <td class="label report-contents">{$field.title}</td>
-                            {include file="CRM/Core/DateRange.tpl" fieldName=$fieldName from='_from' to='_to'}
-                        </tr>
-                    {elseif $form.$fieldOp.html}
-                        <tr class="report-contents crm-report crm-report-criteria-filter crm-report-criteria-filter-{$tableName}" {if $field.no_display} style="display: none;"{/if}>
-                            <td class="label report-contents">{$field.title}</td>
-                            <td class="report-contents">{$form.$fieldOp.html}</td>
-                            <td>
-                               <span id="{$filterVal}_cell">{$form.$filterVal.label}&nbsp;{$form.$filterVal.html}</span>
-                               <span id="{$filterMin}_max_cell">{$form.$filterMin.label}&nbsp;{$form.$filterMin.html}&nbsp;&nbsp;{$form.$filterMax.label}&nbsp;{$form.$filterMax.html}</span>
-                            </td>
-                        </tr>
-                    {/if}
-                {/foreach}
-                {if $colGroups.$tableName.group_title}
-                        </table>
-                        </div><!-- /.crm-accordion-body -->
-                    </div><!-- /.crm-accordion-wrapper -->
-                    {assign var=closed     value=1"} {*-- ie table tags are closed-- *}
-                {else}
-                     {assign var=closed     value=0"} {*-- ie table tags are not closed-- *}
-                {/if}
-
-            {/foreach}
-            {if $closed eq 0 }</table>{/if}
-    {/if}
-
-    {literal}
-    <script type="text/javascript">
-    {/literal}
-        {foreach from=$filters item=table key=tableName}
-            {foreach from=$table item=field key=fieldName}
-    {literal}var val = "dnc";{/literal}
-    {if !($field.operatorType == 4) && !$field.no_display}
-                    {literal}var val = document.getElementById("{/literal}{$fieldName}_op{literal}").value;{/literal}
-    {/if}
-                {literal}showHideMaxMinVal( "{/literal}{$fieldName}{literal}", val );{/literal}
-            {/foreach}
-        {/foreach}
-
-        {literal}
-        function showHideMaxMinVal( field, val ) {
-            var fldVal    = field + "_value_cell";
-            var fldMinMax = field + "_min_max_cell";
-            if ( val == "bw" || val == "nbw" ) {
-                cj('#' + fldVal ).hide();
-                cj('#' + fldMinMax ).show();
-            } else if (val =="nll" || val == "nnll") {
-                cj('#' + fldVal).hide() ;
-                cj('#' + field + '_value').val('');
-                cj('#' + fldMinMax ).hide();
-            } else {
-                cj('#' + fldVal ).show();
-                cj('#' + fldMinMax ).hide();
-            }
-        }
-
-  function selectGroupByFields(id) {
-      var field = 'fields\['+ id+'\]';
-      var group = 'group_bys\['+ id+'\]';
-      var groups = document.getElementById( group ).checked;
-      if ( groups == 1 ) {
-          document.getElementById( field ).checked = true;
-      } else {
-          document.getElementById( field ).checked = false;
-      }
-  }
-    </script>
-    {/literal}
-
-    <div>{$form.buttons.html}</div>
-    </div> {* search div section ends *}
-    </div><!-- /.crm-accordion-body -->
-    </div><!-- /.crm-accordion-wrapper -->
-    </div> {* criteria section ends *}
-
-    {if $instanceForm OR $instanceFormError} {* settings section starts *}
-    <div class="crm-accordion-wrapper crm-report_setting-accordion {if $rows}collapsed{/if}">
-    <div class="crm-accordion-header" {if $updateReportButton} onclick="cj('#update-button').hide(); return false;" {/if} >
-    {if $mode eq 'template'}{ts}Create Report{/ts}{else}{ts}Report Settings{/ts}{/if}
-    </div><!-- /.crm-accordion-header -->
-    <div class="crm-accordion-body">
-        <div id="id_{$instanceForm}">
-                <div id="instanceForm">
-                    {include file="CRM/Report/Form/Instance.tpl"}
-                    {assign var=save value="_qf_"|cat:$form.formName|cat:"_submit_save"}
-                        <div class="crm-submit-buttons">
-                            {$form.$save.html}
-                        </div>
-                </div>
-        </div>
-    </div><!-- /.crm-accordion-body -->
-    </div><!-- /.crm-accordion-wrapper -->
-    {if $updateReportButton}
-      <div id='update-button' class="crm-submit-buttons">
-    {$form.$save.html}
-    </div>
-    {/if}
-    {/if} {* settings section ends *}
-
-    {/if} {* NO print section ends *}
-
-
-    </div>
-
-    <div class="crm-block crm-content-block crm-report-form-block">
-        {*include actions*}
-        {include file="CRM/Report/Form/Actions.tpl"}
-
-        {*Statistics at the Top of the page*}
-        {include file="CRM/Report/Form/Statistics.tpl" top=true}
-
-        {*include the graph*}
-        {include file="CRM/Report/Form/Layout/Graph.tpl"}
-
-        {*include the table layout*}
-        {include file="CRM/Report/Form/Layout/Table.tpl"}
-      <br />
-        {*Statistics at the bottom of the page*}
-        {include file="CRM/Report/Form/Statistics.tpl" bottom=true}
-
-        {include file="CRM/Report/Form/ErrorMessage.tpl"}
-    </div>
-{/if}
-
-<div id="casedetails"></div>
-{literal}
-<script type="text/javascript">
-function viewCase( caseId ,contactId ) {
-   cj("#casedetails").dialog({
-        title: "Case Details",
-        modal: true,
-        width : 700,
-  height: 400,
-        open:function() {
-       var dataUrl = {/literal}"{crmURL p='civicrm/case/ajax/details' h=0 q="snippet=4" }"{literal};
-      dataUrl     = dataUrl + '&caseId=' +caseId + '&contactId=' +contactId ;
-    cj.ajax({
-                         url     : dataUrl,
-                         dataType: "html",
-                         timeout : 5000, //Time in milliseconds
-                         success : function( data ){
-                             cj( "#casedetails").html( data ).trigger('crmLoad');
-                       },
-                   });
-    },
-
-               buttons: { "Done": function() { cj(this).dialog("destroy"); }}
-    });
-}
-</script>
-{/literal}
+{include file="CRM/Report/Form.tpl"}