Bug 7993

Summary: saved report with hierarchies
Product: Koha Reporter: delaye <stephane.delaye>
Component: ReportsAssignee: Srdjan Jankovic <srdjan>
Status: CLOSED FIXED QA Contact: Mason James <mtj>
Severity: enhancement    
Priority: P5 - low CC: chris, claire.hernandez, jonathan.druart, julian.maurice, koha.aixmarseille, mtj, paul.poulain
Version: 3.10   
Hardware: All   
OS: All   
Change sponsored?: Sponsored Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on:    
Bug Blocks: 8811    
Attachments: bug_7993: Save reports with Group/Subgroup hierarchy
Bug 7993: Save reports with Group/Subgroup hierarchy
[SIGNED-OFF] Bug 7993: Save reports with Group/Subgroup hierarchy
bug_7993: Save reports with Group/Subgroup hierarchy
Bug 7993 Follow-up
[SIGNED-OFF] Bug 7993 Follow-up
Bug 7993: Several bug fixes
Signed off patch
Bug 7993: Save reports with Group/Subgroup hierarchy
Bug 7993: Save reports with Group/Subgroup hierarchy

Description delaye 2012-04-23 09:28:11 UTC
1/For the customer:
  -  They wants to create themselves their topics (no freezed topics)
  -  He could move report from a hierarchy to another (modify)
  -  They need 2 level of hierarchy

Suggests to use 2 authorised value lists: "GROUP" "SUBGROUP"
When you register or modify a report, you first choose a "group" (code) and then a "subbgroup" (lib_opac wich represent the link between both).

Liste N1 : GROUP

Code lib lib_opac
CIRC Circulation PRT
CIRC Circulation RET
CAT Catalogage BIB
CAT Catalogage EX
CAT Catalogage AUT
...etc

Liste N2 : SUB_GROUP

Code lib lib_OPAC
PRT PRETS CIRC
RET RETOURS CIRC
BIB NOTICES BIB CAT
EX NOTICES EX CAT
AUT NOTICES AUT CAT 

2 / From "Summary and Statistics" when saving the report, a proposal from the list of tabs (hierarchy) to classify the report as a topic of their choice.

3 / From .../cgi-bin/koha/reports/guided_reports.pl?phase=
First show the top of hierarchies as tabs and then clicking on the opening of the hierarchy.
Reports will be provided in a table with headers that are sortable.


4 / After you save the report ( .../cgi-bin/koha/reports/guided_reports.pl ) add a link from this page 'Start the new report'.

5 / Keep the link "Reports saved" under
 .../cgi-bin/koha/reports/guided_reports.pl?phase=
But adding to the table "standard" one column "Posted in" going back the way the report is filed.
Columns should also be sortable.
Comment 1 Srdjan Jankovic 2012-06-21 00:23:54 UTC Comment hidden (obsolete)
Comment 2 Jared Camins-Esakov 2012-07-02 18:16:59 UTC Comment hidden (obsolete)
Comment 3 Jonathan Druart 2012-07-30 08:51:06 UTC
This patch does not apply :
CONFLICT (content): Merge conflict in svc/report
CONFLICT (content): Merge conflict in opac/svc/report
CONFLICT (content): Merge conflict in installer/data/mysql/updatedatabase.pl
CONFLICT (content): Merge conflict in C4/Reports/Guided.pm
Comment 4 Julian Maurice 2012-08-17 09:55:36 UTC Comment hidden (obsolete)
Comment 5 Julian Maurice 2012-08-17 09:56:13 UTC
Patch rebased on current master and tested OK.
Comment 6 Jonathan Druart 2012-08-17 11:53:52 UTC
QA comments:
The qa tools says me the patch introduces wrong lines in a tt file:
- xt/tt_valid.t tests... FAIL
	intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt: 520, 610, 727, 828 FAIL

See Bug 8407 for more information.

Please correct this and remove some useless commented lines (in opac/svc/report : else{warn})

Marked as Failed QA
Comment 7 Srdjan Jankovic 2012-08-20 05:38:23 UTC Comment hidden (obsolete)
Comment 8 Srdjan Jankovic 2012-08-20 05:41:22 UTC
I apologise but I did not know how to make a follow-up because I had conflicts when rebasing.
Can you please either
a) obsolete the signed-off patch and sign off the new one, or
b) tell me how to produce a follow-up
Comment 9 Julian Maurice 2012-08-20 07:26:59 UTC Comment hidden (obsolete)
Comment 10 Julian Maurice 2012-08-20 07:41:46 UTC
Hello Srdjan,

I made this follow-up by applying your patch over the initial one and resolving the conflicts. Please tell me if it contains all your changes (and nothing else).

What did you do to have conflicts with signed-off patch? It's up-to-date according to master. Maybe you tried to apply the patch on a local branch not recently updated.
To make a follow-up, just write another commit (if you are rebasing, fix your conflicts, git rebase --continue until you have finished, and then make another commit). Does it answer your question?
Comment 11 Srdjan Jankovic 2012-08-20 23:08:50 UTC
Thanks for that Julian, it looks good.

