From 3818a8dc384f1687d287e77fdb683b3eb518e036 Mon Sep 17 00:00:00 2001 From: tgarip1957 Date: Wed, 20 Sep 2006 21:44:36 +0000 Subject: [PATCH] A new acquisition to handle different tax values to each item, receiving multiple baskets as one parcel, stricter rules for biblio and item creation --- acqui/acqui-home.pl | 7 +- acqui/addorder.pl | 161 ++++------------ acqui/basket.pl | 49 ++--- acqui/bookfund.pl | 8 +- acqui/booksellers.pl | 32 +--- acqui/currency.pl | 42 +++++ acqui/finishreceive.pl | 253 +++++-------------------- acqui/histsearch.pl | 2 - acqui/lateorders.pl | 1 - acqui/neworderbiblio.pl | 359 ------------------------------------ acqui/neworderempty.pl | 182 +++++++++--------- acqui/newordersuggestion.pl | 41 ++-- acqui/orderreceive.pl | 189 ------------------- acqui/parcel.pl | 177 +++++++++--------- acqui/parcels.pl | 172 ----------------- acqui/select-late.pl | 4 - acqui/spent.pl | 80 -------- acqui/supplier.pl | 3 - acqui/updatesupplier.pl | 2 +- 19 files changed, 356 insertions(+), 1408 deletions(-) create mode 100755 acqui/currency.pl delete mode 100755 acqui/neworderbiblio.pl delete mode 100644 acqui/orderreceive.pl delete mode 100644 acqui/parcels.pl delete mode 100755 acqui/spent.pl diff --git a/acqui/acqui-home.pl b/acqui/acqui-home.pl index ab94936f24..c8fb8cce9f 100755 --- a/acqui/acqui-home.pl +++ b/acqui/acqui-home.pl @@ -45,9 +45,7 @@ use CGI; use C4::Auth; use C4::Output; use C4::Interface::CGI::Output; -use C4::Database; use C4::Suggestions; -use HTML::Template; use C4::Acquisition; use C4::Bookfund; use C4::Members; @@ -65,11 +63,10 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( ); # budget -my ( $flags, $homebranch ) = GetFlagsAndBranchFromBorrower($loggedinuser); - +my $me= C4::Context->userenv; +my $homebranch=$me->{'branch'} ; my @results = GetBookFunds($homebranch); my $count = scalar @results; - my $classlist = ''; my $total = 0; my $totspent = 0; diff --git a/acqui/addorder.pl b/acqui/addorder.pl index 48d7e07ece..97687d4e22 100755 --- a/acqui/addorder.pl +++ b/acqui/addorder.pl @@ -90,7 +90,7 @@ bookfund use to pay this order. =item C -=item C +=item C =item C @@ -115,20 +115,12 @@ if it is an order from an existing suggestion : the id of this suggestion. use strict; use CGI; use C4::Auth; -use C4::Output; use C4::Acquisition; use C4::Suggestions; use C4::Biblio; -use C4::Output; use C4::Interface::CGI::Output; -use C4::Database; -use HTML::Template; - -#use Data::Dumper; -#use Date::Manip; my $input = new CGI; - # get_template_and_user used only to check auth & get user id my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { @@ -141,6 +133,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); + # get CGI parameters my $ordnum = $input->param('ordnum'); my $basketno = $input->param('basketno'); @@ -154,166 +147,80 @@ my $itemtype = $input->param('format'); my $quantity = $input->param('quantity'); my $listprice = $input->param('list_price'); my $branch = $input->param('branch'); +my $discount=$input->param('discount'); if ( $listprice eq '' ) { $listprice = 0; } my $series = $input->param('series'); my $notes = $input->param('notes'); -my $bookfund = $input->param('bookfund'); +my $bookfundid = $input->param('bookfundid'); my $sort1 = $input->param('sort1'); my $sort2 = $input->param('sort2'); my $rrp = $input->param('rrp'); my $ecost = $input->param('ecost'); -my $gst = $input->param('GST'); +my $gst = $input->param('gstrate'); my $budget = $input->param('budget'); -my $cost = $input->param('cost'); +my $unitprice = $input->param('unitprice'); my $sub = $input->param('sub'); -my $invoice = $input->param('invoice'); +my $purchaseordernumber = $input->param('purchaseordernumber'); my $publishercode = $input->param('publishercode'); my $suggestionid = $input->param('suggestionid'); my $donation = $input->param('donation'); my $user = $input->remote_user; - -#warn "CREATEBIBITEM = $input->param('createbibitem')"; -#warn Dumper $input->param('createbibitem'); +my $biblionumber=$input->param('biblionumber'); my $createbibitem = $input->param('createbibitem'); # create, modify or delete biblio # create if $quantity>=0 and $existing='no' # modify if $quantity>=0 and $existing='yes' # delete if $quantity has been se to 0 by the librarian -my $bibnum; -my $bibitemnum; -if ( $quantity ne '0' ) { +my $dbh=C4::Context->dbh; +if ($quantity ne '0'){ #check to see if biblio exists if ( $existing eq 'no' ) { - - #if it doesnt create it - $bibnum = &newbiblio( - { - title => $title ? $title : "", - author => $author ? $author : "", - copyrightdate => $copyrightdate ? $copyrightdate : "", - series => $series ? $series : "", - } - ); - $bibitemnum = &newbiblioitem( - { - biblionumber => $bibnum, - itemtype => $itemtype ? $itemtype : "", - isbn => $isbn ? $isbn : "", - publishercode => $publishercode ? $publishercode : "", - } - ); - + #if it doesnt its created on template # change suggestion status if applicable if ($suggestionid) { - ModStatus( $suggestionid, 'ORDERED', '', $bibnum ); - } - } - - elsif ( $createbibitem eq 'YES' ) { - $bibnum = $input->param('biblio'); - $bibitemnum = $input->param('bibitemnum'); - $bibitemnum = &newbiblioitem( - { - biblionumber => $bibnum, - itemtype => $itemtype ? $itemtype : "", - isbn => $isbn ? $isbn : "", - publishercode => $publishercode ? $publishercode : "", - } - ); - &modbiblio( - { - biblionumber => $bibnum, - title => $title ? $title : "", - author => $author ? $author : "", - copyrightdate => $copyrightdate ? $copyrightdate : "", - series => $series ? $series : "" - } - ); - } - - # then attach it to an existing bib - - else { - warn "attaching to an existing bibitem"; +my $data=GetSuggestion($suggestionid); - $bibnum = $input->param('biblio'); + my $biblio={title=>$data->{title},author=>$data->{author},publishercode=>$data->{publishercode},copyrightdate=>$data->{copyrightdate},isbn=>$data->{isbn},place=>$data->{place},}; +my $xmlhash=XMLkoha2marc($dbh,$biblio,"biblios"); +$biblionumber = NEWnewbiblio($dbh,$xmlhash,""); - # if we are moddig the bibitem, not creating it createbib wont be set, - # - if ($createbibitem) { - $bibitemnum = $createbibitem; - } - else { - $bibitemnum = $input->param('bibitemnum'); + ModStatus( $suggestionid, 'ORDERED', '', $biblionumber,$input ); +warn "modstatus"; } + }## biblio didnot exist now created - my $oldtype = $input->param('oldtype'); - &modbibitem( - { - biblioitemnumber => $bibitemnum, - isbn => $isbn, - publishercode => $publishercode, - itemtype => - $itemtype, # added itemtype, not prev. being changed. - } - ); - &modbiblio( - { - biblionumber => $bibnum, - title => $title ? $title : "", - author => $author ? $author : "", - copyrightdate => $copyrightdate ? $copyrightdate : "", - series => $series ? $series : "" - }, - ); - } + + + if ($ordnum) { # warn "MODORDER $title / $ordnum / $quantity / $bookfund"; ModOrder( $title, $ordnum, $quantity, $listprice, - $bibnum, $basketno, $booksellerid, $loggedinuser, - $notes, $bookfund, $bibitemnum, $rrp, - $ecost, $gst, $budget, $cost, - $invoice, $sort1, $sort2 + $biblionumber, $basketno, $booksellerid, $loggedinuser, + $notes, $bookfundid, $rrp, + $ecost, $gst, $budget, $unitprice, + $purchaseordernumber, $sort1, $sort2,$discount,$branch ); } else { ( $basketno, $ordnum ) = NewOrder( - $basketno, $bibnum, $title, $quantity, + $basketno, $biblionumber, $title, $quantity, $listprice, $booksellerid, $loggedinuser, $notes, - $bookfund, $bibitemnum, $rrp, $ecost, - $gst, $budget, $cost, $sub, - $invoice, $sort1, $sort2 - ); - } - if ($donation) { - my $barcode = $input->param('barcode'); - my @barcodes = split( /\,| |\|/, $barcode ); - my ($error) = newitems( - { - biblioitemnumber => $bibitemnum, - biblionumber => $bibnum, - replacementprice => $rrp, - price => $cost, - booksellerid => $booksellerid, - homebranch => $branch, - loan => 0 - }, - @barcodes - ); - ModReceiveOrder( - $bibnum, $ordnum, $quantity, $user, $cost, - $invoice, 0, $bookfund, $rrp + $bookfundid, $rrp, $ecost, + $gst, $budget, $unitprice, $sub, + $purchaseordernumber, $sort1, $sort2, $discount,$branch ); } + } else { - $bibnum = $input->param('biblio'); - DelOrder( $bibnum, $ordnum ); +# $biblionumber = $input->param('biblionumber'); + DelOrder( $biblionumber, $ordnum,$loggedinuser ); } -print $input->redirect("basket.pl?basket=$basketno"); +warn "goingout"; +print $input->redirect("basket.pl?basketno=$basketno"); diff --git a/acqui/basket.pl b/acqui/basket.pl index 057e296b8c..4c477e9d68 100755 --- a/acqui/basket.pl +++ b/acqui/basket.pl @@ -25,11 +25,8 @@ use strict; use C4::Auth; use C4::Koha; -use C4::Output; use CGI; use C4::Interface::CGI::Output; -use C4::Database; -use HTML::Template; use C4::Acquisition; use C4::Bookfund; use C4::Bookseller; @@ -81,10 +78,9 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( ); my $basket = GetBasket($basketno); - +$basket->{authorisedbyname}; # FIXME : the query->param('supplierid') below is probably useless. The bookseller is always known from the basket # if no booksellerid in parameter, get it from basket -# warn "=>".$basket->{booksellerid}; $booksellerid = $basket->{booksellerid} unless $booksellerid; my @booksellers = GetBookSeller($booksellerid); my $count2 = scalar @booksellers; @@ -112,29 +108,25 @@ $basket->{authorisedby} = $loggedinuser unless ( $basket->{authorisedby} ); my ( $count, @results ); @results = GetOrders( $basketno, $order ); $count = scalar @results; - my $line_total; # total of each line -my $sub_total; # total of line totals -my $gist; # GST -my $grand_total; # $subttotal + $gist +my $gist =C4::Context->preference('gist'); # GST my $toggle = 0; - # my $line_total_est; # total of each line my $sub_total_est; # total of line totals my $gist_est; # GST -my $grand_total_est; # $subttotal + $gist - +my $grand_total_est; # $subttotal + $gist_est - $disc_est +my $disc_est; my $qty_total; my @books_loop; for ( my $i = 0 ; $i < $count ; $i++ ) { - my $rrp = $results[$i]->{'listprice'}; - $rrp = ConvertCurrency( $results[$i]->{'currency'}, $rrp ); - - $sub_total_est += $results[$i]->{'quantity'} * $results[$i]->{'rrp'}; - $line_total = $results[$i]->{'quantity'} * $results[$i]->{'ecost'}; - $sub_total += $line_total; + $line_total = $results[$i]->{'quantity'} * $results[$i]->{'rrp'}; + $sub_total_est += $line_total ; + $disc_est +=$line_total *$results[$i]->{'discount'}/100; + $gist_est +=($line_total - ($line_total *$results[$i]->{'discount'}/100))*$results[$i]->{'gst'}/100; + + $qty_total += $results[$i]->{'quantity'}; my %line; if ( $toggle == 0 ) { @@ -148,7 +140,7 @@ for ( my $i = 0 ; $i < $count ; $i++ ) { $line{ordernumber} = $results[$i]->{'ordernumber'}; $line{publishercode} = $results[$i]->{'publishercode'}; $line{isbn} = $results[$i]->{'isbn'}; - $line{booksellerid} = $results[$i]->{'booksellerid'}; + $line{booksellerid} = $booksellers[0]->{'id'}; $line{basketno} = $basketno; $line{title} = $results[$i]->{'title'}; $line{notes} = $results[$i]->{'notes'}; @@ -156,20 +148,20 @@ for ( my $i = 0 ; $i < $count ; $i++ ) { $line{i} = $i; $line{rrp} = sprintf( "%.2f", $results[$i]->{'rrp'} ); $line{ecost} = sprintf( "%.2f", $results[$i]->{'ecost'} ); + $line{discount} = sprintf( "%.2f", $results[$i]->{'discount'} ); $line{quantity} = $results[$i]->{'quantity'}; $line{quantityrecieved} = $results[$i]->{'quantityreceived'}; $line{line_total} = sprintf( "%.2f", $line_total ); $line{biblionumber} = $results[$i]->{'biblionumber'}; $line{bookfundid} = $results[$i]->{'bookfundid'}; $line{odd} = $i % 2; +if ($line{quantityrecieved}>0){$line{donotdelete}=1;} push @books_loop, \%line; +$template->param(purchaseordernumber => $results[0]->{'purchaseordernumber'}, + booksellerinvoicenumber=>$results[0]->{booksellerinvoicenumber},); } -my $prefgist = C4::Context->preference("gist"); -$gist = sprintf( "%.2f", $sub_total * $prefgist ); -$grand_total = $sub_total + $gist; -$grand_total_est = - $sub_total_est + sprintf( "%.2f", $sub_total_est * $prefgist ); -$gist_est = sprintf( "%.2f", $sub_total_est * $prefgist ); +$grand_total_est = sprintf( "%.2f", $sub_total_est - $disc_est+$gist_est ); + $template->param( basketno => $basketno, creationdate => format_date( $basket->{creationdate} ), @@ -186,11 +178,10 @@ $template->param( entrydate => format_date( $results[0]->{'entrydate'} ), books_loop => \@books_loop, count => $count, - sub_total => $sub_total, gist => $gist, - grand_total => $grand_total, - sub_total_est => $sub_total_est, - gist_est => $gist_est, + sub_total_est => sprintf( "%.2f",$sub_total_est), + gist_est => sprintf( "%.2f",$gist_est), + disc_est => sprintf( "%.2f",$disc_est), grand_total_est => $grand_total_est, currency => $booksellers[0]->{'listprice'}, qty_total => $qty_total, diff --git a/acqui/bookfund.pl b/acqui/bookfund.pl index 4f6f19bd28..18c06834b1 100755 --- a/acqui/bookfund.pl +++ b/acqui/bookfund.pl @@ -64,15 +64,15 @@ SELECT quantity, ON aqorderbreakdown.ordernumber = aqorders.ordernumber INNER JOIN aqbasket ON aqbasket.basketno = aqorders.basketno - LEFT JOIN biblioitems - ON biblioitems.biblioitemnumber = aqorders.biblioitemnumber + LEFT JOIN biblio + ON biblio.biblionumber = aqorders.biblionumber WHERE bookfundid = ? AND budgetdate >= ? AND budgetdate < ? AND (datecancellationprinted IS NULL OR datecancellationprinted = \'0000-00-00\') '; -warn $query; +##warn $query; my $sth = $dbh->prepare($query); $sth->execute( $bookfund, $start, $end ); my @commited_loop; @@ -97,6 +97,6 @@ $template->param( total => $total ); $sth->finish; -$dbh->disconnect; +#$dbh->disconnect; output_html_with_http_headers $input, $cookie, $template->output; diff --git a/acqui/booksellers.pl b/acqui/booksellers.pl index accf642e67..923a99cbc5 100755 --- a/acqui/booksellers.pl +++ b/acqui/booksellers.pl @@ -55,12 +55,8 @@ the C we have to close if op is equal to 'close'. use strict; use C4::Auth; -use C4::Biblio; -use C4::Output; use CGI; use C4::Interface::CGI::Output; -use C4::Database; -use HTML::Template; use C4::Acquisition; use C4::Date; use C4::Bookseller; @@ -85,19 +81,19 @@ my $count = scalar @suppliers; # check if we have to "close" a basket before building page my $op = $query->param('op'); -my $basket = $query->param('basket'); +my $basketno = $query->param('basketno'); if ( $op eq 'close' ) { - CloseBasket($basket); + CloseBasket($basketno); } #build result page my $toggle = 0; + my $ordcount; my @loop_suppliers; for ( my $i = 0 ; $i < $count ; $i++ ) { - my $orders = GetPendingOrders( $suppliers[$i]->{'id'} ); - my $ordcount = scalar @$orders; -# FIXME : $ordcount seems to be equals to 0 each times... - + my $orders = GetPendingOrders( $suppliers[$i]->{'id'} ); + my $ordercount = scalar @$orders; +$ordcount+=$ordercount; my %line; if ( $toggle == 0 ) { $line{even} = 1; @@ -110,18 +106,10 @@ for ( my $i = 0 ; $i < $count ; $i++ ) { $line{supplierid} = $suppliers[$i]->{'id'}; $line{name} = $suppliers[$i]->{'name'}; $line{active} = $suppliers[$i]->{'active'}; + $line{ordcount}=$ordercount; my @loop_basket; - for ( my $i2 = 0 ; $i2 < $ordcount ; $i2++ ) { - my %inner_line; - $inner_line{basketno} = $orders->[$i2]->{'basketno'}; - $inner_line{total} = $orders->[$i2]->{'count(*)'}; - $inner_line{authorisedby} = $orders->[$i2]->{'authorisedby'}; - $inner_line{surname} = $orders->[$i2]->{'firstname'}; - $inner_line{firstname} = $orders->[$i2]->{'surname'}; - $inner_line{creationdate} = - format_date( $orders->[$i2]->{'creationdate'} ); - $inner_line{closedate} = format_date( $orders->[$i2]->{'closedate'} ); - push @loop_basket, \%inner_line; + foreach my $order(@$orders){ + push @loop_basket, $order; } $line{loop_basket} = \@loop_basket; push @loop_suppliers, \%line; @@ -129,7 +117,7 @@ for ( my $i = 0 ; $i < $count ; $i++ ) { $template->param( loop_suppliers => \@loop_suppliers, supplier => $supplier, - count => $count, + count => $ordcount, intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), intranetstylesheet => C4::Context->preference("intranetstylesheet"), diff --git a/acqui/currency.pl b/acqui/currency.pl new file mode 100755 index 0000000000..09d81c9b5d --- /dev/null +++ b/acqui/currency.pl @@ -0,0 +1,42 @@ +#!/usr/bin/perl + +# $Id$ + +#written by chris@katipo.co.nz +#9/10/2000 +#script to display and update currency rates + + +# 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 CGI; +use C4::Acquisition; +use C4::Biblio; +use C4::Bookfund; + +my $input=new CGI; + +my @params=$input->param; +foreach my $param (@params){ + if ($param ne 'type' && $param !~ /submit/){ + my $data=$input->param($param); +# warn "$data / $param"; + ModCurrencies($param,$data); +} +} +print $input->redirect('/cgi-bin/koha/acqui/acqui-home.pl'); diff --git a/acqui/finishreceive.pl b/acqui/finishreceive.pl index 4aa7d4272d..7491af41c5 100755 --- a/acqui/finishreceive.pl +++ b/acqui/finishreceive.pl @@ -41,21 +41,13 @@ TODO =cut use strict; -use C4::Output; use C4::Acquisition; -use C4::Biblio; use CGI; -use C4::Search; -use C4::Circulation::Circ2; -use C4::Reserves2; use C4::Interface::CGI::Output; use C4::Auth; -use HTML::Template; - -#use Data::Dumper; +use C4::Bookseller; my $input = new CGI; -my $dbh = C4::Context->dbh; my ( $template, $borrowernumber, $cookie ) = get_template_and_user( { @@ -68,206 +60,49 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( } ); -my $user = $input->remote_user; -my $biblionumber = $input->param('biblio'); -my $biblioitemnumber = $input->param('biblioitemnum'); -my $ordnum = $input->param('ordnum'); -my $cost = $input->param('cost'); +my @biblionumber = $input->param('biblionumber'); +my @ordnum = $input->param('ordernumber'); +my $cost = $input->param('invoicetotal'); +my $locacost = $input->param('localtotal'); my $invoiceno = $input->param('invoice'); -my $replacement = $input->param('rrp'); -my $gst = $input->param('gst'); -my $freight = $input->param('freight'); -my $freightperitem = $input->param('freightperitem'); +my @replacement = $input->param('actual'); +my @gst = $input->param('gstrate'); +my $freight = $input->param('actualfreight'); +my @freightperitem = $input->param('freight'); my $supplierid = $input->param('supplierid'); -my $title = $input->param('title'); -my $author = $input->param('author'); -my $copyrightdate = $input->param('copyrightdate'); -my $itemtype = $input->param('format'); -my $isbn = $input->param('ISBN'); -my $seriestitle = $input->param('series'); -my $branch = $input->param('branch'); -my $holdingbranch = $branch; -my $barcode = $input->param('barcode'); -my $bookfund = $input->param('bookfund'); -my $quantity = $input->param('quantity'); -my $quantrec = $input->param('quantityrec'); -my $ecost = $input->param('ecost'); -my $unitprice = $input->param('unitprice'); -my $notes = $input->param('notes'); -my $booksellers = $input->param('booksellers'); -my $foo = $input->param('foo'); -my $volinf = $input->param('volinf'); -my $catview = $input->param('catview'); # for editing from moredetail.tmpl -my $barcodeexists = $input->param('barcodeexists'); # if barcode exists -my $newitemfailed = $input->param('newitemfailed'); # if create new item failed -my $createbibitem = - $input->param('createbibitem'); # user wants to create a new bibitem - -#get additional info on bib and bibitem from dbase for additional needed fields before modbiblio. -( my $bibliocount, my @biblios ) = &getbiblio($biblionumber); -my @biblioitems = &GetBiblioItemByBiblioNumber($biblionumber); -my $biblioitemcount = scalar @biblioitems; - -( my $itemscount, my @items ) = &getitemsbybiblioitem($biblioitemnumber); - -my $bibliohash = { - biblionumber => $biblionumber, - title => $title, - author => $author, - abstract => $biblios[0]->{'abstract'}, - copyrightdate => $copyrightdate, - seriestitle => $seriestitle, - serial => $biblios[0]->{'serial'}, - unititle => $biblios[0]->{'unititle'}, - notes => $biblios[0]->{'notes'} -}; - -my $biblioitemhash = { - illus => $biblioitems[0]->{'illus'}, - number => $biblioitems[0]->{'number'}, - itemtype => $itemtype, - place => $biblioitems[0]->{'place'}, - biblioitemnumber => $biblioitemnumber, - issn => $biblioitems[0]->{'issn'}, - size => $biblioitems[0]->{'size'}, - marc => $biblioitems[0]->{'marc'}, - timestamp => $biblioitems[0]->{'timestamp'}, - biblionumber => $biblionumber, - url => $biblioitems[0]->{'url'}, - dewey => $biblioitems[0]->{'dewey'}, - isbn => $isbn, - publishercode => $biblioitems[0]->{'publishercode'}, - lccn => $biblioitems[0]->{'iccn'}, - volume => $biblioitems[0]->{'volume'}, - subclass => $biblioitems[0]->{'subclass'}, - notes => $biblioitems[0]->{'notes'}, - classification => $biblioitems[0]->{'classification'}, - volumeddesc => $volinf, - publicationyear => $biblioitems[0]->{'publicationyear'}, - volumedate => $biblioitems[0]->{'volumedate'}, - pages => $biblioitems[0]->{'pages'} -}; - -my $itemhash = { - biblionumber => $biblionumber, - itemnum => $items[0]->{'itemnumber'}, - barcode => $barcode, - notes => $items[0]->{'notes'}, - itemcallnumber => $items[0]->{'itemcallnumber'}, - notforloan => $items[0]->{'notforloan'}, - location => $items[0]->{'location'}, - bibitemnum => $biblioitemnumber, - homebranch => $items[0]->{'homebranch'}, - lost => $items[0]->{'itemlost'}, - withdrawn => $items[0]->{'withdrawn'}, - holdingbranch => $items[0]->{'holdingbranch'}, - replacement => $replacement -}; - -# check if barcode exists, if so redirect back to orderreceive.pl and give message -my $error = &checkitems( 1, $barcode ); -#warn "barcode check for $barcode result = $error"; -if ($error) { - print $input->redirect( - "/cgi-bin/koha/acqui/orderreceive.pl?recieve=$ordnum&biblio=$biblionumber&invoice=$invoiceno&supplierid=$supplierid&freight=$freight&gst=$gst&barcodeexists=$barcode" - ); -} -# or if barcode is blank -else { - - if ( $createbibitem eq "YES" ) { - &modbiblio($bibliohash); - $biblioitemnumber = &newbiblioitem($biblioitemhash); - -#lets do a lookup on aqorders, with ordnum, then insert biblioitem fiels with new biblioitem number - - &ModOrderBiblioNumber($biblioitemnumber,$ordnum, $biblionumber); - - else { - &modbiblio($bibliohash); - &modbibitem($biblioitemhash); - } - - if ($catview) { - &moditem($itemhash); - print $input->redirect( -"/cgi-bin/koha/moredetail.pl?type=$itemtype&bib=$biblionumber&bi=$biblioitemnumber" - ); - } - - if ( $quantity != 0 ) { - # save the quantity recieved. - receiveorder( $biblionumber, $ordnum, $quantrec, $user, $cost, - $invoiceno, $freightperitem, $bookfund, $replacement ); - - # create items if the user has entered barcodes - my @barcodes = split( /\,| |\|/, $barcode ); #WTF? - - my ($error) = newitems( - { - biblioitemnumber => $biblioitemnumber, - biblionumber => $biblionumber, - replacementprice => $replacement, - price => $cost, - booksellerid => $supplierid, - homebranch => $branch, - loan => 0 - }, - @barcodes - ); - - if ($error) - { #if newitems failes then display error, and send them back to orderreceive.pl???? - - print $input->redirect( - "/cgi-bin/koha/acqui/orderreceive.pl?recieve=$ordnum&biblio=$biblionumber&invoice=$invoiceno&supplierid=$supplierid&freight=$freight&gst=$gst&newitemfailed=1" - ); - } - - elsif ( $itemtype ne 'P' && $itemtype ne 'PP' ) { # chris's new if bit - my %env; - my $item = getiteminformation( \%env, 0, $barcode ); - my ( $resfound, $resrec ) = CheckReserves( 0, $barcode ); - - if ($resfound) { # reserves is found - my ($borrower) = - getpatroninformation( \%env, $resrec->{'borrowernumber'}, 0 ); - $template->param( - borrowernumber => $borrower->{'borrowernumber'}, - cardnumber => $borrower->{'cardnumber'}, - firstname => $borrower->{'firstname'}, - surname => $borrower->{'surname'}, - invoice => $invoiceno, - id => $supplierid, - freight => $freight, - gst => $gst, - items => $quantity, - ordnum => $ordnum, - biblionumber => $biblionumber, - barcode => $barcode, - ); - - output_html_with_http_headers $input, $cookie, - $template->output; - } - else { #no reserves found - $invoiceno =~ - s/\&/\%26/g; # swapping pesky & with url friendly hex codes. - print $input->redirect( - "/cgi-bin/koha/acqui/receive.pl?invoice=$invoiceno&supplierid=$supplierid&freight=$freight&gst=$gst&quantity=$quantity" - ); - } - } - else { - print $input->redirect( - "/cgi-bin/koha/loadmodules.pl?module=acquisitions") - ; # chris's new bit - } # end of if - } - else { - - # print $input->header; - DelOrder( $biblionumber, $ordnum ); - print $input->redirect("/acquisitions/"); - } +my @title = $input->param('title'); +my $currencyrate=$input->param('currencyrate'); +my @bookfund = $input->param('bookfund'); +my @discount = $input->param('discount'); +my @quantrec = $input->param('received'); +my $totalreceived=$input->param('totalreceived'); +my $incgst=$input->param('incgst'); +my $ecost; +my $unitprice; +my $listprice; + +my @supplier=GetBookSeller($supplierid); +my $count=scalar @quantrec; +my @additems; + + for (my $i=0; $i<$count;$i++){ + $freightperitem[$i]=$freight/$totalreceived unless $freightperitem[$i]; +$listprice=$replacement[$i]; + $replacement[$i]= $replacement[$i]*$currencyrate; + if ($incgst){ + $ecost= ($replacement[$i]*100/($gst[$i]+100))*(100 - $discount[$i])/100; + }else{ + $ecost= $replacement[$i]*(100 - $discount[$i])/100; + } +$unitprice=$ecost + $ecost*$gst[$i]/100; + if ( $quantrec[$i] != 0 ) { + # save the quantity recieved. + ModReceiveOrder( $biblionumber[$i], $ordnum[$i], $quantrec[$i], $unitprice, + $invoiceno, $freightperitem[$i], $replacement[$i] ,$listprice,$input ); + push @additems,{biblionumber=>$biblionumber[$i],itemcount=>$quantrec[$i], title=>$title[$i],supplier=>$supplier[0]->{name},rrp=>$replacement[$i],}; + + } } +$template->param(loopbiblios => \@additems,); + + output_html_with_http_headers $input, $cookie, $template->output; \ No newline at end of file diff --git a/acqui/histsearch.pl b/acqui/histsearch.pl index 0cc0df3447..be1ddd4cb8 100755 --- a/acqui/histsearch.pl +++ b/acqui/histsearch.pl @@ -52,8 +52,6 @@ to filter on ended date. use strict; require Exporter; use CGI; -use HTML::Template; - use C4::Auth; # get_template_and_user use C4::Interface::CGI::Output; use C4::Acquisition; diff --git a/acqui/lateorders.pl b/acqui/lateorders.pl index 880bedb41e..bee0f88c23 100755 --- a/acqui/lateorders.pl +++ b/acqui/lateorders.pl @@ -51,7 +51,6 @@ use C4::Koha; use C4::Output; use C4::Interface::CGI::Output; use C4::Context; -use HTML::Template; use C4::Acquisition; my $query = new CGI; diff --git a/acqui/neworderbiblio.pl b/acqui/neworderbiblio.pl deleted file mode 100755 index fa0f199834..0000000000 --- a/acqui/neworderbiblio.pl +++ /dev/null @@ -1,359 +0,0 @@ -#!/usr/bin/perl - -#origninally script to provide intranet (librarian) advanced search facility -#now script to do searching for acquisitions - -# 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 - -=head1 NAME - -neworderbiblio.pl - -=head1 DESCRIPTION -this script allows to perform a new order from an existing record. - -=head1 CGI PARAMETERS - -=over 4 - -=item search -the title the librarian has typed to search an existing record. - -=item type -To know if this script is called from intranet or from the opac. - -=item d -the keyword the librarian has typed to search an existing record. - -=item author -the author of the new record. - -=item offset - -=item num - -=item booksellerid -the id of the bookseller this script has to add an order. - -=item basketno -the basket number to know on which basket this script have to add a new order. - -=item sub -FIXME : is this param still used ? - -=back - -=cut - - -use strict; -use C4::Search; -use CGI; -use C4::Output; -use C4::Bookseller; -use C4::Biblio; -use HTML::Template; -use C4::Auth; -use C4::Interface::CGI::Output; - - -#use Data::Dumper; - -my $env; -my $input = new CGI; - -#print $input->header; - -#whether it is called from the opac of the intranet -my $type = $input->param('type'); -my $acq_search = $input->param('acq_search'); -if ( $type eq '' ) { - $type = 'intra'; -} - -#print $input->dump; -my $blah; -my %search; - -#build hash of users input -my $title = $input->param('search'); -$search{'title'} = $title; -my $keyword = $input->param('d'); -$search{'keyword'} = $keyword; -my $author = $input->param('author'); -$search{'author'} = $author; - -my @results; -my $offset = $input->param('offset'); - -#default value for offset -my $offset = 0 unless $offset; - -my $num = $input->param('num'); - -#default value for num -my $num = 10 unless $num; - -my $donation; -my $booksellerid = $input->param('booksellerid'); -if ( $booksellerid == 72 ) { - $donation = 'yes'; -} -my $basketno = $input->param('basketno'); -my $sub = $input->param('sub'); - -#print $sub; -my @booksellers = GetBookSeller($booksellerid); -my $count = scalar @booksellers; - -my ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { - template_name => "acqui/neworderbiblio.tmpl", - query => $input, - type => "intranet", - authnotrequired => 0, - flagsrequired => { order => 1 }, - debug => 1, - } -); - -#my $template = gettemplate("acqui/neworderbiblio.tmpl"); -#print startpage(); -#print startmenu('acquisitions'); -my $invalidsearch; - -if ( $keyword ne '' ) { - ( $count, @results ) = - KeywordSearch( undef, 'intra', \%search, $num, $offset ); -} -elsif ( $search{'front'} ne '' ) { - ( $count, @results ) = - FrontSearch( undef, 'intra', \%search, $num, $offset ); -} -elsif ( $search{'author'} || $search{'title'} ) { - if($acq_search == 1){ - ( $count, @results ) = CatSearch( undef, 'loose_acq', \%search, $num, $offset ); - } else { - ( $count, @results ) = CatSearch( undef, 'loose', \%search, $num, $offset ); - } -} -else { - $invalidsearch = 1; -} - -my @loopsearch; - -while ( my ( $key, $value ) = each %search ) { - if ( $value ne '' ) { - my %linesearch; - $value =~ s/\\//g; - $linesearch{key} = $key; - $linesearch{value} = $value; - push( @loopsearch, \%linesearch ); - } -} - -my $offset2 = $num + $offset; -my $dispnum = $offset + 1; -if ( $offset2 > $count ) { - $offset2 = $count; -} - -my $count2 = @results; -if ( $keyword ne '' && $offset > 0 ) { - $count2 = $count - $offset; - if ( $count2 > 10 ) { - $count2 = 10; - } -} -my $i = 0; -my $colour = 0; - -my @loopresult; - -while ( $i < $count2 ) { - my %lineres; - my $toggle; - - my $result = $results[$i]; - $result->{'title'} =~ s/\`/\\\'/g; - my $title2 = $result->{'title'}; - my $author2 = $result->{'author'}; - $author2 =~ s/ /%20/g; - $title2 =~ s/ /%20/g; - $title2 =~ s/\#/\&\#x23;/g; - $title2 =~ s/\"/\"\;/g; - - my $itemcount; - my $location = ''; - my $location_only = ''; - my $word = $result->{'author'}; - $word =~ s/([a-z]) +([a-z])/$1%20$2/ig; - $word =~ s/ //g; - $word =~ s/ /%20/g; - $word =~ s/\,/\,%20/g; - $word =~ s/\n//g; - $lineres{word} = $word; - $lineres{type} = $type; - - my ( $counts, $branchcounts ) = - C4::Search::itemcount( $env, $result->{'biblionumber'}, $type ); - - if ( $counts->{'nacount'} > 0 ) { - $location .= "On Loan"; - if ( $counts->{'nacount'} > 1 ) { - $location .= "=($counts->{'nacount'})"; - } - $location .= " "; - $lineres{'on-loan-p'} = 1; - } - foreach my $key ( keys %$branchcounts ) { - if ( $branchcounts->{$key} > 0 ) { - $location .= $key; - $location_only .= $key; - - if ( $branchcounts->{$key} > 1 ) { - $location .= "=$branchcounts->{$key}"; - $location_only .= "=$branchcounts->{$key}"; - } - $location .= " "; - $location_only .= " "; - } - } - if ( $counts->{'lostcount'} > 0 ) { - $location .= "Lost"; - if ( $counts->{'lostcount'} > 1 ) { - $location .= "=($counts->{'lostcount'})"; - } - $location .= " "; - $lineres{'lost-p'} = 1; - } - if ( $counts->{'mending'} > 0 ) { - $location .= "Mending"; - if ( $counts->{'mending'} > 1 ) { - $location .= "=($counts->{'mending'})"; - } - $location .= " "; - $lineres{'mending-p'} = 1; - } - if ( $counts->{'transit'} > 0 ) { - $location .= "In Transit"; - if ( $counts->{'transit'} > 1 ) { - $location .= "=($counts->{'transit'})"; - } - $location .= " "; - $lineres{'in-transit-p'} = 1; - } - if ( $colour eq 0 ) { - $toggle = 1; - $colour = 1; - } - else { - $colour = 0; - $toggle = 0; - } - $lineres{author2} = $author2; - $lineres{title2} = $title2; - $lineres{copyright} = $result->{'copyrightdate'}; - $lineres{booksellerid} = $booksellerid; - $lineres{basketno} = $basketno; - $lineres{sub} = $sub; - $lineres{biblionumber} = $result->{biblionumber}; - $lineres{title} = $result->{title}; - $lineres{author} = $result->{author}; - $lineres{toggle} = $toggle; - $lineres{itemcount} = $counts->{'count'}; - $lineres{location} = $location; - $lineres{'location-only'} = $location_only; - - # lets get a list on existing orders for all bibitems. - my @bibitems = GetBiblioItemByBiblioNumber( $result->{biblionumber} ); - my $count1 = scalar @bibitems; - my $order, my $ordernumber; - - my $i1 = 0; - - my @ordernumbers; - foreach my $bibitem (@bibitems) { - my $ordernumber = GetOrderNumber($result->{biblionumber},$bibitem->{biblioitemnumber}); - $order = &GetOrder($ordernumber); - - #only show order if its current; - my %order; - $order{'number'} = $ordernumber; - if ( ( !$order->{cancelledby} ) - && ( $order->{quantityreceived} < $order->{quantity} ) ) - { - push @ordernumbers, \%order; - } - } - $lineres{existingorder} = \@ordernumbers; - push( @loopresult, \%lineres ); - $i++; -} - -my $prevoffset = $offset - $num; -my $offsetprev = 1; -if ( $prevoffset < 0 ) { - $offsetprev = 0; -} - -$offset = $num + $offset; - -my @numbers = (); -if ( $count > 10 ) { - for ( my $i = 0 ; $i < ( $count / $num ) ; $i++ ) { - my $highlight = 0; - my $numberoffset = $i * $num; - if ( ( $numberoffset + $num ) == $offset ) { $highlight = 1 } - - # warn "I $i | N $num | O $offset | NO $numberoffset | H $highlight"; - push @numbers, - { - number => ( $i + 1 ), - highlight => $highlight, - numberoffset => $numberoffset - }; - } -} - -$template->param( - bookselname => $booksellers[0]->{'name'}, - booksellerid => $booksellerid, - basketno => $basketno, - parsub => $sub, - count => $count, - offset2 => $offset2, - dispnum => $dispnum, - offsetover => ( $offset < $count ), - num => $num, - offset => $prevoffset, - offsetprev => $offsetprev, - type => $type, - title => $title, - author => $author, - donation => $donation, - loopsearch => \@loopsearch, - loopresult => \@loopresult, - numbers => \@numbers, - invalidsearch => $invalidsearch, - 'use-location-flags-p' => 1 -); - -output_html_with_http_headers $input, $cookie, $template->output; - diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl index c45ea8397b..587c1fcf42 100755 --- a/acqui/neworderempty.pl +++ b/acqui/neworderempty.pl @@ -65,8 +65,6 @@ if this order comes from a suggestion. use strict; use CGI; use C4::Context; -use C4::Input; -use C4::Database; use C4::Auth; use C4::Bookfund; use C4::Bookseller; @@ -74,12 +72,11 @@ use C4::Acquisition; use C4::Suggestions; use C4::Biblio; use C4::Search; -use C4::Output; -use C4::Input; use C4::Koha; use C4::Interface::CGI::Output; -use HTML::Template; use C4::Members; +use C4::Input; +use C4::Date; my $input = new CGI; my $booksellerid = $input->param('booksellerid'); @@ -89,47 +86,14 @@ my $copyright = $input->param('copyright'); my @booksellers = GetBookSeller($booksellerid); my $count = scalar @booksellers; my $ordnum = $input->param('ordnum'); -my $biblio = $input->param('biblio'); +my $biblionumber = $input->param('biblionumber'); my $basketno = $input->param('basketno'); my $suggestionid = $input->param('suggestionid'); -# my $donation = $input->param('donation'); my $close = $input->param('close'); my $data; my $new; -my $dbh = C4::Context->dbh; -if ( $ordnum eq '' ) { # create order - $new = 'yes'; - - # $ordnum=newordernum; - if ( $biblio && !$suggestionid ) { - $data = bibdata($biblio); - } - -# get suggestion fields if applicable. If it's a subscription renewal, then the biblio already exists -# otherwise, retrieve suggestion information. - if ($suggestionid) { - if ($biblio) { - $data = bibdata($biblio); - } - else { - $data = GetSuggestion($suggestionid); - } - } - if ( $data->{'title'} eq '' ) { - $data->{'title'} = $title; - $data->{'author'} = $author; - $data->{'copyrightdate'} = $copyright; - } -} -else { #modify order - $data = GetSingleOrder($ordnum); - $biblio = $data->{'biblionumber'}; - #get basketno and suppleirno. too! - my $data2 = GetBasket( $data->{'basketno'} ); - $basketno = $data2->{'basketno'}; - $booksellerid = $data2->{'booksellerid'}; -} +my $dbh = C4::Context->dbh; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { @@ -141,8 +105,69 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( debug => 1, } ); +my $me= C4::Context->userenv; +my $homebranch=$me->{'branch'} ; +my $branch; +my $bookfundid; +my $discount= $booksellers[0]->{'discount'}; +my $gstrate=C4::Context->preference('gist')*100; +if ( $ordnum eq '' ) { # create order + $new = 'yes'; + if ( $biblionumber ) { + my $record=XMLgetbibliohash($dbh,$biblionumber); + ###Error checking if a non existent biblionumber given manually + if (!$record){ + print $input->redirect("/cgi-bin/koha/acqui/basket.pl?supplierid=$booksellerid"); + } + $data = XMLmarc2koha_onerecord($dbh,$record,"biblios"); + }elsif($suggestionid){ + $data = GetSuggestion($suggestionid); + + if ( $data->{'title'} eq '' ) { + $data->{'title'} = $title; + $data->{'author'} = $author; + $data->{'copyrightdate'} = $copyright; + } + }### if biblionumber + if ($basketno){ + my $basket = GetBasket( $basketno); + my @orders=GetOrders($basketno); + if (@orders){ + $template->param( + purchaseordernumber => $orders[0]->{purchaseordernumber}, ); + } + $template->param( + creationdate => format_date( $basket->{creationdate} ), + authorisedbyname => $basket->{authorisedbyname},); + }else{ + my @datetoday = localtime(); + my $date = (1900+$datetoday[5])."-".($datetoday[4]+1)."-". $datetoday[3]; + $template->param( + creationdate => format_date($date), + authorisedbyname => $loggedinuser,); + } +}else { #modify order + $data = GetSingleOrder($ordnum); + $biblionumber = $data->{'biblionumber'}; + #get basketno and suppleirno. too! + my $data2 = GetBasket( $data->{'basketno'} ); + $basketno = $data->{'basketno'}; + $booksellerid = $data2->{'booksellerid'}; + $discount=$data->{'discount'}; + $gstrate=$data->{'gst'} ; + $bookfundid =$data->{'bookfundid'}; + my $aqbookfund=GetBookFund($data->{'bookfundid'}); +$branch=$aqbookfund->{branchcode}; +$template->param( + purchaseordernumber => $data->{purchaseordernumber}, + creationdate => format_date( $data2->{creationdate} ), + authorisedbyname => $data2->{authorisedbyname},); + +} -# get currencies (for change rates calcs if needed) + + +# get currencies (for exchange rates calcs if needed) my @rates = GetCurrencies(); my $count = scalar @rates; @@ -154,45 +179,31 @@ for ( my $i = 0 ; $i < $count ; $i++ ) { push @loop_currency, \%line; } -# build itemtype list -my $itemtypes = GetItemTypes; -my @itemtypesloop; -my %itemtypesloop; -foreach my $thisitemtype (sort keys %$itemtypes) { - push @itemtypesloop, $itemtypes->{$thisitemtype}->{'itemtype'}; - $itemtypesloop{$itemtypes->{$thisitemtype}->{'itemtype'}} = $itemtypes->{$thisitemtype}->{'description'}; -} -my $CGIitemtype = CGI::scrolling_list( - -name => 'format', - -values => \@itemtypesloop, - -default => $data->{'itemtype'}, - -labels => \%itemtypesloop, - -size => 1, - -multiple => 0 -); + # build branches list my $branches = GetBranches; my @branchloop; foreach my $thisbranch ( sort keys %$branches ) { - my %row = ( +my $selected=1 if $thisbranch eq $branch; + my %row = ( value => $thisbranch, branchname => $branches->{$thisbranch}->{'branchname'}, + selected=>$selected , ); push @branchloop, \%row; } $template->param( branchloop => \@branchloop ); # build bookfund list -my ($flags, $homebranch) = GetFlagsAndBranchFromBorrower($loggedinuser); my $count2; my @bookfund; my @select_bookfund; my %select_bookfunds; - +my $selbookfund; @bookfund = GetBookFunds($homebranch); $count2 = scalar @bookfund; @@ -200,18 +211,22 @@ for ( my $i = 0 ; $i < $count2 ; $i++ ) { push @select_bookfund, $bookfund[$i]->{'bookfundid'}; $select_bookfunds{ $bookfund[$i]->{'bookfundid'} } = $bookfund[$i]->{'bookfundname'}; + if ($bookfund[$i]->{'bookfundid'} eq $bookfundid){ + $selbookfund=1; + } } my $CGIbookfund = CGI::scrolling_list( - -name => 'bookfund', + -name => 'bookfundid', -values => \@select_bookfund, -default => $data->{'bookfundid'}, -labels => \%select_bookfunds, -size => 1, + -selected =>$selbookfund, -multiple => 0 ); my $bookfundname; -my $bookfundid; + if ($close) { $bookfundid = $data->{'bookfundid'}; $bookfundname = $select_bookfunds{$bookfundid}; @@ -236,28 +251,19 @@ else { my $bibitemsexists; -#do a biblioitems lookup on bib -my @bibitems = GetBiblioItemByBiblioNumber($biblio); -my $bibitemscount = scalar @bibitems; - -if ( $bibitemscount > 0 ) { - # warn "NEWBIBLIO: bibitems for $biblio exists\n"; - # warn Dumper $bibitemscount, @bibitems; - $bibitemsexists = 1; - - my @bibitemloop; - for ( my $i = 0 ; $i < $bibitemscount ; $i++ ) { - my %line; - $line{biblioitemnumber} = $bibitems[$i]->{'biblioitemnumber'}; - $line{isbn} = $bibitems[$i]->{'isbn'}; - $line{itemtype} = $bibitems[$i]->{'itemtype'}; - $line{volumeddesc} = $bibitems[$i]->{'volumeddesc'}; +# + + $template->param( bibitemexists => "1" ) if $biblionumber; + my @bibitemloop; + my %line; + $line{isbn} = $data->{'isbn'}; + $line{itemtype} = $data->{'itemtype'}; + $line{volumeddesc} = $data->{'volumeddesc'}; push( @bibitemloop, \%line ); $template->param( bibitemloop => \@bibitemloop ); - } - $template->param( bibitemexists => "1" ); -} + + # fill template $template->param( @@ -268,16 +274,14 @@ $template->param( if ($close); $template->param( - existing => $biblio, - title => $title, + existing => $biblionumber, ordnum => $ordnum, basketno => $basketno, booksellerid => $booksellerid, suggestionid => $suggestionid, - biblio => $biblio, - biblioitemnumber => $data->{'biblioitemnumber'}, + biblionumber => $biblionumber, itemtype => $data->{'itemtype'}, - discount => $booksellers[0]->{'discount'}, + discount => $discount, listincgst => $booksellers[0]->{'listincgst'}, listprice => $booksellers[0]->{'listprice'}, gstreg => $booksellers[0]->{'gstreg'}, @@ -286,13 +290,12 @@ $template->param( nocalc => $booksellers[0]->{'nocalc'}, name => $booksellers[0]->{'name'}, currency => $booksellers[0]->{'listprice'}, - gstrate => C4::Context->preference("gist"), + gstrate =>$gstrate, loop_currencies => \@loop_currency, orderexists => ( $new eq 'yes' ) ? 0 : 1, title => $data->{'title'}, author => $data->{'author'}, copyrightdate => $data->{'copyrightdate'}, - CGIitemtype => $CGIitemtype, CGIbookfund => $CGIbookfund, isbn => $data->{'isbn'}, seriestitle => $data->{'seriestitle'}, @@ -301,6 +304,9 @@ $template->param( rrp => $data->{'rrp'}, invoice => $data->{'booksellerinvoicenumber'}, ecost => $data->{'ecost'}, + total =>$data->{'unitprice'}* $data->{'quantity'}, + unitprice => $data->{'unitprice'}, + gst => $data->{'ecost'}*$gstrate/100, notes => $data->{'notes'}, publishercode => $data->{'publishercode'}, # donation => $donation diff --git a/acqui/newordersuggestion.pl b/acqui/newordersuggestion.pl index d58c1d9180..0571d5eaec 100755 --- a/acqui/newordersuggestion.pl +++ b/acqui/newordersuggestion.pl @@ -77,7 +77,6 @@ can be equal to use strict; require Exporter; use CGI; -use HTML::Template; use C4::Auth; # get_template_and_user use C4::Interface::CGI::Output; use C4::Suggestions; @@ -120,50 +119,40 @@ if ($op eq 'connectDuplicate') { my $suggestions_loop= &SearchSuggestion($borrowernumber,$author,$title,$publishercode,$status,$suggestedbyme); foreach (@$suggestions_loop) { unless ($_->{biblionumber}) { - my (@tags, @and_or, @excluding, @operator, @value, $offset,$length); + my (@kohafields, @and_or, @value, @relation, $offset,$length); # search on biblio.title if ($_->{title}) { - my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,"biblio.title",""); - push @tags, "'".$tag.$subfield."'"; - push @and_or, "and"; - push @excluding, ""; - push @operator, "contains"; + push @kohafields, "title"; + push @and_or, "\@and"; + push @relation, "\@attr 5=1"; push @value, $_->{title}; } if ($_->{author}) { - my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,"biblio.author",""); - push @tags, "'".$tag.$subfield."'"; - push @and_or, "and"; - push @excluding, ""; - push @operator, "contains"; + push @kohafields, "author"; + push @and_or, "\@and"; + push @relation, ""; push @value, $_->{author}; } # ... and on publicationyear. if ($_->{publicationyear}) { - my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,"biblioitems.publicationyear",""); - push @tags, "'".$tag.$subfield."'"; - push @and_or, "and"; - push @excluding, ""; - push @operator, "="; + push @kohafields, "copyrightdate"; + push @and_or, "\@and"; + push @relation, ""; push @value, $_->{publicationyear}; } # ... and on publisher. if ($_->{publishercode}) { - my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,"biblioitems.publishercode",""); - push @tags, "'".$tag.$subfield."'"; - push @and_or, "and"; - push @excluding, ""; - push @operator, "="; + push @kohafields, "publishercode"; + push @and_or, "\@and"; + push @relation, ""; push @value, $_->{publishercode}; } - my ($finalresult,$nbresult) = catalogsearch($dbh,\@tags,\@and_or,\@excluding,\@operator,\@value,0,10); + my ($nbresult,@finalresult) = ZEBRAsearch_kohafields(\@kohafields,\@value,\@relation,"",\@and_or,0,"",0,1); # there is at least 1 result => return the 1st one if ($nbresult) { - #warn "$nbresult => ".@$finalresult[0]->{biblionumber},@$finalresult[0]->{bibid},@$finalresult[0]->{title}; - #warn "DUPLICATE ==>".@$finalresult[0]->{biblionumber},@$finalresult[0]->{bibid},@$finalresult[0]->{title}; - $_->{duplicateBiblionumber} = @$finalresult[0]->{biblionumber}; + $_->{duplicateBiblionumber} = $finalresult[0]->{biblionumber}; } } } diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl deleted file mode 100644 index 033e31d8ca..0000000000 --- a/acqui/orderreceive.pl +++ /dev/null @@ -1,189 +0,0 @@ -#!/usr/bin/perl - -# $Id$ - -#script to recieve orders -#written by chris@katipo.co.nz 24/2/2000 - -# 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 - -=head1 NAME - -orderreceive.pl - -=head1 DESCRIPTION -This script shows all order already receive and all pendings orders. -It permit to write a new order as 'received'. - -=head1 CGI PARAMETERS - -=over 4 - -=item supplierid -to know on what supplier this script has to display receive order. - -=item recieve - -=item invoice -the number of this invoice. - -=item freight - -=item biblio -The biblionumber of this order. - -=item catview - -=item gst - -=back - -=cut - -use strict; -use CGI; -use C4::Context; -use C4::Acquisition; -use C4::Koha; -use C4::Auth; -use C4::Interface::CGI::Output; -use C4::Date; -use C4::Bookseller; -use C4::Members; - -my $input = new CGI; -my $supplierid = $input->param('supplierid'); -my $dbh = C4::Context->dbh; - -my $search = $input->param('recieve'); -my $invoice = $input->param('invoice'); -my $freight = $input->param('freight'); -my $biblio = $input->param('biblio'); -my $catview = $input->param('catview'); -my $gst = $input->param('gst'); -my @results = SearchOrder( $search, $supplierid, $biblio, $catview ); -my $count = scalar @results; - -# warn "C:$count for ordersearch($search,$supplierid,$biblio,$catview);"; -my @booksellers = GetBookSeller( $results[0]->{'booksellerid'} ); - -my $date = $results[0]->{'entrydate'}; - -my ( $template, $loggedinuser, $cookie ) = get_template_and_user( -{ - template_name => "acqui/orderreceive.tmpl", - query => $input, - type => "intranet", - authnotrequired => 0, - flagsrequired => { acquisition => 1 }, - debug => 1, -} -); -$template->param($count); -my ($flags, $homebranch) = GetFlagsAndBranchFromBorrower($loggedinuser); - -if ( $count == 1 ) { - my $sth; - - my $branches = GetBranches; - my @branchloop; - foreach my $thisbranch ( sort keys %$branches ) { - my %row = ( - value => $thisbranch, - branchname => $branches->{$thisbranch}->{'branchname'}, - ); - push @branchloop, \%row; -} - - my $auto_barcode = C4::Context->boolean_preference("autoBarcode") || 0; - -# See whether barcodes should be automatically allocated. -# Defaults to 0, meaning "no". - my $barcode; - if ( $auto_barcode eq '1' ) { - $sth = $dbh->prepare("Select max(barcode) from items"); - $sth->execute; - my $data = $sth->fetchrow_hashref; - $barcode = $results[0]->{'barcode'} + 1; - $sth->finish; -} - - if ( $results[0]->{'quantityreceived'} == 0 ) { - $results[0]->{'quantityreceived'} = ''; -} - if ( $results[0]->{'unitprice'} == 0 ) { - $results[0]->{'unitprice'} = ''; -} - $template->param( - branchloop => \@branchloop, - count => 1, - biblionumber => $results[0]->{'biblionumber'}, - ordernumber => $results[0]->{'ordernumber'}, - biblioitemnumber => $results[0]->{'biblioitemnumber'}, - supplierid => $results[0]->{'booksellerid'}, - freight => $freight, - gst => $gst, - catview => ( $catview ne 'yes' ? 1 : 0 ), - name => $booksellers[0]->{'name'}, - date => format_date($date), - title => $results[0]->{'title'}, - author => $results[0]->{'author'}, - copyrightdate => format_date( $results[0]->{'copyrightdate'} ), - itemtype => $results[0]->{'itemtype'}, - isbn => $results[0]->{'isbn'}, - seriestitle => $results[0]->{'seriestitle'}, - barcode => $barcode, - bookfund => $results[0]->{'bookfundid'}, - quantity => $results[0]->{'quantity'}, - quantityreceived => $results[0]->{'quantityreceived'}, - rrp => $results[0]->{'rrp'}, - ecost => $results[0]->{'ecost'}, - unitprice => $results[0]->{'unitprice'}, - invoice => $invoice, - notes => $results[0]->{'notes'}, - ); -} -else { - my @loop; - for ( my $i = 0 ; $i < $count ; $i++ ) { - my %line; - $line{isbn} = $results[$i]->{'isbn'}; - $line{basketno} = $results[$i]->{'basketno'}; - $line{quantity} = $results[$i]->{'quantity'}; - $line{quantityrecieved} = $results[$i]->{'quantityreceived'}; - $line{ordernumber} = $results[$i]->{'ordernumber'}; - $line{biblionumber} = $results[$i]->{'biblionumber'}; - $line{invoice} = $invoice; - $line{freight} = $freight; - $line{gst} = $gst; - $line{title} = $results[$i]->{'title'}; - $line{author} = $results[$i]->{'author'}; - $line{supplierid} = $supplierid; - push @loop, \%line; -} - $template->param( - loop => \@loop, - date => format_date($date), - name => $booksellers[0]->{'name'}, - supplierid => $supplierid, - invoice => $invoice, - ); - -} -output_html_with_http_headers $input, $cookie, $template->output; - diff --git a/acqui/parcel.pl b/acqui/parcel.pl index 079fe936b1..c0533cf255 100644 --- a/acqui/parcel.pl +++ b/acqui/parcel.pl @@ -54,29 +54,26 @@ To filter the results list on this given date. =back =cut - +use strict; use C4::Auth; use C4::Acquisition; use C4::Bookseller; +use C4::Bookfund; use C4::Biblio; -use C4::Output; use CGI; use C4::Interface::CGI::Output; -use C4::Database; -use HTML::Template; -use strict; +use C4::Date; +use Time::localtime; + my $input=new CGI; my $supplierid=$input->param('supplierid'); +my $basketno=$input->param('basketno'); my @booksellers=GetBookSeller($supplierid); my $count = scalar @booksellers; -my $invoice=$input->param('code') || ''; -my $freight=$input->param('freight'); -my $gst=$input->param('gst'); -my $date=$input->param('datereceived'); -my $code=$input->param('code'); - +my @datetoday = localtime(); +my $date = (1900+$datetoday[5])."-".($datetoday[4]+1)."-". $datetoday[3]; my ($template, $loggedinuser, $cookie) = get_template_and_user({template_name => "acqui/parcel.tmpl", query => $input, @@ -86,97 +83,103 @@ my ($template, $loggedinuser, $cookie) debug => 1, }); -my @parcelitems=GetParcel($supplierid,$invoice,$date); -my $countlines = scalar @parcelitems; +my @booksellers=GetBookSeller($supplierid); +my $gstreg=$booksellers[0]->{gstreg}; +my $incgst=$booksellers[0]->{'invoiceincgst'}; +my $invcurrency=$booksellers[0]->{'invoiceprice'}; +my $discount=$booksellers[0]->{'discount'}; +my $currencyrate; +# get currencies (for exchange rates calcs if needed) +my @rates = GetCurrencies(); +my $count = scalar @rates; + +for ( my $i = 0 ; $i < $count ; $i++ ) { + if ($rates[$i]->{'currency'} eq $invcurrency){ + $currencyrate = $rates[$i]->{'rate'}; + } +} +my $me=C4::Context->userenv; +my $user=$me->{'cardnumber'}; my $totalprice=0; my $totalfreight=0; my $totalquantity=0; +my $totaldiscount=0; my $total; my $tototal; my $toggle; -my @loop_received = (); -for (my $i=0;$i<$countlines;$i++){ - $total=($parcelitems[$i]->{'unitprice'} + $parcelitems[$i]->{'freight'}) * $parcelitems[$i]->{'quantityreceived'}; #weird, are the freight fees counted by book? (pierre) - $parcelitems[$i]->{'unitprice'}+=0; - my %line; - if ($toggle==0){ - $line{color}='#EEEEEE'; - $toggle=1; -} else { - $line{color}='white'; - $toggle=0; -} - $line{basketno} = $parcelitems[$i]->{'basketno'}; - $line{isbn} = $parcelitems[$i]->{'isbn'}; - $line{ordernumber} = $parcelitems[$i]->{'ordernumber'}; - $line{biblionumber} = $parcelitems[$i]->{'biblionumber'}; - $line{invoice} = $invoice; - $line{gst} = $gst; - $line{title} = $parcelitems[$i]->{'title'}; - $line{author} = $parcelitems[$i]->{'author'}; - $line{unitprice} = $parcelitems[$i]->{'unitprice'}; - $line{ecost} = $parcelitems[$i]->{'ecost'}; - $line{quantityrecieved} = $parcelitems[$i]->{'quantityreceived'}; - $line{quantity} = $parcelitems[$i]->{'quantity'}; - $line{total} = $total; - $line{supplierid} = $supplierid; - push @loop_received, \%line; - $totalprice+=$parcelitems[$i]->{'unitprice'}; - $totalfreight+=$parcelitems[$i]->{'freight'}; - $totalquantity+=$parcelitems[$i]->{'quantityreceived'}; - $tototal+=$total; -} +my $totalgst; +my $totaltoreceive; +my $totaltoprice; +my $totaltogst; +my $totaltodiscount; +my @loop_orders; +my $countpendings; +my $invoice; +##Receiving a single basket or all baskets of a supplier +unless($basketno){ my $pendingorders = GetPendingOrders($supplierid); -my $countpendings = scalar @$pendingorders; - -my @loop_orders = (); -for (my $i=0;$i<$countpendings;$i++){ - my %line; - if ($toggle==0){ - $line{color}='#EEEEEE'; - $toggle=1; -} else { - $line{color}='white'; - $toggle=0; +$countpendings = scalar @$pendingorders; +foreach my $pendingorder (@$pendingorders){ + my @orders=GetOrders($pendingorder->{basketno}); + foreach my $order(@orders){ + $order->{toreceive}=$order->{quantity} - $order->{quantityreceived}; + $totalquantity+=$order->{quantity}; + $totaltoreceive+=$order->{toreceive}; + $totalprice+=$order->{rrp}*$order->{quantity}; + $totaltoprice+=$order->{rrp}*$order->{toreceive}; + $totalgst+=(($order->{rrp}*$order->{quantity}) -($order->{rrp}*$order->{quantity}*$order->{discount}/100))* $order->{gst}/100; + $totaltogst+=(($order->{rrp}*$order->{toreceive}) -($order->{rrp}*$order->{toreceive}*$order->{discount}/100))* $order->{gst}/100; + $totaldiscount +=$order->{rrp}*$order->{quantity}*$order->{discount}/100; + $totaltodiscount +=$order->{rrp}*$order->{toreceive}*$order->{discount}/100; + $order->{actualrrp}=sprintf( "%.2f",$order->{rrp}/$currencyrate); + push @loop_orders, $order; + } } - $line{basketno} = $pendingorders->[$i]->{'basketno'}; - $line{isbn} = $pendingorders->[$i]->{'isbn'}; - $line{ordernumber} = $pendingorders->[$i]->{'ordernumber'}; - $line{biblionumber} = $pendingorders->[$i]->{'biblionumber'}; - $line{invoice} = $invoice; - $line{gst} = $gst; - $line{title} = $pendingorders->[$i]->{'title'}; - $line{author} = $pendingorders->[$i]->{'author'}; - $line{unitprice} = $pendingorders->[$i]->{'unitprice'}; - $line{ecost} = $pendingorders->[$i]->{'ecost'}; - $line{quantityrecieved} = $pendingorders->[$i]->{'quantityreceived'}; - $line{quantity} = $pendingorders->[$i]->{'quantity'}; - $line{total} = $total; - $line{supplierid} = $supplierid; - push @loop_orders, \%line; + +}else{ +## one basket +$countpendings=1; + +my @orders=GetOrders($basketno); + foreach my $order(@orders){ +$invoice=$order->{booksellerinvoicenumber} unless $invoice; + $order->{toreceive}=$order->{quantity} - $order->{quantityreceived}; + $totalquantity+=$order->{quantity}; + $totaltoreceive+=$order->{toreceive}; + $totalprice+=$order->{rrp}*$order->{quantity}; + $totaltoprice+=$order->{rrp}*$order->{toreceive}; + $totalgst+=(($order->{rrp}*$order->{quantity}) -($order->{rrp}*$order->{quantity}*$order->{discount}/100))* $order->{gst}/100; + $totaltogst+=(($order->{rrp}*$order->{toreceive}) -($order->{rrp}*$order->{toreceive}*$order->{discount}/100))* $order->{gst}/100; + $totaldiscount +=$order->{rrp}*$order->{quantity}*$order->{discount}/100; + $totaltodiscount +=$order->{rrp}*$order->{toreceive}*$order->{discount}/100; + $order->{actualrrp}=sprintf( "%.2f",$order->{rrp}/$currencyrate); + push @loop_orders, $order; + } } +undef $invcurrency if ($currencyrate ==1); -$totalfreight=$freight; -$tototal=$tototal+$freight; - -$template->param(invoice => $invoice, - date => $date, +$template->param( invoice=>$invoice, + date => format_date($date), name => $booksellers[0]->{'name'}, supplierid => $supplierid, - gst => $gst, - freight => $freight, - invoice => $invoice, - countreceived => $countlines, - loop_received => \@loop_received, countpending => $countpendings, loop_orders => \@loop_orders, - totalprice => $totalprice, - totalfreight => $totalfreight, - totalquantity => $totalquantity, - tototal => $tototal, - gst => $gst, - grandtot => $tototal+$gst, + user=>$user, + totalquantity=>$totalquantity, + totaltoreceive=>$totaltoreceive, + totalprice=>sprintf( "%.2f",$totalprice), + totalactual =>sprintf( "%.2f",$totaltoprice/$currencyrate), + totalgst=>sprintf( "%.2f",$totalgst), + actualgst=>sprintf( "%.2f",$totaltogst/$currencyrate), + totaldiscount=>sprintf( "%.2f",$totaldiscount), + actualdiscount=>sprintf( "%.2f",$totaltodiscount/$currencyrate), + total=>sprintf( "%.2f",$totalprice+$totalgst-$totaldiscount), + gstreg=>$gstreg, + gstrate=>C4::Context->preference('gist')*100, + currencyrate=>$currencyrate, + incgst =>$incgst, + invcurrency=>$invcurrency , intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), intranetstylesheet => C4::Context->preference("intranetstylesheet"), IntranetNav => C4::Context->preference("IntranetNav"), diff --git a/acqui/parcels.pl b/acqui/parcels.pl deleted file mode 100644 index a825848e2f..0000000000 --- a/acqui/parcels.pl +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/perl - -# $Id$ - -#script to show display basket of orders -#written by chris@katipo.co.nz 24/2/2000 - - -# 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 - -=head1 NAME - -parcels.pl - -=head1 DESCRIPTION -This script shows all orders/parcels receipt or pending for a given supplier. -It allows to write an order/parcels as 'received' when he arrives. - -=head1 CGI PARAMETERS - -=over 4 - -=item supplierid -To know the supplier this script has to show orders. - -=item orderby -sort list of order by 'orderby'. -Orderby can be equals to - * datereceived desc (default value) - * aqorders.booksellerinvoicenumber - * datereceived - * aqorders.booksellerinvoicenumber desc - -=item filter - -=item datefrom -To filter on date - -=item dateto -To filter on date - -=item resultsperpage -To know how many results have to be display / page. - -=back - -=cut - -use strict; -use CGI; -use C4::Auth; -use C4::Output; -use C4::Interface::CGI::Output; -use C4::Database; -use C4::Date; -use HTML::Template; -use C4::Acquisition; -use C4::Bookseller; - -my $input=new CGI; -my $supplierid=$input->param('supplierid'); -my $order=$input->param('orderby') || "datereceived desc"; -my $startfrom=$input->param('startfrom'); -my $code=$input->param('filter'); -my $datefrom=$input->param('datefrom'); -my $dateto=$input->param('dateto'); -my $resultsperpage = $input->param('resultsperpage'); - -my @booksellers=GetBookSeller($supplierid); -my $count = scalar @booksellers; - -my ($template, $loggedinuser, $cookie) - = get_template_and_user({template_name => "acqui/parcels.tmpl", - query => $input, - type => "intranet", - authnotrequired => 0, - flagsrequired => {acquisition => 1}, - debug => 1, -}); - - -$resultsperpage = 20 unless ($resultsperpage); -my @results =GetParcels($supplierid, $order, $code,$datefrom,$dateto); -my $count = scalar @results; - -# multi page display gestion -$startfrom=0 unless ($startfrom); -if ($count>$resultsperpage){ - my $displaynext=0; - my $displayprev=$startfrom; - if(($count - ($startfrom+$resultsperpage)) > 0 ) { - $displaynext = 1; - } - - my @numbers = (); - if ($count>$resultsperpage) { - for (my $i=1; $i<$count/$resultsperpage+1; $i++) { - if ($i<16) { - my $highlight=0; - ($startfrom/$resultsperpage==($i-1)) && ($highlight=1); - push @numbers, { number => $i, - highlight => $highlight , -# searchdata=> "test", - startfrom => ($i-1)*$resultsperpage}; - } - } - } - - my $from = $startfrom*$resultsperpage+1; - my $to; - if($count < (($startfrom+1)*$resultsperpage)){ - $to = $count; - } else { - $to = (($startfrom+1)*$resultsperpage); - } - $template->param(numbers=>\@numbers, - displaynext=>$displaynext, - displayprev=>$displayprev, - nextstartfrom=>(($startfrom+$resultsperpage<$count)?$startfrom+$resultsperpage:$count), - prevstartfrom=>(($startfrom-$resultsperpage>0)?$startfrom-$resultsperpage:0) - ); -} -my @loopres; - -my $hilighted=0; -for (my $i=$startfrom;$i<=($startfrom+$resultsperpage-1<$count-1?$startfrom+$resultsperpage-1:$count-1);$i++){ -### startfrom: $startfrom -### resultsperpage: $resultsperpage -### count: $count -### code: $results[$i]->{booksellerinvoicenumber} -### datereceived: $results[$i]->{datereceived} - - my %cell; - $cell{number}=$i+1; - $cell{code}=$results[$i]->{booksellerinvoicenumber}; - $cell{nullcode}=$results[$i]->{booksellerinvoicenumber} eq "NULL"; - $cell{emptycode}=$results[$i]->{booksellerinvoicenumber} eq ''; - $cell{raw_datereceived}=$results[$i]->{datereceived}; - $cell{datereceived}=format_date($results[$i]->{datereceived}); - $cell{bibcount}=$results[$i]->{biblio}; - $cell{reccount}=$results[$i]->{itemsreceived}; - $cell{itemcount}=$results[$i]->{itemsexpected}; - $cell{hilighted} = $hilighted%2; - $hilighted++; - push @loopres, \%cell; -} -$template->param(searchresults=>\@loopres, count=>$count) if ($count); -$template->param(orderby=>$order, filter=>$code, datefrom=>$datefrom,dateto=>$dateto, resultsperpage=>$resultsperpage); -$template->param( - name => $booksellers[0]->{'name'}, - supplierid => $supplierid, - intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), - intranetstylesheet => C4::Context->preference("intranetstylesheet"), - IntranetNav => C4::Context->preference("IntranetNav"), - ); - -output_html_with_http_headers $input, $cookie, $template->output; diff --git a/acqui/select-late.pl b/acqui/select-late.pl index 87ecf931aa..4503effadc 100755 --- a/acqui/select-late.pl +++ b/acqui/select-late.pl @@ -26,12 +26,8 @@ use strict; use C4::Auth; use C4::Biblio; -use C4::Output; use CGI; use C4::Interface::CGI::Output; -use C4::Database; -use HTML::Template; -# use C4::Catalogue; use C4::Context; use C4::Date; use C4::Acquisition; diff --git a/acqui/spent.pl b/acqui/spent.pl deleted file mode 100755 index f4231e268a..0000000000 --- a/acqui/spent.pl +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/perl - -# script to show a breakdown of committed and spent budgets - -# needs to be templated at some point - -use C4::Context; -use C4::Auth; -use C4::Interface::CGI::Output; -use strict; -use CGI; - -my $dbh = C4::Context->dbh; -my $input = new CGI; -my $bookfund = $input->param('bookfund'); -my $start = $input->param('start'); -my $end = $input->param('end'); - -my ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { - template_name => "acqui/spent.tmpl", - query => $input, - type => "intranet", - authnotrequired => 0, - flagsrequired => { acquisition => 1 }, - debug => 1, - } -); - -my $query = -"Select quantity,datereceived,freight,unitprice,listprice,ecost,quantityreceived - as qrev,subscription,title,itemtype,aqorders.biblionumber,aqorders.booksellerinvoicenumber, - quantity-quantityreceived as tleft, - aqorders.ordernumber - as ordnum,entrydate,budgetdate,booksellerid,aqbasket.basketno - from aqorders,aqorderbreakdown,aqbasket - left join biblioitems on biblioitems.biblioitemnumber=aqorders.biblioitemnumber - where bookfundid=? and - aqorders.ordernumber=aqorderbreakdown.ordernumber and - aqorders.basketno=aqbasket.basketno - and ( - (datereceived >= ? and datereceived < ?)) - and (datecancellationprinted is NULL or - datecancellationprinted='0000-00-00') - - - "; -my $sth = $dbh->prepare($query); -$sth->execute( $bookfund, $start, $end ); - -my $total = 0; -my $toggle; -my @spent_loop; -while ( my $data = $sth->fetchrow_hashref ) { - my $recv = $data->{'qrev'}; - if ( $recv > 0 ) { - my $subtotal = $recv * $data->{'unitprice'}; - $data->{'subtotal'} = $subtotal; - $data->{'unitprice'} += 0; - $total += $subtotal; - if ($toggle) { - $toggle = 0; - } - else { - $toggle = 1; - } - $data->{'toggle'} = $toggle; - push @spent_loop, $data; - } - -} - -$template->param( - SPENTLOOP => \@spent_loop, - total => $total -); -$sth->finish; - -$dbh->disconnect; -output_html_with_http_headers $input, $cookie, $template->output; diff --git a/acqui/supplier.pl b/acqui/supplier.pl index db21d2002b..5c8910f0bb 100755 --- a/acqui/supplier.pl +++ b/acqui/supplier.pl @@ -45,11 +45,8 @@ use strict; use C4::Auth; use C4::Acquisition; use C4::Biblio; -use C4::Output; use CGI; use C4::Interface::CGI::Output; -use C4::Database; -use HTML::Template; use C4::Bookseller; use C4::Bookfund; diff --git a/acqui/updatesupplier.pl b/acqui/updatesupplier.pl index ddcca31367..d000d528fd 100755 --- a/acqui/updatesupplier.pl +++ b/acqui/updatesupplier.pl @@ -83,7 +83,7 @@ $data{'listprice'}=$input->param('list_currency'); $data{'invoiceprice'}=$input->param('invoice_currency'); $data{'gstreg'}=$input->param('gst'); $data{'listincgst'}=$input->param('list_gst'); -$data{'invoiceincgst'}=$input->param('invoice_gst'); +$data{'invoiceincgst'}=$input->param('invoiceincgst'); $data{'discount'}=$input->param('discount'); my $id=$input->param('id'); if ($data{'id'} != 0){ -- 2.39.2