Bugzilla – Attachment 172649 Details for
Bug 10190
Overdue notice triggers based on item type
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10190: Remove old overduerules interface
Bug-10190-Remove-old-overduerules-interface.patch (text/plain), 34.44 KB, created by
Martin Renvoize (ashimema)
on 2024-10-10 16:20:40 UTC
(
hide
)
Description:
Bug 10190: Remove old overduerules interface
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-10-10 16:20:40 UTC
Size:
34.44 KB
patch
obsolete
>From 5759d12dadf263008ed32ad8541dc7355fa49576 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 15 Aug 2024 10:18:33 +0100 >Subject: [PATCH] Bug 10190: Remove old overduerules interface > >This patch updates the link from the tools homepage to open the new >circulation triggers administration page. > >We then remove the old overduerules controller and template, and finally >we drop the no longer referenced >C4::Overdues::GetOverdueMessageTransportTypes method and associated unit >tests. > >Sponsored-by: Glasgow Colleges Library Group <https://library.cityofglasgowcollege.ac.uk> >Signed-off-by: George Harkins <George.Harkins@cityofglasgowcollege.ac.uk> >--- > C4/Overdues.pm | 34 -- > .../prog/en/includes/tools-menu.inc | 2 +- > .../prog/en/modules/tools/overduerules.tt | 211 ------------ > .../prog/en/modules/tools/tools-home.tt | 2 +- > t/db_dependent/Overdues.t | 62 +--- > tools/overduerules.pl | 309 ------------------ > 6 files changed, 4 insertions(+), 616 deletions(-) > delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/tools/overduerules.tt > delete mode 100755 tools/overduerules.pl > >diff --git a/C4/Overdues.pm b/C4/Overdues.pm >index 8c0d3b149f3..60ec751b917 100644 >--- a/C4/Overdues.pm >+++ b/C4/Overdues.pm >@@ -52,7 +52,6 @@ BEGIN { > GetBranchcodesWithOverdueRules > get_chargeable_units > GetOverduesForBranch >- GetOverdueMessageTransportTypes > parse_overdues_letter > GetIssuesIteminfo > ); >@@ -755,39 +754,6 @@ sub GetOverduesForBranch { > } > } > >-=head2 GetOverdueMessageTransportTypes >- >- my $message_transport_types = GetOverdueMessageTransportTypes( $branchcode, $categorycode, $letternumber); >- >- return a arrayref with all message_transport_type for given branchcode, categorycode and letternumber(1,2 or 3) >- >-=cut >- >-sub GetOverdueMessageTransportTypes { >- my ( $branchcode, $categorycode, $letternumber ) = @_; >- return unless $categorycode and $letternumber; >- my $dbh = C4::Context->dbh; >- my $sth = $dbh->prepare(" >- SELECT message_transport_type >- FROM overduerules odr LEFT JOIN overduerules_transport_types ott USING (overduerules_id) >- WHERE branchcode = ? >- AND categorycode = ? >- AND letternumber = ? >- "); >- $sth->execute( $branchcode, $categorycode, $letternumber ); >- my @mtts; >- while ( my $mtt = $sth->fetchrow ) { >- push @mtts, $mtt; >- } >- >- # Put 'print' in first if exists >- # It avoid to sent a print notice with an email or sms template is no email or sms is defined >- @mtts = uniq( 'print', @mtts ) >- if grep { $_ eq 'print' } @mtts; >- >- return \@mtts; >-} >- > =head2 parse_overdues_letter > > parses the letter template, replacing the placeholders with data >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc >index b106cffbea8..34cd98f630d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc >@@ -26,7 +26,7 @@ > <li><a href="/cgi-bin/koha/tools/letter.pl">Notices and slips</a></li> > [% END %] > [% IF ( CAN_user_tools_edit_notice_status_triggers ) %] >- <li><a href="/cgi-bin/koha/tools/overduerules.pl">Overdue notice/status triggers</a></li> >+ <li><a href="/cgi-bin/koha/admin/circulation_triggers">Overdue notice/status triggers</a></li> > [% END %] > [% IF ( CAN_user_tools_label_creator ) %] > <li><a href="/cgi-bin/koha/patroncards/home.pl">Patron card creator</a></li> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/overduerules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/overduerules.tt >deleted file mode 100644 >index c14e3e728e4..00000000000 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/overduerules.tt >+++ /dev/null >@@ -1,211 +0,0 @@ >-[% USE raw %] >-[% USE Asset %] >-[% USE Koha %] >-[% USE Branches %] >-[% PROCESS 'i18n.inc' %] >-[% SET footerjs = 1 %] >-[% INCLUDE 'doc-head-open.inc' %] >-<title>[% FILTER collapse %] >- [% t("Overdue notice/status triggers") | html %] › >- [% t("Tools") | html %] › >- [% t("Koha") | html %] >-[% END %]</title> >-[% INCLUDE 'doc-head-close.inc' %] >-</head> >- >-<body id="tools_overduerules" class="tools"> >-[% WRAPPER 'header.inc' %] >- [% INCLUDE 'cat-search.inc' %] >-[% END %] >- >-[% WRAPPER 'sub-header.inc' %] >- [% WRAPPER breadcrumbs %] >- [% WRAPPER breadcrumb_item %] >- <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> >- [% END %] >- [% WRAPPER breadcrumb_item bc_active= 1 %] >- <span>Overdue notice/status triggers</span> >- [% END %] >- [% END #/ WRAPPER breadcrumbs %] >-[% END #/ WRAPPER sub-header.inc %] >- >-<div class="main container-fluid"> >- <div class="row"> >- <div class="col-md-10 order-md-2 order-sm-1"> >- <main> >- [% INCLUDE 'messages.inc' %] >- >- <h1>Defining [% IF ( branch ) %]overdue actions for [% Branches.GetName( branch ) | html %][% ELSE %]default overdue actions[% END %]</h1> >- <div class="help"> >- <p>Delay is the number of days after a checkout is due before an action is triggered. </p> >- <p>If you want Koha to trigger an action (send a letter or restrict a member), a delay value is required.</p> >- <p>Columns must be filled left to right: if the first column is blank, other columns will be ignored. </p> >- </div> >- <form method="get" action="/cgi-bin/koha/tools/overduerules.pl" id="selectlibrary"> >- <label for="branch">Select a library:</label> >- <select id="branch" name="branch"> >- <option value="">Default</option> >- [% PROCESS options_for_libraries libraries => Branches.all( selected => branch ) %] >- </select> >- <input type="submit" class="btn btn-primary" value="Select" /> >- </form> >- [% IF ( ERROR ) %] >- <div class="alert alert-warning"> >- <h3>Data error</h3> >- <p>The following errors were found. Please correct them and submit again:</p> >- <ul> >- [% IF ( ERRORDELAY ) %] >- <li>Delay [% ERRORDELAY | html %] for [% BORERR | html %] patron category has some unexpected characters. There should be only numerical characters. </li> >- [% END %] >- [% IF ( ERRORUSELESSDELAY ) %] >- <li>No letter or restriction action specified for delay [% ERRORUSELESSDELAY | html %] for [% BORERR | html %] patron category. If a delay is supplied, either a letter, restrict action, or both should be specified.</li> >- [% END %] >- [% IF ( ERRORORDER ) %] >- <li>The first notice's delay should be less than the second, which should be less than the third for the <strong>[% BORERR | html %]</strong> patron category </li> >- [% END %] >- </ul> >- </div> >- [% END %] >- [% IF ( table ) %] >- <form method="post" id="overduerulesf" action="/cgi-bin/koha/tools/overduerules.pl"> >- [% INCLUDE 'csrf-token.inc' %] >- <input type="hidden" name="op" value="cud-save" /> >- <input type="hidden" name="branch" value="[% branch | html %]" /> >- <h3>Rules for overdue actions: [% IF ( branch ) %][% Branches.GetName( branch ) | html %][% ELSE %] default library [% END %]</h3> >- [% IF ( datasaved ) %]<div class="alert alert-info">Changes saved.</div> [% END %] >- >- [% WRAPPER tabs id= "rulestabs" %] >- [% WRAPPER tabs_nav %] >- [% FOR tab IN tabs %] >- [% WRAPPER tab_item tabname= tab.id %][% END %] >- [% END %] >- [% END # /WRAPPER tabs_nav %] >- >- [% WRAPPER tab_panels %] >- [% FOR tab IN tabs %] >- [% WRAPPER tab_panel tabname=tab.id %] >- <table class="overduerulest" id="overduerulest-[% tab.id | html %]"> >- <thead> >- <tr> >- <th>Patron category</th> >- <th class="NoSort" scope="col">Delay</th> >- <th class="NoSort" scope="col">Letter</th> >- <th class="NoSort" scope="col">Restrict</th> >- [% FOREACH mtt IN message_transport_types %] >- [% NEXT IF mtt == 'itiva' AND !Koha.Preference('TalkingTechItivaPhoneNotification') %] >- [% NEXT IF mtt == 'phone' AND !Koha.Preference('PhoneNotification') %] >- <th class="NoSort" scope="col"> >- [% SWITCH mtt %] >- [% CASE 'email' %]<span>Email</span> >- [% CASE 'print' %]<span>[% tp('Message transport type', 'Print') | html %]</span> >- [% CASE 'sms' %]<span>SMS</span> >- [% CASE 'feed' %]<span>Feed</span> >- [% CASE 'itiva' %]<span>Phone (i-tiva)</span> >- [% CASE 'phone' %]<span>Phone</span> >- [% CASE %]<span>[% mtt | html %]</span> >- [% END %] >- </th> >- [% END %] >- </tr> >- </thead> >- <tbody> >- [% FOREACH value IN tab.values %] >- <tr> >- <th scope="row">[% value.line | html %]</th> >- <td> >- <input type="text" inputmode="numeric" pattern="[0-9]*" name="delay[% tab.number | html %]-[% value.overduename | html %]" value="[% value.delay | html %]" /> >- </td> >- <td> >- <select name="letter[% tab.number | html %]-[% value.overduename | html %]"> >- <option value="">No notice</option> >- [% FOREACH letter IN letters %] >- [% IF letter.code == value.selected_lettercode %] >- <option value="[% letter.code | html %]" selected="selected">[% letter.name | html %] ( [% letter.code | html %] )</option> >- [% ELSE %] >- <option value="[% letter.code | html %]">[% letter.name | html %] ( [% letter.code | html %] )</option> >- [% END %] >- [% END %] >- </select> >- </td> >- <td> >- [% IF ( value.debarred ) %] >- <input type="checkbox" name="debarred[% tab.number | html %]-[% value.overduename | html %]" checked="checked" value="1" /> >- [% ELSE %] >- <input type="checkbox" name="debarred[% tab.number | html %]-[% value.overduename | html %]" value="1" /> >- [% END %] >- </td> >- [% FOREACH mtt IN value.message_transport_types %] >- [% NEXT IF mtt.value == 'itiva' AND !Koha.Preference('TalkingTechItivaPhoneNotification') %] >- [% NEXT IF mtt.value == 'phone' AND !Koha.Preference('PhoneNotification') %] >- <td> >- [% IF mtt.selected %] >- <input type="checkbox" name="mtt[% tab.number | html %]-[% value.overduename | html %]" value="[% mtt.value | html %]" checked="checked" /> >- [% ELSE %] >- [% IF mtt.value == "sms" and not Koha.Preference("SMSSendDriver") %] >- <input type="checkbox" name="mtt[% tab.number | html %]-[% value.overduename | html %]" value="[% mtt.value | html %]" disabled="disabled" /> >- [% ELSE %] >- <input type="checkbox" name="mtt[% tab.number | html %]-[% value.overduename | html %]" value="[% mtt.value | html %]" /> >- [% END %] >- [% END %] >- </td> >- [% END # /FOREACH mtt %] >- </tr> >- [% END # /FOREACH value %] >- </tbody> >- </table> >- [% END # /tab_panel# %] >- [% END %] >- [% END # /WRAPPER tab_panels %] >- [% END # /WRAPPER tabs %] >- >- <fieldset class="action"><input type="submit" class="btn btn-primary" value="Save changes" /></fieldset> >- </form> >- [% ELSE %] >- <div class="warning">You don't have patron categories defined, or the patron categories are not set to receive overdue notices.</div> >- <div class="warning">If this is not what you were expecting, go to <a href="../admin/categories.pl">patron categories</p></div> >- [% END %] >- >- </main> >- </div> <!-- /.col-md-10.order-md-2 --> >- >- <div class="col-md-2 order-sm-2 order-md-1"> >- <aside> >- [% INCLUDE 'tools-menu.inc' %] >- </aside> >- </div> <!-- /.col-md-2.order-md-1 --> >- </div> <!-- /.row --> >- >-[% MACRO jsinclude BLOCK %] >- [% Asset.js("js/tools-menu.js") | $raw %] >- [% INCLUDE 'datatables.inc' %] >- <script> >- var tab_map = { "0" : _("First"), "1" : _("Second"), "2" : _("Third")}; >- $(document).ready(function() { >- $('#selectlibrary').find("input:submit").hide(); >- $('#branch').change(function() { >- $('#selectlibrary').submit(); >- }); >- $("#rulestabs li > a").each( function( i ){ >- $(this).html(tab_map[ i ]); >- }); >- if( $("#rulestabs .tab-pane.active").length < 1 ){ >- $("#rulestabs a:first").tab("show"); >- } >- $(".overduerulest").dataTable($.extend(true, {}, dataTablesDefaults, { >- "aoColumnDefs": [ >- { "targets": [ "NoSort" ], "orderable": false, "searchable": false }, >- ], >- "dom": '<"top pager"f>rt<"clear">', >- "paginate": false, >- })); >- >- $("#overduerulesf").on("submit", function(e){ >- $(".overduerulest").DataTable().search('').draw(); >- return true; >- }); >- >- }); >- </script> >-[% END %] >- >-[% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt >index c63b73cbc8e..46398b35c1e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt >@@ -65,7 +65,7 @@ > [% END %] > > [% IF ( CAN_user_tools_edit_notice_status_triggers ) %] >- <dt><a href="/cgi-bin/koha/tools/overduerules.pl">Overdue notice/status triggers</a></dt> >+ <dt><a href="/cgi-bin/koha/admin/circulation_triggers">Overdue notice/status triggers</a></dt> > <dd>Set notice/status triggers for overdue items</dd> > [% END %] > >diff --git a/t/db_dependent/Overdues.t b/t/db_dependent/Overdues.t >index 78be653025d..697515c1b09 100755 >--- a/t/db_dependent/Overdues.t >+++ b/t/db_dependent/Overdues.t >@@ -1,7 +1,7 @@ > #!/usr/bin/perl; > > use Modern::Perl; >-use Test::More tests => 18; >+use Test::More tests => 8; > use Test::Warn; > > use C4::Context; >@@ -11,8 +11,7 @@ use Koha::Libraries; > use t::lib::Mocks; > use t::lib::TestBuilder; > >-use_ok('C4::Overdues', qw( GetOverdueMessageTransportTypes GetBranchcodesWithOverdueRules UpdateFine )); >-can_ok('C4::Overdues', 'GetOverdueMessageTransportTypes'); >+use_ok('C4::Overdues', qw( GetBranchcodesWithOverdueRules UpdateFine )); > can_ok('C4::Overdues', 'GetBranchcodesWithOverdueRules'); > > my $schema = Koha::Database->new->schema; >@@ -24,63 +23,6 @@ my $dbh = C4::Context->dbh; > $dbh->do(q|DELETE FROM letter|); > $dbh->do(q|DELETE FROM message_queue|); > $dbh->do(q|DELETE FROM message_transport_types|); >-$dbh->do(q|DELETE FROM overduerules|); >-$dbh->do(q|DELETE FROM overduerules_transport_types|); >- >-$dbh->do(q| >- INSERT INTO message_transport_types( message_transport_type ) VALUES ('email'), ('phone'), ('print'), ('sms') >-|); >- >-$dbh->do(q| >- INSERT INTO overduerules ( overduerules_id, branchcode, categorycode ) VALUES >- (1, 'CPL', 'PT'), >- (2, 'CPL', 'YA'), >- (3, '', 'PT'), >- (4, '', 'YA') >-|); >- >-$dbh->do(q|INSERT INTO overduerules_transport_types (overduerules_id, letternumber, message_transport_type) VALUES >- (1, 1, 'email'), >- (1, 2, 'sms'), >- (1, 3, 'email'), >- (2, 3, 'print'), >- (3, 1, 'email'), >- (3, 2, 'email'), >- (3, 2, 'sms'), >- (3, 3, 'sms'), >- (3, 3, 'email'), >- (3, 3, 'print'), >- (4, 2, 'sms') >-|); >- >-my $mtts; >- >-$mtts = C4::Overdues::GetOverdueMessageTransportTypes('CPL', 'PT'); >-is( $mtts, undef, 'GetOverdueMessageTransportTypes: returns undef if no letternumber given' ); >- >-$mtts = C4::Overdues::GetOverdueMessageTransportTypes('CPL', undef, 1); >-is( $mtts, undef, 'GetOverdueMessageTransportTypes: returns undef if no categorycode given' ); >- >-$mtts = C4::Overdues::GetOverdueMessageTransportTypes('CPL'); >-is( $mtts, undef, 'GetOverdueMessageTransportTypes: returns undef if no letternumber and categorycode given' ); >- >-$mtts = C4::Overdues::GetOverdueMessageTransportTypes('CPL', 'PT', 1); >-is_deeply( $mtts, ['email'], 'GetOverdueMessageTransportTypes: first overdue is by email for PT (CPL)' ); >- >-$mtts = C4::Overdues::GetOverdueMessageTransportTypes('CPL', 'PT', 2); >-is_deeply( $mtts, ['sms'], 'GetOverdueMessageTransportTypes: second overdue is by sms for PT (CPL)' ); >- >-$mtts = C4::Overdues::GetOverdueMessageTransportTypes('CPL', 'PT', 3); >-is_deeply( $mtts, ['email'], 'GetOverdueMessageTransportTypes: third overdue is by email for PT (CPL)' ); >- >-$mtts = C4::Overdues::GetOverdueMessageTransportTypes('', 'PT', 1); >-is_deeply( $mtts, ['email'], 'GetOverdueMessageTransportTypes: first overdue is by email for PT (default)' ); >- >-$mtts = C4::Overdues::GetOverdueMessageTransportTypes('', 'PT', 2); >-is_deeply( $mtts, ['email', 'sms'], 'GetOverdueMessageTransportTypes: second overdue is by email and sms for PT (default)' ); >- >-$mtts = C4::Overdues::GetOverdueMessageTransportTypes('', 'PT', 3); >-is_deeply( $mtts, ['print', 'sms', 'email'], 'GetOverdueMessageTransportTypes: third overdue is by print, sms and email for PT (default). With print in first.' ); > > # Test GetBranchcodesWithOverdueRules > $dbh->do(q|DELETE FROM circulation_rules WHERE rule_name LIKE 'overdue_%' |); >diff --git a/tools/overduerules.pl b/tools/overduerules.pl >deleted file mode 100755 >index 4ebc6d44f5f..00000000000 >--- a/tools/overduerules.pl >+++ /dev/null >@@ -1,309 +0,0 @@ >-#!/usr/bin/perl >- >-# Copyright 2000-2002 Katipo Communications >-# >-# This file is part of Koha. >-# >-# Koha is free software; you can redistribute it and/or modify it >-# under the terms of the GNU General Public License as published by >-# the Free Software Foundation; either version 3 of the License, or >-# (at your option) any later version. >-# >-# Koha is distributed in the hope that it will be useful, but >-# WITHOUT ANY WARRANTY; without even the implied warranty of >-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >-# GNU General Public License for more details. >-# >-# You should have received a copy of the GNU General Public License >-# along with Koha; if not, see <http://www.gnu.org/licenses>. >- >-use Modern::Perl; >-use CGI qw ( -utf8 ); >-use C4::Context; >-use C4::Output qw( output_html_with_http_headers ); >-use C4::Auth qw( get_template_and_user ); >-use C4::Letters; >-use C4::Members; >-use C4::Overdues qw( GetOverdueMessageTransportTypes ); >-use Koha::Libraries; >- >-use Koha::Patron::Categories; >- >-our $input = CGI->new; >-my $dbh = C4::Context->dbh; >- >-my @patron_categories = Koha::Patron::Categories->search( { overduenoticerequired => { '>' => 0 } } )->as_list; >-my @category_codes = map { $_->categorycode } @patron_categories; >-our @rule_params = qw(delay letter debarred); >- >-# blank_row($category_code) - return true if the entire row is blank. >-sub blank_row { >- my ($category_code) = @_; >- for my $rp (@rule_params) { >- for my $n (1 .. 3) { >- my $key = "${rp}${n}-$category_code"; >- >- if (utf8::is_utf8($key)) { >- utf8::encode($key); >- } >- >- my $value = $input->param($key); >- if ($value) { >- return 0; >- } >- } >- } >- return 1; >-} >- >-my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >- { >- template_name => "tools/overduerules.tt", >- query => $input, >- type => "intranet", >- flagsrequired => { tools => 'edit_notice_status_triggers' }, >- } >-); >- >-my $type = $input->param('type'); >- >-my $branch = $input->param('branch'); >-$branch = >- defined $branch ? $branch >- : C4::Context->preference('DefaultToLoggedInLibraryOverdueTriggers') ? C4::Context::mybranch() >- : Koha::Libraries->search->count() == 1 ? undef >- : undef; >-$branch ||= q{}; >- >-my $op = $input->param('op'); >-$op ||= q{}; >- >-my $err=0; >- >-# save the values entered into tables >-my %temphash; >-my $input_saved = 0; >-if ($op eq 'cud-save') { >- my @names=$input->multi_param(); >- my $sth_search = $dbh->prepare("SELECT count(*) AS total FROM overduerules WHERE branchcode=? AND categorycode=?"); >- >- my $sth_insert = $dbh->prepare("INSERT INTO overduerules (branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3) VALUES (?,?,?,?,?,?,?,?,?,?,?)"); >- my $sth_update=$dbh->prepare("UPDATE overduerules SET delay1=?, letter1=?, debarred1=?, delay2=?, letter2=?, debarred2=?, delay3=?, letter3=?, debarred3=? WHERE branchcode=? AND categorycode=?"); >- my $sth_delete=$dbh->prepare("DELETE FROM overduerules WHERE branchcode=? AND categorycode=?"); >- my $sth_insert_mtt = $dbh->prepare(" >- INSERT INTO overduerules_transport_types( >- overduerules_id, letternumber, message_transport_type >- ) VALUES ( >- (SELECT overduerules_id FROM overduerules WHERE branchcode = ? AND categorycode = ?), ?, ? >- ) >- "); >- my $sth_delete_mtt = $dbh->prepare(" >- DELETE FROM overduerules_transport_types >- WHERE overduerules_id = (SELECT overduerules_id FROM overduerules WHERE branchcode = ? AND categorycode = ?) >- "); >- >- foreach my $key (@names){ >- # ISSUES >- if ($key =~ /(delay|letter|debarred)([1-3])-(.*)/) { >- my $type = $1; # data type >- my $num = $2; # From 1 to 3 >- my $bor = $3; # borrower category >- my $value = $input->param($key); >- if ($type eq 'delay') { >- $temphash{$bor}->{"$type$num"} = ($value =~ /^\d+$/ && int($value) > 0) ? int($value) : ''; >- } else { >- # type is letter >- $temphash{$bor}->{"$type$num"} = $value if $value ne ''; >- } >- } >- } >- >- # figure out which rows need to be deleted >- my @rows_to_delete = grep { blank_row($_) } @category_codes; >- >- foreach my $bor (keys %temphash){ >- # get category name if we need it for an error message >- my $bor_category = Koha::Patron::Categories->find($bor); >- my $bor_category_name = $bor_category ? $bor_category->description : $bor; >- >- # Do some Checking here : delay1 < delay2 <delay3 all of them being numbers >- # Raise error if not true >- if ($temphash{$bor}->{delay1}=~/[^0-9]/ and $temphash{$bor}->{delay1} ne ""){ >- $template->param("ERROR"=>1,"ERRORDELAY"=>"delay1","BORERR"=>$bor_category_name); >- $err=1; >- } elsif ($temphash{$bor}->{delay2}=~/[^0-9]/ and $temphash{$bor}->{delay2} ne ""){ >- $template->param("ERROR"=>1,"ERRORDELAY"=>"delay2","BORERR"=>$bor_category_name); >- $err=1; >- } elsif ($temphash{$bor}->{delay3}=~/[^0-9]/ and $temphash{$bor}->{delay3} ne ""){ >- $template->param("ERROR"=>1,"ERRORDELAY"=>"delay3","BORERR"=>$bor_category_name); >- $err=1; >- } elsif ($temphash{$bor}->{delay1} and not ($temphash{$bor}->{"letter1"} or $temphash{$bor}->{"debarred1"})) { >- $template->param("ERROR"=>1,"ERRORUSELESSDELAY"=>"delay1","BORERR"=>$bor_category_name); >- $err=1; >- } elsif ($temphash{$bor}->{delay2} and not ($temphash{$bor}->{"letter2"} or $temphash{$bor}->{"debarred2"})) { >- $template->param("ERROR"=>1,"ERRORUSELESSDELAY"=>"delay2","BORERR"=>$bor_category_name); >- $err=1; >- } elsif ($temphash{$bor}->{delay3} and not ($temphash{$bor}->{"letter3"} or $temphash{$bor}->{"debarred3"})) { >- $template->param("ERROR"=>1,"ERRORUSELESSDELAY"=>"delay3","BORERR"=>$bor_category_name); >- $err=1; >- }elsif ($temphash{$bor}->{delay3} and >- ($temphash{$bor}->{delay3}<=$temphash{$bor}->{delay2} or $temphash{$bor}->{delay3}<=$temphash{$bor}->{delay1}) >- or $temphash{$bor}->{delay2} and ($temphash{$bor}->{delay2}<=$temphash{$bor}->{delay1})){ >- $template->param("ERROR"=>1,"ERRORORDER"=>1,"BORERR"=>$bor_category_name); >- $err=1; >- } >- unless ($err){ >- if (($temphash{$bor}->{delay1} and ($temphash{$bor}->{"letter1"} or $temphash{$bor}->{"debarred1"})) >- or ($temphash{$bor}->{delay2} and ($temphash{$bor}->{"letter2"} or $temphash{$bor}->{"debarred2"})) >- or ($temphash{$bor}->{delay3} and ($temphash{$bor}->{"letter3"} or $temphash{$bor}->{"debarred3"}))) { >- $sth_search->execute($branch,$bor); >- my $res = $sth_search->fetchrow_hashref(); >- if ($res->{'total'}>0) { >- $sth_update->execute( >- ($temphash{$bor}->{"delay1"}?$temphash{$bor}->{"delay1"}:undef), >- ($temphash{$bor}->{"letter1"}?$temphash{$bor}->{"letter1"}:""), >- ($temphash{$bor}->{"debarred1"}?$temphash{$bor}->{"debarred1"}:0), >- ($temphash{$bor}->{"delay2"}?$temphash{$bor}->{"delay2"}:undef), >- ($temphash{$bor}->{"letter2"}?$temphash{$bor}->{"letter2"}:""), >- ($temphash{$bor}->{"debarred2"}?$temphash{$bor}->{"debarred2"}:0), >- ($temphash{$bor}->{"delay3"}?$temphash{$bor}->{"delay3"}:undef), >- ($temphash{$bor}->{"letter3"}?$temphash{$bor}->{"letter3"}:""), >- ($temphash{$bor}->{"debarred3"}?$temphash{$bor}->{"debarred3"}:0), >- $branch ,$bor >- ); >- } else { >- $sth_insert->execute($branch,$bor, >- ($temphash{$bor}->{"delay1"}?$temphash{$bor}->{"delay1"}:0), >- ($temphash{$bor}->{"letter1"}?$temphash{$bor}->{"letter1"}:""), >- ($temphash{$bor}->{"debarred1"}?$temphash{$bor}->{"debarred1"}:0), >- ($temphash{$bor}->{"delay2"}?$temphash{$bor}->{"delay2"}:0), >- ($temphash{$bor}->{"letter2"}?$temphash{$bor}->{"letter2"}:""), >- ($temphash{$bor}->{"debarred2"}?$temphash{$bor}->{"debarred2"}:0), >- ($temphash{$bor}->{"delay3"}?$temphash{$bor}->{"delay3"}:0), >- ($temphash{$bor}->{"letter3"}?$temphash{$bor}->{"letter3"}:""), >- ($temphash{$bor}->{"debarred3"}?$temphash{$bor}->{"debarred3"}:0) >- ); >- } >- >- $sth_delete_mtt->execute( $branch, $bor ); >- for my $letternumber ( 1..3 ) { >- my @mtt = $input->multi_param( "mtt${letternumber}-$bor" ); >- next unless @mtt; >- for my $mtt ( @mtt ) { >- $sth_insert_mtt->execute( $branch, $bor, $letternumber, $mtt); >- } >- } >- } >- } >- } >- unless ($err) { >- for my $category_code (@rows_to_delete) { >- $sth_delete->execute($branch, $category_code); >- } >- $template->param(datasaved => 1); >- $input_saved = 1; >- } >-} >- >-my $letters = C4::Letters::GetLettersAvailableForALibrary( >- { >- branchcode => $branch, >- module => "circulation", >- } >-); >- >-my $message_transport_types = C4::Letters::GetMessageTransportTypes(); >-my ( @first, @second, @third ); >-for my $patron_category (@patron_categories) { >- if (%temphash and not $input_saved){ >- # if we managed to save the form submission, don't >- # reuse %temphash, but take the values from the >- # database - this makes it easier to identify >- # bugs where the form submission was not correctly saved >- for my $i ( 1..3 ){ >- my %row = ( >- overduename => $patron_category->categorycode, >- line => $patron_category->description, >- ); >- $row{delay}=$temphash{$patron_category->categorycode}->{"delay$i"}; >- $row{debarred}=$temphash{$patron_category->categorycode}->{"debarred$i"}; >- $row{selected_lettercode} = $temphash{ $patron_category->categorycode }->{"letter$i"}; >- my @selected_mtts = @{ GetOverdueMessageTransportTypes( $branch, $patron_category->categorycode, $i) }; >- my @mtts; >- for my $mtt ( @$message_transport_types ) { >- push @mtts, { >- value => $mtt, >- selected => ( grep {/$mtt/} @selected_mtts ) ? 1 : 0 , >- } >- } >- $row{message_transport_types} = \@mtts; >- if ( $i == 1 ) { >- push @first, \%row; >- } elsif ( $i == 2 ) { >- push @second, \%row; >- } else { >- push @third, \%row; >- } >- } >- } else { >- #getting values from table >- my $sth2=$dbh->prepare("SELECT * from overduerules WHERE branchcode=? AND categorycode=?"); >- $sth2->execute($branch,$patron_category->categorycode); >- my $dat=$sth2->fetchrow_hashref; >- for my $i ( 1..3 ){ >- my %row = ( >- overduename => $patron_category->categorycode, >- line => $patron_category->description, >- ); >- >- $row{selected_lettercode} = $dat->{"letter$i"}; >- >- if ($dat->{"delay$i"}){$row{delay}=$dat->{"delay$i"};} >- if ($dat->{"debarred$i"}){$row{debarred}=$dat->{"debarred$i"};} >- my @selected_mtts = @{ GetOverdueMessageTransportTypes( $branch, $patron_category->categorycode, $i) }; >- my @mtts; >- for my $mtt ( @$message_transport_types ) { >- push @mtts, { >- value => $mtt, >- selected => ( grep {/$mtt/} @selected_mtts ) ? 1 : 0 , >- } >- } >- $row{message_transport_types} = \@mtts; >- if ( $i == 1 ) { >- push @first, \%row; >- } elsif ( $i == 2 ) { >- push @second, \%row; >- } else { >- push @third, \%row; >- } >- >- } >- } >-} >- >-my @tabs = ( >- { >- id => 'first', >- number => 1, >- values => \@first, >- }, >- { >- id => 'second', >- number => 2, >- values => \@second, >- }, >- { >- id => 'third', >- number => 3, >- values => \@third, >- }, >-); >- >-$template->param( >- table => ( @first or @second or @third ? 1 : 0 ), >- branch => $branch, >- tabs => \@tabs, >- message_transport_types => $message_transport_types, >- letters => $letters, >-); >-output_html_with_http_headers $input, $cookie, $template->output; >-- >2.47.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 10190
:
170357
|
170358
|
170359
|
170360
|
170361
|
170362
|
170363
|
170364
|
170365
|
170366
|
170367
|
170368
|
170369
|
170370
|
170371
|
170372
|
170373
|
170374
|
170375
|
170376
|
170380
|
170449
|
171727
|
171728
|
171729
|
171730
|
171731
|
171732
|
171733
|
171734
|
171735
|
171736
|
171737
|
171738
|
171739
|
171740
|
171741
|
171742
|
171743
|
171744
|
171745
|
171746
|
171747
|
171748
|
171749
|
171750
|
171751
|
171752
|
171753
|
171754
|
171755
|
172588
|
172589
|
172590
|
172591
|
172592
|
172593
|
172594
|
172595
|
172596
|
172597
|
172598
|
172599
|
172600
|
172601
|
172602
|
172603
|
172604
|
172605
|
172606
|
172607
|
172608
|
172609
|
172612
|
172614
|
172617
|
172619
|
172621
|
172622
|
172623
|
172624
|
172625
|
172626
|
172630
|
172631
|
172632
|
172633
|
172634
|
172635
|
172636
|
172637
|
172638
|
172639
|
172640
|
172641
|
172642
|
172643
|
172644
|
172645
|
172646
|
172647
|
172648
| 172649 |
172650
|
172651
|
172652
|
172653
|
172654
|
172655
|
172656
|
172657
|
172658
|
172659
|
172660
|
172661
|
172662
|
172663