From 1e21ba6968296c3b3484dce7105bb70dcf524761 Mon Sep 17 00:00:00 2001 From: btoumi Date: Mon, 21 May 2007 08:44:17 +0000 Subject: [PATCH] add security when u delete biblio : u must delete linked items before delete biblio --- C4/Biblio.pm | 27 +++++++++++++++++++ catalogue/MARCdetail.pl | 4 +++ .../prog/en/catalogue/MARCdetail.tmpl | 27 +++++++++++++++---- 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index efb5e9ded5..08978d961f 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -58,6 +58,7 @@ push @EXPORT, qw( &GetItemLocation &GetLostItems &GetItemsForInventory + &GetItemsCount &GetMarcNotes &GetMarcSubjects @@ -3879,6 +3880,28 @@ sub set_service_options { return $serviceOptions; } +=head2 GetItemsCount + +$count = &GetItemsCount( $biblionumber); +this function return count of item with $biblionumber +=cut + +sub GetItemsCount { + my ( $biblionumber ) = @_; + my $dbh = C4::Context->dbh; + my $query = qq|SELECT count(*) + FROM items + WHERE biblionumber=?|; + my $sth = $dbh->prepare($query); + $sth->execute($biblionumber); + my $count = $sth->fetchrow; + $sth->finish; + return ($count); +} + + + + END { } # module clean-up code here (global destructor) 1; @@ -3897,6 +3920,10 @@ Joshua Ferraro jmf@liblime.com # $Id$ # $Log$ +# Revision 1.206 2007/05/21 08:44:17 btoumi +# add security when u delete biblio : +# u must delete linked items before delete biblio +# # Revision 1.205 2007/05/11 16:04:03 btoumi # bug fix: # problem in displayed label link with subject in detail.tmpl diff --git a/catalogue/MARCdetail.pl b/catalogue/MARCdetail.pl index 17ae11b433..9f9007fc98 100755 --- a/catalogue/MARCdetail.pl +++ b/catalogue/MARCdetail.pl @@ -116,6 +116,10 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); +#count of item linked +my $itemcount = GetItemsCount($biblionumber); +$template->param( count => $itemcount); + #Getting the list of all frameworks my $queryfwk = $dbh->prepare("select frameworktext, frameworkcode from biblio_framework"); diff --git a/koha-tmpl/intranet-tmpl/prog/en/catalogue/MARCdetail.tmpl b/koha-tmpl/intranet-tmpl/prog/en/catalogue/MARCdetail.tmpl index 6d11408e0c..12b768d9f9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/catalogue/MARCdetail.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/catalogue/MARCdetail.tmpl @@ -370,12 +370,29 @@ function active(numlayer) } } -function confirm_deletion() { - var is_confirmed = confirm('Are you sure you want to delete this biblio?'); - if (is_confirmed) { - window.location="../cataloguing/addbiblio.pl?op=delete&biblionumber="; +function confirm_deletion(count) { + // var is_confirmed = confirm('Are you sure you want to delete this biblio?'); +// if (is_confirmed) { +// window.location="../cataloguing/addbiblio.pl?op=delete&biblionumber="; +// } + var is_confirmed; + if (count>0){ + is_confirmed= alert('you have [ '+ count +' ] item(s) linked \n you must delete all items before delete this biblio'); + } + else{ + is_confirmed= confirm('Are you sure you want to delete this biblio? '); + } + + + if (is_confirmed) { + if (count=0){ +// window.location="/cgi-bin/koha/catalogue/detail.pl?biblionumber="; + window.location="/cgi-bin/koha/cataloguing/addbiblio.pl?op=delete&biblionumber="; + } + } -} + } + function Dopop(link) { newin=window.open(link,'popup','width=500,height=400,toolbar=false,scrollbars=yes'); } -- 2.39.5