X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=acqui%2Finvoices.pl;h=4909b78b4f89422f54dc89c52640099b0cac59a7;hb=31f60fd522e39b3f737cfcaee766bc778ae48a17;hp=4b45e31dbae1a4cff823d887f389b4ce69f965d6;hpb=3e131101911fda60580b1dd757d078c172f19c3b;p=koha.git diff --git a/acqui/invoices.pl b/acqui/invoices.pl index 4b45e31dba..4909b78b4f 100755 --- a/acqui/invoices.pl +++ b/acqui/invoices.pl @@ -3,18 +3,18 @@ # Copyright 2011 BibLibre SARL # 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 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 3 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. +# 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., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . =head1 NAME @@ -29,18 +29,18 @@ Search for invoices use strict; use warnings; -use CGI; +use CGI qw ( -utf8 ); use C4::Auth; use C4::Output; -use C4::Acquisition; -use C4::Bookseller qw/GetBookSeller/; -use C4::Branch; +use C4::Acquisition qw/GetInvoices/; +use C4::Branch qw/GetBranches/; +use C4::Budgets; -my $input = new CGI; +my $input = CGI->new; my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( { - template_name => 'acqui/invoices.tmpl', + template_name => 'acqui/invoices.tt', query => $input, type => 'intranet', authnotrequired => 0, @@ -50,7 +50,7 @@ my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( ); my $invoicenumber = $input->param('invoicenumber'); -my $supplier = $input->param('supplier'); +my $supplierid = $input->param('supplierid'); my $shipmentdatefrom = $input->param('shipmentdatefrom'); my $shipmentdateto = $input->param('shipmentdateto'); my $billingdatefrom = $input->param('billingdatefrom'); @@ -63,15 +63,15 @@ my $publicationyear = $input->param('publicationyear'); my $branch = $input->param('branch'); my $op = $input->param('op'); -my @results_loop = (); -if ( $op and $op eq "do_search" ) { - my $shipmentdatefrom_iso = C4::Dates->new($shipmentdatefrom)->output("iso"); - my $shipmentdateto_iso = C4::Dates->new($shipmentdateto)->output("iso"); - my $billingdatefrom_iso = C4::Dates->new($billingdatefrom)->output("iso"); - my $billingdateto_iso = C4::Dates->new($billingdateto)->output("iso"); - my @invoices = GetInvoices( +my $invoices = []; +if ( $op and $op eq 'do_search' ) { + my $shipmentdatefrom_iso = C4::Dates->new($shipmentdatefrom)->output('iso'); + my $shipmentdateto_iso = C4::Dates->new($shipmentdateto)->output('iso'); + my $billingdatefrom_iso = C4::Dates->new($billingdatefrom)->output('iso'); + my $billingdateto_iso = C4::Dates->new($billingdateto)->output('iso'); + @{$invoices} = GetInvoices( invoicenumber => $invoicenumber, - suppliername => $supplier, + supplierid => $supplierid, shipmentdatefrom => $shipmentdatefrom_iso, shipmentdateto => $shipmentdateto_iso, billingdatefrom => $billingdatefrom_iso, @@ -83,42 +83,29 @@ if ( $op and $op eq "do_search" ) { publicationyear => $publicationyear, branchcode => $branch ); - foreach (@invoices) { - my %row = ( - invoiceid => $_->{invoiceid}, - billingdate => $_->{billingdate}, - invoicenumber => $_->{invoicenumber}, - suppliername => $_->{suppliername}, - receivedbiblios => $_->{receivedbiblios}, - receiveditems => $_->{receiveditems}, - subscriptionid => $_->{subscriptionid}, - closedate => $_->{closedate}, - ); - push @results_loop, \%row; - } } # Build suppliers list -my @suppliers = GetBookSeller(undef); -my @suppliers_loop = (); +my @suppliers = Koha::Acquisition::Bookseller->search; +my $suppliers_loop = []; my $suppliername; foreach (@suppliers) { my $selected = 0; - if ( $supplier && $supplier == $_->{'id'} ) { - $selected = 1; - $suppliername = $_->{'name'}; + if ($supplierid && $supplierid == $_->{id} ) { + $selected = 1; + $suppliername = $_->{name}; } - my %row = ( - suppliername => $_->{'name'}, - supplierid => $_->{'id'}, + push @{$suppliers_loop}, + { + suppliername => $_->{name}, + booksellerid => $_->{id}, selected => $selected, - ); - push @suppliers_loop, \%row; + }; } # Build branches list my $branches = GetBranches(); -my @branches_loop = (); +my $branches_loop = []; my $branchname; foreach ( sort keys %$branches ) { my $selected = 0; @@ -126,32 +113,39 @@ foreach ( sort keys %$branches ) { $selected = 1; $branchname = $branches->{$_}->{'branchname'}; } - my %row = ( + push @{$branches_loop}, + { branchcode => $_, - branchname => $branches->{$_}->{'branchname'}, + branchname => $branches->{$_}->{branchname}, selected => $selected, - ); - push @branches_loop, \%row; + }; } +my $budgets = GetBudgets(); +my @budgets_loop; +foreach my $budget (@$budgets) { + push @budgets_loop, $budget if CanUserUseBudget( $loggedinuser, $budget, $flags ); +} + +$template->{'VARS'}->{'budgets_loop'} = \@budgets_loop; + $template->param( - do_search => ( $op and $op eq "do_search" ) ? 1 : 0, - results_loop => \@results_loop, - invoicenumber => $invoicenumber, - supplier => $supplier, - suppliername => $suppliername, - billingdatefrom => $billingdatefrom, - billingdateto => $billingdateto, - isbneanissn => $isbneanissn, - title => $title, - author => $author, - publisher => $publisher, - publicationyear => $publicationyear, - branch => $branch, - branchname => $branchname, - suppliers_loop => \@suppliers_loop, - branches_loop => \@branches_loop, - DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), + do_search => ( $op and $op eq 'do_search' ) ? 1 : 0, + invoices => $invoices, + invoicenumber => $invoicenumber, + booksellerid => $supplierid, + suppliername => $suppliername, + billingdatefrom => $billingdatefrom, + billingdateto => $billingdateto, + isbneanissn => $isbneanissn, + title => $title, + author => $author, + publisher => $publisher, + publicationyear => $publicationyear, + branch => $branch, + branchname => $branchname, + suppliers_loop => $suppliers_loop, + branches_loop => $branches_loop, ); output_html_with_http_headers $input, $cookie, $template->output;