compucorp / uk.co.compucorp.civicrm.pivotreport

CiviCRM Pivot table reporting solution
Other
8 stars 13 forks source link

WIP-PCHR-3431: Reports Milestone One POC. #107

Closed tunbola closed 3 years ago

tunbola commented 6 years ago

This is not a proper PR per say but a proof of concept to demonstrate how to use the Pivot report extension to display the People reports in CiviHR.

contact pivot report _ staging17 2018-03-16 19-23-40

contact pivot report _ staging17 2018-03-16 19-28-01

Limitations

Caching

Date Filters

Recommendations

update on making the extension work with Leave Report

I tried to see how to get the Leave Report working with the pivot report extension as is, I came up with the following API call:

  $result = civicrm_api3('LeaveRequest', 'get', array(
    'sequential' => 1,
    'return' => array("contact_id", "type_id", "status_id", "request_type"),
    'api.Contact.get' => array(
      'id' => "\$value.contact_id", 
      'return' => array("display_name", "birth_date", "gender_id")
    ),
    'api.HRJobContract.get' => array(
      'contact_id' => "\$value.contact_id", 
      'return' => array("position", "title", "contract_type", "period_start_date", "period_end_date", "is_current", "jobcontract_revision_id"), 

      'api.HRJobHour.get' => array(
        'jobcontract_revision_id' => "\$value.jobcontract_revision_id"
      ),

      'api.HRJobPay.get' => array(
        'jobcontract_revision_id' => "\$value.jobcontract_revision_id",
        'sequential' => 1,
      ),
      'api.HrJobRoles.get' => array('sequential' => 1, 'job_contract_id' => "\$value.id"),
    ),
    'api.LeaveRequestDate.get' => array(
      'leave_request_id' => "\$value.id"),
      'api.LeaveBalanceChange.get' => array('source_id' => "\$value.id", 'source_type' => "leave_request_day"),
  ));

The results for some fields would still need to be modified either via handlers or in the logic when results are fetched e.g Employee Age group(by modifying the birth_date field), Employee Age, Absence Is Credit(by modifying the request_type field), Absence Day of Week, Absence Start Month, Absence End month.... The API calls to api.HRJobPay.get and api.HRJobHour.get did not return any results, This seems to be because the jobcontract_revision_id field returned by the Job contract API is not a true field of the Entity per say because the field actually belongs to the HRJobDetails Entity.

Update on other extensions injecting their report.

I tried making the People report to reside in L&A extension and it was successful to some extent.

jamienovick commented 6 years ago

@tunbola @davialexandre can we also consider making the caching mechanism optional in some way? Perhaps that doesn't need to be part of this first milestone but please keep it in mind in case we do want to simplify this point.

jamienovick commented 6 years ago

Also - in terms of the "supported entities" vs "reports".

In future we will want to iterate to a scenario where we have a base "report templates" which define the available fields, filters and perhaps features and then an individual "report instance" which is the configured report (previously our report configurations available from the dropdown). each report instance would be listed in a report listing, then have a separate menu link to open up and view it, can be emailed automatically and also should be available for CiviCRM dashboard.

Whilst I think we support this data structure already, I think we should try and get the terminology correct now if that is possible.

tunbola commented 6 years ago

@jamienovick , Will take a look at how to decouple the caching mechanism but tbh, the whole extension seems to depend on this caching mechanism as all the reports are pulled from the caching table. Will see if its possible to decouple to fetch data in real time but I wonder how effective this would be considering that even the current L&A reports fetch data from views whose data are refreshed at some intervals. Regarding the Report instance listing, I think we have the structure in place like you rightly said but will pay more attention to the terminologies and implementation.

tunbola commented 3 years ago

Not needed anymore