"Fossies" - the Fresh Open Source Software Archive

Member "koha-19.11.15/catalogue/detail.pl" (23 Feb 2021, 21131 Bytes) of package /linux/misc/koha-19.11.15.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "detail.pl" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 20.05.06_vs_20.11.00.

    1 #!/usr/bin/perl
    2 
    3 # This file is part of Koha.
    4 #
    5 # Koha is free software; you can redistribute it and/or modify it
    6 # under the terms of the GNU General Public License as published by
    7 # the Free Software Foundation; either version 3 of the License, or
    8 # (at your option) any later version.
    9 #
   10 # Koha is distributed in the hope that it will be useful, but
   11 # WITHOUT ANY WARRANTY; without even the implied warranty of
   12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   13 # GNU General Public License for more details.
   14 #
   15 # You should have received a copy of the GNU General Public License
   16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
   17 
   18 
   19 use Modern::Perl;
   20 
   21 use CGI qw ( -utf8 );
   22 use HTML::Entities;
   23 use Try::Tiny;
   24 use C4::Auth;
   25 use C4::Context;
   26 use C4::Koha;
   27 use C4::Serials;    #uses getsubscriptionfrom biblionumber
   28 use C4::Output;
   29 use C4::Biblio;
   30 use C4::Items;
   31 use C4::Circulation;
   32 use C4::Reserves;
   33 use C4::Serials;
   34 use C4::XISBN qw(get_xisbns);
   35 use C4::External::Amazon;
   36 use C4::Search;        # enabled_staff_search_views
   37 use C4::Tags qw(get_tags);
   38 use C4::XSLT;
   39 use C4::Images;
   40 use Koha::DateUtils;
   41 use C4::HTML5Media;
   42 use C4::CourseReserves qw(GetItemCourseReservesInfo);
   43 use C4::Acquisition qw(GetOrdersByBiblionumber);
   44 use Koha::AuthorisedValues;
   45 use Koha::Biblios;
   46 use Koha::Items;
   47 use Koha::ItemTypes;
   48 use Koha::Patrons;
   49 use Koha::Virtualshelves;
   50 use Koha::Plugins;
   51 
   52 my $query = CGI->new();
   53 
   54 my $analyze = $query->param('analyze');
   55 
   56 my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user(
   57     {
   58     template_name   =>  'catalogue/detail.tt',
   59         query           => $query,
   60         type            => "intranet",
   61         flagsrequired   => { catalogue => 1 },
   62     }
   63 );
   64 
   65 # Determine if we should be offering any enhancement plugin buttons
   66 if ( C4::Context->preference('UseKohaPlugins') &&
   67      C4::Context->config('enable_plugins') ) {
   68     # Only pass plugins that can offer a toolbar button
   69     my @plugins = Koha::Plugins->new()->GetPlugins({
   70         method => 'intranet_catalog_biblio_enhancements_toolbar_button'
   71     });
   72 
   73     my @tab_plugins = Koha::Plugins->new()->GetPlugins({
   74         method => 'intranet_catalog_biblio_tab',
   75     });
   76     my @tabs;
   77     foreach my $tab_plugin (@tab_plugins) {
   78         my @biblio_tabs;
   79 
   80         try {
   81             @biblio_tabs = $tab_plugin->intranet_catalog_biblio_tab();
   82             foreach my $tab (@biblio_tabs) {
   83                 my $tab_id = 'tab-' . $tab->title;
   84                 $tab_id =~ s/[^0-9A-Za-z]+/-/g;
   85                 $tab->id( $tab_id );
   86                 push @tabs, $tab,
   87             }
   88         }
   89         catch {
   90             warn "Error calling 'intranet_catalog_biblio_tab' on the " . $tab_plugin->{class} . "plugin ($_)";
   91         };
   92     }
   93 
   94     $template->param(
   95         plugins => \@plugins,
   96         tabs => \@tabs,
   97     );
   98 }
   99 
  100 my $biblionumber = $query->param('biblionumber');
  101 $biblionumber = HTML::Entities::encode($biblionumber);
  102 my $record       = GetMarcBiblio({ biblionumber => $biblionumber });
  103 my $biblio = Koha::Biblios->find( $biblionumber );
  104 $template->param( 'biblio', $biblio );
  105 
  106 if ( not defined $record ) {
  107     # biblionumber invalid -> report and exit
  108     $template->param( unknownbiblionumber => 1,
  109                       biblionumber => $biblionumber );
  110     output_html_with_http_headers $query, $cookie, $template->output;
  111     exit;
  112 }
  113 
  114 eval { $biblio->metadata->record };
  115 $template->param( decoding_error => $@ );
  116 
  117 if($query->cookie("holdfor")){ 
  118     my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
  119     $template->param(
  120         # FIXME Should pass the patron object
  121         holdfor => $query->cookie("holdfor"),
  122         holdfor_surname => $holdfor_patron->surname,
  123         holdfor_firstname => $holdfor_patron->firstname,
  124         holdfor_cardnumber => $holdfor_patron->cardnumber,
  125     );
  126 }
  127 
  128 my $fw           = GetFrameworkCode($biblionumber);
  129 my $showallitems = $query->param('showallitems');
  130 my $marcflavour  = C4::Context->preference("marcflavour");
  131 
  132 # XSLT processing of some stuff
  133 my $xslfile = C4::Context->preference('XSLTDetailsDisplay') || "default";
  134 my $lang   = $xslfile ? C4::Languages::getlanguage()  : undef;
  135 my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef;
  136 
  137 if ( $xslfile ) {
  138     $template->param(
  139         XSLTDetailsDisplay => '1',
  140         XSLTBloc => XSLTParse4Display(
  141                         $biblionumber, $record, "XSLTDetailsDisplay",
  142                         1, undef, $sysxml, $xslfile, $lang
  143                     )
  144     );
  145 }
  146 
  147 $template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") );
  148 
  149 # Catch the exception as Koha::Biblio::Metadata->record can explode if the MARCXML is invalid
  150 # Do not propagate it as we already deal with it previously in this script
  151 my $coins = eval { $biblio->get_coins };
  152 $template->param( ocoins => $coins );
  153 
  154 # some useful variables for enhanced content;
  155 # in each case, we're grabbing the first value we find in
  156 # the record and normalizing it
  157 my $upc = GetNormalizedUPC($record,$marcflavour);
  158 my $ean = GetNormalizedEAN($record,$marcflavour);
  159 my $oclc = GetNormalizedOCLCNumber($record,$marcflavour);
  160 my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
  161 
  162 $template->param(
  163     normalized_upc => $upc,
  164     normalized_ean => $ean,
  165     normalized_oclc => $oclc,
  166     normalized_isbn => $isbn,
  167 );
  168 
  169 my $marcnotesarray   = GetMarcNotes( $record, $marcflavour );
  170 my $marcisbnsarray   = GetMarcISBN( $record, $marcflavour );
  171 my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
  172 my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
  173 my $marcseriesarray  = GetMarcSeries($record,$marcflavour);
  174 my $marcurlsarray    = GetMarcUrls    ($record,$marcflavour);
  175 my $marchostsarray   = GetMarcHosts($record,$marcflavour);
  176 
  177 my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
  178 
  179 my $dbh = C4::Context->dbh;
  180 
  181 my @all_items = GetItemsInfo( $biblionumber );
  182 my @items;
  183 my $patron = Koha::Patrons->find( $borrowernumber );
  184 for my $itm (@all_items) {
  185     push @items, $itm unless ( $itm->{itemlost} && $patron->category->hidelostitems && !$showallitems);
  186 }
  187 
  188 # flag indicating existence of at least one item linked via a host record
  189 my $hostrecords;
  190 # adding items linked via host biblios
  191 my @hostitems = GetHostItemsInfo($record);
  192 if (@hostitems){
  193     $hostrecords =1;
  194     push (@items,@hostitems);
  195 }
  196 
  197 my $dat = &GetBiblioData($biblionumber);
  198 
  199 #coping with subscriptions
  200 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
  201 my @subscriptions       = SearchSubscriptions({ biblionumber => $biblionumber, orderby => 'title' });
  202 my @subs;
  203 
  204 foreach my $subscription (@subscriptions) {
  205     my %cell;
  206     my $serials_to_display;
  207     $cell{subscriptionid}    = $subscription->{subscriptionid};
  208     $cell{subscriptionnotes} = $subscription->{internalnotes};
  209     $cell{missinglist}       = $subscription->{missinglist};
  210     $cell{librariannote}     = $subscription->{librariannote};
  211     $cell{branchcode}        = $subscription->{branchcode};
  212     $cell{hasalert}          = $subscription->{hasalert};
  213     $cell{callnumber}        = $subscription->{callnumber};
  214     $cell{location}          = $subscription->{location};
  215     $cell{closed}            = $subscription->{closed};
  216     #get the three latest serials.
  217     $serials_to_display = $subscription->{staffdisplaycount};
  218     $serials_to_display = C4::Context->preference('StaffSerialIssueDisplayCount') unless $serials_to_display;
  219     $cell{staffdisplaycount} = $serials_to_display;
  220     $cell{latestserials} =
  221       GetLatestSerials( $subscription->{subscriptionid}, $serials_to_display );
  222     push @subs, \%cell;
  223 }
  224 
  225 
  226 # Get acquisition details
  227 if ( C4::Context->preference('AcquisitionDetails') ) {
  228     my $orders = Koha::Acquisition::Orders->search(
  229         { biblionumber => $biblionumber },
  230         {
  231             join => 'basketno',
  232             order_by => 'basketno.booksellerid'
  233         }
  234     );    # GetHistory sorted by aqbooksellerid, but does it make sense?
  235 
  236     $template->param(
  237         orders => $orders,
  238     );
  239 }
  240 
  241 if ( defined $dat->{'itemtype'} ) {
  242     $dat->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $dat->{itemtype} }{imageurl} );
  243 }
  244 
  245 $dat->{'count'} = scalar @all_items + @hostitems;
  246 $dat->{'showncount'} = scalar @items + @hostitems;
  247 $dat->{'hiddencount'} = scalar @all_items + @hostitems - scalar @items;
  248 
  249 my $shelflocations =
  250   { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.location' } ) };
  251 my $collections =
  252   { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.ccode' } ) };
  253 my $copynumbers =
  254   { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.copynumber' } ) };
  255 my (@itemloop, @otheritemloop, %itemfields);
  256 my $norequests = 1;
  257 
  258 my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] });
  259 if ( $mss->count ) {
  260     $template->param( itemlostloop => GetAuthorisedValues( $mss->next->authorised_value ) );
  261 }
  262 $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.damaged', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] });
  263 if ( $mss->count ) {
  264     $template->param( itemdamagedloop => GetAuthorisedValues( $mss->next->authorised_value ) );
  265 }
  266 $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.withdrawn', authorised_value => { not => undef } });
  267 if ( $mss->count ) {
  268     $template->param( itemwithdrawnloop => GetAuthorisedValues( $mss->next->authorised_value) );
  269 }
  270 
  271 $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.materials', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] });
  272 my %materials_map;
  273 if ($mss->count) {
  274     my $materials_authvals = GetAuthorisedValues($mss->next->authorised_value);
  275     if ($materials_authvals) {
  276         foreach my $value (@$materials_authvals) {
  277             $materials_map{$value->{authorised_value}} = $value->{lib};
  278         }
  279     }
  280 }
  281 
  282 my $analytics_flag;
  283 my $materials_flag; # set this if the items have anything in the materials field
  284 my $currentbranch = C4::Context->userenv ? C4::Context->userenv->{branch} : undef;
  285 if ($currentbranch and C4::Context->preference('SeparateHoldings')) {
  286     $template->param(SeparateHoldings => 1);
  287 }
  288 my $separatebranch = C4::Context->preference('SeparateHoldingsBranch') || 'homebranch';
  289 foreach my $item (@items) {
  290     my $itembranchcode = $item->{$separatebranch};
  291 
  292     # can place holds defaults to yes
  293     $norequests = 0 unless ( ( $item->{'notforloan'} > 0 ) || ( $item->{'itemnotforloan'} > 0 ) );
  294 
  295     $item->{imageurl} = defined $item->{itype} ? getitemtypeimagelocation('intranet', $itemtypes->{ $item->{itype} }{imageurl})
  296                                                : '';
  297 
  298     $item->{datedue} = format_sqldatetime($item->{datedue});
  299 
  300     #get shelf location and collection code description if they are authorised value.
  301     # same thing for copy number
  302     my $shelfcode = $item->{'location'};
  303     $item->{'location'} = $shelflocations->{$shelfcode} if ( defined( $shelfcode ) && defined($shelflocations) && exists( $shelflocations->{$shelfcode} ) );
  304     my $ccode = $item->{'ccode'};
  305     $item->{'ccode'} = $collections->{$ccode} if ( defined( $ccode ) && defined($collections) && exists( $collections->{$ccode} ) );
  306     my $copynumber = $item->{'copynumber'};
  307     $item->{'copynumber'} = $copynumbers->{$copynumber} if ( defined($copynumber) && defined($copynumbers) && exists( $copynumbers->{$copynumber} ) );
  308     foreach (qw(ccode enumchron copynumber stocknumber itemnotes itemnotes_nonpublic uri publisheddate)) { # Warning when removing GetItemsInfo - publisheddate (at least) is not part of the items table
  309         $itemfields{$_} = 1 if ( $item->{$_} );
  310     }
  311 
  312     # checking for holds
  313     my $item_object = Koha::Items->find( $item->{itemnumber} );
  314     my $holds = $item_object->current_holds;
  315     if ( my $first_hold = $holds->next ) {
  316         $item->{first_hold} = $first_hold;
  317     }
  318 
  319     if ( my $checkout = $item_object->checkout ) {
  320         $item->{CheckedOutFor} = $checkout->patron;
  321     }
  322 
  323     # Check the transit status
  324     my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($item->{itemnumber});
  325     if ( defined( $transfertwhen ) && ( $transfertwhen ne '' ) ) {
  326         $item->{transfertwhen} = $transfertwhen;
  327         $item->{transfertfrom} = $transfertfrom;
  328         $item->{transfertto}   = $transfertto;
  329         $item->{nocancel} = 1;
  330     }
  331 
  332     foreach my $f (qw( itemnotes )) {
  333         if ($item->{$f}) {
  334             $item->{$f} =~ s|\n|<br />|g;
  335             $itemfields{$f} = 1;
  336         }
  337     }
  338 
  339     #item has a host number if its biblio number does not match the current bib
  340 
  341     if ($item->{biblionumber} ne $biblionumber){
  342         $item->{hostbiblionumber} = $item->{biblionumber};
  343         $item->{hosttitle} = GetBiblioData($item->{biblionumber})->{title};
  344     }
  345     
  346 
  347     if ( $analyze ) {
  348         # count if item is used in analytical bibliorecords
  349         # The 'countanalytics' flag is only used in the templates if analyze is set
  350         my $countanalytics = C4::Context->preference('EasyAnalyticalRecords') ? GetAnalyticsCount($item->{itemnumber}) : 0;
  351         if ($countanalytics > 0){
  352             $analytics_flag=1;
  353             $item->{countanalytics} = $countanalytics;
  354         }
  355     }
  356 
  357     if (defined($item->{'materials'}) && $item->{'materials'} =~ /\S/){
  358         $materials_flag = 1;
  359         if (defined $materials_map{ $item->{materials} }) {
  360             $item->{materials} = $materials_map{ $item->{materials} };
  361         }
  362     }
  363 
  364     if ( C4::Context->preference('UseCourseReserves') ) {
  365         $item->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->{'itemnumber'} );
  366     }
  367 
  368     if ( C4::Context->preference('IndependentBranches') ) {
  369         my $userenv = C4::Context->userenv();
  370         if ( not C4::Context->IsSuperLibrarian()
  371             and $userenv->{branch} ne $item->{homebranch} ) {
  372             $item->{cannot_be_edited} = 1;
  373         }
  374     }
  375 
  376     if ($currentbranch and $currentbranch ne "NO_LIBRARY_SET"
  377     and C4::Context->preference('SeparateHoldings')) {
  378         if ($itembranchcode and $itembranchcode eq $currentbranch) {
  379             push @itemloop, $item;
  380         } else {
  381             push @otheritemloop, $item;
  382         }
  383     } else {
  384         push @itemloop, $item;
  385     }
  386 }
  387 
  388 # Display only one tab if one items list is empty
  389 if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) {
  390     $template->param(SeparateHoldings => 0);
  391     if (scalar(@itemloop) == 0) {
  392         @itemloop = @otheritemloop;
  393     }
  394 }
  395 
  396 $template->param( norequests => $norequests );
  397 $template->param(
  398     MARCNOTES   => $marcnotesarray,
  399     MARCSUBJCTS => $marcsubjctsarray,
  400     MARCAUTHORS => $marcauthorsarray,
  401     MARCSERIES  => $marcseriesarray,
  402     MARCURLS => $marcurlsarray,
  403     MARCISBNS => $marcisbnsarray,
  404     MARCHOSTS => $marchostsarray,
  405     itemdata_ccode      => $itemfields{ccode},
  406     itemdata_enumchron  => $itemfields{enumchron},
  407     itemdata_uri        => $itemfields{uri},
  408     itemdata_copynumber => $itemfields{copynumber},
  409     itemdata_stocknumber => $itemfields{stocknumber},
  410     itemdata_publisheddate => $itemfields{publisheddate},
  411     volinfo                => $itemfields{enumchron},
  412         itemdata_itemnotes  => $itemfields{itemnotes},
  413         itemdata_nonpublicnotes => $itemfields{itemnotes_nonpublic},
  414     z3950_search_params    => C4::Search::z3950_search_args($dat),
  415         hostrecords         => $hostrecords,
  416     analytics_flag    => $analytics_flag,
  417     C4::Search::enabled_staff_search_views,
  418         materials       => $materials_flag,
  419 );
  420 
  421 if (C4::Context->preference("AlternateHoldingsField") && scalar @items == 0) {
  422     my $fieldspec = C4::Context->preference("AlternateHoldingsField");
  423     my $subfields = substr $fieldspec, 3;
  424     my $holdingsep = C4::Context->preference("AlternateHoldingsSeparator") || ' ';
  425     my @alternateholdingsinfo = ();
  426     my @holdingsfields = $record->field(substr $fieldspec, 0, 3);
  427 
  428     for my $field (@holdingsfields) {
  429         my %holding = ( holding => '' );
  430         my $havesubfield = 0;
  431         for my $subfield ($field->subfields()) {
  432             if ((index $subfields, $$subfield[0]) >= 0) {
  433                 $holding{'holding'} .= $holdingsep if (length $holding{'holding'} > 0);
  434                 $holding{'holding'} .= $$subfield[1];
  435                 $havesubfield++;
  436             }
  437         }
  438         if ($havesubfield) {
  439             push(@alternateholdingsinfo, \%holding);
  440         }
  441     }
  442 
  443     $template->param(
  444         ALTERNATEHOLDINGS   => \@alternateholdingsinfo,
  445         );
  446 }
  447 
  448 my @results = ( $dat, );
  449 foreach ( keys %{$dat} ) {
  450     $template->param( "$_" => defined $dat->{$_} ? $dat->{$_} : '' );
  451 }
  452 
  453 # does not work: my %views_enabled = map { $_ => 1 } $template->query(loop => 'EnableViews');
  454 # method query not found?!?!
  455 $template->param( AmazonTld => get_amazon_tld() ) if ( C4::Context->preference("AmazonCoverImages"));
  456 $template->param(
  457     itemloop        => \@itemloop,
  458     otheritemloop   => \@otheritemloop,
  459     biblionumber        => $biblionumber,
  460     ($analyze? 'analyze':'detailview') =>1,
  461     subscriptions       => \@subs,
  462     subscriptionsnumber => $subscriptionsnumber,
  463     subscriptiontitle   => $dat->{title},
  464     searchid            => scalar $query->param('searchid'),
  465 );
  466 
  467 # $debug and $template->param(debug_display => 1);
  468 
  469 # Lists
  470 
  471 if (C4::Context->preference("virtualshelves") ) {
  472     my $shelves = Koha::Virtualshelves->search(
  473         {
  474             biblionumber => $biblionumber,
  475             category => 2,
  476         },
  477         {
  478             join => 'virtualshelfcontents',
  479         }
  480     );
  481     $template->param( 'shelves' => $shelves );
  482 }
  483 
  484 # XISBN Stuff
  485 if (C4::Context->preference("FRBRizeEditions")==1) {
  486     eval {
  487         $template->param(
  488             XISBNS => scalar get_xisbns($isbn, $biblionumber)
  489         );
  490     };
  491     if ($@) { warn "XISBN Failed $@"; }
  492 }
  493 
  494 if ( C4::Context->preference("LocalCoverImages") == 1 ) {
  495     my @images = ListImagesForBiblio($biblionumber);
  496     $template->{VARS}->{localimages} = \@images;
  497 }
  498 
  499 # HTML5 Media
  500 if ( (C4::Context->preference("HTML5MediaEnabled") eq 'both') or (C4::Context->preference("HTML5MediaEnabled") eq 'staff') ) {
  501     $template->param( C4::HTML5Media->gethtml5media($record));
  502 }
  503 
  504 # Displaying tags
  505 
  506 my $tag_quantity;
  507 if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->preference('TagsShowOnDetail')) {
  508     $template->param(
  509         TagsEnabled => 1,
  510         TagsShowOnDetail => $tag_quantity
  511     );
  512     $template->param(TagLoop => get_tags({biblionumber=>$biblionumber, approved=>1,
  513                                 'sort'=>'-weight', limit=>$tag_quantity}));
  514 }
  515 
  516 #we only need to pass the number of holds to the template
  517 my $holds = $biblio->holds;
  518 $template->param( holdcount => $holds->count );
  519 
  520 my $StaffDetailItemSelection = C4::Context->preference('StaffDetailItemSelection');
  521 if ($StaffDetailItemSelection) {
  522     # Only enable item selection if user can execute at least one action
  523     if (
  524         $flags->{superlibrarian}
  525         || (
  526             ref $flags->{tools} eq 'HASH' && (
  527                 $flags->{tools}->{items_batchmod}       # Modify selected items
  528                 || $flags->{tools}->{items_batchdel}    # Delete selected items
  529             )
  530         )
  531         || ( ref $flags->{tools} eq '' && $flags->{tools} )
  532       )
  533     {
  534         $template->param(
  535             StaffDetailItemSelection => $StaffDetailItemSelection );
  536     }
  537 }
  538 
  539 my @allorders_using_biblio = GetOrdersByBiblionumber ($biblionumber);
  540 my @deletedorders_using_biblio;
  541 my @orders_using_biblio;
  542 my @baskets_orders;
  543 my @baskets_deletedorders;
  544 
  545 foreach my $myorder (@allorders_using_biblio) {
  546     my $basket = $myorder->{'basketno'};
  547     if ((defined $myorder->{'datecancellationprinted'}) and  ($myorder->{'datecancellationprinted'} ne '0000-00-00') ){
  548         push @deletedorders_using_biblio, $myorder;
  549         unless (grep(/^$basket$/, @baskets_deletedorders)){
  550             push @baskets_deletedorders,$myorder->{'basketno'};
  551         }
  552     }
  553     else {
  554         push @orders_using_biblio, $myorder;
  555         unless (grep(/^$basket$/, @baskets_orders)){
  556             push @baskets_orders,$myorder->{'basketno'};
  557             }
  558     }
  559 }
  560 
  561 $template->param(biblio => $biblio);
  562 
  563 my $count_orders_using_biblio = scalar @orders_using_biblio ;
  564 $template->param (countorders => $count_orders_using_biblio);
  565 
  566 my $count_deletedorders_using_biblio = scalar @deletedorders_using_biblio ;
  567 $template->param (countdeletedorders => $count_deletedorders_using_biblio);
  568 
  569 $template->param (basketsorders => \@baskets_orders);
  570 $template->param (basketsdeletedorders => \@baskets_deletedorders);
  571 
  572 output_html_with_http_headers $query, $cookie, $template->output;