From a5b7464c8afac9180f85582165b0846de5db2a16 Mon Sep 17 00:00:00 2001 From: The Minh Luong Date: Tue, 8 Feb 2022 17:22:30 -0500 Subject: [PATCH] Bug 28556: Guarantor's information is available in notice This patch adds the guarantor's information when sending overdue notice. To test: 1. Make sure that there is an overdue letter. a) Go in Tools/Notices & Slips. b) Search for the code "ODUE" and note the "Name" of the letter. c) Click on "Edit". d) Click on "Email" and make sure that there is text inside the box. e) Add the following code in the textbox: C/O <> <>
Or add another guarantor. in the textbox from the select list. f) Click on "Save". 2. Set up the status trigger. a) Go in Tools/Overdue notice/status triggers. b) In "First" tab, put a number of days in the "Delay" column (ex: 1). c) In the column "Letter", put the "Name" of the letter of step 1a) . d) Check "Email". e) Click "Save". 3. Create a patron with a guarantor. a) Go in Administration/Patron categories. b) Create a child category AND a adult category. c) Create an adult patron. d) Create a child patron. e) Go in the child patron's page and click "Edit". f) In the "Patron guarantor" section, click add guarantor. g) Search for your adult patron and click "Select". h) Select a relationship for the guarantor (ex: Mother). i) Click on "Save". 4. Borrow an overdue item. a) Click on the arrow next to "Search button" (Top of the screen). b) Click on "Items search". c) Click on search. d) Copy a barcode in the list. e) Search for your child patron. f) Go in his page and click on "Checkout". g) Paste the barcode copied at step 4d) . h) Click on "Checkout settings". i) Put a date in the past greater than the number of days that you put on step 2b). j) Click on "Check out". k) Click on "Yes" Notice tht there is a message saying that Patron has ITEMS OVERDUE. 5. Test the patch. a) In the terminal, run ./misc/cronjobs/overdue_notices.pl b) Return in your child patron's page. c) Click on "Notice" and you should see a letter. d) Click on the letter to see the content. c) Notice that you can't see the guarantor's informations (Adult patron). d) Apply the patch. e) Repeat steps a) to d) f) Notice that you can see the guarantor's informations. This also works if you decide to add a non-patron guarantor instead of a patron guarantor at step 3. NOTE: If you want to delete the letters, go in your database and run: - delete from message_queue; Signed-off-by: Marius Mandrescu --- C4/Letters.pm | 1 + C4/Overdues.pm | 1 + tools/letter.pl | 15 +++++++++++---- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index a28319d5bd..560772d5a8 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -740,6 +740,7 @@ sub _parseletter_sth { ($table eq 'old_issues' ) ? "SELECT * FROM $table WHERE issue_id = ?" : ($table eq 'reserves' ) ? "SELECT * FROM $table WHERE borrowernumber = ? and biblionumber = ?" : ($table eq 'borrowers' ) ? "SELECT * FROM $table WHERE borrowernumber = ?" : + ($table eq 'guarantor' ) ? "SELECT * FROM borrowers INNER JOIN borrower_relationships ON borrower_relationships.guarantee_id = ? WHERE borrowernumber = borrower_relationships.guarantor_id " : ($table eq 'branches' ) ? "SELECT * FROM $table WHERE branchcode = ?" : ($table eq 'suggestions' ) ? "SELECT * FROM $table WHERE suggestionid = ?" : ($table eq 'aqbooksellers') ? "SELECT * FROM $table WHERE id = ?" : diff --git a/C4/Overdues.pm b/C4/Overdues.pm index 3076217380..1256ec5059 100644 --- a/C4/Overdues.pm +++ b/C4/Overdues.pm @@ -821,6 +821,7 @@ sub parse_overdues_letter { if ( my $p = $params->{'branchcode'} ) { $tables{'branches'} = $p; } + $tables{guarantor}=$params->{'borrowernumber'}; my $active_currency = Koha::Acquisition::Currencies->get_active; diff --git a/tools/letter.pl b/tools/letter.pl index 775921533d..d38d2e6683 100755 --- a/tools/letter.pl +++ b/tools/letter.pl @@ -227,7 +227,7 @@ sub add_form { my $field_selection; push @{$field_selection}, add_fields('branches'); if ($module eq 'reserves') { - push @{$field_selection}, add_fields('borrowers', 'reserves', 'biblio', 'biblioitems', 'items'); + push @{$field_selection}, add_fields('borrowers', 'borrower_relationships', 'reserves', 'biblio', 'biblioitems', 'items'); } elsif ( $module eq 'acquisition' ) { push @{$field_selection}, add_fields('aqbooksellers', 'aqorders', 'biblio', 'items'); @@ -239,17 +239,18 @@ sub add_form { push @{$field_selection}, add_fields('aqbooksellers', 'serial', 'subscription', 'biblio', 'biblioitems'); } elsif ($module eq 'serial') { - push @{$field_selection}, add_fields('branches', 'biblio', 'biblioitems', 'borrowers', 'subscription', 'serial'); + push @{$field_selection}, add_fields('branches', 'biblio', 'biblioitems', 'borrowers', 'borrower_relationships', 'subscription', 'serial'); } elsif ($module eq 'suggestions') { - push @{$field_selection}, add_fields('suggestions', 'borrowers', 'biblio'); + push @{$field_selection}, add_fields('suggestions', 'borrowers', 'borrower_relationships', 'biblio'); } else { push @{$field_selection}, add_fields('biblio','biblioitems'), add_fields('items'), {value => 'items.content', text => 'items.content'}, {value => 'items.fine', text => 'items.fine'}, - add_fields('borrowers'); + add_fields('borrowers'), + add_fields('borrower_relationships'); if ($module eq 'circulation') { push @{$field_selection}, add_fields('additional_contents', 'recalls'); @@ -496,6 +497,12 @@ sub get_columns_for { my $sql = "SHOW COLUMNS FROM $table";# TODO not db agnostic my $table_prefix = $table . q|.|; + + if($table eq 'borrower_relationships'){ + $sql = "SHOW COLUMNS FROM borrowers";# TODO not db agnostic + $table_prefix = 'guarantor' . q|.|; + } + my $rows = C4::Context->dbh->selectall_arrayref($sql, { Slice => {} }); for my $row (@{$rows}) { next if $row->{'Field'} eq 'timestamp'; # this is really an irrelevant field and there may be other common fields that should be excluded from the list -- 2.34.1