From 8cafcef8bfe1cb500f662dd278a60e5a153bd799 Mon Sep 17 00:00:00 2001 From: Darrell Ulm Date: Tue, 1 Apr 2008 12:01:00 -0500 Subject: [PATCH] All patches to Koha 3 beta to date. All work with branches. Billing.pl -- new, gives bills that occur in a range, works pendingreserves.pl -- fixed, works now, with branches also reserveratios.pl -- indicates distressed reserves itemslost.pl -- Fix to this to make it more useful and fix bugs Itmes.pm -- small change to work for itemslost, should not affect anything else and all tmpl files. Signed-off-by: Galen Charlton Signed-off-by: Joshua Ferraro --- C4/Items.pm | 13 +- circ/billing.pl | 216 ++++++++++++++ circ/pendingreserves.pl | 264 +++++++++++------- circ/reserveratios.pl | 206 ++++++++++++++ .../prog/en/modules/circ/billing.tmpl | 175 ++++++++++++ .../en/modules/circ/circulation-home.tmpl | 2 + .../prog/en/modules/circ/pendingreserves.tmpl | 71 +++-- .../prog/en/modules/circ/reserveratios.tmpl | 186 ++++++++++++ .../prog/en/modules/reports/itemslost.tmpl | 22 +- reports/itemslost.pl | 14 +- 10 files changed, 1031 insertions(+), 138 deletions(-) create mode 100755 circ/billing.pl create mode 100755 circ/reserveratios.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/circ/billing.tmpl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tmpl diff --git a/C4/Items.pm b/C4/Items.pm index a315e94392..eccc5aef69 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -876,14 +876,19 @@ sub GetLostItems { my $query = " SELECT * - FROM items - WHERE itemlost IS NOT NULL - AND itemlost <> 0 + FROM items, biblio, authorised_values + WHERE + items.biblionumber = biblio.biblionumber + AND items.itemlost = authorised_values.authorised_value + AND authorised_values.category = 'LOST' + AND itemlost IS NOT NULL + AND itemlost <> 0 + "; foreach my $key (keys %$where) { $query .= " AND " . $key . " LIKE '%" . $where->{$key} . "%'"; } - $query .= " ORDER BY ".$orderby if defined $orderby; + $query .= " ORDER BY ".$orderby." " if defined $orderby; my $sth = $dbh->prepare($query); $sth->execute; diff --git a/circ/billing.pl b/circ/billing.pl new file mode 100755 index 0000000000..f73962d890 --- /dev/null +++ b/circ/billing.pl @@ -0,0 +1,216 @@ +#!/usr/bin/perl + + +# Copyright 2000-2002 Katipo Communications +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + +use strict; +use C4::Context; +use C4::Output; +use CGI; +use C4::Auth; +use C4::Dates qw/format_date format_date_in_iso/; + +use vars qw($debug); + +BEGIN { + $debug = $ENV{DEBUG} || 0; +} + +my $input = new CGI; +my $order = $input->param('order'); +my $startdate=$input->param('from'); +my $enddate=$input->param('to'); +my $max_bill=$input->param('ratio'); + +my $theme = $input->param('theme'); # only used if allowthemeoverride is set + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "circ/billing.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => { circulate => 1 }, + debug => 1, + } +); + +my $duedate; +my $borrowernumber; +my $itemnum; +my $data1; +my $data2; +my $data3; +my $name; +my $phone; +my $email; +my $biblionumber; +my $title; +my $author; + +my @datearr = localtime( time() ); +my +$todaysdate = + ( 1900 + $datearr[5] ) . '-' + . sprintf( "%0.2d", ( $datearr[4] + 1 ) ) . '-' + . sprintf( "%0.2d", $datearr[3] ); + +# Find yesterday for the default shelf pull start and end dates +# A defualt of the prior years's holds is a reasonable way to pull holds +my @datearr_yesterday = localtime( time() - 86400*365 ); +my $yesterdaysdate = + ( 1900 + $datearr_yesterday[5] ) . '-' + . sprintf( "%0.2d", ( $datearr_yesterday[4] + 1 ) ) . '-' + . sprintf( "%0.2d", $datearr_yesterday[3] ); + +# Predefine the start and end dates if they are not already defined +$startdate =~ s/^\s+//; +$startdate =~ s/\s+$//; +$enddate =~ s/^\s+//; +$enddate =~ s/\s+$//; +# Check if null, should string match, if so set start and end date to yesterday +if (!defined($startdate) or $startdate eq "") { + $startdate = format_date($yesterdaysdate); +} +if (!defined($enddate) or $enddate eq "") { + $enddate = format_date($todaysdate); +} +if (!defined($max_bill) or $max_bill eq "") { + $max_bill = C4::Context->preference('noissuescharge'); + if ($max_bill <= 0) { + $max_bill = 20.00; + } +} + +my $dbh = C4::Context->dbh; +my ($sqlorderby, $sqldatewhere, $presqldatewhere) = ("","",""); +$debug and warn format_date_in_iso($startdate) . "\n" . format_date_in_iso($enddate); +# the dates below is to check for compliance of the current date range +#$sqldatewhere .= " AND date >= " . $dbh->quote(format_date_in_iso($startdate)) if ($startdate) ; +$sqldatewhere .= " AND date <= " . $dbh->quote(format_date_in_iso($enddate)) if ($enddate) ; +# the date below is to check for compliance of all fees prior +$presqldatewhere .= " AND date < " . $dbh->quote(format_date_in_iso($startdate)) if ($startdate) ; + +if ($order eq "patron") { + $sqlorderby = " order by surname, firstname "; +} elsif ($order eq "fee") { + $sqlorderby = " order by l_amountoutstanding DESC "; +} elsif ($order eq "desc") { + $sqlorderby = " order by l_description "; +} elsif ($order eq "type") { + $sqlorderby = " order by l_accounttype "; +} elsif ($order eq "date") { + $sqlorderby = " order by l_date DESC "; +} elsif ($order eq "total") { + $sqlorderby = " order by sum_amount DESC "; +} else { + $sqlorderby = " order by surname, firstname "; +} +my $strsth = + "SELECT + GROUP_CONCAT(accountlines.accounttype ORDER BY accountlines.date DESC SEPARATOR '
') as l_accounttype, + GROUP_CONCAT(description ORDER BY accountlines.date DESC SEPARATOR '
') as l_description, + GROUP_CONCAT(round(amountoutstanding,2) ORDER BY accountlines.date DESC SEPARATOR '
') as l_amountoutstanding, + GROUP_CONCAT(accountlines.date ORDER BY accountlines.date DESC SEPARATOR '
') as l_date, + GROUP_CONCAT(accountlines.itemnumber ORDER BY accountlines.date DESC SEPARATOR '
') as l_itemnumber, + count(*) as cnt, + max(accountlines.date) as maxdate, + round(sum(amountoutstanding),2) as sum_amount, + borrowers.borrowernumber as borrowernumber, + borrowers.surname as surname, + borrowers.firstname as firstname, + borrowers.email as email, + borrowers.phone as phone, + accountlines.itemnumber, + description, + accountlines.date as accountdate + FROM + borrowers, accountlines + WHERE + accountlines.borrowernumber = borrowers.borrowernumber + AND accountlines.amountoutstanding <> 0 + AND accountlines.borrowernumber + IN (SELECT borrowernumber FROM accountlines + where borrowernumber >= 0 + $sqldatewhere + GROUP BY accountlines.borrowernumber HAVING sum(amountoutstanding) >= $max_bill ) + AND accountlines.borrowernumber + NOT IN (SELECT borrowernumber FROM accountlines + where borrowernumber >= 0 + $presqldatewhere + GROUP BY accountlines.borrowernumber HAVING sum(amountoutstanding) >= $max_bill ) +"; + + +if (C4::Context->preference('IndependantBranches')){ + $strsth .= " AND borrowers.branchcode=? "; +} +$strsth .= " GROUP BY accountlines.borrowernumber HAVING sum(amountoutstanding) >= $max_bill " . $sqlorderby; +my $sth = $dbh->prepare($strsth); + +if (C4::Context->preference('IndependantBranches')){ + $sth->execute(C4::Context->userenv->{'branch'}); +} +else { + $sth->execute(); +} +my @reservedata; +my $previous; +my $this; +while ( my $data = $sth->fetchrow_hashref ) { + my @itemlist; + push( + @reservedata, + { + l_accountype => $data->{l_accounttype}, + l_description => $data->{l_description}, + l_amountoutstanding => $data->{l_amountoutstanding}, + l_date => $data->{l_date}, + l_itemnumber => $data->{l_itemnumber}, + l_accounttype => $data->{l_accounttype}, + l_title => $data->{l_title}, + cnt => $data->{cnt}, + maxdate => $data->{maxdate}, + sum_amount => $data->{sum_amount}, + borrowernumber => $data->{borrowernumber}, + surname => $data->{surname}, + firstname => $data->{firstname}, + phone => $data->{phone}, + email => $data->{email}, + patronname => $data->{surname} . ", " . $data->{firstname} , + description => $data->{description}, + amountoutstanding => $data->{amountoutstanding}, + accountdata => $data->{accountdata} + } + ); +} + + +$sth->finish; + +$template->param( + todaysdate => format_date($todaysdate), + from => $startdate, + to => $enddate, + ratio => $max_bill, + reserveloop => \@reservedata, + "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1, + DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), +); + +output_html_with_http_headers $input, $cookie, $template->output; diff --git a/circ/pendingreserves.pl b/circ/pendingreserves.pl index 7ce7015f59..326fb3054c 100755 --- a/circ/pendingreserves.pl +++ b/circ/pendingreserves.pl @@ -18,6 +18,11 @@ # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA +# Modification by D.Ulm, actually works (as long as indep. branches not turned on) +# Someone let me know what indep. branches is supposed to do and I'll make that part work too +# +# The reserve pull lists *works* as long as not for indepencdant branches, I can fix! + use strict; use C4::Context; use C4::Output; @@ -33,18 +38,14 @@ BEGIN { my $input = new CGI; my $order = $input->param('order'); -my $startdate = $input->param('from'); -my $enddate = $input->param('to'); -my $theme = $input->param('theme'); # only used if allowthemeoverride is set -my $op = $input->param('op'); -my $biblionumber = $input->param('biblionumber'); -my $borrowernumber = $input->param('borrowernumber'); +my $startdate=$input->param('from'); +my $enddate=$input->param('to'); -my $tmpl_name = ($op eq 'slip') ? "circ/hold-transfer-slip.tmpl" : "circ/pendingreserves.tmpl" ; +my $theme = $input->param('theme'); # only used if allowthemeoverride is set my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { - template_name => $tmpl_name, + template_name => "circ/pendingreserves.tmpl", query => $input, type => "intranet", authnotrequired => 0, @@ -54,6 +55,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( ); my $duedate; +my $borrowernumber; my $itemnum; my $data1; my $data2; @@ -61,70 +63,115 @@ my $data3; my $name; my $phone; my $email; +my $biblionumber; my $title; my $author; -warn $op; -warn $biblionumber; -warn $borrowernumber; + my @datearr = localtime( time() ); my $todaysdate = ( 1900 + $datearr[5] ) . '-' . sprintf( "%0.2d", ( $datearr[4] + 1 ) ) . '-' . sprintf( "%0.2d", $datearr[3] ); +# Find yesterday for the default shelf pull end dates +# A defualt of the prior day's holds is a reasonable way to pull holds +my @datearr_yesterday = localtime( time() - 86400 ); +my $yesterdaysdate = + ( 1900 + $datearr_yesterday[5] ) . '-' + . sprintf( "%0.2d", ( $datearr_yesterday[4] + 1 ) ) . '-' + . sprintf( "%0.2d", $datearr_yesterday[3] ); +# Find 10 years ago for the default shelf pull start and end dates +# A defualt of the prior day's holds is a reasonable way to pull holds +my @datearr_past = localtime( time() - 86400*365*10 ); +my $pastdate = + ( 1900 + $datearr_past[5] ) . '-' + . sprintf( "%0.2d", ( $datearr_past[4] + 1 ) ) . '-' + . sprintf( "%0.2d", $datearr_past[3] ); + +# Predefine the start and end dates if they are not already defined +$startdate =~ s/^\s+//; +$startdate =~ s/\s+$//; +$enddate =~ s/^\s+//; +$enddate =~ s/\s+$//; +# Check if null, should string match, if so set start and end date to yesterday +if (!defined($startdate) or $startdate eq "") { + $startdate = format_date($pastdate); +} +if (!defined($enddate) or $enddate eq "") { + $enddate = format_date($yesterdaysdate); +} + + my $dbh = C4::Context->dbh; -my ($sqlorderby, $sqldatewhere, $sqlwhowhere) = ("","",""); +my ($sqlorderby, $sqldatewhere) = ("",""); $debug and warn format_date_in_iso($startdate) . "\n" . format_date_in_iso($enddate); -if ($op eq 'slip') { - $sqlwhowhere .= " && reserves.borrowernumber = " . $dbh->quote($borrowernumber) ; - $sqlwhowhere .= " && reserves.biblionumber = " . $dbh->quote($biblionumber) ; -} else { - $sqldatewhere .= " AND reservedate >= " . $dbh->quote(format_date_in_iso($startdate)) if ($startdate) ; - $sqldatewhere .= " AND reservedate <= " . $dbh->quote(format_date_in_iso($enddate)) if ($enddate) ; -} -if ($order eq "borrower") { - $sqlorderby = " order by borrower, reservedate"; -} elsif ($order eq "biblio") { - $sqlorderby = " order by biblio.title, priority,reservedate"; -} elsif ($order eq "priority") { - $sqlorderby = "order by priority DESC"; +$sqldatewhere .= " AND reservedate >= " . $dbh->quote(format_date_in_iso($startdate)) if ($startdate) ; +$sqldatewhere .= " AND reservedate <= " . $dbh->quote(format_date_in_iso($enddate)) if ($enddate) ; + + +if ($order eq "biblio") { + $sqlorderby = " order by biblio.title "; +} elsif ($order eq "itype") { + $sqlorderby = " order by l_itype, location, l_itemcallnumber "; +} elsif ($order eq "location") { + $sqlorderby = " order by location, l_itemcallnumber, holdingbranch "; +} elsif ($order eq "date") { + $sqlorderby = " order by l_reservedate, location, l_itemcallnumber "; +} elsif ($order eq "library") { + $sqlorderby = " order by holdingbranch, l_itemcallnumber, location "; +} elsif ($order eq "call") { + $sqlorderby = " order by l_itemcallnumber, holdingbranch, location "; } else { - $sqlorderby = " order by reservedate, borrower"; + $sqlorderby = " order by biblio.title "; } my $strsth = -"SELECT reservedate, +"SELECT min(reservedate) as l_reservedate, reserves.borrowernumber as borrowernumber, - concat(firstname,' ',surname) as borrower, - borrowers.phone, - borrowers.email, + GROUP_CONCAT(DISTINCT items.holdingbranch + ORDER BY items.itemnumber SEPARATOR '
') l_holdingbranch, reserves.biblionumber, - reserves.branchcode as branch, - items.holdingbranch, + reserves.branchcode, + GROUP_CONCAT(DISTINCT reserves.branchcode + ORDER BY items.itemnumber SEPARATOR ', ') l_branch, + items.holdingbranch as branch, items.itemcallnumber, + GROUP_CONCAT(DISTINCT items.itype + ORDER BY items.itemnumber SEPARATOR '
') l_itype, + GROUP_CONCAT(DISTINCT items.location + ORDER BY items.itemnumber SEPARATOR '
') l_location, + GROUP_CONCAT(DISTINCT items.itemcallnumber + ORDER BY items.itemnumber SEPARATOR '
') l_itemcallnumber, items.itemnumber, notes, notificationdate, reminderdate, - priority, + max(priority) as priority, reserves.found, biblio.title, - biblio.author + biblio.author, + count(DISTINCT items.itemnumber) as icount, + count(DISTINCT reserves.borrowernumber) as rcount FROM reserves - LEFT JOIN items ON items.biblionumber=reserves.biblionumber - LEFT JOIN borrowers ON reserves.borrowernumber=borrowers.borrowernumber - LEFT JOIN biblio ON reserves.biblionumber=biblio.biblionumber - WHERE reserves.found is NULL - $sqlwhowhere + LEFT JOIN items ON items.biblionumber=reserves.biblionumber + LEFT JOIN biblio ON reserves.biblionumber=biblio.biblionumber + LEFT JOIN branchtransfers ON items.itemnumber=branchtransfers.itemnumber + WHERE +reserves.found IS NULL $sqldatewhere - AND items.itemnumber NOT IN (SELECT itemnumber FROM issues) - AND reserves.itemnumber is NULL"; +AND items.itemnumber NOT IN (SELECT itemnumber FROM branchtransfers where datearrived IS NULL) +AND items.itemnumber NOT IN (SELECT itemnumber FROM issues) +AND reserves.priority <> 0 +AND reserves.itemnumber is NULL +AND notforloan = 0 AND damaged = 0 AND itemlost = 0 AND wthdrawn = 0 +"; +# GROUP BY reserves.biblionumber allows only items that are not checked out, else multiples occur when +# multiple patrons have a hold on an item + if (C4::Context->preference('IndependantBranches')){ $strsth .= " AND items.holdingbranch=? "; } -$strsth .= $sqlorderby; -warn $strsth; - +$strsth .= " GROUP BY reserves.biblionumber " . $sqlorderby; my $sth = $dbh->prepare($strsth); if (C4::Context->preference('IndependantBranches')){ @@ -142,76 +189,89 @@ while ( my $data = $sth->fetchrow_hashref ) { push( @reservedata, { - reservedate => $previous eq $this?"":format_date( $data->{reservedate} ), - priority => $previous eq $this?"":$data->{priority}, - name => $previous eq $this?"":$data->{borrower}, - title => $previous eq $this?"":$data->{title}, - author => $previous eq $this?"":$data->{author}, - borrowernumber => $previous eq $this?"":$data->{borrowernumber}, - itemnum => $previous eq $this?"":$data->{itemnumber}, - phone => $previous eq $this?"":$data->{phone}, - email => $previous eq $this?"":$data->{email}, - biblionumber => $previous eq $this?"":$data->{biblionumber}, + reservedate => format_date( $data->{l_reservedate} ), + priority => $data->{priority}, + name => $data->{l_patron}, + title => $data->{title}, + author => $data->{author}, + borrowernumber => $data->{borrowernumber}, + itemnum => $data->{itemnumber}, + phone => $data->{phone}, + email => $data->{email}, + biblionumber => $data->{biblionumber}, statusw => ( $data->{found} eq "W" ), statusf => ( $data->{found} eq "F" ), - holdingbranch => $data->{holdingbranch}, - branch => $previous eq $this?"":$data->{branch}, - itemcallnumber => $data->{itemcallnumber}, - notes => $previous eq $this?"":$data->{notes}, - notificationdate => $previous eq $this?"":$data->{notificationdate}, - reminderdate => $previous eq $this?"":$data->{reminderdate} + holdingbranch => $data->{l_holdingbranch}, + branch => $data->{l_branch}, + itemcallnumber => $data->{l_itemcallnumber}, + notes => $data->{notes}, + notificationdate => $data->{notificationdate}, + reminderdate => $data->{reminderdate}, + count => $data->{icount}, + rcount => $data->{rcount}, + pullcount => $data->{icount} <= $data->{rcount} ? $data->{icount} : $data->{rcount}, + itype => $data->{l_itype}, + location => $data->{l_location} } ); $previous=$this; } $sth->finish; -$strsth=~ s/AND reserves.itemnumber is NULL/AND reserves.itemnumber is NOT NULL/; -$strsth=~ s/LEFT JOIN items ON items.biblionumber=reserves.biblionumber/LEFT JOIN items ON items.biblionumber=reserves.itemnumber/; -$sth = $dbh->prepare($strsth); -if (C4::Context->preference('IndependantBranches')){ - $sth->execute(C4::Context->userenv->{'branch'}); -} -else { - $sth->execute(); -} -while ( my $data = $sth->fetchrow_hashref ) { - $this=$data->{biblionumber}.":".$data->{borrowernumber}; - my @itemlist; - push( - @reservedata, - { - reservedate => $previous eq $this?"":format_date( $data->{reservedate} ), - priority => $previous eq $this?"":$data->{priority}, - name => $previous eq $this?"":$data->{borrower}, - title => $previous eq $this?"":$data->{title}, - author => $previous eq $this?"":$data->{author}, - borrowernumber => $previous eq $this?"":$data->{borrowernumber}, - itemnum => $previous eq $this?"":$data->{itemnumber}, - phone => $previous eq $this?"":$data->{phone}, - email => $previous eq $this?"":$data->{email}, - biblionumber => $previous eq $this?"":$data->{biblionumber}, - statusw => ( $data->{found} eq "W" ), - statusf => ( $data->{found} eq "F" ), - holdingbranch => $data->{holdingbranch}, - branch => $previous eq $this?"":$data->{branch}, - itemcallnumber => $data->{itemcallnumber}, - notes => $previous eq $this?"":$data->{notes}, - notificationdate => $previous eq $this?"":$data->{notificationdate}, - reminderdate => $previous eq $this?"":$data->{reminderdate}, - thisitemonly => 1, - } - ); - $previous=$this; -} -$sth->finish; +# *** I doubt any of this is needed now with the above fixes *** -d.u. + +#$strsth=~ s/AND reserves.itemnumber is NULL/AND reserves.itemnumber is NOT NULL/; +#$strsth=~ s/LEFT JOIN items ON items.biblionumber=reserves.biblionumber/LEFT JOIN items ON items.biblionumber=reserves.itemnumber/; +#$sth = $dbh->prepare($strsth); +#if (C4::Context->preference('IndependantBranches')){ +# $sth->execute(C4::Context->userenv->{'branch'}); +#} +#else { +# $sth->execute(); +#} +#while ( my $data = $sth->fetchrow_hashref ) { +# $this=$data->{biblionumber}.":".$data->{borrowernumber}; +# my @itemlist; +# push( +# @reservedata, +# { +# reservedate => format_date( $data->{l_reservedate} ), +# priority => $data->{priority}, +# name => $data->{l_patron}, +# title => $data->{title}, +# author => $data->{author}, +# borrowernumber => $data->{borrowernumber}, +# itemnum => $data->{itemnumber}, +# phone => $data->{phone}, +# email => $data->{email}, +# biblionumber => $data->{biblionumber}, +# statusw => ( $data->{found} eq "W" ), +# statusf => ( $data->{found} eq "F" ), +# holdingbranch => $data->{l_holdingbranch}, +# branch => $data->{l_branch}, +# itemcallnumber => $data->{l_itemcallnumber}, +# notes => $data->{notes}, +# notificationdate => $data->{notificationdate}, +# reminderdate => $data->{reminderdate}, +# count => $data->{icount}, +# rcount => $data->{rcount}, +# pullcount => $data->{icount} <= $data->{rcount} ? $data->{icount} : $data->{rcount}, +# itype => $data->{l_itype}, +# location => $data->{l_location}, +# thisitemonly => 1, +# +# } +# ); +# $previous=$this; +#} +#$sth->finish; $template->param( - todaysdate => format_date($todaysdate), + todaysdate => format_date($todaysdate), from => $startdate, - to => $enddate, - reserveloop => \@reservedata, + to => $enddate, + reserveloop => \@reservedata, "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1, DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), ); diff --git a/circ/reserveratios.pl b/circ/reserveratios.pl new file mode 100755 index 0000000000..2ec48ebae8 --- /dev/null +++ b/circ/reserveratios.pl @@ -0,0 +1,206 @@ +#!/usr/bin/perl + + +# Copyright 2000-2002 Katipo Communications +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + +use strict; +use C4::Context; +use C4::Output; +use CGI; +use C4::Auth; +use C4::Dates qw/format_date format_date_in_iso/; + +use vars qw($debug); + +BEGIN { + $debug = $ENV{DEBUG} || 0; +} + +my $input = new CGI; +my $order = $input->param('order'); +my $startdate=$input->param('from'); +my $enddate=$input->param('to'); +my $ratio=$input->param('ratio'); + +my $theme = $input->param('theme'); # only used if allowthemeoverride is set + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "circ/reserveratios.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => { circulate => 1 }, + debug => 1, + } +); + +my $duedate; +my $borrowernumber; +my $itemnum; +my $data1; +my $data2; +my $data3; +my $name; +my $phone; +my $email; +my $biblionumber; +my $title; +my $author; + +my @datearr = localtime( time() ); +my +$todaysdate = + ( 1900 + $datearr[5] ) . '-' + . sprintf( "%0.2d", ( $datearr[4] + 1 ) ) . '-' + . sprintf( "%0.2d", $datearr[3] ); + +# Find yesterday for the default shelf pull start and end dates +# A defualt of the prior years's holds is a reasonable way to pull holds +my @datearr_yesterday = localtime( time() - 86400*365 ); +my $yesterdaysdate = + ( 1900 + $datearr_yesterday[5] ) . '-' + . sprintf( "%0.2d", ( $datearr_yesterday[4] + 1 ) ) . '-' + . sprintf( "%0.2d", $datearr_yesterday[3] ); + +# Predefine the start and end dates if they are not already defined +$startdate =~ s/^\s+//; +$startdate =~ s/\s+$//; +$enddate =~ s/^\s+//; +$enddate =~ s/\s+$//; +# Check if null, should string match, if so set start and end date to yesterday +if (!defined($startdate) or $startdate eq "") { + $startdate = format_date($yesterdaysdate); +} +if (!defined($enddate) or $enddate eq "") { + $enddate = format_date($todaysdate); +} +if (!defined($ratio) or $ratio eq "") { + $ratio = 3; +} + +my $dbh = C4::Context->dbh; +my ($sqlorderby, $sqldatewhere) = ("",""); +$debug and warn format_date_in_iso($startdate) . "\n" . format_date_in_iso($enddate); +$sqldatewhere .= " AND reservedate >= " . $dbh->quote(format_date_in_iso($startdate)) if ($startdate) ; +$sqldatewhere .= " AND reservedate <= " . $dbh->quote(format_date_in_iso($enddate)) if ($enddate) ; + +if ($order eq "biblio") { + $sqlorderby = " order by biblio.title, holdingbranch, listcall, l_location "; +} elsif ($order eq "callnumber") { + $sqlorderby = " order by listcall, holdingbranch, l_location "; +} elsif ($order eq "itemcount") { + $sqlorderby = " order by itemcount, reservecount "; +} elsif ($order eq "itype") { + $sqlorderby = " order by l_itype, holdingbranch, listcall "; +} elsif ($order eq "location") { + $sqlorderby = " order by l_location, holdingbranch, listcall "; +} elsif ($order eq "reservecount") { + $sqlorderby = " order by reservecount DESC "; +} elsif ($order eq "branch") { + $sqlorderby = " order by holdingbranch, l_location, listcall "; +} else { + $sqlorderby = " order by reservecount DESC "; +} +my $strsth = +"SELECT reservedate, + reserves.borrowernumber as borrowernumber, + reserves.biblionumber, + reserves.branchcode as branch, + items.holdingbranch, + items.itemcallnumber, + items.itemnumber, + GROUP_CONCAT(DISTINCT items.itemcallnumber + ORDER BY items.itemnumber SEPARATOR '
') as listcall, + GROUP_CONCAT(DISTINCT holdingbranch + ORDER BY items.itemnumber SEPARATOR '
') as listbranch, + GROUP_CONCAT(DISTINCT items.location + ORDER BY items.itemnumber SEPARATOR '
') as l_location, + GROUP_CONCAT(DISTINCT items.itype + ORDER BY items.itemnumber SEPARATOR '
') as l_itype, + notes, + reserves.found, + biblio.title, + biblio.author, + count(DISTINCT reserves.borrowernumber) as reservecount, + count(DISTINCT items.itemnumber) as itemcount + FROM reserves + LEFT JOIN items ON items.biblionumber=reserves.biblionumber + LEFT JOIN biblio ON reserves.biblionumber=biblio.biblionumber + WHERE +notforloan = 0 AND damaged = 0 AND itemlost = 0 AND wthdrawn = 0 + $sqldatewhere +"; + + +if (C4::Context->preference('IndependantBranches')){ + $strsth .= " AND items.holdingbranch=? "; +} +$strsth .= " GROUP BY reserves.biblionumber " . $sqlorderby; +my $sth = $dbh->prepare($strsth); + +if (C4::Context->preference('IndependantBranches')){ + $sth->execute(C4::Context->userenv->{'branch'}); +} +else { + $sth->execute(); +} +my @reservedata; +while ( my $data = $sth->fetchrow_hashref ) { + my @itemlist; + my $ratiocalc = int(10 * $data->{reservecount} / $data->{itemcount} / $ratio )/10; + push( + @reservedata, + { + reservedate => format_date( $data->{reservedate} ), + priority => $data->{priority}, + name => $data->{borrower}, + title => $data->{title}, + author => $data->{author}, + notes => $data->{notes}, + itemnum => $data->{itemnumber}, + biblionumber => $data->{biblionumber}, + holdingbranch => $data->{holdingbranch}, + listbranch => $data->{listbranch}, + branch => $data->{branch}, + itemcallnumber => $data->{itemcallnumber}, + location => $data->{l_location}, + itype => $data->{l_itype}, + reservecount => $data->{reservecount}, + itemcount => $data->{itemcount}, + ratiocalc => $ratiocalc, + ratio_ge_one => $ratiocalc ge 1.0 ? 1 : "", + listcall => $data->{listcall} + } + ); +} + + +$sth->finish; + +$template->param( + todaysdate => format_date($todaysdate), + from => $startdate, + to => $enddate, + ratio => $ratio, + reserveloop => \@reservedata, + "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1, + DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), +); + +output_html_with_http_headers $input, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/billing.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/billing.tmpl new file mode 100644 index 0000000000..26463accba --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/billing.tmpl @@ -0,0 +1,175 @@ + +Koha › Circulation › Billing + + +/lib/calendar/calendar-system.css" /> + + + + + + + + + + + + + +
+ +
+
+
+ +

Billing on +
From + to

+
+
+ +
+

+ +" /> + +" /> +/lib/calendar/cal.gif" border="0" id="openCalendarFrom" style="cursor: pointer;" alt="" /> + + +" type="text" /> +/lib/calendar/cal.gif" alt="" id="openCalendarTo" style="cursor: pointer;" valign="top" border="0" /> + +(inclusive) + + +

+
+

The following patrons have bills.

+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Patron + &to=">Sort + Fee Item + &to=">Sort + Description + &to=">Sort + Type + &to=">Sort + Date + &to=">Sort + Total Amount + &to=">Sort +
+

">

+ ?subject=Account: "> + +

+
+

+
+

+
+

+
+

+
+

+
+ + No items found. + +
+
+
+
+ +
+
+ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tmpl index bd8b310970..229f4cdec0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tmpl @@ -35,6 +35,8 @@
  • Overdues
  • Fines
  • Daily reconciliation
  • +
  • Reserve Ratios
  • +
  • Billing
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tmpl index 33b19d55fd..5c32764a37 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tmpl @@ -22,12 +22,14 @@
    - -

    Pending holds as of

    +

    Reserve Pull List

    +

    Pending holds on (from + to )


    + @@ -91,7 +93,8 @@ Calendar.setup( } ); -(inclusive) +
    +(Inclusive, default is (10yr/ago to yesterday), set"to" to today as needed. )

    @@ -103,39 +106,46 @@ Calendar.setup( - - + - + + + + + - - - + + + - - - + + + + +
    - Priority - &to=">Sort - Hold Date - &to=">Sort + + Pull This Many Items + + Items Available Patron - &to=">Sort + + Patrons with Reserves Title &to=">Sort - Library + Libraries + &to=">Sort + + Available Call Numbers + &to=">Sort + + Available Itypes + &to=">Sort + Available Locations + &to=">Sort + Earliest Hold Date + &to=">Sort +

    -

    -

    in

    -

    Waiting

    Fullfilled

    -
    -

    ">

    - ?subject=Reservation: "> - -

    -

    @@ -157,13 +167,20 @@ Calendar.setup(

    +   ""

    +

    +

    in

    +

    Waiting

    Fullfilled

    +
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tmpl new file mode 100644 index 0000000000..7791da17b1 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tmpl @@ -0,0 +1,186 @@ + +Koha › Circulation › Reserve Ratios + + +/lib/calendar/calendar-system.css" /> + + + + + + + + + + + + + +
    + +
    +
    +
    + +

    Reserve Ratios to Calculate Items Needed
    + Calculated on
    From + to

    +
    +
    + +
    +

    + +" /> + +" /> +/lib/calendar/cal.gif" border="0" id="openCalendarFrom" style="cursor: pointer;" alt="" /> + + +" type="text" /> +/lib/calendar/cal.gif" alt="" id="openCalendarTo" style="cursor: pointer;" valign="top" border="0" /> + +(inclusive) + + +

    +
    +

    These items have a large number of holds.

    +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Reserves + &order=reservecount&from=&to=">Sort + Items + &order=itemcount&from=&to=">Sort + Title + &order=biblio&from=&to=">Sort + Holding Branches + &order=branch&from=&to=">Sort + Location + &order=location&from=&to=">Sort + Itype + &order=itype&from=&to=">Sort + Call Numbers + &order=callnumber&from=&to=">Sort + Items Needed +
    +

    +
    +

    +
    +

    + + "> + + + + + "> + + + + "> + + + + +

    +

    +

    Order:

    + + No items found. + +
    +
    +
    +
    + +
    +
    + diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tmpl index b907e8f585..4d958cd9f0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tmpl @@ -28,9 +28,13 @@ + + + + @@ -39,12 +43,18 @@ + + + + + - + @@ -57,10 +67,16 @@
    1. diff --git a/reports/itemslost.pl b/reports/itemslost.pl index 33fbfef4e2..52ff1f9069 100755 --- a/reports/itemslost.pl +++ b/reports/itemslost.pl @@ -57,14 +57,24 @@ if ( $get_items ) { $where{barcode} = $barcodefilter if defined $barcodefilter; $where{itemtype} = $itemtypesfilter if defined $itemtypesfilter; - my $items = GetLostItems( \%where, $orderbyfilter ); + my $items = GetLostItems( \%where, $orderbyfilter ); $template->param( total => scalar @$items, itemsloop => $items, - get_items => $get_items + get_items => $get_items ); } +# Get the Lost colletion codes +#my $fw = GetFrameworkCode($biblionumber); +#$item = GetAuthorisedValues(GetAuthValCode('items.itemlost',$fw),$item->{itemlost}) if GetAuthValCode('items.itemlost',$fw); +#if ($item->{damaged}) { +# $item->{itemdamagedloop}= GetAuthorisedValues(GetAuthValCode('items.damaged',$fw),$item->{damaged}) if GetAuthValCode('items.damaged',$fw); +#} +#get collection code description, too +#my $ccodes = GetAuthorisedValueDesc('','', 'ccode' ,'','','ccode'); + + # getting all branches. my $branches = GetBranches; my $branch = C4::Context->userenv->{"branchname"}; -- 2.39.5
    TitleAuthorLost Code Barcode Date last seen PriceRep.Price Branch Itemtype Holdingbranch
    " title=""> + " title="">