Bug 38663

Summary: Add additional fields to libraries
Product: Koha Reporter: Pedro Amorim <pedro.amorim>
Component: Staff interfaceAssignee: Pedro Amorim <pedro.amorim>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: dcook, gmcharlt, martin.renvoize
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:
Circulation function:
Bug Depends on: 38662    
Bug Blocks: 38457    
Attachments: Bug 38663: [DONT PUSH] Preparation: Change record_id to varchar: DBIC
Bug 38663: Preparation: Change record_id to varchar: database
Bug 38663: Add libraries table to additional fields admin screen
Bug 38663: DBIC: Add AdditionalFields to Library
Bug 38663: Add AdditionalFields to Library
Bug 38663: Add AdditionalFields to Library

Description Pedro Amorim 2024-12-10 11:14:30 UTC

    
Comment 1 Pedro Amorim 2024-12-10 15:18:37 UTC
Created attachment 175355 [details] [review]
Bug 38663: [DONT PUSH] Preparation: Change record_id to varchar: DBIC
Comment 2 Pedro Amorim 2024-12-10 15:18:39 UTC
Created attachment 175356 [details] [review]
Bug 38663: Preparation: Change record_id to varchar: database

record_if in the additional_field_values is an int(11)
This works for most cases, but in the branches case, the id column is
actually a varchar (branchcode).
This patch updates the column to accomodate for this.
Comment 3 Pedro Amorim 2024-12-10 15:18:41 UTC
Created attachment 175357 [details] [review]
Bug 38663: Add libraries table to additional fields admin screen
Comment 4 Pedro Amorim 2024-12-10 15:18:43 UTC
Created attachment 175358 [details] [review]
Bug 38663: DBIC: Add AdditionalFields to Library
Comment 5 Pedro Amorim 2024-12-10 15:18:45 UTC
Created attachment 175359 [details] [review]
Bug 38663: Add AdditionalFields to Library

Test plan, k-t-d:
1) Add a new additional field to 'branches':
  <staff_url>/cgi-bin/koha/admin/additional-fields.pl?tablename=branches
2) Click 'New field'. Add a name. Click Save.
3) Repeat step 2 but repeatable. Repeat again for 2 more of AV category
   (one repeatable, one not repeatable)
4) Edit a library:
  <staff_url>/cgi-bin/koha/admin/branches.pl?op=add_form&branchcode=CPL
5) Input various values in the different additional fields. Click
   'Submit'
6) Visit the detail page of the library and verify the additional fields
   data is displayed correctly:
<staff_url>/cgi-bin/koha/admin/branches.pl?op=view&branchcode=CPL
Comment 6 Pedro Amorim 2024-12-11 10:30:51 UTC
Created attachment 175370 [details] [review]
Bug 38663: Add AdditionalFields to Library

Test plan, k-t-d:
1) Add a new additional field to 'branches':
  <staff_url>/cgi-bin/koha/admin/additional-fields.pl?tablename=branches
2) Click 'New field'. Add a name. Click Save.
3) Repeat step 2 but repeatable. Repeat again for 2 more of AV category
   (one repeatable, one not repeatable)
4) Edit a library:
  <staff_url>/cgi-bin/koha/admin/branches.pl?op=add_form&branchcode=CPL
5) Input various values in the different additional fields. Click
   'Submit'
6) Visit the detail page of the library and verify the additional fields
   data is displayed correctly:
<staff_url>/cgi-bin/koha/admin/branches.pl?op=view&branchcode=CPL
Comment 7 David Cook 2024-12-12 04:21:26 UTC
It's a good question. Historically, I think we'd say branches should be converted to have a branch_id. 

Once upon a time, reserve_id didn't exist (see Bug 7065), but that was a long time ago and a different set of circumstances... (e.g. it didn't have a primary key at all)

Technically, I suppose we could keep branchcode as the PK, and maybe just add an autoincrementing branch_id int(11) with a UNIQUE constraint. 

I don't know enough about additional_field_values to know if that would be workable or not though
Comment 8 David Cook 2024-12-12 04:23:01 UTC
One day, it would be cool to switch from autoincrementing integers to UUIDs, which are less prone to enumeration attacks, but that's a whole other story...