[Koha-patches] [PATCH] (bug #3710) add recent acquisitions script
Nahuel ANGELINETTI
nahuel.angelinetti at biblibre.com
Wed Oct 14 15:48:58 CEST 2009
This script in opac and intranet add the feature to search in recent acquisitions.
It add a syspref OpacRecentAcquisitions to enable the script in opac.
---
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
diff --git a/C4/Auth.pm b/C4/Auth.pm
index 0b92868..d1288cb 100755
--- a/C4/Auth.pm
+++ b/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'),
diff --git a/C4/Biblio.pm b/C4/Biblio.pm
index 9b63223..88a8d27 100755
--- a/C4/Biblio.pm
+++ b/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="<b>".$marc->subfield('245',"a")."</b>" if $marc->subfield('245','a');
+ $str.= " <i>".$marc->subfield('245',"b")."</i> " 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.=" - <u>".$itemtypes->{$marc->subfield('942','c')}->{'description'}."</u> ";
+ $str.="<br />\n";
+
+ }else{
+ $str = "<b>".$marc->subfield('200','a')."</b>" if $marc->subfield('200','a');
+ $str.= " <i>".$marc->subfield('200','e')."</i> " 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.=" - <u>".$itemtypes->{$marc->subfield('200','b')}->{'description'}."</u> ";
+ }
+ $str.="<br />\n";
+ }
+ return $str;
+}
=head2 GetAuthorisedValueDesc
diff --git a/C4/Search.pm b/C4/Search.pm
index c47b130..b8644d4 100644
--- a/C4/Search.pm
+++ b/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, at 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#
diff --git a/admin/systempreferences.pl b/admin/systempreferences.pl
index fa7c749..067ab12 100755
--- a/admin/systempreferences.pl
+++ b/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";
diff --git a/catalogue/recentacquisitions.pl b/catalogue/recentacquisitions.pl
new file mode 100755
index 0000000..c0cc790
--- /dev/null
+++ b/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", at 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;
+
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index 6c552f6..e69a923 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/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)
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/recentacquisitions.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/recentacquisitions.tmpl
new file mode 100644
index 0000000..926a48a
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/recentacquisitions.tmpl
@@ -0,0 +1,108 @@
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
+<title>
+ Catalogue › Recent Acquisitions <!-- TMPL_IF NAME="show_list" -->› Results<!-- TMPL_ELSE -->› Choose<!-- /TMPL_IF -->
+</title>
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+<!-- TMPL_INCLUDE NAME="calendar.inc" -->
+</head>
+<body>
+
+<!-- TMPL_INCLUDE NAME="header.inc" -->
+<!-- TMPL_INCLUDE NAME="cat-search.inc" -->
+
+<div id="doc3" class="yui-t2">
+
+ <div id="bd">
+ <div id="yui-main">
+ <div class="yui-b">
+
+<!-- TMPL_IF NAME="show_list" -->
+ <h1>Recent Acquisitions </h1>
+ <!-- TMPL_LOOP NAME="loopacquisitions" -->
+ <a href="#<!--TMPL_VAR Name="titlecode"-->"><!--TMPL_VAR Name="title"--></a><br />
+ <!-- /TMPL_LOOP -->
+
+ <!-- TMPL_LOOP NAME="loopacquisitions" -->
+ <h2><a name="<!--TMPL_VAR Name="titlecode"-->"><!--TMPL_VAR Name="title"--></a></h2>
+ <!-- TMPL_LOOP NAME="loopdata" -->
+ <!--TMPL_VAR Name="summary"--><br /> <br/>
+ <!-- /TMPL_LOOP-->
+ <!-- /TMPL_LOOP -->
+<!-- TMPL_ELSE -->
+ <form method="get" action="">
+ <fieldset class="rows"><legend>Recent Acquisitions </legend>
+ <p>Between <input type="text" readonly="readonly" size="10" id="datebegin" name="datebegin" value="<!--TMPL_VAR Name="datebegin"-->"/>
+ <script type="text/javascript">
+ //<![CDATA[
+ Calendar.setup(
+ {
+ inputField : "datebegin",
+ ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
+ button : "openCalendarDateBegin",
+ }
+ );
+ //]]>
+ </script>
+ and <input readonly="readonly" size="10" id="dateend" name="dateend" value="<!--TMPL_VAR Name="dateend"-->" type="text" />
+
+ <script type="text/javascript">
+ //<![CDATA[
+ Calendar.setup(
+ {
+ inputField : "dateend",
+ ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
+ button : "openCalendarDateEnd",
+ }
+ );
+ //]]>
+ </script></p>
+ <p>
+ List by:
+ <select name="criteria">
+ <option value="itemtype">Item Type</option>
+ <option value="itemcallnumber">Call Number</option>
+ <option value="title">Title</option>
+ </select>
+ </p>
+
+ <p>Limit by item type:</p>
+ <table>
+ <tr>
+ <!--TMPL_LOOP Name="itemtypeloop"-->
+ <td>
+ <!-- TMPL_IF name="imageurl"-->
+ <img border="0" src="<!--TMPL_VAR Name="imageurl" -->" alt="<!--TMPL_VAR Name="description" -->" />
+ <!-- /TMPL_IF -->
+ <input type="checkbox" id="mc-<!--TMPL_VAR Name="number" -->" name="itemtypes" value="<!--TMPL_VAR Name="code" -->" />
+ <label for="mc-<!--TMPL_VAR Name="number" -->">
+ <!--TMPL_VAR Name="description" -->
+ </label>
+ </td>
+ <!-- TMPL_UNLESS name="count5" --></tr><tr><!-- /TMPL_UNLESS -->
+ <!--/TMPL_LOOP-->
+ </tr>
+ </table>
+
+ <p>Order by:
+ <select name="orderby">
+ <option value=""> </option>
+ <option value="date_desc">Date desc</option>
+ <option value="title">Title</option>
+ </select>
+ </p>
+
+
+ </fieldset>
+ <fieldset class="action">
+ <input type="submit" value="Submit" name="OK"/>
+ <input type="hidden" name="op" value="show_list" />
+ </fieldset>
+ </form>
+<!-- /TMPL_IF -->
+
+</div>
+</div>
+<div class="yui-b">
+</div>
+</div>
+<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tmpl
index 07159e1..795a223 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tmpl
@@ -48,6 +48,9 @@
<input type="submit" value=" OK " class="submit" />
</form>
</li>
+ <li>
+ <a accesskey="v" href="/cgi-bin/koha/catalogue/recentacquisitions.pl">Recent Acquisitions</a>
+ </li>
</ul>
<!-- /TMPL_IF -->
<h3><a href="/cgi-bin/koha/virtualshelves/shelves.pl">Lists</a></h3>
diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc
index 0112166..8633617 100644
--- a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc
+++ b/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc
@@ -85,6 +85,7 @@
<!-- TMPL_IF NAME="TagsEnabled" --><span class="pipe"> | </span><a href="/cgi-bin/koha/opac-tags.pl">Tag Cloud</a><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="OpacCloud" --><span class="pipe"> | </span><a href="/cgi-bin/koha/opac-tags_subject.pl">Subject Cloud</a><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="OpacTopissue" --><span class="pipe"> | </span><a href="/cgi-bin/koha/opac-topissues.pl">Most Popular</a><!-- /TMPL_IF -->
+<!-- TMPL_IF NAME="OpacRecentAcquisitions" --><span class="pipe"> | </span><a href="/cgi-bin/koha/opac-recentacquisitions.pl">Recent Acquisitions</a><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="suggestion" -->
<!-- TMPL_IF NAME="AnonSuggestions" --><span class="pipe"> | </span><a href="/cgi-bin/koha/opac-suggestions.pl">Purchase Suggestions</a>
<!-- TMPL_ELSIF NAME="OPACViewOthersSuggestions" --><span class="pipe"> | </span><a href="/cgi-bin/koha/opac-suggestions.pl">Purchase Suggestions</a>
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-recentacquisitions.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-recentacquisitions.tmpl
new file mode 100644
index 0000000..694b1d9
--- /dev/null
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-recentacquisitions.tmpl
@@ -0,0 +1,106 @@
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
+<!-- TMPL_IF NAME="LibraryNameTitle" --><!-- TMPL_VAR NAME="LibraryNameTitle" --><!-- TMPL_ELSE -->Koha en ligne<!-- /TMPL_IF -->
+ Catalogue › Acquisitions Récentes <!-- TMPL_IF NAME="show_list" -->› Resultats<!-- TMPL_ELSE -->› Choisir<!-- /TMPL_IF -->
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+<!-- TMPL_INCLUDE NAME="calendar.inc" -->
+</head>
+<body>
+<!-- TMPL_INCLUDE NAME="masthead.inc" -->
+
+
+<div id="doc3" class="yui-t2">
+
+ <div id="bd">
+ <div id="yui-main">
+ <div class="yui-b">
+
+<!-- TMPL_IF NAME="show_list" -->
+ <h1>Recent Acquisitions </h1>
+ <!-- TMPL_LOOP NAME="loopacquisitions" -->
+ <a href="#<!--TMPL_VAR Name="titlecode"-->"><!--TMPL_VAR Name="title"--></a><br />
+ <!-- /TMPL_LOOP -->
+
+ <!-- TMPL_LOOP NAME="loopacquisitions" -->
+ <h2><a name="<!--TMPL_VAR Name="titlecode"-->"><!--TMPL_VAR Name="title"--></a></h2>
+ <!-- TMPL_LOOP NAME="loopdata" -->
+ <!--TMPL_VAR Name="summary"--><br /> <br/>
+ <!-- /TMPL_LOOP-->
+ <!-- /TMPL_LOOP -->
+<!-- TMPL_ELSE -->
+ <form method="get" action="">
+ <fieldset class="rows"><legend>Recent Acquisitions </legend>
+ <p>Between <input type="text" readonly="readonly" size="10" id="datebegin" name="datebegin" value="<!--TMPL_VAR Name="datebegin"-->"/>
+ <script type="text/javascript">
+ //<![CDATA[
+ Calendar.setup(
+ {
+ inputField : "datebegin",
+ ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
+ button : "openCalendarDateBegin",
+ }
+ );
+ //]]>
+ </script>
+ and <input readonly="readonly" size="10" id="dateend" name="dateend" value="<!--TMPL_VAR Name="dateend"-->" type="text" />
+
+ <script type="text/javascript">
+ //<![CDATA[
+ Calendar.setup(
+ {
+ inputField : "dateend",
+ ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
+ button : "openCalendarDateEnd",
+ }
+ );
+ //]]>
+ </script></p>
+ <p>
+ List by:
+ <select name="criteria">
+ <option value="itemtype">Item Type</option>
+ <option value="itemcallnumber">Call Number</option>
+ <option value="title">Title</option>
+ </select>
+ </p>
+
+ <p>Limit by item type:</p>
+ <table>
+ <tr>
+ <!--TMPL_LOOP Name="itemtypeloop"-->
+ <td>
+ <!-- TMPL_IF name="imageurl"-->
+ <img border="0" src="<!--TMPL_VAR Name="imageurl" -->" alt="<!--TMPL_VAR Name="description" -->" />
+ <!-- /TMPL_IF -->
+ <input type="checkbox" id="mc-<!--TMPL_VAR Name="number" -->" name="itemtypes" value="<!--TMPL_VAR Name="code" -->" />
+ <label for="mc-<!--TMPL_VAR Name="number" -->">
+ <!--TMPL_VAR Name="description" -->
+ </label>
+ </td>
+ <!-- TMPL_UNLESS name="count5" --></tr><tr><!-- /TMPL_UNLESS -->
+ <!--/TMPL_LOOP-->
+ </tr>
+ </table>
+
+ <p>Order by:
+ <select name="orderby">
+ <option value=""> </option>
+ <option value="date_desc">Date desc</option>
+ <option value="title">Title</option>
+ </select>
+ </p>
+
+
+ </fieldset>
+ <fieldset class="action">
+ <input type="submit" value="Submit" name="OK"/>
+ <input type="hidden" name="op" value="show_list" />
+ </fieldset>
+ </form>
+<!-- /TMPL_IF -->
+
+</div>
+</div>
+<div class="yui-b">
+</div>
+</div>
+<!-- TMPL_INCLUDE NAME="opac-bottom.inc" -->
diff --git a/opac/opac-recentacquisitions.pl b/opac/opac-recentacquisitions.pl
new file mode 100755
index 0000000..39d45f6
--- /dev/null
+++ b/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", at 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;
+
--
1.6.0.4
More information about the Koha-patches
mailing list