From 0734f8fca0f7e3f3bcd79056673dd1f0a96437d6 Mon Sep 17 00:00:00 2001 From: Ryan Higgins Date: Sun, 9 Dec 2007 12:54:49 -0600 Subject: [PATCH] Clean up moredetail.pl and updateitem.pl Signed-off-by: Joshua Ferraro --- C4/Biblio.pm | 7 +- C4/Koha.pm | 36 +++-- catalogue/moredetail.pl | 14 +- catalogue/updateitem.pl | 64 +++++---- .../prog/en/css/staff-global.css | 7 +- .../prog/en/modules/catalogue/moredetail.tmpl | 136 +++++++++--------- 6 files changed, 155 insertions(+), 109 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 966343d163..ecd5fcaf71 100755 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -3905,8 +3905,9 @@ sub _koha_modify_item { my $error; # calculate items.cn_sort - $item->{'cn_sort'} = GetClassSort($item->{'items.cn_source'}, $item->{'itemcallnumber'}, ""); - + if($item->{'itemcallnumber'}) { + $item->{'cn_sort'} = GetClassSort($item->{'items.cn_source'}, $item->{'itemcallnumber'}, ""); + } my $query = "UPDATE items SET "; my @bind; for my $key ( keys %$item ) { @@ -3915,7 +3916,7 @@ sub _koha_modify_item { } $query =~ s/,$//; $query .= " WHERE itemnumber=?"; - push @bind, $item->{'itemnumber'}; + push @bind, $item->{'itemnumber'}; my $sth = $dbh->prepare($query); $sth->execute(@bind); if ( $dbh->errstr ) { diff --git a/C4/Koha.pm b/C4/Koha.pm index 06ff7a32d1..1724e6d72b 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -68,6 +68,7 @@ $VERSION = 3.00; &GetAuthorisedValues &FixEncoding &GetKohaAuthorisedValues + &GetAuthValCode &GetManagedTagSubfields $DEBUG @@ -787,6 +788,22 @@ sub displaySecondaryServers { return; #$secondary_servers_loop; } +=head2 GetAuthValCode + +$authvalcode = GetAuthValCode($kohafield,$frameworkcode); + +=cut + +sub GetAuthValCode { + my ($kohafield,$fwcode) = @_; + my $dbh = C4::Context->dbh; + $fwcode='' unless $fwcode; + my $sth = $dbh->prepare('select authorised_value from marc_subfield_structure where kohafield=? and frameworkcode=?'); + $sth->execute($kohafield,$fwcode); + my ($authvalcode) = $sth->fetchrow_array; + return $authvalcode; +} + =head2 GetAuthorisedValues $authvalues = GetAuthorisedValues($category); @@ -879,18 +896,17 @@ sub FixEncoding { =cut sub GetKohaAuthorisedValues { - my ($kohafield) = @_; + my ($kohafield,$fwcode) = @_; + $fwcode='' unless $fwcode; my %values; my $dbh = C4::Context->dbh; - my $sthnflstatus = $dbh->prepare('select authorised_value from marc_subfield_structure where kohafield=?'); - $sthnflstatus->execute($kohafield); - my $authorised_valuecode = $sthnflstatus->fetchrow; - if ($authorised_valuecode) { - $sthnflstatus = $dbh->prepare("select authorised_value, lib from authorised_values where category=? "); - $sthnflstatus->execute($authorised_valuecode); - while ( my ($val, $lib) = $sthnflstatus->fetchrow_array ) { - $values{$val}= $lib; - } + my $avcode = GetAuthValCode($kohafield,$fwcode); + if ($avcode) { + my $sth = $dbh->prepare("select authorised_value, lib from authorised_values where category=? "); + $sth->execute($avcode); + while ( my ($val, $lib) = $sth->fetchrow_array ) { + $values{$val}= $lib; + } } return \%values; } diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl index b82d9673f9..96b85a9715 100755 --- a/catalogue/moredetail.pl +++ b/catalogue/moredetail.pl @@ -65,20 +65,22 @@ my $dewey = $data->{'dewey'}; # $data->{'dewey'}=$dewey; my @results; - +my $fw = GetFrameworkCode($biblionumber); my $items= GetItemsByBiblioitemnumber($bi); my $count=@$items; $data->{'count'}=$count; my $ordernum = GetOrderNumber($biblionumber,$bi); my $order = GetOrder($ordernum); - +my $ccodes= GetKohaAuthorisedValues('items.ccode',$fw); +my $itemtypes = GetItemTypes; $results[0]=$data; - foreach my $item (@$items){ - $item->{itemlostloop}= GetAuthorisedValues('LOST',$item->{itemlost}); - $item->{itemdamagedloop}= GetAuthorisedValues('DAMAGED',$item->{damaged}); - $item->{'replacementprice'}=sprintf("%.2f", $item->{'replacementprice'}); + $item->{itemlostloop}= GetAuthorisedValues(GetAuthValCode('items.itemlost',$fw),$item->{itemlost}); + $item->{itemdamagedloop}= GetAuthorisedValues(GetAuthValCode('items.damaged',$fw),$item->{damaged}); + $item->{'collection'} = $ccodes->{$item->{ccode}}; + $item->{'itype'} = $itemtypes->{$item->{'itype'}}->{'description'}; + $item->{'replacementprice'}=sprintf("%.2f", $item->{'replacementprice'}); $item->{'datelastborrowed'}= format_date($item->{'datelastborrowed'}); $item->{'dateaccessioned'} = format_date($item->{'dateaccessioned'}); $item->{'datelastseen'} = format_date($item->{'datelastseen'}); diff --git a/catalogue/updateitem.pl b/catalogue/updateitem.pl index 41e2dd5a6d..0c4a35d65f 100755 --- a/catalogue/updateitem.pl +++ b/catalogue/updateitem.pl @@ -32,6 +32,7 @@ my $biblionumber=$cgi->param('biblionumber'); my $itemnumber=$cgi->param('itemnumber'); my $biblioitemnumber=$cgi->param('biblioitemnumber'); my $itemlost=$cgi->param('itemlost'); +my $itemnotes=$cgi->param('itemnotes'); my $wthdrawn=$cgi->param('wthdrawn'); my $damaged=$cgi->param('damaged'); @@ -39,32 +40,48 @@ my $confirm=$cgi->param('confirm'); my $dbh = C4::Context->dbh; # get the rest of this item's information my $item_data_hashref = GetItem($itemnumber, undef); - -# modify bib MARC -if ((not defined($item_data_hashref->{'itemlost'})) or ($itemlost ne $item_data_hashref->{'itemlost'})) { +my $newitemdata; +# modify MARC item if input differs from items table. +if ( $itemnotes ne $item_data_hashref->{'itemnotes'}) { + ModItemInMarconefield($biblionumber, $itemnumber, 'items.itemnotes', $itemnotes); + $newitemdata->{'itemnotes'} = $itemnotes; +} elsif ($itemlost ne $item_data_hashref->{'itemlost'}) { ModItemInMarconefield($biblionumber, $itemnumber, 'items.itemlost', $itemlost); -} -if ((not defined($item_data_hashref->{'wthdrawn'})) or ($wthdrawn ne $item_data_hashref->{'wthdrawn'})) { + $newitemdata->{'itemlost'} = $itemlost; +} elsif ($wthdrawn ne $item_data_hashref->{'wthdrawn'}) { ModItemInMarconefield($biblionumber, $itemnumber, 'items.wthdrawn', $wthdrawn); -} -if ((not defined($item_data_hashref->{'damaged'})) or ($damaged ne $item_data_hashref->{'damaged'})) { + $newitemdata->{'wthdrawn'} = $wthdrawn; +} elsif ($damaged ne $item_data_hashref->{'damaged'}) { ModItemInMarconefield($biblionumber, $itemnumber, 'items.damaged', $damaged); + $newitemdata->{'damaged'} = $damaged; +} else { + #nothings changed, so do nothing. + print $cgi->redirect("moredetail.pl?biblionumber=$biblionumber&itemnumber=$itemnumber"); } -# check reservations -my ($status, $reserve) = CheckReserves($itemnumber, $item_data_hashref->{'barcode'}); -if ($reserve){ - #print $cgi->header; - warn "Reservation found on item $itemnumber"; +# FIXME: eventually we'll use Biblio.pm, but it's currently too buggy (is this current ??) +#ModItem( $dbh,'',$biblionumber,$itemnumber,'',$item_hashref ); + $newitemdata->{'itemnumber'} = $itemnumber; + &C4::Biblio::_koha_modify_item($dbh,$newitemdata); +#$sth = $dbh->prepare("UPDATE items SET wthdrawn=?,itemlost=?,damaged=? WHERE itemnumber=?"); +#$sth->execute($wthdrawn,$itemlost,$damaged,$itemnumber); + +# check reservations (why ?) +#my ($status, $reserve) = CheckReserves($itemnumber, $item_data_hashref->{'barcode'}); +#if ($reserve){ +## #print $cgi->header; +# warn "Reservation found on item $itemnumber"; #exit; -} -# check issues -my $sth=$dbh->prepare("SELECT * FROM issues WHERE (itemnumber=? AND returndate IS NULL)"); -$sth->execute($itemnumber); -my $issues=$sth->fetchrow_hashref(); +#} +# check issues iff itemlost. + # FIXME : is there documentation or enforcement that itemlost value must be '1'? if no replacement price, then borrower just doesn't get charged? +if ($itemlost==1) { + my $sth=$dbh->prepare("SELECT * FROM issues WHERE (itemnumber=? AND returndate IS NULL)"); + $sth->execute($itemnumber); + my $issues=$sth->fetchrow_hashref(); -# if a borrower lost the item, add a replacement cost to the their record -if ( ($issues->{borrowernumber}) && ($itemlost==1) ){ + # if a borrower lost the item, add a replacement cost to the their record + if ( ($issues->{borrowernumber}) && ($itemlost==1) ){ # first make sure the borrower hasn't already been charged for this item my $sth1=$dbh->prepare("SELECT * from accountlines @@ -84,13 +101,10 @@ if ( ($issues->{borrowernumber}) && ($itemlost==1) ){ "Lost Item $item_data_hashref->{'title'} $item_data_hashref->{'barcode'}", $item_data_hashref->{'replacementprice'},$itemnumber); $sth2->finish; + # FIXME: Log this ? } + } + $sth->finish; } -$sth->finish; - -# FIXME: eventually we'll use Biblio.pm, but it's currently too buggy -#ModItem( $dbh,'',$biblionumber,$itemnumber,'',$item_hashref ); -$sth = $dbh->prepare("UPDATE items SET wthdrawn=?,itemlost=?,damaged=? WHERE itemnumber=?"); -$sth->execute($wthdrawn,$itemlost,$damaged,$itemnumber); print $cgi->redirect("moredetail.pl?biblionumber=$biblionumber&itemnumber=$itemnumber"); diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css index 8e2a410574..5fc71817a3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css +++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css @@ -833,6 +833,11 @@ ol.bibliodetails span.label { margin-right: 1em; } +ol.bibliodetails span.listgroup { + font-weight: bold; + font-style: oblique; +} + div.sysprefs h3 { margin : .2em 0 .2em .4em; } @@ -1103,4 +1108,4 @@ h1#logo a { .patroninfo+#menu { margin-right : 0; -} \ No newline at end of file +} diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tmpl index 8f3bfc063b..a26e8fc340 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tmpl @@ -21,9 +21,9 @@

, by

    -
  1. Collection:
  2. Biblionumber:
  3. -
  4. Item type:  
  5. +
  6. Item type:  
  7. +
  8. Collection: 
  9. URL: "> 
  10. Loan length:  
  11. Rental charge: 0.00
  12. @@ -38,69 +38,58 @@
    -

    Barcode

    - &itemnumber=">Modify | - &itemnumber=">Delete - +

    Barcode

      +
    1. Item Information &itemnumber=">Edit Items
    2. +
      • Home Library:
      • -
      • Current Library:
      • -
      • Last seen:
      • -
      • Last borrowed:  
      • -
      • Item Status: Checked out to ">Not Checked out
      • -
      • Date Due:
      • -
      • Last Borrower 1:  
      • -
      • Last Borrower 2:  
      • -
      • Replacement Price:  
      • -
      • Item Status Summary Item Lost Item Damaged Item Withdrawn  
      • - -
      • Damaged Status: - -
        -" /> -" /> -" /> - -" /> -" /> -
        -
      • - +
      • Itemtype:  
      • +
      • Collection:
      • +
      • Item Callnumber:  
      • +
      • Copy / Vol :
      • +
      • Replacement Price:
      • +
      +
    3. Status ( Item Lost Item Damaged Item Withdrawn )
    4. +
        +
      • Current Location:
      • +
      • Circulation Status: Checked out to ">Not Checked out
      • Lost Status: - -
        -" /> -" /> -" /> - -" /> -" /> -
        +
        + " /> + " /> + " /> + + " /> + " /> +
        +
      • +
      • Damaged Status: +
        + " /> + " /> + " /> + + " /> + " /> +
      • -
      • Paid for:  
      • -
      • Notes:  
      • -
      • Renewals:  
      • -
      • &biblionumber=&invoice=&catview=yes">Accession Date:Accession Date:
      • - -
      • Withdrawn:YesNo
        " /> " /> @@ -112,14 +101,33 @@ NAME="biblionumber"-->&itemnumber=">Modif - +
      • +
      +
    5. History
    6. + +
    7. Notes
    8. +
        +
      • Public Note: +
        " /> + " />" /> +
        +
      • + +
      -
    9. Total Issues:0 (&bi=&itm=">View Circulation History)
    10. -
    11. Group Number:
    12. -
    13. Biblio number:
    -- 2.39.2