⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Aggregate Functions



Vrajesh

Vrajesh
  • profile picture
  • Member

Posted 31 January 2017 - 17:00 PM

I need to display custom summary reports of Billable, Non-Billable and Total hours which will be:

Employee wise, Weekly, Monthly, Project wise, Based on Date range which requires extensive use of aggregate functions. Please guide me how do I proceed to get these calculations done in grocery crud. 

 

Is there any callback function that can be called before_display which can be used to do needful calculation and simply display data.

Total hrs = Billable hrs + Non Billable hrs, which needs to be calculated dynamically based on filter applied. Also let me know, if there is any custom library available for performing aggregate function while displaying data.

 

Please help. Thank You.


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 01 February 2017 - 06:20 AM

Well if u want to display the output in a column (in each row) ... u surely can do the following:

 

1: add a extra column .. indicating the same.

2: add a callback to the column which will calculate the values as desired and return the same.

 

If there is another requirement - do express the exact desire .. so a proper solution can be applied / set.

 

Happy GCing:)


Vrajesh

Vrajesh
  • profile picture
  • Member

Posted 07 February 2017 - 07:09 AM

Thank You Amit for the response. Can you tell which callback function I should go for. Actually I want the value of aggregate function only for display purpose, but there are no such callback function l found like callback_before_display. I am new to Grocery CRUD callback functions. I would be very much thankful if you can explain it with some example. The requirement is, "In the database table 'employee' daily data of project billing hrs for employee is added, there is one of the column called 'bill_hrs'. At the end of the month, in the result, I want records showing name of Project with their total_billable_hrs (sum of projectwise bill hours). 


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 08 February 2017 - 09:06 AM

Hi Vrajesh,

 

There aint any specific callback functions to do that.. a callback is basically a feature provided by the library for you to hook into your own custom code for a given criteria .. like since u want to have an aggregate value for a specific column .. u have to create a callback function for that column and hook it to the column .. in that function you need to write up your logic that will suffice your needs.

 

http://www.grocerycrud.com/documentation/options_functions/callback_column

here u can refer to the document for the same and achieve your desired functionality.

 

Happy GCing :)