[Koha-cvs] koha/acqui addorder.pl basket.pl bookfund.pl bo...
paul poulain
paul at koha-fr.org
Fri Mar 9 15:28:54 CET 2007
CVSROOT: /sources/koha
Module name: koha
Changes by: paul poulain <tipaul> 07/03/09 14:28:54
Modified files:
acqui : addorder.pl basket.pl bookfund.pl
booksellers.pl currency.pl finishreceive.pl
histsearch.pl lateorders.pl neworderempty.pl
newordersuggestion.pl parcel.pl supplier.pl
updatesupplier.pl
Log message:
rel_3_0 moved to HEAD
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/addorder.pl?cvsroot=koha&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/basket.pl?cvsroot=koha&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/bookfund.pl?cvsroot=koha&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/booksellers.pl?cvsroot=koha&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/currency.pl?cvsroot=koha&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/finishreceive.pl?cvsroot=koha&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/histsearch.pl?cvsroot=koha&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/lateorders.pl?cvsroot=koha&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/neworderempty.pl?cvsroot=koha&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/newordersuggestion.pl?cvsroot=koha&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/parcel.pl?cvsroot=koha&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/supplier.pl?cvsroot=koha&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/updatesupplier.pl?cvsroot=koha&r1=1.10&r2=1.11
Patches:
Index: addorder.pl
===================================================================
RCS file: /sources/koha/koha/acqui/addorder.pl,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- addorder.pl 28 Sep 2006 14:13:37 -0000 1.35
+++ addorder.pl 9 Mar 2007 14:28:54 -0000 1.36
@@ -90,7 +90,7 @@
=item C<ecost>
-=item C<gst>
+=item C<GST>
=item C<budget>
@@ -115,12 +115,19 @@
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 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(
{
@@ -133,7 +140,6 @@
}
);
-
# get CGI parameters
my $ordnum = $input->param('ordnum');
my $basketno = $input->param('basketno');
@@ -147,79 +153,80 @@
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 $bookfundid = $input->param('bookfundid');
+my $bookfund = $input->param('bookfund');
my $sort1 = $input->param('sort1');
my $sort2 = $input->param('sort2');
my $rrp = $input->param('rrp');
my $ecost = $input->param('ecost');
-my $gst = $input->param('gstrate');
+my $gst = $input->param('GST');
my $budget = $input->param('budget');
-my $unitprice = $input->param('unitprice');
+my $cost = $input->param('cost');
my $sub = $input->param('sub');
-my $purchaseordernumber = $input->param('purchaseordernumber');
+my $invoice = $input->param('invoice');
my $publishercode = $input->param('publishercode');
my $suggestionid = $input->param('suggestionid');
-my $donation = $input->param('donation');
my $user = $input->remote_user;
-my $biblionumber=$input->param('biblionumber');
+
+#warn "CREATEBIBITEM = $input->param('createbibitem')";
+#warn Dumper $input->param('createbibitem');
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 $dbh=C4::Context->dbh;
-
-if ($quantity ne '0'){
+my $biblionumber=$input->param('biblionumber');
+my $bibitemnum;
+if ( $quantity ne '0' ) {
#check to see if biblio exists
if ( $existing eq 'no' ) {
- #if it doesnt its created on template
- # change suggestion status if applicable
- if ($suggestionid) {
-my $data=GetSuggestion($suggestionid);
- 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 it doesnt create it
+ my $record = Koha2Marc(
+ {
+ "biblio.title" => "$title",
+ "biblio.author" => "$author",
+ "biblio.copyrightdate" => $copyrightdate ? $copyrightdate : "",
+ "biblio.series" => $series ? $series : "",
+ "biblioitems.itemtype" => $itemtype ? $itemtype : "",
+ "biblioitems.isbn" => $isbn ? $isbn : "",
+ "biblioitems.publishercode" => $publishercode ? $publishercode : "",
+ });
+ # create the record in catalogue, with framework ''
+ ($biblionumber,$bibitemnum) = AddBiblio($record,'');
- ModStatus( $suggestionid, 'ORDERED', '', $biblionumber,$input );
+ # change suggestion status if applicable
+ if ($suggestionid) {
+ ModStatus( $suggestionid, 'ORDERED', '', $biblionumber );
}
- }## biblio didnot exist now created
-
-
-
-
+ }
+ # if we already have $ordnum, then it's an ordermodif
if ($ordnum) {
-
- # warn "MODORDER $title / $ordnum / $quantity / $bookfund";
ModOrder(
$title, $ordnum, $quantity, $listprice,
$biblionumber, $basketno, $booksellerid, $loggedinuser,
- $notes, $bookfundid, $rrp,
- $ecost, $gst, $budget, $unitprice,
- $purchaseordernumber, $sort1, $sort2,$discount,$branch
+ $notes, $bookfund, $bibitemnum, $rrp,
+ $ecost, $gst, $budget, $cost,
+ $invoice, $sort1, $sort2
);
}
- else {
+ else { # else, it's a new line
( $basketno, $ordnum ) = NewOrder(
$basketno, $biblionumber, $title, $quantity,
$listprice, $booksellerid, $loggedinuser, $notes,
- $bookfundid, $rrp, $ecost,
- $gst, $budget, $unitprice, $sub,
- $purchaseordernumber, $sort1, $sort2, $discount,$branch
+ $bookfund, $bibitemnum, $rrp, $ecost,
+ $gst, $budget, $cost, $sub,
+ $invoice, $sort1, $sort2
);
}
-
}
-else {
-# $biblionumber = $input->param('biblionumber');
- DelOrder( $biblionumber, $ordnum,$loggedinuser );
+else { # qty=0, delete the line
+ $biblionumber = $input->param('biblionumber');
+ DelOrder( $biblionumber, $ordnum );
}
-
print $input->redirect("basket.pl?basketno=$basketno");
Index: basket.pl
===================================================================
RCS file: /sources/koha/koha/acqui/basket.pl,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- basket.pl 20 Sep 2006 21:44:36 -0000 1.35
+++ basket.pl 9 Mar 2007 14:28:54 -0000 1.36
@@ -20,13 +20,16 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
-# $Id: basket.pl,v 1.35 2006/09/20 21:44:36 tgarip1957 Exp $
+# $Id: basket.pl,v 1.36 2007/03/09 14:28:54 tipaul Exp $
use strict;
use C4::Auth;
use C4::Koha;
+use C4::Output;
use CGI;
use C4::Interface::CGI::Output;
+
+
use C4::Acquisition;
use C4::Bookfund;
use C4::Bookseller;
@@ -78,9 +81,10 @@
);
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;
@@ -108,27 +112,32 @@
my ( $count, @results );
@results = GetOrders( $basketno, $order );
$count = scalar @results;
+
my $line_total; # total of each line
-my $gist =C4::Context->preference('gist'); # GST
+my $sub_total; # total of line totals
+my $gist; # GST
+my $grand_total; # $subttotal + $gist
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_est - $disc_est
-my $disc_est;
+my $grand_total_est; # $subttotal + $gist
+
my $qty_total;
my @books_loop;
for ( my $i = 0 ; $i < $count ; $i++ ) {
- $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;
-
+ 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;
$qty_total += $results[$i]->{'quantity'};
my %line;
+ %line=%{$results[$i]};
if ( $toggle == 0 ) {
$line{color} = '#EEEEEE';
$toggle = 1;
@@ -137,31 +146,20 @@
$line{color} = 'white';
$toggle = 0;
}
- $line{ordernumber} = $results[$i]->{'ordernumber'};
- $line{publishercode} = $results[$i]->{'publishercode'};
- $line{isbn} = $results[$i]->{'isbn'};
- $line{booksellerid} = $booksellers[0]->{'id'};
$line{basketno} = $basketno;
- $line{title} = $results[$i]->{'title'};
- $line{notes} = $results[$i]->{'notes'};
- $line{author} = $results[$i]->{'author'};
$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{rrp} = sprintf( "%.2f", $line{'rrp'} );
+ $line{ecost} = sprintf( "%.2f", $line{'ecost'} );
$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},);
}
-$grand_total_est = sprintf( "%.2f", $sub_total_est - $disc_est+$gist_est );
-
+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 );
$template->param(
basketno => $basketno,
creationdate => format_date( $basket->{creationdate} ),
@@ -178,10 +176,11 @@
entrydate => format_date( $results[0]->{'entrydate'} ),
books_loop => \@books_loop,
count => $count,
+ sub_total => $sub_total,
gist => $gist,
- sub_total_est => sprintf( "%.2f",$sub_total_est),
- gist_est => sprintf( "%.2f",$gist_est),
- disc_est => sprintf( "%.2f",$disc_est),
+ grand_total => $grand_total,
+ sub_total_est => $sub_total_est,
+ gist_est => $gist_est,
grand_total_est => $grand_total_est,
currency => $booksellers[0]->{'listprice'},
qty_total => $qty_total,
Index: bookfund.pl
===================================================================
RCS file: /sources/koha/koha/acqui/bookfund.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- bookfund.pl 20 Sep 2006 21:44:36 -0000 1.3
+++ bookfund.pl 9 Mar 2007 14:28:54 -0000 1.4
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
# Copyright 2006 Katipo Communications
#
@@ -64,15 +64,14 @@
ON aqorderbreakdown.ordernumber = aqorders.ordernumber
INNER JOIN aqbasket
ON aqbasket.basketno = aqorders.basketno
- LEFT JOIN biblio
- ON biblio.biblionumber = aqorders.biblionumber
+ LEFT JOIN biblioitems
+ ON biblioitems.biblioitemnumber = aqorders.biblioitemnumber
WHERE bookfundid = ?
AND budgetdate >= ?
AND budgetdate < ?
AND (datecancellationprinted IS NULL
OR datecancellationprinted = \'0000-00-00\')
';
-##warn $query;
my $sth = $dbh->prepare($query);
$sth->execute( $bookfund, $start, $end );
my @commited_loop;
@@ -97,6 +96,6 @@
total => $total
);
$sth->finish;
-#$dbh->disconnect;
+$dbh->disconnect;
output_html_with_http_headers $input, $cookie, $template->output;
Index: booksellers.pl
===================================================================
RCS file: /sources/koha/koha/acqui/booksellers.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- booksellers.pl 20 Sep 2006 21:44:36 -0000 1.3
+++ booksellers.pl 9 Mar 2007 14:28:54 -0000 1.4
@@ -20,7 +20,7 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
-# $Id: booksellers.pl,v 1.3 2006/09/20 21:44:36 tgarip1957 Exp $
+# $Id: booksellers.pl,v 1.4 2007/03/09 14:28:54 tipaul Exp $
=head1 NAME
@@ -55,8 +55,12 @@
use strict;
use C4::Auth;
+use C4::Biblio;
+use C4::Output;
use CGI;
use C4::Interface::CGI::Output;
+
+
use C4::Acquisition;
use C4::Date;
use C4::Bookseller;
@@ -81,35 +85,39 @@
# check if we have to "close" a basket before building page
my $op = $query->param('op');
-my $basketno = $query->param('basketno');
+my $basket = $query->param('basketno');
if ( $op eq 'close' ) {
- CloseBasket($basketno);
+ CloseBasket($basket);
}
#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 $ordercount = scalar @$orders;
-$ordcount+=$ordercount;
+ my $orders = GetPendingOrders( $suppliers[$i]->{'id'}, "grouped" );
+ my $ordcount = scalar @$orders;
my %line;
if ( $toggle == 0 ) {
$line{even} = 1;
$toggle = 1;
- }
- else {
+ } else {
$line{even} = 0;
$toggle = 0;
}
$line{supplierid} = $suppliers[$i]->{'id'};
$line{name} = $suppliers[$i]->{'name'};
$line{active} = $suppliers[$i]->{'active'};
- $line{ordcount}=$ordercount;
my @loop_basket;
- foreach my $order(@$orders){
- push @loop_basket, $order;
+ 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;
}
$line{loop_basket} = \@loop_basket;
push @loop_suppliers, \%line;
@@ -117,7 +125,7 @@
$template->param(
loop_suppliers => \@loop_suppliers,
supplier => $supplier,
- count => $ordcount,
+ count => $count,
intranetcolorstylesheet =>
C4::Context->preference("intranetcolorstylesheet"),
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
Index: currency.pl
===================================================================
RCS file: /sources/koha/koha/acqui/currency.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- currency.pl 20 Sep 2006 21:44:36 -0000 1.2
+++ currency.pl 9 Mar 2007 14:28:54 -0000 1.3
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# $Id: currency.pl,v 1.2 2006/09/20 21:44:36 tgarip1957 Exp $
+# $Id: currency.pl,v 1.3 2007/03/09 14:28:54 tipaul Exp $
#written by chris at katipo.co.nz
#9/10/2000
@@ -35,7 +35,6 @@
foreach my $param (@params){
if ($param ne 'type' && $param !~ /submit/){
my $data=$input->param($param);
-# warn "$data / $param";
ModCurrencies($param,$data);
}
}
Index: finishreceive.pl
===================================================================
RCS file: /sources/koha/koha/acqui/finishreceive.pl,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- finishreceive.pl 20 Sep 2006 21:44:36 -0000 1.21
+++ finishreceive.pl 9 Mar 2007 14:28:54 -0000 1.22
@@ -3,6 +3,7 @@
#script to add a new item and to mark orders as received
#written 1/3/00 by chris at katipo.co.nz
+
# Copyright 2000-2002 Katipo Communications
#
# This file is part of Koha.
@@ -20,89 +21,51 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
-# this script makes the items, addorder.pl has already made the biblio and biblioitem records: MASON
-
-
-=head1 NAME
-
-finishreceive.pl
-
-=head1 DESCRIPTION
-TODO
-
-=head1 CGI PARAMETERS
-
-=over 4
-
-TODO
-
-=back
-
-=cut
-
use strict;
+use C4::Output;
use C4::Acquisition;
+use C4::Biblio;
use CGI;
-use C4::Interface::CGI::Output;
-use C4::Auth;
-use C4::Bookseller;
-
-my $input = new CGI;
-
-my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
- {
- template_name => "acqui/finishreceive.tmpl",
- query => $input,
- type => "intranet",
- authnotrequired => 0,
- flagsrequired => { editcatalogue => 1 },
- debug => 1,
- }
-);
-
-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('actual');
-my @gst = $input->param('gstrate');
-my $freight = $input->param('actualfreight');
-my @freightperitem = $input->param('freight');
+use C4::Search;
+
+my $input=new CGI;
+
+my $user=$input->remote_user;
+my $biblionumber = $input->param('biblionumber');
+my $biblioitemnumber=$input->param('biblioitemnumber');
+my $ordnum=$input->param('ordnum');
+my $quantrec=$input->param('quantityrec');
+my $quantity=$input->param('quantity');
+my $cost=$input->param('cost');
+my $invoiceno=$input->param('invoice');
+my $datereceived=$input->param('datereceived');
+my $replacement=$input->param('rrp');
+my $gst=$input->param('gst');
+my $freight=$input->param('freight');
my $supplierid = $input->param('supplierid');
-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],};
+my $branch=$input->param('branch');
- }
-}
-$template->param(loopbiblios => \@additems,);
+# if ($quantrec != 0){
+# $cost /= $quantrec;
+# }
- output_html_with_http_headers $input, $cookie, $template->output;
\ No newline at end of file
+if ($quantity != 0) {
+ # save the quantity recieved.
+ $datereceived = ModReceiveOrder($biblionumber,$ordnum,$quantrec,$user,$cost,$invoiceno,$datereceived,$freight,$replacement);
+ # create items if the user has entered barcodes
+ my $barcode=$input->param('barcode');
+ my @barcodes=split(/\,| |\|/,$barcode);
+ my ($error) = newitems({ biblioitemnumber => $biblioitemnumber,
+ biblionumber => $biblionumber,
+ replacementprice => $replacement,
+ price => $cost,
+ booksellerid => $supplierid,
+ homebranch => $branch,
+ loan => 0 },
+ @barcodes);
+ print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoice=$invoiceno&supplierid=$supplierid&freight=$freight&gst=$gst&datereceived=$datereceived");
+} else {
+ print $input->header;
+ delorder($biblionumber,$ordnum);
+ print $input->redirect("/acquisitions/");
+}
Index: histsearch.pl
===================================================================
RCS file: /sources/koha/koha/acqui/histsearch.pl,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- histsearch.pl 20 Sep 2006 21:44:36 -0000 1.9
+++ histsearch.pl 9 Mar 2007 14:28:54 -0000 1.10
@@ -15,16 +15,15 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
-# $Id: histsearch.pl,v 1.9 2006/09/20 21:44:36 tgarip1957 Exp $
-
+# $Id: histsearch.pl,v 1.10 2007/03/09 14:28:54 tipaul Exp $
=head1 NAME
histsearch.pl
=head1 DESCRIPTION
-this script offer a interface to search among order.
+this script offer a interface to search among order.
=head1 CGI PARAMETERS
@@ -64,27 +63,35 @@
my $to_placed_on = $input->param('toplacedon');
my $dbh = C4::Context->dbh;
-my ($template, $loggedinuser, $cookie)
- = get_template_and_user({template_name => "acqui/histsearch.tmpl",
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name => "acqui/histsearch.tmpl",
query => $input,
type => "intranet",
authnotrequired => 0,
- flagsrequired => {acquisition => 1},
+ flagsrequired => { acquisition => 1 },
debug => 1,
- });
-my ($order_loop,$total_qty,$total_price,$total_qtyreceived)= &GetHistory($title,$author,$name,$from_placed_on,$to_placed_on);
-$template->param(suggestions_loop => $order_loop,
+ }
+);
+
+my ( $order_loop, $total_qty, $total_price, $total_qtyreceived ) =
+ &GetHistory( $title, $author, $name, $from_placed_on, $to_placed_on );
+
+$template->param(
+ suggestions_loop => $order_loop,
total_qty => $total_qty,
total_qtyreceived => $total_qtyreceived,
- total_price => sprintf ("%.2f",$total_price),
+ total_price => sprintf( "%.2f", $total_price ),
numresults => scalar(@$order_loop),
title => $title,
author => $author,
name => $name,
- from_placed_on =>$from_placed_on,
- to_placed_on =>$to_placed_on,
- intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
+ from_placed_on => $from_placed_on,
+ to_placed_on => $to_placed_on,
+ intranetcolorstylesheet =>
+ C4::Context->preference("intranetcolorstylesheet"),
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
IntranetNav => C4::Context->preference("IntranetNav"),
);
+
output_html_with_http_headers $input, $cookie, $template->output;
Index: lateorders.pl
===================================================================
RCS file: /sources/koha/koha/acqui/lateorders.pl,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- lateorders.pl 20 Sep 2006 21:44:36 -0000 1.7
+++ lateorders.pl 9 Mar 2007 14:28:54 -0000 1.8
@@ -15,7 +15,7 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
-# $Id: lateorders.pl,v 1.7 2006/09/20 21:44:36 tgarip1957 Exp $
+# $Id: lateorders.pl,v 1.8 2007/03/09 14:28:54 tipaul Exp $
=head1 NAME
@@ -52,21 +52,23 @@
use C4::Interface::CGI::Output;
use C4::Context;
use C4::Acquisition;
+use C4::Letters;
+use C4::Branch; # GetBranches
-my $query = new CGI;
+my $input = new CGI;
my ($template, $loggedinuser, $cookie)
= get_template_and_user(
{template_name => "acqui/lateorders.tmpl",
- query => $query,
+ query => $input,
type => "intranet",
authnotrequired => 0,
flagsrequired => {acquisition => 1},
debug => 1,
});
-my $supplierid = $query->param('supplierid');
-my $delay = $query->param('delay');
-my $branch = $query->param('branch');
+my $supplierid = $input->param('supplierid');
+my $delay = $input->param('delay');
+my $branch = $input->param('branch');
#default value for delay
$delay = 30 unless $delay;
@@ -88,22 +90,6 @@
$template->param(Supplier=>$supplierlist{$supplierid}) if ($supplierid);
-my $branches = GetBranches;
-
-my @branchloop;
-foreach my $thisbranch (sort keys %$branches) {
- my %row =(value => $thisbranch,
- branchname => $branches->{$thisbranch}->{'branchname'},
- );
- push @branchloop, \%row;
-}
-my $CGIbranch=CGI::scrolling_list( -name => 'branch',
- -values => \@branchloop,
- -labels => $branches,
- -size => 1,
- -tabindex=>'',
- -multiple => 0 );
-
my @lateorders = GetLateOrders($delay,$supplierid,$branch);
my $count = scalar @lateorders;
@@ -111,12 +97,25 @@
foreach my $lateorder (@lateorders){
$total+=$lateorder->{subtotal};
}
+
+my @letters;
+my $letters=GetLetters("claimacquisition");
+foreach (keys %$letters){
+ push @letters ,{code=>$_,name=>$letters->{$_}};
+}
+
+$template->param(letters=>\@letters) if (@letters);
+my $op=$input->param("op");
+if ($op eq "send_alert"){
+ my @ordernums=$input->param("claim_for");
+ SendAlerts('claimacquisition',\@ordernums,$input->param("letter_code"));
+}
+
$template->param(delay=>$delay) if ($delay);
$template->param(
- branchloop => \@branchloop,
CGIsupplier => $CGIsupplier,
lateorders => \@lateorders,
total=>$total,
intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
);
-output_html_with_http_headers $query, $cookie, $template->output;
+output_html_with_http_headers $input, $cookie, $template->output;
Index: neworderempty.pl
===================================================================
RCS file: /sources/koha/koha/acqui/neworderempty.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- neworderempty.pl 15 Nov 2006 01:41:51 -0000 1.3
+++ neworderempty.pl 9 Mar 2007 14:28:54 -0000 1.4
@@ -65,18 +65,20 @@
use strict;
use CGI;
use C4::Context;
+use C4::Input;
+
use C4::Auth;
use C4::Bookfund;
use C4::Bookseller;
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 C4::Branch; # GetBranches
use C4::Members;
-use C4::Input;
-use C4::Date;
my $input = new CGI;
my $booksellerid = $input->param('booksellerid');
@@ -89,87 +91,54 @@
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;
-my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
- {
- template_name => "acqui/neworderempty.tmpl",
- query => $input,
- type => "intranet",
- authnotrequired => 0,
- flagsrequired => { acquisition => 1 },
- 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");
+
+ # $ordnum=newordernum;
+ if ( $biblionumber && !$suggestionid ) {
+ $data = GetBiblioData($biblionumber);
}
- $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 $date = get_today();
- $template->param(
- creationdate => format_date($date),
- authorisedbyname => $loggedinuser,);
+# get suggestion fields if applicable. If it's a subscription renewal, then the biblio already exists
+# otherwise, retrieve suggestion information.
+ if ($suggestionid) {
+ if ($biblionumber) {
+ $data = GetBiblioData($biblionumber);
}
-}else { #modify order
- $data = GetSingleOrder($ordnum);
+ else {
+ $data = GetSuggestion($suggestionid);
+ }
+ }
+}
+else { #modify order
+ $data = GetOrder($ordnum);
$biblionumber = $data->{'biblionumber'};
#get basketno and suppleirno. too!
my $data2 = GetBasket( $data->{'basketno'} );
- $basketno = $data->{'basketno'};
+ $basketno = $data2->{'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},);
-
}
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name => "acqui/neworderempty.tmpl",
+ query => $input,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => { acquisition => 1 },
+ debug => 1,
+ }
+);
-
-# get currencies (for exchange rates calcs if needed)
+# get currencies (for change rates calcs if needed)
my @rates = GetCurrencies();
-my $count = scalar @rates;
+$count = scalar @rates;
my @loop_currency = ();
for ( my $i = 0 ; $i < $count ; $i++ ) {
@@ -179,31 +148,50 @@
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,
+ -tabindex=>'',
+ -multiple => 0
+);
# build branches list
-my $branches = GetBranches;
+my $onlymine=C4::Context->preference('IndependantBranches') &&
+ C4::Context->userenv &&
+ C4::Context->userenv->{flags}!=1 &&
+ C4::Context->userenv->{branch};
+my $branches = GetBranches($onlymine);
my @branchloop;
foreach my $thisbranch ( sort keys %$branches ) {
-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;
@@ -211,22 +199,19 @@
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 => 'bookfundid',
+ -name => 'bookfund',
-values => \@select_bookfund,
-default => $data->{'bookfundid'},
-labels => \%select_bookfunds,
-size => 1,
- -selected =>$selbookfund,
+ -tabindex=>'',
-multiple => 0
);
my $bookfundname;
-
+my $bookfundid;
if ($close) {
$bookfundid = $data->{'bookfundid'};
$bookfundname = $select_bookfunds{$bookfundid};
@@ -251,19 +236,27 @@
my $bibitemsexists;
-#
+#do a biblioitems lookup on bib
+my @bibitems = GetBiblioItemByBiblioNumber($biblionumber);
+my $bibitemscount = scalar @bibitems;
+
+if ( $bibitemscount > 0 ) {
+ # warn "NEWBIBLIO: bibitems for $biblio exists\n";
+ $bibitemsexists = 1;
- $template->param( bibitemexists => "1" ) if $biblionumber;
my @bibitemloop;
+ for ( my $i = 0 ; $i < $bibitemscount ; $i++ ) {
my %line;
- $line{isbn} = $data->{'isbn'};
- $line{itemtype} = $data->{'itemtype'};
- $line{volumeddesc} = $data->{'volumeddesc'};
+ $line{biblioitemnumber} = $bibitems[$i]->{'biblioitemnumber'};
+ $line{isbn} = $bibitems[$i]->{'isbn'};
+ $line{itemtype} = $bibitems[$i]->{'itemtype'};
+ $line{volumeddesc} = $bibitems[$i]->{'volumeddesc'};
push( @bibitemloop, \%line );
$template->param( bibitemloop => \@bibitemloop );
-
-
+ }
+ $template->param( bibitemexists => "1" );
+}
# fill template
$template->param(
@@ -280,8 +273,9 @@
booksellerid => $booksellerid,
suggestionid => $suggestionid,
biblionumber => $biblionumber,
+ biblioitemnumber => $data->{'biblioitemnumber'},
itemtype => $data->{'itemtype'},
- discount => $discount,
+ discount => $booksellers[0]->{'discount'},
listincgst => $booksellers[0]->{'listincgst'},
listprice => $booksellers[0]->{'listprice'},
gstreg => $booksellers[0]->{'gstreg'},
@@ -290,23 +284,22 @@
nocalc => $booksellers[0]->{'nocalc'},
name => $booksellers[0]->{'name'},
currency => $booksellers[0]->{'listprice'},
- gstrate =>$gstrate,
+ gstrate => C4::Context->preference("gist"),
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'},
quantity => $data->{'quantity'},
listprice => $data->{'listprice'},
rrp => $data->{'rrp'},
+ total => $data->{ecost}*$data->{quantity},
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
Index: newordersuggestion.pl
===================================================================
RCS file: /sources/koha/koha/acqui/newordersuggestion.pl,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- newordersuggestion.pl 28 Sep 2006 14:13:37 -0000 1.5
+++ newordersuggestion.pl 9 Mar 2007 14:28:54 -0000 1.6
@@ -15,61 +15,74 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
-# $Id: newordersuggestion.pl,v 1.5 2006/09/28 14:13:37 tgarip1957 Exp $
+# $Id: newordersuggestion.pl,v 1.6 2007/03/09 14:28:54 tipaul Exp $
=head1 NAME
+
newordersuggestion.pl
=head1 DESCRIPTION
+
this script allow to add an order from a existing suggestion.
+The suggestion must have 'ACCEPTED' as status.
=head1 CGI PARAMETERS
=over 4
=item basketno
-the number of this basket.
+
+ the number of this basket.
=item booksellerid
-the bookseller who sells this record.
+
+ the bookseller who sells this record.
=item title
-the title of this record suggested.
+
+ to filter on title when searching among ACCEPTED suggestion.
=item author
-the author of this suggestion.
+
+ to filter on author when searching among ACCEPTED suggestion.
=item note
-this param allow to enter a note with this suggestion.
+
+ to filter on note when searching among ACCEPTED suggestion.
=item copyrightdate
-the copyright date for this suggestion.
=item publishercode
=item volumedesc
=item publicationyear
+
the publication year of this record.
=item place
=item isbn
+
the isbn of this suggestion.
=item duplicateNumber
+
is the biblionumber to put to the new suggestion.
=item suggestionid
+
the id of the suggestion to select.
=item op
+
can be equal to
* connectDuplicate :
then call to the function : ConnectSuggestionAndBiblio.
i.e set the biblionumber of this suggestion.
* else :
is the default value.
+
=back
=cut
@@ -81,92 +94,50 @@
use C4::Interface::CGI::Output;
use C4::Suggestions;
use C4::Biblio;
-use C4::Search;
my $input = new CGI;
+# getting the CGI params
my $basketno = $input->param('basketno');
my $supplierid = $input->param('booksellerid');
-my $title = $input->param('title');
my $author = $input->param('author');
-my $note = $input->param('note');
-my $copyrightdate =$input->param('copyrightdate');
+my $title = $input->param('title');
my $publishercode = $input->param('publishercode');
-my $volumedesc = $input->param('volumedesc');
-my $publicationyear = $input->param('publicationyear');
-my $place = $input->param('place');
-my $isbn = $input->param('isbn');
-my $duplicateNumber = $input->param('duplicateNumber');
+my $op = $input->param('op');
my $suggestionid = $input->param('suggestionid');
+my $duplicateNumber = $input->param('duplicateNumber');
-my $status = 'ACCEPTED'; # the suggestion had to be accepeted before to order it.
-my $suggestedbyme = -1; # search ALL suggestors
-my $op = $input->param('op');
$op = 'else' unless $op;
my $dbh = C4::Context->dbh;
-my ($template, $borrowernumber, $cookie)
- = get_template_and_user({template_name => "acqui/newordersuggestion.tmpl",
+my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
+ {
+ template_name => "acqui/newordersuggestion.tmpl",
type => "intranet",
query => $input,
authnotrequired => 1,
- flagsrequired => {acquisition => 1},
- });
+ flagsrequired => { acquisition => 1 },
+ }
+);
-if ($op eq 'connectDuplicate') {
- ConnectSuggestionAndBiblio($suggestionid,$duplicateNumber);
+if ( $op eq 'connectDuplicate' ) {
+ ConnectSuggestionAndBiblio( $suggestionid, $duplicateNumber );
}
-my $suggestions_loop= &SearchSuggestion($borrowernumber,$author,$title,$publishercode,$status,$suggestedbyme);
-foreach (@$suggestions_loop) {
- unless ($_->{biblionumber}) {
- my (@kohafields, @and_or, @value, @relation, $offset,$length);
- # search on biblio.title
- if ($_->{title}) {
- push @kohafields, "title";
- push @and_or, "\@and";
- push @relation, "\@attr 5=1";
- push @value, $_->{title};
- }
- if ($_->{author}) {
- push @kohafields, "author";
- push @and_or, "\@and";
- push @relation, "";
- push @value, $_->{author};
- }
- # ... and on publicationyear.
- if ($_->{publicationyear}) {
- push @kohafields, "copyrightdate";
- push @and_or, "\@and";
- push @relation, "";
- push @value, $_->{publicationyear};
- }
- # ... and on publisher.
- if ($_->{publishercode}) {
- push @kohafields, "publishercode";
- push @and_or, "\@and";
- push @relation, "";
- push @value, $_->{publishercode};
- }
- my ($nbresult,$facets, at finalresult) = ZEBRAsearch_kohafields(\@kohafields,\@value,\@relation,"",\@and_or,0,"",0,1);
+# getting all suggestions.
+my $suggestions_loop =
+ &SearchSuggestion( $borrowernumber, $author, $title, $publishercode,'ACCEPTED',
+ -1 );
- # there is at least 1 result => return the 1st one
- if ($nbresult) {
- $_->{duplicateBiblionumber} = $finalresult[0]->{biblionumber};
- }
- }
-}
-$template->param(suggestions_loop => $suggestions_loop,
- title => $title,
- author => $author,
- publishercode => $publishercode,
- status => $status,
- suggestedbyme => $suggestedbyme,
+$template->param(
+ suggestions_loop => $suggestions_loop,
basketno => $basketno,
supplierid => $supplierid,
"op_$op" => 1,
- intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
+ intranetcolorstylesheet =>
+ C4::Context->preference("intranetcolorstylesheet"),
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
IntranetNav => C4::Context->preference("IntranetNav"),
);
+
output_html_with_http_headers $input, $cookie, $template->output;
Index: parcel.pl
===================================================================
RCS file: /sources/koha/koha/acqui/parcel.pl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- parcel.pl 20 Sep 2006 21:44:36 -0000 1.4
+++ parcel.pl 9 Mar 2007 14:28:54 -0000 1.5
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# $Id: parcel.pl,v 1.4 2006/09/20 21:44:36 tgarip1957 Exp $
+# $Id: parcel.pl,v 1.5 2007/03/09 14:28:54 tipaul Exp $
#script to recieve orders
#written by chris at katipo.co.nz 24/2/2000
@@ -54,26 +54,29 @@
=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::Date;
-use Time::localtime;
+use strict;
my $input=new CGI;
my $supplierid=$input->param('supplierid');
-my $basketno=$input->param('basketno');
my @booksellers=GetBookSeller($supplierid);
my $count = scalar @booksellers;
-my @datetoday = localtime();
-my $date = (1900+$datetoday[5])."-".($datetoday[4]+1)."-". $datetoday[3];
+my $invoice=$input->param('invoice') || '';
+my $freight=$input->param('freight');
+my $gst=$input->param('gst');
+my $datereceived=$input->param('datereceived') || format_date(join "-",Date::Calc::Today());
+my $code=$input->param('code');
+
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "acqui/parcel.tmpl",
query => $input,
@@ -82,104 +85,82 @@
flagsrequired => {acquisition => 1},
debug => 1,
});
+my @parcelitems=GetParcel($supplierid,$invoice,$datereceived);
+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 $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);
-$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;
+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 = %{$parcelitems[$i]};
+ $line{invoice} = $invoice;
+ $line{gst} = $gst;
+ $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 $pendingorders = GetPendingOrders($supplierid);
+my $countpendings = scalar @$pendingorders;
-}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;
+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;
}
+ %line = %{$pendingorders->[$i]};
+ $line{ecost} = sprintf("%.2f",$line{ecost});
+ $line{unitprice} = sprintf("%.2f",$line{unitprice});
+ $line{invoice} = $invoice;
+ $line{gst} = $gst;
+ $line{total} = $total;
+ $line{supplierid} = $supplierid;
+ push @loop_orders, \%line;
}
-undef $invcurrency if ($currencyrate ==1);
-$template->param( invoice=>$invoice,
- date => format_date($date),
+$totalfreight=$freight;
+$tototal=$tototal+$freight;
+
+$template->param(invoice => $invoice,
+ datereceived => $datereceived,
+ formatteddatereceived => format_date($datereceived),
name => $booksellers[0]->{'name'},
supplierid => $supplierid,
+ gst => $gst,
+ freight => $freight,
+ invoice => $invoice,
+ countreceived => $countlines,
+ loop_received => \@loop_received,
countpending => $countpendings,
loop_orders => \@loop_orders,
- 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 ,
+ totalprice => $totalprice,
+ totalfreight => $totalfreight,
+ totalquantity => $totalquantity,
+ tototal => $tototal,
+ gst => $gst,
+ grandtot => $tototal+$gst,
intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
IntranetNav => C4::Context->preference("IntranetNav"),
Index: supplier.pl
===================================================================
RCS file: /sources/koha/koha/acqui/supplier.pl,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- supplier.pl 20 Sep 2006 21:44:36 -0000 1.14
+++ supplier.pl 9 Mar 2007 14:28:54 -0000 1.15
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# $Id: supplier.pl,v 1.14 2006/09/20 21:44:36 tgarip1957 Exp $
+# $Id: supplier.pl,v 1.15 2007/03/09 14:28:54 tipaul Exp $
#script to show display basket of orders
#written by chris at katipo.co.nz 24/2/2000
@@ -45,15 +45,19 @@
use C4::Auth;
use C4::Acquisition;
use C4::Biblio;
+use C4::Output;
use CGI;
use C4::Interface::CGI::Output;
+
+
use C4::Bookseller;
use C4::Bookfund;
my $query=new CGI;
my $id=$query->param('supplierid');
-my @booksellers = GetBookSeller($id);
+my @booksellers = GetBookSeller($id) if $id;
my $count = scalar @booksellers;
+my $op=$query->param('op') || "display";
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "acqui/supplier.tmpl",
@@ -65,12 +69,42 @@
});
#build array for currencies
-my @currencies = GetCurrencies();
-my $count = scalar @currencies;
-
-my @loop_pricescurrency;
-my @loop_invoicecurrency;
-for (my $i=0;$i<$count;$i++) {
+if ($op eq "display"){
+ $template->param(id => $id,
+ name => $booksellers[0]->{'name'},
+ postal =>$booksellers[0]->{'postal'},
+ address1 => $booksellers[0]->{'address1'},
+ address2 => $booksellers[0]->{'address2'},
+ address3 => $booksellers[0]->{'address3'},
+ address4 => $booksellers[0]->{'address4'},
+ phone =>$booksellers[0]->{'phone'},
+ fax => $booksellers[0]->{'fax'},
+ url => $booksellers[0]->{'url'},
+ contact => $booksellers[0]->{'contact'},
+ contpos => $booksellers[0]->{'contpos'},
+ contphone => $booksellers[0]->{'contphone'},
+ contaltphone => $booksellers[0]->{'contaltphone'},
+ contfax => $booksellers[0]->{'contfax'},
+ contemail => $booksellers[0]->{'contemail'},
+ contnotes => $booksellers[0]->{'contnotes'},
+ notes => $booksellers[0]->{'notes'},
+ active => $booksellers[0]->{'active'},
+ specialty => $booksellers[0]->{'specialty'},
+ gstreg => $booksellers[0]->{'gstreg'},
+ listincgst => $booksellers[0]->{'listincgst'},
+ invoiceincgst => $booksellers[0]->{'invoiceincgst'},
+ discount => $booksellers[0]->{'discount'},
+ invoiceprice=>$booksellers[0]->{'invoiceprice'},
+ listprice=>$booksellers[0]->{'listprice'},
+ GST => C4::Context->preference("gist"),
+ );
+}else{
+ my @currencies = GetCurrencies();
+ my $count = scalar @currencies;
+
+ my @loop_pricescurrency;
+ my @loop_invoicecurrency;
+ for (my $i=0;$i<$count;$i++) {
if ($booksellers[0]->{'listprice'} eq $currencies[$i]->{'currency'}) {
push @loop_pricescurrency, { currency => "<option selected=\"selected\" value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>" };
} else {
@@ -81,8 +115,8 @@
} else {
push @loop_invoicecurrency, { currency => "<option value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>"};
}
-}
-$template->param(id => $id,
+ }
+ $template->param(id => $id,
name => $booksellers[0]->{'name'},
postal =>$booksellers[0]->{'postal'},
address1 => $booksellers[0]->{'address1'},
@@ -107,6 +141,9 @@
invoiceincgst => $booksellers[0]->{'invoiceincgst'},
discount => $booksellers[0]->{'discount'},
loop_pricescurrency => \@loop_pricescurrency,
- loop_invoicecurrency => \@loop_invoicecurrency,);
-
+ loop_invoicecurrency => \@loop_invoicecurrency,
+ GST => C4::Context->preference("gist"),
+ enter=>1,
+ );
+}
output_html_with_http_headers $query, $cookie, $template->output;
Index: updatesupplier.pl
===================================================================
RCS file: /sources/koha/koha/acqui/updatesupplier.pl,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- updatesupplier.pl 20 Sep 2006 21:44:36 -0000 1.10
+++ updatesupplier.pl 9 Mar 2007 14:28:54 -0000 1.11
@@ -83,14 +83,13 @@
$data{'invoiceprice'}=$input->param('invoice_currency');
$data{'gstreg'}=$input->param('gst');
$data{'listincgst'}=$input->param('list_gst');
-$data{'invoiceincgst'}=$input->param('invoiceincgst');
+$data{'invoiceincgst'}=$input->param('invoice_gst');
$data{'discount'}=$input->param('discount');
-my $id=$input->param('id');
-if ($data{'id'} != 0){
+if ($data{'id'}){
ModBookseller(\%data);
} else {
- $id=AddBookseller(\%data);
+ $data{id}=AddBookseller(\%data);
}
#redirect to booksellers.pl
-print $input->redirect("booksellers.pl?supplier=$id");
+print $input->redirect("booksellers.pl?supplier=".$data{id});
More information about the Koha-cvs
mailing list