Bugzilla – Attachment 59715 Details for
Bug 17944
Remove the sql code from itemtypes.pl administrative perl script
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17944 - Moved the DBIx code into the ItemType.pm file
Bug-17944---Moved-the-DBIx-code-into-the-ItemTypep.patch (text/plain), 2.31 KB, created by
Alex Buckley
on 2017-02-01 04:05:54 UTC
(
hide
)
Description:
Bug 17944 - Moved the DBIx code into the ItemType.pm file
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2017-02-01 04:05:54 UTC
Size:
2.31 KB
patch
obsolete
>From abd45dfcec0864ad60de2df4c7bd39a336436490 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Wed, 1 Feb 2017 17:01:37 +1300 >Subject: [PATCH] Bug 17944 - Moved the DBIx code into the ItemType.pm file > >--- > Koha/ItemType.pm | 14 ++++++++++++++ > admin/itemtypes.pl | 11 +++-------- > 2 files changed, 17 insertions(+), 8 deletions(-) > >diff --git a/Koha/ItemType.pm b/Koha/ItemType.pm >index 48df808..87aa644 100644 >--- a/Koha/ItemType.pm >+++ b/Koha/ItemType.pm >@@ -81,6 +81,20 @@ sub translated_descriptions { > } @translated_descriptions ]; > } > >+ >+=head3 get_items_and_biblioitems >+ >+=cut >+ >+sub get_items_and_biblioitems { >+ my $itemtype_code = $_[1]; >+ my $schema = Koha::Database->new()->schema(); >+ my $itemtotal = $schema->resultset('Item')->search({ 'itype' => $itemtype_code})->count; >+ my $bibliototal = $schema->resultset('Biblioitem')->search({ 'itemtype' => $itemtype_code})->count; >+ my $overalltotal = $itemtotal + $bibliototal; >+ return $overalltotal; >+} >+ > =head3 type > > =cut >diff --git a/admin/itemtypes.pl b/admin/itemtypes.pl >index e926418..373a16c 100755 >--- a/admin/itemtypes.pl >+++ b/admin/itemtypes.pl >@@ -32,7 +32,7 @@ use C4::Context; > use C4::Auth; > use C4::Output; > >-use Koha::ItemTypes; >+use Koha::ItemType; > use Koha::Localizations; > > my $input = new CGI; >@@ -140,12 +140,7 @@ if ( $op eq 'add_form' ) { > > } elsif ( $op eq 'delete_confirm' ) { > >- my $schema = Koha::Database->new()->schema(); >- my $itemtotal = $schema->resultset('Item')->search({ 'itype' => $itemtype_code})->count; >- my $bibliototal = $schema->resultset('Biblioitem')->search({ 'itemtype' => $itemtype_code})->count; >- >- my $overalltotal = $itemtotal + $bibliototal; >- >+ my $overalltotal = Koha::ItemType->get_items_and_biblioitems($itemtype_code); > if ($overalltotal) { > push @messages, { type => 'error', code => 'cannot_be_deleted', total => $overalltotal }; > $op = 'list'; >@@ -156,7 +151,7 @@ if ( $op eq 'add_form' ) { > > } elsif ( $op eq 'delete_confirmed' ) { > >- my $itemtype = Koha::ItemTypes->find($itemtype_code); >+ my $itemtype = Koha::ItemType->get_items_and_biblioitems($itemtype_code); > my $deleted = eval { $itemtype->delete }; > if ( $@ or not $deleted ) { > push @messages, { type => 'error', code => 'error_on_delete' }; >-- >2.1.4
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 17944
:
59391
|
59564
|
59565
|
59655
|
59656
|
59657
|
59715
|
59716
|
59717
|
59718
|
59953
|
59954
|
62499
|
62500
|
62501
|
62502
|
62503
|
62504
|
62505
|
63045
|
63152
|
63220
|
63259
|
63307
|
63308
|
63309
|
63310
|
63924
|
63925