Jump to content

Create a Report Generator in Admin


NooseLadder
 Share

Recommended Posts

Hi,

I am looking to create a report generator for my client's admin. I currently have this table from:

$bookings = $pages->find("template=the_form_submission, sort=-booking_date"); 

post-564-0-53270000-1380632699_thumb.jpg

I would like to have one report template where you can select the fields to appear on the report (like a filter) in select (dropdown) for each column, or just select the fields and auto-generate the appropriate number of columns with headings. This will be for the client to use in the admin.

Any help appreciated as always.

Link to comment
Share on other sites

I think you may be asking for something broader in scope than can be answered in a forum post. There are any number of ways to do it, but I would try and find a good jQuery table plugin (perhaps ajax driven) that provides some of what you already need and take it from there. Retrieving the data to display in your table from ProcessWire will be the easy part. 

Link to comment
Share on other sites

  • 1 month later...

I've finally got round to looking at this. Would Soma's DataTable module be a good starting point for this? If I create a template with the required fields for my reports and modify the module markup accordingly, would that work?

Just thinking a bit further. I've loaded Soma's DataTable module. I wouldn't know how to go about this, but it looks as though the module is part-way towards what I am trying to achieve. There is a selector/fllter for the Templates. Could this be extended so that when a template is selected, a selector/filter for the fields in that template can be used to select the columns for the table.

Example

Template called 'Bookings'.

'Bookings' has the following fields: title, firstName, lastName, dateOfBirth, age, gender, address1, address2, town, postCode, homeTel, mobile, email, courseBooked, bookingDate, courseDate, courseClosingDate, coursePrice, agreeToTerms, depositPaid, invNum.

But I only want some of these fields to appear in the DataTable: firstName, lastName, email, courseDate, courseBooked, bookingDate, depositPaid.

After the template is selected, I need a filter to select the fields for the DataTable columns, using the field Label as the column heading.

Can anyone point me in the right direction please?

Edited by NooseLadder
Link to comment
Share on other sites

I've not had experience with the DataTable module, so replying more to bump the topic up to someone that has. But everything you've mentioned sounds feasible to me (outside of any specific module), but would no doubt involve significant development. 

Link to comment
Share on other sites

NooseLadder, I have a requirement for something like this.

I've had a look at the different options for returning a JSON containing specific data, which could then be fed straight into a JQuery reporting plugin (eg dataTables). The problem with selectors is they don't allow you to specify which fields should be returned.

I've looked at creating a specific page in the front-end which could take a selector AND a list of fields as a query string and just return a JSON, but I think this would be a massive security risk.

I'm now looking into the possibility of creating a process in the admin based on ProcessPageSearch, which could accept a list of fields to be returned and return everything as JSON.

Link to comment
Share on other sites

I can now see ProcessPageSearch does exactly what I want with the following example:

/page/search/for?parent=/&display=title+modified

If called in with ajax it returns a JSON with: id, parent_id, template, path, name as standard, then whatever fields are specified in the 'display' parameter

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...
I've looked at creating a specific page in the front-end which could take a selector AND a list of fields as a query string and just return a JSON, but I think this would be a massive security risk.

It would be a security risk, which is why ProcessPageSearch only works from the admin side. However, if you grab the ServicePages module, that essentially gives you a safety net/mediator between ProcessPageSearch and your front-end. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...