Bug 7335

Summary: Allow custom parameters for sorting in SQL reports
Product: Koha Reporter: Katrin Fischer <katrin.fischer>
Component: ReportsAssignee: Galen Charlton <gmcharlt>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P5 - low CC: bibliwho, blawlor, kebliss, mspinney
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:

Description Katrin Fischer 2011-12-08 13:39:32 UTC
I was trying to find a solution to make it possible to select how a report is sorted before running it.

Perhaps we could have a table sorter on tables generated by reports? 

I tried using the placeholders to provide a pull down with search options, but this didn't work. The replaced text is always in quotes, so the generated sql will not work:

select concat(surname, ", ", firstname) as Name, cardnumber from borrowers order by 'cardnumber desc'
Comment 1 Cab Vinton 2018-06-06 16:02:25 UTC
This is a bit kludgy, but I believe it works:

Report for patrons w/ emails:

SELECT cardnumber, surname, firstname, email, dateexpiry, dateenrolled
FROM borrowers
WHERE email IS NOT NULL AND email!= ''
ORDER BY CASE WHEN @SortOrder:=<<Search order>> = 'dateexpiry' THEN dateexpiry
              WHEN @SortOrder= 'cardnumber' THEN cardnumber
         END

Official column names have to be used rather than something more user-friendly, but otherwise it's