What I did was rebased my local branch that I used for the patch to the master and got conflicts. At that point I was not sure which would be the starting point for my follow-up. So what I did was pretty much what you described, just need to know where to anchor my follow-up patch.
Comment 12 Julian Maurice 2012-08-23 11:40:29 UTC Comment hidden (obsolete)
Comment 13 Julian Maurice 2012-08-23 11:41:11 UTC
This patch is ok, but I found a problem with the first patch. I will submit another follow-up.
Comment 14 Julian Maurice 2012-08-23 11:41:58 UTC Comment hidden (obsolete)
Comment 15 Chris Cormack 2012-08-23 21:33:50 UTC Comment hidden (obsolete)
Comment 16 Jonathan Druart 2012-09-07 12:22:58 UTC
Patch does not apply
CONFLICT (content): Merge conflict in reports/guided_reports.pl
CONFLICT (content): Merge conflict in installer/data/mysql/updatedatabase.pl
Comment 17 Srdjan Jankovic 2012-09-10 01:21:20 UTC Comment hidden (obsolete)
Comment 18 Paul Poulain 2012-09-11 08:10:13 UTC
Patch tested with a sandbox, by Delaye Stephane <stephane.delaye@biblibre.com>
Comment 19 Paul Poulain 2012-09-11 08:10:35 UTC
Created attachment 12126 [details] [review]
Bug 7993: Save reports with Group/Subgroup hierarchy

This should make saved reports more manageable.
Group/Subgroup hierarchy is stored in authorised_values,
categories REPORT_GROUP and REPORT_SUBGROUP, connected by
REPORT_SUBGROUP.lib_opac -> REPORT_GROUP.authorised_value

Database changes:
* authorised_values: expanded category to 16 chars
* created default set of REPORT_GROUP authorised values to match
  hardcoded report areas
* reports_dictionary: replaced area int with report_area text, converted
  values
* saved_sql: added report_area, report_group and report_subgroup;
  report_area is not currently used, saved for the record

C4/Reports/Guided.pm:
* Replaced Area numeric values with the mnemonic codes
* get_report_areas(): returns hardcoded areas list
* created get_report_areas(): returns full hierarchy (groups with belonging
  subgroups)
* save_report(): changed iterface, accepts fields hashref as input
* update_sql(): changed iterface, accepts id and fields hashref as input
* get_saved_reports():]
- join to authorised_values to pick group and subgroup name
- accept group and subgroup filter params
* get_saved_report():
- changed iterface, return record hashref
- join to authorised_values to pick group and subgroup name
* build_authorised_value_list(): new sub, moved code from
  reports/guided_reports.pl
* Updated interfaces in:
cronjobs/runreport.pl, svc/report, opac/svc/report: get_saved_report()
reports/dictionary.pl: get_report_areas()
reports/guided_reports.pl

reports/guided_reports_start.tt:
* Reports list:
- added group/subgroup filter
- display area/group/subgroup for the reports
* Create report wizard:
- carry area to the end
- select group and subgroup when saving the report; group defaults to area,
  useful when report groups match areas
* Update report and Create from SQL: added group/subgroup
* Amended reports/guided_reports.pl accordingly

Conflicts:

    C4/Reports/Guided.pm
    admin/authorised_values.pl
    installer/data/mysql/kohastructure.sql
    installer/data/mysql/updatedatabase.pl
    koha-tmpl/intranet-tmpl/prog/en/modules/reports/dictionary.tmpl
    koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tmpl
    misc/cronjobs/runreport.pl
    reports/dictionary.pl
    reports/guided_reports.pl

Signed-off-by: Delaye Stephane <stephane.delaye@biblibre.com>
Comment 20 Mason James 2012-09-16 14:31:06 UTC
(In reply to comment #19)
> Created attachment 12126 [details] [review]
> Bug 7993: Save reports with Group/Subgroup hierarchy
> > Signed-off-by: Delaye Stephane <stephane.delaye@biblibre.com>

patch looks good, passing QA…
 
$ koha-qa.pl  

testing 1 commit(s) (applied to commit 3f31617)
 * 4d90348 Bug 7993: Save reports with Group/Subgroup hierarchy
      C4/Reports/Guided.pm
      admin/authorised_values.pl
      installer/data/mysql/kohastructure.sql
      installer/data/mysql/updatedatabase.pl
      koha-tmpl/intranet-tmpl/prog/en/modules/reports/dictionary.tt
      koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt
      misc/cronjobs/runreport.pl
      opac/svc/report
      reports/dictionary.pl
      reports/guided_reports.pl
      svc/report

* C4/Reports/Guided.pm                                                     OK
* admin/authorised_values.pl                                               OK
* installer/data/mysql/updatedatabase.pl                                   OK
* misc/cronjobs/runreport.pl                                               OK
* reports/dictionary.pl                                                    OK
* reports/guided_reports.pl                                                OK
* koha-tmpl/intranet-tmpl/prog/en/modules/reports/dictionary.tt            OK
* koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt  OK
Comment 21 Paul Poulain 2012-09-18 16:21:24 UTC
Patch pushed to master

However, a few questions/glitches:
 * the "type" and "Area" columns can't be filled when you edit an SQL directly, and can't be updated anyway. Shouldn't we do something for that ?
 * Shouldn't group/sub-group be the first columns ?
 * do we need the ID displayed ?
 * on my laptop, the "Notes" tab is really small, and would not deserve be larger (we could put subgroup in the same column as group, because it will not be used everyday
 * why are author column and date not sortable ?
Comment 22 Paul Poulain 2012-09-19 10:13:27 UTC
Jenkins complain because of an incorrect pod doc. I've pushed a follow-up to fix it.
Comment 23 Julian Maurice 2012-11-22 10:50:07 UTC
Ok in master