From 6eb2c6141dfeb3e03c9870dca032a902f6fbe0d9 Mon Sep 17 00:00:00 2001 From: tipaul Date: Mon, 24 Nov 2003 16:28:49 +0000 Subject: [PATCH] biblio & item deletion now works fine in MARC editor. Stores deleted biblio/item in the marc field of the deletedbiblio/deleteditem table. --- C4/Biblio.pm | 40 ++++++++++++++++--- .../default/en/acqui.simple/additem.tmpl | 9 ++++- .../default/fr/acqui.simple/addbiblio.tmpl | 2 +- .../default/fr/acqui.simple/additem.tmpl | 9 ++++- 4 files changed, 51 insertions(+), 9 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 6081128afe..556513845c 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -54,7 +54,7 @@ $VERSION = 0.01; &NEWnewbiblio &NEWnewitem &NEWmodbiblio &NEWmoditem - &NEWdelbiblio + &NEWdelbiblio &NEWdelitem &MARCaddbiblio &MARCadditem &MARCmodsubfield &MARCaddsubfield @@ -538,6 +538,23 @@ sub MARCdelbiblio { $dbh->do("delete from marc_word where bibid=$bibid"); } } + +sub MARCdelitem { +# delete the item passed in parameter in MARC tables. + my ($dbh,$bibid,$itemnumber)=@_; + # my $record = MARC::Record->new(); + # search MARC tagorder + my $record = MARCgetitem($dbh,$bibid,$itemnumber); + my $copy2deleted=$dbh->prepare("update deleteditems set marc=? where itemnumber=?"); + $copy2deleted->execute($record->as_usmarc(),$itemnumber); + + my $sth2 = $dbh->prepare("select tagorder from marc_subfield_table,marc_subfield_structure where marc_subfield_table.tag=marc_subfield_structure.tagfield and marc_subfield_table.subfieldcode=marc_subfield_structure.tagsubfield and bibid=? and kohafield='items.itemnumber' and subfieldvalue=?"); + $sth2->execute($bibid,$itemnumber); + my ($tagorder) = $sth2->fetchrow_array(); + my $sth=$dbh->prepare("delete from marc_subfield_table where bibid=? and tagorder=?"); + $sth->execute($bibid,$tagorder); +} + sub MARCmoditem { my ($dbh,$record,$bibid,$itemnumber,$delete)=@_; my $oldrecord=&MARCgetitem($dbh,$bibid,$itemnumber); @@ -1090,6 +1107,13 @@ sub NEWmoditem { OLDmoditem($dbh,$olditem); } +sub NEWdelitem { + my ($dbh,$bibid,$itemnumber)=@_; + my $biblio = &MARCfind_oldbiblionumber_from_MARCbibid($dbh,$bibid); + &OLDdelitem($dbh,$itemnumber); + &MARCdelitem($dbh,$bibid,$itemnumber); +} + # # # OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD @@ -1484,13 +1508,13 @@ sub OLDdelitem{ my $query="select * from items where itemnumber=$itemnum"; my $sth=$dbh->prepare($query); $sth->execute; - my @data=$sth->fetchrow_array; + my $data=$sth->fetchrow_hashref; $sth->finish; - $query="Insert into deleteditems values ("; - foreach my $temp (@data){ - $query .= "'$temp',"; + $query="Insert into deleteditems set "; + foreach my $temp (keys %$data){ + $query .= "$temp = ".$dbh->quote($data->{$temp}).","; } - $query=~ s/\,$/\)/; + $query=~ s/\,$//; # print $query; $sth=$dbh->prepare($query); $sth->execute; @@ -2185,6 +2209,10 @@ Paul POULAIN paul.poulain@free.fr # $Id$ # $Log$ +# Revision 1.71 2003/11/24 16:28:49 tipaul +# biblio & item deletion now works fine in MARC editor. +# Stores deleted biblio/item in the marc field of the deletedbiblio/deleteditem table. +# # Revision 1.70 2003/11/24 13:29:55 tipaul # moving $id from beginning to end of file (70 commits... huge comments...) # diff --git a/koha-tmpl/intranet-tmpl/default/en/acqui.simple/additem.tmpl b/koha-tmpl/intranet-tmpl/default/en/acqui.simple/additem.tmpl index 455ad2dfa7..2fb75e9ff2 100644 --- a/koha-tmpl/intranet-tmpl/default/en/acqui.simple/additem.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/acqui.simple/additem.tmpl @@ -38,7 +38,8 @@ - &itemnum=">Edit + &itemnum=">//images/fileopen.png" border=0> + ,)">//images/edittrash.png" border=0> @@ -121,6 +122,12 @@ function Dopop(link,i) { defaultvalue=document.forms[0].field_value[i].value; newin=window.open(link+"&result="+defaultvalue,"value builder",'width=500,height=400,toolbar=false,scrollbars=yes'); } +function confirm_deletion(bibid,itemnum) { + var is_confirmed = confirm('Do you confirm item deletion ?'); + if (is_confirmed) { + window.location = "additem.pl?op=delitem&bibid="+bibid+"&itemnum="+itemnum; + } +} diff --git a/koha-tmpl/intranet-tmpl/default/fr/acqui.simple/addbiblio.tmpl b/koha-tmpl/intranet-tmpl/default/fr/acqui.simple/addbiblio.tmpl index 35e8929059..64ebc5188d 100644 --- a/koha-tmpl/intranet-tmpl/default/fr/acqui.simple/addbiblio.tmpl +++ b/koha-tmpl/intranet-tmpl/default/fr/acqui.simple/addbiblio.tmpl @@ -29,7 +29,7 @@ "> - + recherche z3950 diff --git a/koha-tmpl/intranet-tmpl/default/fr/acqui.simple/additem.tmpl b/koha-tmpl/intranet-tmpl/default/fr/acqui.simple/additem.tmpl index e86a52b48d..949985a91f 100644 --- a/koha-tmpl/intranet-tmpl/default/fr/acqui.simple/additem.tmpl +++ b/koha-tmpl/intranet-tmpl/default/fr/acqui.simple/additem.tmpl @@ -38,6 +38,7 @@ &itemnum=">//images/fileopen.png" border=0> + ,)">//images/edittrash.png" border=0> @@ -64,7 +65,7 @@ "> -
ERROR : Barcode already exists !
+
ERREUR : le code barre existe déjà !
@@ -119,6 +120,12 @@ function Dopop(link,i) { defaultvalue=document.forms[0].field_value[i].value; newin=window.open(link+"&result="+defaultvalue,"value builder",'width=500,height=400,toolbar=false,scrollbars=yes'); } +function confirm_deletion(bibid,itemnum) { + var is_confirmed = confirm('Confirmez vous la suppression ?'); + if (is_confirmed) { + window.location = "additem.pl?op=delitem&bibid="+bibid+"&itemnum="+itemnum; + } +} -- 2.39.5