https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16631

--- Comment #49 from Casey Conlin <[email protected]> ---
Comment on attachment 184847
  --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=184847
Bug 16631: [DO NOT PUSH] Add schema files for reports_branches and adjust
saved_sql table

>From 04bb1e1220d059f1d28b48de8a5d095912311ef6 Mon Sep 17 00:00:00 2001
>From: "Cameron E. Tidd" <[email protected]>
>Date: Sat, 26 Jul 2025 02:02:50 +0000
>Subject: [PATCH 1/2] Bug 16631: [DO NOT PUSH] Add schema files for
> reports_branches and adjust saved_sql table
>MIME-Version: 1.0
>Content-Type: text/plain; charset=UTF-8
>Content-Transfer-Encoding: 8bit
>
>This patch adds the reports_branches table to enforce library limits for 
>reports, and adjusts the saved_sql table to point to reports_branches.
>
> Sponsored-by: The Ramapo Catskill Library System
>Test plan:
>Confirm Initial Settings
>1. Log in to Koha staff and set your library as Centerville if itâs not 
>already.
>2. Visit the Saved reports.
>3. Three (3) previously created reports should be visible.
>
>Verify Patch Settings
>4. From the Koha Sandbox, Apply the patch, then Restart services.
>5. Go to the System Preferences page (Click the More dropdown from the top nav 
>bar, click Administration, click System Preferences).
>6. Verify Reports is an option in the left side navigation bar, and that when 
>clicked, you see the EnableFilteringReports option.
>7. Enable EnableFilteringReports as described in step 6.
>8. Go back to Saved reports as in Step 2.
>9. Click Edit in the row menu for Report 1.
>10. At the bottom of the Report 1 edit page, you should see a Library 
>limitation select box.
>
>Verify the Library Limitation Settings are Persisted
>11. Choose Centerville from the select box and click Update SQL.
>12. Reload the page, or navigate away from the page and go back to the edit 
>screen for Report 1.
>13. Verify that Centerville is still in the Library limitation select box.
>14. Add Fairfield in the Library limitation select box and click Update and 
>run SQL.
>15. Go back to editing Report 1.
>16. Confirm the Library limitation select box has both Centerville and 
>Fairfield selected.
>17. Duplicate Report 1.
>18. Confirm the Library limitation select box has both Centerville and 
>Fairfield selected.
>19. Click Save Report.
>20. Confirm the Library limitation select box has both Centerville and 
>Fairfield selected.
>
>Verify Reports are Filtered Based on Library Limitations
>21. Go to Saved reports as in Step 2.
>22. Click Edit for Report 2.
>23. Add Fairfield in the Library limitation select box as the only choice and 
>click Update and run SQL.
>24. Go to Saved reports as in Step 2.
>25. Confirm you do not see Report 2, and only Report 1 and Report 3.
>26. In the upper right corner, click the drop down that says koha Centerville 
>and click Set library to change your library.
>27. Set your library to Fairfield.
>28. Go to Saved reports as in Step 2.
>29. Confirm you do not see Report 1, and only Report 2 and Report 3.
>
>Verify Disabling EnableFilteringReports Preference Shows All Reports
>30. Disable EnableFilteringReports preference as in steps 5 to 7.
>31. Go to Saved reports as in Step 2.
>32. Confirm Report 1, Report 2, Report 3 are visible.
>33. Click to edit Report 1 and verify there is no Library limitation select 
>box.
>
>Verify Library limitations are Persisted When EnableFilteringReports is 
>Toggled On or Off
>34. Enable EnableFilteringReports preference as in steps 5 to 7.
>35. Ensure youâre library is set to Fairfield as in step 26.
>36. Go to Saved reports as in Step 2.
>37. Confirm Report 1 is not visible, and Report 2 and Report 3 are visible.
>38. Click to edit Report 2 and verify the Library limitation select box is at 
>the bottom of the page and that it has Fairfield selected.
>
>Run Unit Tests
>39. In the Koha home directory run the command: prove 
>t/db_dependent/Koha/Reports.t
>40. The new unit tests for the reprots_branches tables are in this file
>41. All tests should pass.
>
>Signoff
>42. Sign off if the steps above checkout.
>---
> Koha/Schema/Result/ReportsBranch.pm |  86 ++++++++++++++
> Koha/Schema/Result/SavedSql.pm      | 220 ++++++++++++++++++++++++++++++++++++
> 2 files changed, 306 insertions(+)
> create mode 100644 Koha/Schema/Result/ReportsBranch.pm
>
>diff --git a/Koha/Schema/Result/ReportsBranch.pm 
>b/Koha/Schema/Result/ReportsBranch.pm
>new file mode 100644
>index 0000000000..80472a5ff1
>--- /dev/null
>+++ b/Koha/Schema/Result/ReportsBranch.pm
>@@ -0,0 +1,86 @@
>+use utf8;
>+
>+package Koha::Schema::Result::ReportsBranch;
>+
>+# Created by DBIx::Class::Schema::Loader
>+# DO NOT MODIFY THE FIRST PART OF THIS FILE
>+
>+=head1 NAME
>+
>+Koha::Schema::Result::ItemtypesBranch
>+
>+=cut
>+
>+use strict;
>+use warnings;
>+
>+use base 'DBIx::Class::Core';
>+
>+=head1 TABLE: C<itemtypes_branches>
>+
>+=cut
>+
>+__PACKAGE__->table("reports_branches");
>+
>+=head1 ACCESSORS
>+
>+=head2 report_id
>+
>+  data_type: 'varchar'
>+  is_foreign_key: 1
>+  is_nullable: 1
>+  size: 80
>+
>+=head2 branchcode
>+
>+  data_type: 'varchar'
>+  is_foreign_key: 1
>+  is_nullable: 0
>+  size: 10
>+
>+=cut
>+
>+__PACKAGE__->add_columns(
>+    "report_id",
>+    { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 
>80 },
>+    "branchcode",
>+    { data_type => "varchar", is_foreign_key => 1, is_nullable => 0, size => 
>10 },
>+);
>+
>+=head1 RELATIONS
>+
>+=head2 branchcode
>+
>+Type: belongs_to
>+
>+Related object: L<Koha::Schema::Result::Branch>
>+
>+=cut
>+
>+__PACKAGE__->belongs_to(
>+    "branchcode",
>+    "Koha::Schema::Result::Branch",
>+    { branchcode    => "branchcode" },
>+    { is_deferrable => 1, on_delete => "CASCADE", on_update => "RESTRICT" },
>+);
>+
>+=head2 itemtype
>+
>+Type: belongs_to
>+
>+Related object: L<Koha::Schema::Result::Itemtype>
>+
>+=cut
>+
>+__PACKAGE__->belongs_to(
>+    "report_id",
>+    "Koha::Schema::Result::Report",
>+    { report_id     => "report_id" },
>+    { is_deferrable => 1, on_delete => "CASCADE", on_update => "RESTRICT" },
>+);
>+
>+# Created by DBIx::Class::Schema::Loader v0.07048 @ 2019-07-04 04:56:48
>+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:cBTswjKV8VWN1iueB+PygQ
>+
>+# You can replace this text with custom code or comments, and it will be 
>preserved on regeneration
>+1;
>diff --git a/Koha/Schema/Result/SavedSql.pm b/Koha/Schema/Result/SavedSql.pm
>index 6f75ae3b31..88d54b52ef 100644
>--- a/Koha/Schema/Result/SavedSql.pm
>+++ b/Koha/Schema/Result/SavedSql.pm
>@@ -185,6 +185,221 @@ __PACKAGE__->add_columns(
> 
> __PACKAGE__->set_primary_key("id");
> 
>+=head1 RELATIONS
>+
>+=head2 reports_branches
>+
>+Type: has_many
>+
>+Related object: L<Koha::Schema::Result::ReportsBranch>
>+
>+=cut
>+
>+__PACKAGE__->has_many(
>+  "reports_branches",
>+  "Koha::Schema::Result::ReportsBranch",
>+  { "foreign.report_id" => "self.id" },
>+  { cascade_copy => 0, cascade_delete => 0 },
>+);
>+
>+
>+# Created by DBIx::Class::Schema::Loader v0.07051 @ 2025-07-26 01:58:59
>+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:w7XKvOV/ylS6Dq8tsUNmSg
>+# These lines were loaded from 
>'/kohadevbox/koha/Koha/Schema/Result/SavedSql.pm' found in @INC.
>+# They are now part of the custom portion of this file
>+# for you to hand-edit.  If you do not either delete
>+# this section or remove that file from @INC, this section
>+# will be repeated redundantly when you re-create this
>+# file again via Loader!  See skip_load_external to disable
>+# this feature.
>+
>+use utf8;
>+package Koha::Schema::Result::SavedSql;
>+
>+# Created by DBIx::Class::Schema::Loader
>+# DO NOT MODIFY THE FIRST PART OF THIS FILE
>+
>+=head1 NAME
>+
>+Koha::Schema::Result::SavedSql
>+
>+=cut
>+
>+use strict;
>+use warnings;
>+
>+use base 'DBIx::Class::Core';
>+
>+=head1 TABLE: C<saved_sql>
>+
>+=cut
>+
>+__PACKAGE__->table("saved_sql");
>+
>+=head1 ACCESSORS
>+
>+=head2 id
>+
>+  data_type: 'integer'
>+  is_auto_increment: 1
>+  is_nullable: 0
>+
>+unique id and primary key assigned by Koha
>+
>+=head2 borrowernumber
>+
>+  data_type: 'integer'
>+  is_nullable: 1
>+
>+the staff member who created this report (borrowers.borrowernumber)
>+
>+=head2 date_created
>+
>+  data_type: 'datetime'
>+  datetime_undef_if_invalid: 1
>+  is_nullable: 1
>+
>+the date this report was created
>+
>+=head2 last_modified
>+
>+  data_type: 'datetime'
>+  datetime_undef_if_invalid: 1
>+  is_nullable: 1
>+
>+the date this report was last edited
>+
>+=head2 savedsql
>+
>+  data_type: 'mediumtext'
>+  is_nullable: 1
>+
>+the SQL for this report
>+
>+=head2 last_run
>+
>+  data_type: 'datetime'
>+  datetime_undef_if_invalid: 1
>+  is_nullable: 1
>+
>+=head2 report_name
>+
>+  data_type: 'varchar'
>+  default_value: (empty string)
>+  is_nullable: 0
>+  size: 255
>+
>+the name of this report
>+
>+=head2 type
>+
>+  data_type: 'varchar'
>+  is_nullable: 1
>+  size: 255
>+
>+always 1 for tabular
>+
>+=head2 notes
>+
>+  data_type: 'mediumtext'
>+  is_nullable: 1
>+
>+the notes or description given to this report
>+
>+=head2 cache_expiry
>+
>+  data_type: 'integer'
>+  default_value: 300
>+  is_nullable: 0
>+
>+=head2 public
>+
>+  data_type: 'tinyint'
>+  default_value: 0
>+  is_nullable: 0
>+
>+=head2 report_area
>+
>+  data_type: 'varchar'
>+  is_nullable: 1
>+  size: 6
>+
>+=head2 report_group
>+
>+  data_type: 'varchar'
>+  is_nullable: 1
>+  size: 80
>+
>+=head2 report_subgroup
>+
>+  data_type: 'varchar'
>+  is_nullable: 1
>+  size: 80
>+
>+=head2 mana_id
>+
>+  data_type: 'integer'
>+  is_nullable: 1
>+
>+=cut
>+
>+__PACKAGE__->add_columns(
>+  "id",
>+  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
>+  "borrowernumber",
>+  { data_type => "integer", is_nullable => 1 },
>+  "date_created",
>+  {
>+    data_type => "datetime",
>+    datetime_undef_if_invalid => 1,
>+    is_nullable => 1,
>+  },
>+  "last_modified",
>+  {
>+    data_type => "datetime",
>+    datetime_undef_if_invalid => 1,
>+    is_nullable => 1,
>+  },
>+  "savedsql",
>+  { data_type => "mediumtext", is_nullable => 1 },
>+  "last_run",
>+  {
>+    data_type => "datetime",
>+    datetime_undef_if_invalid => 1,
>+    is_nullable => 1,
>+  },
>+  "report_name",
>+  { data_type => "varchar", default_value => "", is_nullable => 0, size => 
>255 },
>+  "type",
>+  { data_type => "varchar", is_nullable => 1, size => 255 },
>+  "notes",
>+  { data_type => "mediumtext", is_nullable => 1 },
>+  "cache_expiry",
>+  { data_type => "integer", default_value => 300, is_nullable => 0 },
>+  "public",
>+  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
>+  "report_area",
>+  { data_type => "varchar", is_nullable => 1, size => 6 },
>+  "report_group",
>+  { data_type => "varchar", is_nullable => 1, size => 80 },
>+  "report_subgroup",
>+  { data_type => "varchar", is_nullable => 1, size => 80 },
>+  "mana_id",
>+  { data_type => "integer", is_nullable => 1 },
>+);
>+
>+=head1 PRIMARY KEY
>+
>+=over 4
>+
>+=item * L</id>
>+
>+=back
>+
>+=cut
>+
>+__PACKAGE__->set_primary_key("id");
>+
> 
> # Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-01-21 13:39:29
> # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:198dNG9DGQzop+s5IHy7sw
>@@ -214,3 +429,8 @@ sub koha_objects_class {
> }
> 
> 1;
>+# End of lines loaded from '/kohadevbox/koha/Koha/Schema/Result/SavedSql.pm'
>+
>+
>+# You can replace this text with custom code or comments, and it will be 
>preserved on regeneration
>+1;
>-- 
>2.15.0
>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to