@@ -, +, @@ --- C4/Auth.pm | 1 + C4/Biblio.pm | 113 ++++++++++++++++++++ C4/Search.pm | 82 ++++++++++++++ admin/systempreferences.pl | 1 + catalogue/recentacquisitions.pl | 84 +++++++++++++++ installer/data/mysql/updatedatabase.pl | 8 ++- .../en/modules/catalogue/recentacquisitions.tmpl | 108 +++++++++++++++++++ .../prog/en/modules/intranet-main.tmpl | 3 + koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc | 1 + .../prog/en/modules/opac-recentacquisitions.tmpl | 106 ++++++++++++++++++ opac/opac-recentacquisitions.pl | 86 +++++++++++++++ 11 files changed, 592 insertions(+), 1 deletions(-) create mode 100755 catalogue/recentacquisitions.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/recentacquisitions.tmpl create mode 100644 koha-tmpl/opac-tmpl/prog/en/modules/opac-recentacquisitions.tmpl create mode 100755 opac/opac-recentacquisitions.pl --- a/C4/Auth.pm +++ a/C4/Auth.pm @@ -404,6 +404,7 @@ sub get_template_and_user { OPACPatronDetails => C4::Context->preference("OPACPatronDetails"), OPACFinesTab => C4::Context->preference("OPACFinesTab"), OpacTopissue => C4::Context->preference("OpacTopissue"), + OpacRecentAcquisitions => C4::Context->preference("OpacRecentAcquisitions"), RequestOnOpac => C4::Context->preference("RequestOnOpac"), TemplateEncoding => "". C4::Context->preference("TemplateEncoding"), 'Version' => C4::Context->preference('Version'), --- a/C4/Biblio.pm +++ a/C4/Biblio.pm @@ -57,6 +57,7 @@ BEGIN { &GetBiblioItemInfosOf &GetBiblioItemByBiblioNumber &GetBiblioFromItemNumber + &GetBiblioSummary &GetRecordValue &GetFieldMapping @@ -1267,6 +1268,118 @@ sub GetCOinSBiblio { return $coins_value; } +=head2 GetBiblioSummary + +=over 4 + +$summary = GetBiblioSummary($marcrecord); + +Return the summary of a record. + +=back + +=cut + +sub GetBiblioSummary { + my $recorddata =shift @_; + + my $marcflavour = C4::Context->preference("marcflavour"); + my $marc=MARC::Record::new_from_xml($recorddata,"utf-8",$marcflavour); + + my $str; + + if($marcflavour eq "MARC21"){ + $str="".$marc->subfield('245',"a")."" if $marc->subfield('245','a'); + $str.= " ".$marc->subfield('245',"b")." " if $marc->subfield('245','b'); + + if ($marc->field('245')){ + $str.=" / "; + foreach ($marc->field('100')->subfield("a")) { + $str.=$_." ; "; + } + $str=~s/ ; $/. /; + } + + if ($marc->field('260')){ + $str.=" - "; + $str.=$marc->subfield('260',"a")." " if $marc->subfield('260','a'); + $str.=" : ".$marc->subfield('260',"b")." " if $marc->subfield('260','b'); + $str.=", ".$marc->subfield('260',"c")." " if $marc->subfield('260','c'); + } + if ($marc->field('300')){ + $str.=" - "; + $str.=$marc->subfield('300','a') if ($marc->subfield(300,'a')); + $str.=" ; ".$marc->subfield('300','b') if $marc->subfield('300','b'); + $str.=" ; ".$marc->subfield('300','c') if $marc->subfield('300','c'); + $str.=" ; ".$marc->subfield('300','e') if $marc->subfield('300','e'); + } + foreach ($marc->field('500')){ + $str.= " - "; + foreach ($_->subfield("a")){ + $str.=$_."; " + } + } + my $itemtypes=GetItemTypes(); + $str.=" - ".$itemtypes->{$marc->subfield('942','c')}->{'description'}." "; + $str.="
\n"; + + }else{ + $str = "".$marc->subfield('200','a')."" if $marc->subfield('200','a'); + $str.= " ".$marc->subfield('200','e')." " if $marc->subfield('200','e'); + if ($marc->field('200')){ + $str.=" / "; + foreach ($marc->field('200')->subfield("f")) { + $str.=$_." ; "; + } + $str=~s/ ; $/. /; + } + + if ($marc->subfield('200','g')){ + $str.=" ; "; + foreach ($marc->field('200')->subfield("g")){ + $str.=$_." ; "; + } + $str=~s/ ; $/. /; + } + + if ($marc->field('461')){ + $str.="- In :"; + $str.= $marc->subfield('461','t') if $marc->subfield('461','t'); + $str.=", ".$marc->subfield('461','d') if $marc->subfield('461','d'); + $str.=", ".$marc->subfield('461','v') if $marc->subfield('461','v'); + $str.=", ".$marc->subfield('461','h') if $marc->subfield('461','h'); + $str.=" ; ".$marc->subfield('461','x') if $marc->subfield('461','x'); + } + + if ($marc->field('210')){ + $str.=" - "; + $str.=$marc->subfield('210',"a")." " if $marc->subfield('210','a'); + $str.=" : ".$marc->subfield('210',"c")." " if $marc->subfield('210','c'); + $str.=", ".$marc->subfield('210',"d")." " if $marc->subfield('210','d'); + } + + if ($marc->field('215')){ + $str.=" - "; + $str.=$marc->subfield('215','a') if ($marc->subfield(215,'a')); + $str.=" ; ".$marc->subfield('215','d') if $marc->subfield('215','d'); + $str.=" ; ".$marc->subfield('215','c') if $marc->subfield('215','c'); + $str.=" ; ".$marc->subfield('215','e') if $marc->subfield('215','e'); + } + foreach ($marc->field('300')){ + $str.=" - "; + foreach ($_->subfield("a")){ + $str.=$_."; " + } + } + + my $itemtypes=GetItemTypes; + if($itemtypes->{$marc->subfield('200','b')}){ + $str.=" - ".$itemtypes->{$marc->subfield('200','b')}->{'description'}." "; + } + $str.="
\n"; + } + return $str; +} =head2 GetAuthorisedValueDesc --- a/C4/Search.pm +++ a/C4/Search.pm @@ -60,6 +60,7 @@ This module provides searching functions for Koha's bibliographic databases &FindDuplicate &SimpleSearch &searchResults + &SearchAcquisitions &getRecords &buildQuery &NZgetRecords @@ -1468,6 +1469,87 @@ sub searchResults { return @newresults; } +=head2 SearchAcquisitions + Search for acquisitions +=cut + +sub SearchAcquisitions{ + my ($datebegin, $dateend, $itemtypes,$criteria, $orderby) = @_; + + my $dbh=C4::Context->dbh; + # Variable initialization + my $str=qq| + SELECT marcxml + FROM biblio + LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber + LEFT JOIN items ON items.biblionumber=biblio.biblionumber + WHERE dateaccessioned BETWEEN ? AND ? + |; + + my (@params,@loopcriteria); + + push @params, $datebegin->output("iso"); + push @params, $dateend->output("iso"); + + if (scalar(@$itemtypes)>0 and $criteria ne "itemtype" ){ + if(C4::Context->preference("item-level_itypes")){ + $str .= "AND items.itype IN (?".( ',?' x scalar @$itemtypes - 1 ).") "; + }else{ + $str .= "AND biblioitems.itemtype IN (?".( ',?' x scalar @$itemtypes - 1 ).") "; + } + push @params, @$itemtypes; + } + + if ($criteria =~/itemtype/){ + if(C4::Context->preference("item-level_itypes")){ + $str .= "AND items.itype=? "; + }else{ + $str .= "AND biblioitems.itemtype=? "; + } + @loopcriteria= @$itemtypes; + }elsif ($criteria=~/itemcallnumber/){ + $str .= "AND (items.itemcallnumber LIKE CONCAT(?,'%') + OR items.itemcallnumber is NULL + OR items.itemcallnumber = '')"; + @loopcriteria = ("AA".."zz", "") unless (scalar(@loopcriteria)>0); + }else { + $str .= "AND biblio.title LIKE CONCAT(?,'%') "; + @loopcriteria = ("A".."z") unless (scalar(@loopcriteria)>0); + } + + if ($orderby =~ /date_desc/){ + $str.=" ORDER BY dateaccessioned DESC"; + } else { + $str.=" ORDER BY title"; + } + + my $qdataacquisitions=$dbh->prepare($str); + + my @loopacquisitions; + foreach my $value(@loopcriteria){ + push @params,$value; + my %cell; + $cell{"title"}=$value; + $cell{"titlecode"}=$value; + + eval{$qdataacquisitions->execute(@params);}; + + if ($@){ warn "recentacquisitions Error :$@";} + else { + my @loopdata; + while (my $data=$qdataacquisitions->fetchrow_hashref){ + push @loopdata, {"summary"=>GetBiblioSummary( $data->{'marcxml'} ) }; + } + $cell{"loopdata"}=\@loopdata; + } + push @loopacquisitions,\%cell if (scalar(@{$cell{loopdata}})>0); + pop @params; + } + $qdataacquisitions->finish; + return \@loopacquisitions; +} + + #---------------------------------------------------------------------- # # Non-Zebra GetRecords# --- a/admin/systempreferences.pl +++ a/admin/systempreferences.pl @@ -345,6 +345,7 @@ $tabsysprefs{AnonSuggestions} = "OPAC"; $tabsysprefs{suggestion} = "OPAC"; $tabsysprefs{OpacTopissue} = "OPAC"; $tabsysprefs{OpacBrowser} = "OPAC"; +$tabsysprefs{OpacRecentAcquisitions} = "OPAC"; $tabsysprefs{kohaspsuggest} = "OPAC"; $tabsysprefs{OpacRenewalAllowed} = "OPAC"; $tabsysprefs{OPACItemHolds} = "OPAC"; --- a/catalogue/recentacquisitions.pl +++ a/catalogue/recentacquisitions.pl @@ -0,0 +1,84 @@ +#!/usr/bin/perl + +#attention fichier pour notices MARC21 + +use strict; +use warnings; + +use C4::Context; +use C4::Search; +use MARC::File::XML; +#use XML::LibXML; +#use XML::LibXSLT; +use CGI; +use C4::Dates; +use Date::Calc; +use C4::Auth; +use C4::Output; +use C4::Koha; + +my $query= new CGI; +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "catalogue/recentacquisitions.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {catalogue => 1}, + debug => 1, + } +); + +my $op = $query->param('op'); +if ($op eq "show_list"){ + + my $datebegin = C4::Dates->new($query->param('datebegin')); + my $dateend = C4::Dates->new($query->param('dateend')) if ($query->param('dateend')); + + my $orderby = $query->param('orderby') if ($query->param('orderby')); + my $criteria = $query->param('criteria'); + my @itemtypes = $query->param('itemtypes'); + + + my $loopacquisitions = SearchAcquisitions($datebegin, $dateend, \@itemtypes, + $criteria, $orderby); + + $template->param(loopacquisitions=>$loopacquisitions, + show_list=>1); +} else { + my $period = C4::Context->preference("recentacquisitionregularPeriod")||30; + my $dateend = C4::Dates->new(); + #warn " dateend :".$dateend->output("syspref"); + my @dateend = Date::Calc::Today; + my @datebegin = Date::Calc::Add_Delta_Days(@dateend,-$period) if ($period); + my $datebegin = C4::Dates->new(sprintf("%04d-%02d-%02d",@datebegin[0..2]),'iso'); + #warn 'datebegin :'.$datebegin->output("syspref")." dateend :".$dateend->output("syspref"); + my $itemtypes = GetItemTypes; + + my @itemtypesloop; + my $selected=1; + my $cnt; + my $imgdir = getitemtypeimagesrc(); + + foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) { + my %row =( number=>$cnt++, + imageurl=> $itemtypes->{$thisitemtype}->{'imageurl'}?($imgdir."/".$itemtypes->{$thisitemtype}->{'imageurl'}):"", + code => $thisitemtype, + selected => $selected, + description => $itemtypes->{$thisitemtype}->{'description'}, + count5 => $cnt % 4, + ); + $selected = 0 if ($selected) ; + push @itemtypesloop, \%row; + } + + $template->param(datebegin => $datebegin->output("syspref"), + dateend => $dateend->output("syspref"),); + $template->param(period => $period, + itemtypeloop => \@itemtypesloop, + DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), + ); + +} +output_html_with_http_headers $query, $cookie, $template->output; + --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -3064,7 +3064,13 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } - +$DBversion = "3.01.00.116"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,type) + VALUES ('OpacRecentAcquisitions','1','If on, show OPAC link to recent acquisitions page.','YesNo');"); + print "Upgrade to $DBversion done drop column budget_amount_sublevel from aqbudgets\n"; + SetVersion ($DBversion); +} =item DropAllForeignKeys($table) --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/recentacquisitions.tmpl +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/recentacquisitions.tmpl @@ -0,0 +1,108 @@ + + + Catalogue › Recent Acquisitions <!-- TMPL_IF NAME="show_list" -->› Results<!-- TMPL_ELSE -->› Choose<!-- /TMPL_IF --> + + + + + + + + + +
+ +
+
+
+ + +

Recent Acquisitions

+ + ">
+ + + +

">

+ +

+ + + +
+
Recent Acquisitions +

Between "/> + + and " type="text" /> + +

+

+ List by: + +

+ +

Limit by item type:

+ + + + + + + +
+ + " alt="" /> + + " name="itemtypes" value="" />  + +
+ +

Order by: + +

+ + +
+
+ + +
+
+ + +
+
+
+
+
+ --- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tmpl +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tmpl @@ -48,6 +48,9 @@ +
  • + Recent Acquisitions +
  • Lists

    --- a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc +++ a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc @@ -85,6 +85,7 @@ | Tag Cloud | Subject Cloud | Most Popular + | Recent Acquisitions | Purchase Suggestions | Purchase Suggestions --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-recentacquisitions.tmpl +++ a/koha-tmpl/opac-tmpl/prog/en/modules/opac-recentacquisitions.tmpl @@ -0,0 +1,106 @@ + +Koha en ligne + Catalogue › Acquisitions RĂ©centes › Resultats› Choisir + + + + + + + +
    + +
    +
    +
    + + +

    Recent Acquisitions

    + + ">
    + + + +

    ">

    + +

    + + + +
    +
    Recent Acquisitions +

    Between "/> + + and " type="text" /> + +

    +

    + List by: + +

    + +

    Limit by item type:

    + + + + + + + +
    + + " alt="" /> + + " name="itemtypes" value="" />  + +
    + +

    Order by: + +

    + + +
    +
    + + +
    +
    + + +
    +
    +
    +
    +
    + --- a/opac/opac-recentacquisitions.pl +++ a/opac/opac-recentacquisitions.pl @@ -0,0 +1,86 @@ +#!/usr/bin/perl + +#attention fichier pour notices MARC21 + +use strict; +use warnings; + +use C4::Context; +use C4::Search; +use MARC::File::XML; +#use XML::LibXML; +#use XML::LibXSLT; +use CGI; +use C4::Dates; +use Date::Calc; +use C4::Auth; +use C4::Output; +use C4::Koha; + +my $query= new CGI; +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "opac-recentacquisitions.tmpl", + query => $query, + type => "opac", + authnotrequired => 1, + flagsrequired => {}, + debug => 1, + } +); + +die() unless C4::Context->preference("OpacRecentAcquisitions"); + +my $op = $query->param('op'); +if ($op eq "show_list"){ + + my $datebegin = C4::Dates->new($query->param('datebegin')); + my $dateend = C4::Dates->new($query->param('dateend')) if ($query->param('dateend')); + + my $orderby = $query->param('orderby') if ($query->param('orderby')); + my $criteria = $query->param('criteria'); + my @itemtypes = $query->param('itemtypes'); + + + my $loopacquisitions = SearchAcquisitions($datebegin, $dateend, \@itemtypes, + $criteria, $orderby); + + $template->param(loopacquisitions=>$loopacquisitions, + show_list=>1); +} else { + my $period = C4::Context->preference("recentacquisitionregularPeriod")||30; + my $dateend = C4::Dates->new(); + #warn " dateend :".$dateend->output("syspref"); + my @dateend = Date::Calc::Today; + my @datebegin = Date::Calc::Add_Delta_Days(@dateend,-$period) if ($period); + my $datebegin = C4::Dates->new(sprintf("%04d-%02d-%02d",@datebegin[0..2]),'iso'); + #warn 'datebegin :'.$datebegin->output("syspref")." dateend :".$dateend->output("syspref"); + my $itemtypes = GetItemTypes; + + my @itemtypesloop; + my $selected=1; + my $cnt; + my $imgdir = getitemtypeimagesrc(); + + foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) { + my %row =( number=>$cnt++, + imageurl=> $itemtypes->{$thisitemtype}->{'imageurl'}?($imgdir."/".$itemtypes->{$thisitemtype}->{'imageurl'}):"", + code => $thisitemtype, + selected => $selected, + description => $itemtypes->{$thisitemtype}->{'description'}, + count5 => $cnt % 4, + ); + $selected = 0 if ($selected) ; + push @itemtypesloop, \%row; + } + + $template->param(datebegin => $datebegin->output("syspref"), + dateend => $dateend->output("syspref"),); + $template->param(period => $period, + itemtypeloop => \@itemtypesloop, + DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), + ); + +} +output_html_with_http_headers $query, $cookie, $template->output; + --