Bugzilla – Attachment 42126 Details for
Bug 12772
Add item type and on-hold status to overdue notice/status triggers tool
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12772 - Fix rule updates
Bug-12772---Fix-rule-updates.patch (text/plain), 4.82 KB, created by
Martin Stenberg
on 2015-08-31 20:10:59 UTC
(
hide
)
Description:
Bug 12772 - Fix rule updates
Filename:
MIME Type:
Creator:
Martin Stenberg
Created:
2015-08-31 20:10:59 UTC
Size:
4.82 KB
patch
obsolete
>From a13498750a81a6b9f6a50e0038cbf6da8b6438e8 Mon Sep 17 00:00:00 2001 >From: Martin Stenberg <martin@xinxidi.net> >Date: Mon, 31 Aug 2015 22:06:46 +0200 >Subject: [PATCH] Bug 12772 - Fix rule updates > >Overduerules ID was not sent correctly when editing rules, resulting in rule >being cleared instead of updated. This patch fixes this issue, and a couple of >uninitilized values as a bonus. >--- > .../intranet-tmpl/prog/en/modules/tools/overduerules.tt | 11 ++++------- > tools/overduerules.pl | 16 +++++++++------- > 2 files changed, 13 insertions(+), 14 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/overduerules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/overduerules.tt >index fd96b90..014217d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/overduerules.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/overduerules.tt >@@ -33,12 +33,9 @@ function clear_edit(){ > } > > function edit_value_add(id_overduerules) { >- var input = document.getElementById('edit_id'); >- if (id_overduerules != 0) { >- input.value = "add&overduerules_id=" + id_overduerules; >- } else { >- input.value = "add"; >- } >+ $('#edit_id').val('add'); >+ if (id_overduerules != 0) >+ $('#edit_overduerules_id').val(id_overduerules); > } > > $(document).ready(function() { >@@ -114,7 +111,7 @@ fieldset.rows .ui-tabs-nav { margin-left : 10px; } > > <form method="post" action="/cgi-bin/koha/tools/overduerules.pl"> > <input id="edit_id" type="hidden" name="op" value="add" /> >-<input type="hidden" name="edit_overduerules_id" value="0" /> >+<input id="edit_overduerules_id" type="hidden" name="overduerules_id" value="0" /> > <table id="table_overduerules"> > <thead> > <tr> >diff --git a/tools/overduerules.pl b/tools/overduerules.pl >index 15d3618..16e0c5f 100755 >--- a/tools/overduerules.pl >+++ b/tools/overduerules.pl >@@ -19,6 +19,7 @@ > > use strict; > use warnings; >+use Carp; > use CGI qw ( -utf8 ); > use List::Util qw/min/; > use File::Spec; >@@ -34,8 +35,10 @@ use Data::Dumper; > sub StringSearch { > my ( $searchstring, $type ) = @_; > my $dbh = C4::Context->dbh; >+ $searchstring = "" unless $searchstring; > $searchstring =~ s/\'/\\\'/g; > my @data = split( ' ', $searchstring ); >+ $data[0] = "" unless scalar @data; > my $sth = $dbh->prepare( > "SELECT * FROM overduerules WHERE (branchcode LIKE ?) or (categorycode LIKE ?) or (letter LIKE ?) or (itemtype LIKE ?) ORDER BY branchcode, delay" > ); >@@ -47,8 +50,9 @@ sub StringSearch { > my $input = new CGI; > my $searchfield = $input->param('description'); > my $script_name = "/cgi-bin/koha/tools/overduerules.pl"; >-my $op = $input->param('op'); >+my $op = $input->param('op') || 'search'; > my $overduerules_id = $input->param('overduerules_id'); >+$overduerules_id = 0 unless (defined $overduerules_id && $overduerules_id =~ /\d+/); > my $branch = $input->param('branchcode'); > my $cat = $input->param('categorycode'); > my $itemtype = $input->param('itemtype'); >@@ -59,7 +63,7 @@ foreach ($input->param){ > push (@mttparams, $1) if ($_ =~ /^mtt-(.*)/); > } > >-$searchfield =~ s/\,//g; >+$searchfield =~ s/\,//g if $searchfield; > my ($template, $borrowernumber, $cookie ) = get_template_and_user( > { > template_name => "tools/overduerules.tt", >@@ -92,9 +96,7 @@ $template->param( > > # operations > if ( $op =~ m/add/ ) { >- $op =~ s/\D//g; > $branch = (!defined $branch ) ? '' : $branch; >- $op = ($op eq '') ? 0 : $op; > $cat = (!defined $cat ) ? 0 : $cat; > $itemtype = (!defined $itemtype ) ? '' :$itemtype; > $onhold = (!defined $onhold ) ? 0 : $onhold; >@@ -109,14 +111,14 @@ if ( $op =~ m/add/ ) { > $sth->execute($input->param('letter') || '', $debarred , $branch, $cat, $itemtype, $onhold, $delay); > $dbh->do("DELETE FROM overduerules_transport_types where overduerules_id = $ruleId"); > } >- elsif ($op != 0) { # case edit pkeys >+ elsif ($overduerules_id != 0) { # case edit pkeys > my $query2 = " > UPDATE overduerules > SET letter = ?, debarred = ?, branchcode = ?, categorycode = ?, itemtype = ?, onhold = ?, delay = ? > WHERE overduerules_id = ? "; > my $sth = $dbh->prepare($query2); >- $sth->execute($input->param('letter') || '', $debarred , $branch, $cat, $itemtype, $onhold, $delay, $op); >- $dbh->do("DELETE FROM overduerules_transport_types where overduerules_id = $op"); >+ $sth->execute($input->param('letter') || '', $debarred , $branch, $cat, $itemtype, $onhold, $delay, $overduerules_id); >+ $dbh->do("DELETE FROM overduerules_transport_types where overduerules_id = $overduerules_id"); > } else { # add a new entry in overrules > my $query = " > INSERT INTO overduerules (branchcode, categorycode, itemtype, onhold, delay, letter, debarred) >-- >2.5.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 12772
:
41477
|
41478
|
41479
|
41480
|
41855
|
42126
|
45184
|
45185
|
45186
|
45187
|
45188
|
45189
|
45190
|
45191
|
45192
|
45193
|
45194
|
45195
|
45196
|
45197
|
45198
|
45199
|
45200
|
45201
|
45202
|
45203
|
45204
|
45544
|
45545
|
45546
|
45547
|
45548
|
45549
|
45550
|
45551
|
45552
|
56063
|
56077