koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] koha/acqui acqui-home.pl addorder.pl basket.pl ...


From: Tumer Garip
Subject: [Koha-cvs] koha/acqui acqui-home.pl addorder.pl basket.pl ...
Date: Wed, 20 Sep 2006 21:44:37 +0000

CVSROOT:        /sources/koha
Module name:    koha
Changes by:     Tumer Garip <tgarip1957>        06/09/20 21:44:36

Modified files:
        acqui          : acqui-home.pl addorder.pl basket.pl bookfund.pl 
                         booksellers.pl finishreceive.pl histsearch.pl 
                         lateorders.pl neworderempty.pl 
                         newordersuggestion.pl parcel.pl select-late.pl 
                         supplier.pl updatesupplier.pl 
Added files:
        acqui          : currency.pl 
Removed files:
        acqui          : neworderbiblio.pl orderreceive.pl parcels.pl 
                         spent.pl 

Log message:
        A new acquisition to handle different tax values to each item, 
receiving multiple baskets as one parcel, stricter rules for biblio and item 
creation

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/acqui-home.pl?cvsroot=koha&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/addorder.pl?cvsroot=koha&r1=1.33&r2=1.34
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/basket.pl?cvsroot=koha&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/bookfund.pl?cvsroot=koha&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/booksellers.pl?cvsroot=koha&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/finishreceive.pl?cvsroot=koha&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/histsearch.pl?cvsroot=koha&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/lateorders.pl?cvsroot=koha&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/neworderempty.pl?cvsroot=koha&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/newordersuggestion.pl?cvsroot=koha&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/parcel.pl?cvsroot=koha&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/select-late.pl?cvsroot=koha&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/supplier.pl?cvsroot=koha&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/updatesupplier.pl?cvsroot=koha&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/currency.pl?cvsroot=koha&rev=1.2
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/neworderbiblio.pl?cvsroot=koha&r1=1.2&r2=0
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/orderreceive.pl?cvsroot=koha&r1=1.2&r2=0
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/parcels.pl?cvsroot=koha&r1=1.2&r2=0
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/spent.pl?cvsroot=koha&r1=1.1&r2=0

Patches:
Index: acqui-home.pl
===================================================================
RCS file: /sources/koha/koha/acqui/acqui-home.pl,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- acqui-home.pl       31 Jul 2006 15:59:03 -0000      1.15
+++ acqui-home.pl       20 Sep 2006 21:44:36 -0000      1.16
@@ -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: acqui-home.pl,v 1.15 2006/07/31 15:59:03 toins Exp $
+# $Id: acqui-home.pl,v 1.16 2006/09/20 21:44:36 tgarip1957 Exp $
 
 
 =head1 NAME
@@ -45,9 +45,7 @@
 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 @@
 );
 
 # 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;

Index: addorder.pl
===================================================================
RCS file: /sources/koha/koha/acqui/addorder.pl,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- addorder.pl 7 Aug 2006 13:17:42 -0000       1.33
+++ addorder.pl 20 Sep 2006 21:44:36 -0000      1.34
@@ -90,7 +90,7 @@
 
 =item C<ecost>
 
-=item C<GST>
+=item C<gst>
 
 =item C<budget>
 
@@ -115,20 +115,12 @@
 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 @@
     }
 );
 
+
 # get CGI parameters
 my $ordnum       = $input->param('ordnum');
 my $basketno     = $input->param('basketno');
@@ -154,166 +147,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 $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 );
-        }
-    }
+my $data=GetSuggestion($suggestionid);
 
-    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 : ""
-            }
-        );
+ 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,"");
+
+            ModStatus( $suggestionid, 'ORDERED', '', $biblionumber,$input );
+warn "modstatus";
     }
+    }## biblio didnot exist now created
 
-    # then attach it to an existing bib
 
-    else {
-        warn "attaching to an existing bibitem";
 
-        $bibnum = $input->param('biblio');
 
-        # if we are moddig the bibitem, not creating it createbib wont be set,
-        #
-        if ($createbibitem) {
-            $bibitemnum = $createbibitem;
-        }
-        else {
-            $bibitemnum = $input->param('bibitemnum');
-        }
-
-        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");

Index: basket.pl
===================================================================
RCS file: /sources/koha/koha/acqui/basket.pl,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- basket.pl   1 Aug 2006 08:30:58 -0000       1.34
+++ basket.pl   20 Sep 2006 21:44:36 -0000      1.35
@@ -20,16 +20,13 @@
 # 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.34 2006/08/01 08:30:58 toins Exp $
+# $Id: basket.pl,v 1.35 2006/09/20 21:44:36 tgarip1957 Exp $
 
 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 $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 @@
 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 );
+     $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;
+   
 
-    $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;
    if ( $toggle == 0 ) {
@@ -148,7 +140,7 @@
     $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 @@
     $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 @@
     entrydate        => format_date( $results[0]->{'entrydate'} ),
     books_loop       => address@hidden,
     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,

Index: bookfund.pl
===================================================================
RCS file: /sources/koha/koha/acqui/bookfund.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- bookfund.pl 7 Jun 2006 11:03:17 -0000       1.2
+++ bookfund.pl 20 Sep 2006 21:44:36 -0000      1.3
@@ -64,15 +64,15 @@
       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 @@
     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.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- booksellers.pl      1 Aug 2006 15:34:44 -0000       1.2
+++ booksellers.pl      20 Sep 2006 21:44:36 -0000      1.3
@@ -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.2 2006/08/01 15:34:44 toins Exp $
+# $Id: booksellers.pl,v 1.3 2006/09/20 21:44:36 tgarip1957 Exp $
 
 =head1 NAME
 
@@ -55,12 +55,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::Acquisition;
 use C4::Date;
 use C4::Bookseller;
@@ -85,19 +81,19 @@
 
 # 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    $ordercount = scalar @$orders;
+$ordcount+=$ordercount;
     my %line;
     if ( $toggle == 0 ) {
         $line{even} = 1;
@@ -110,18 +106,10 @@
     $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} = address@hidden;
     push @loop_suppliers, \%line;
@@ -129,7 +117,7 @@
 $template->param(
     loop_suppliers          => address@hidden,
     supplier                => $supplier,
-    count                   => $count,
+    count                   => $ordcount,
     intranetcolorstylesheet =>
     C4::Context->preference("intranetcolorstylesheet"),
     intranetstylesheet => C4::Context->preference("intranetstylesheet"),

Index: finishreceive.pl
===================================================================
RCS file: /sources/koha/koha/acqui/finishreceive.pl,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- finishreceive.pl    1 Aug 2006 15:04:33 -0000       1.20
+++ finishreceive.pl    20 Sep 2006 21:44:36 -0000      1.21
@@ -41,21 +41,13 @@
 =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 $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"
-        );
+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;
     }
-
-    if ( $quantity != 0 ) {
+$unitprice=$ecost + $ecost*$gst[$i]/100;
+       if ( $quantrec[$i] != 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?
+               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 ($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/");
     }
 }
+$template->param(loopbiblios => address@hidden,);
+                      
+ output_html_with_http_headers $input, $cookie, $template->output;
\ No newline at end of file

Index: histsearch.pl
===================================================================
RCS file: /sources/koha/koha/acqui/histsearch.pl,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- histsearch.pl       26 Jul 2006 10:27:47 -0000      1.8
+++ histsearch.pl       20 Sep 2006 21:44:36 -0000      1.9
@@ -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: histsearch.pl,v 1.8 2006/07/26 10:27:47 toins Exp $
+# $Id: histsearch.pl,v 1.9 2006/09/20 21:44:36 tgarip1957 Exp $
 
 
 =head1 NAME
@@ -52,8 +52,6 @@
 use strict;
 require Exporter;
 use CGI;
-use HTML::Template;
-
 use C4::Auth;       # get_template_and_user
 use C4::Interface::CGI::Output;
 use C4::Acquisition;

Index: lateorders.pl
===================================================================
RCS file: /sources/koha/koha/acqui/lateorders.pl,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- lateorders.pl       26 Jul 2006 09:57:33 -0000      1.6
+++ lateorders.pl       20 Sep 2006 21:44:36 -0000      1.7
@@ -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.6 2006/07/26 09:57:33 toins Exp $
+# $Id: lateorders.pl,v 1.7 2006/09/20 21:44:36 tgarip1957 Exp $
 
 =head1 NAME
 
@@ -51,7 +51,6 @@
 use C4::Output;
 use C4::Interface::CGI::Output;
 use C4::Context;
-use HTML::Template;
 use C4::Acquisition;
 
 my $query = new CGI;

Index: neworderempty.pl
===================================================================
RCS file: /sources/koha/koha/acqui/neworderempty.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- neworderempty.pl    2 Aug 2006 08:06:02 -0000       1.1
+++ neworderempty.pl    20 Sep 2006 21:44:36 -0000      1.2
@@ -65,8 +65,6 @@
 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::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,60 +86,88 @@
 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;
 
+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';
-
-    #  $ordnum=newordernum;
-    if ( $biblio && !$suggestionid ) {
-        $data = bibdata($biblio);
+    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");
     }
-
-# 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 = XMLmarc2koha_onerecord($dbh,$record,"biblios");
+    }elsif($suggestionid){
             $data = GetSuggestion($suggestionid);
-        }
-    }
+    
     if ( $data->{'title'} eq '' ) {
         $data->{'title'}         = $title;
         $data->{'author'}        = $author;
         $data->{'copyrightdate'} = $copyright;
     }
-}
-else {    #modify order
+   }### 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);
-    $biblio = $data->{'biblionumber'};
+    $biblionumber = $data->{'biblionumber'};
     #get basketno and suppleirno. too!
     my $data2 = GetBasket( $data->{'basketno'} );
-    $basketno     = $data2->{'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},);
+       
 }
 
-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 change rates calcs if needed)
+
+# get currencies (for exchange rates calcs if needed)
 my @rates = GetCurrencies();
 my $count = scalar @rates;
 
@@ -154,45 +179,31 @@
     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   => address@hidden,
-    -default  => $data->{'itemtype'},
-    -labels   => \%itemtypesloop,
-    -size     => 1,
-    -multiple => 0
-);
+
 
 # build branches list
 my $branches = GetBranches;
 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 => address@hidden );
 
 # 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 @@
     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   => address@hidden,
     -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 @@
 
 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;
+#
 
+    $template->param( bibitemexists => "1" ) if $biblionumber;
     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'};
+        $line{isbn}             = $data->{'isbn'};
+        $line{itemtype}         = $data->{'itemtype'};
+        $line{volumeddesc}      = $data->{'volumeddesc'};
         push( @bibitemloop, \%line );
 
         $template->param( bibitemloop => address@hidden );
-    }
-    $template->param( bibitemexists => "1" );
-}
+    
+
 
 # fill template
 $template->param(
@@ -268,16 +274,14 @@
   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 @@
     nocalc           => $booksellers[0]->{'nocalc'},
     name             => $booksellers[0]->{'name'},
     currency         => $booksellers[0]->{'listprice'},
-    gstrate          => C4::Context->preference("gist"),
+    gstrate          =>$gstrate,
     loop_currencies  => address@hidden,
     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 @@
     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

Index: newordersuggestion.pl
===================================================================
RCS file: /sources/koha/koha/acqui/newordersuggestion.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- newordersuggestion.pl       10 Aug 2006 12:58:17 -0000      1.3
+++ newordersuggestion.pl       20 Sep 2006 21:44:36 -0000      1.4
@@ -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: newordersuggestion.pl,v 1.3 2006/08/10 12:58:17 toins Exp $
+# $Id: newordersuggestion.pl,v 1.4 2006/09/20 21:44:36 tgarip1957 Exp $
 
 =head1 NAME
 newordersuggestion.pl
@@ -77,7 +77,6 @@
 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 @@
 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, "address@hidden";
+                       push @relation, "address@hidden 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, "address@hidden";
+                       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, "address@hidden";
+                       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, "address@hidden";
+                       push @relation, "";
                        push @value, $_->{publishercode};
                }
        
-               my ($finalresult,$nbresult) = 
catalogsearch($dbh,address@hidden,address@hidden,address@hidden,address@hidden,address@hidden,0,10);
+               my ($nbresult,@finalresult) = 
ZEBRAsearch_kohafields(address@hidden,address@hidden,address@hidden,"",address@hidden,0,"",0,1);
 
                # there is at least 1 result => return the 1st one
                if ($nbresult) {
-                       #warn "$nbresult => 
"address@hidden>{biblionumber},@$finalresult[0]->{bibid},@$finalresult[0]->{title};
-                       #warn "DUPLICATE 
==>"address@hidden>{biblionumber},@$finalresult[0]->{bibid},@$finalresult[0]->{title};
-                       $_->{duplicateBiblionumber} = 
@$finalresult[0]->{biblionumber};
+                       $_->{duplicateBiblionumber} = 
$finalresult[0]->{biblionumber};
                }
        }
 }

Index: parcel.pl
===================================================================
RCS file: /sources/koha/koha/acqui/parcel.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- parcel.pl   1 Aug 2006 08:29:02 -0000       1.3
+++ parcel.pl   20 Sep 2006 21:44:36 -0000      1.4
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: parcel.pl,v 1.3 2006/08/01 08:29:02 toins Exp $
+# $Id: parcel.pl,v 1.4 2006/09/20 21:44:36 tgarip1957 Exp $
 
 #script to recieve orders
 #written by address@hidden 24/2/2000
@@ -54,29 +54,26 @@
 =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 @@
                  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;
-}
-    $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;
+$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;
+  }    
 }
 
-$totalfreight=$freight;
-$tototal=$tototal+$freight;
+}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);
 
-$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 => address@hidden,
                         countpending => $countpendings,
                         loop_orders => address@hidden,
-                        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"),

Index: select-late.pl
===================================================================
RCS file: /sources/koha/koha/acqui/select-late.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- select-late.pl      31 Jul 2006 16:03:46 -0000      1.3
+++ select-late.pl      20 Sep 2006 21:44:36 -0000      1.4
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: select-late.pl,v 1.3 2006/07/31 16:03:46 toins Exp $
+# $Id: select-late.pl,v 1.4 2006/09/20 21:44:36 tgarip1957 Exp $
 
 #script to show suppliers and orders
 #written by address@hidden 23/2/2000
@@ -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;

Index: supplier.pl
===================================================================
RCS file: /sources/koha/koha/acqui/supplier.pl,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- supplier.pl 27 Jul 2006 15:08:32 -0000      1.13
+++ supplier.pl 20 Sep 2006 21:44:36 -0000      1.14
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: supplier.pl,v 1.13 2006/07/27 15:08:32 toins Exp $
+# $Id: supplier.pl,v 1.14 2006/09/20 21:44:36 tgarip1957 Exp $
 
 #script to show display basket of orders
 #written by address@hidden 24/2/2000
@@ -45,11 +45,8 @@
 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;
 

Index: updatesupplier.pl
===================================================================
RCS file: /sources/koha/koha/acqui/updatesupplier.pl,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- updatesupplier.pl   1 Aug 2006 15:03:19 -0000       1.9
+++ updatesupplier.pl   20 Sep 2006 21:44:36 -0000      1.10
@@ -83,7 +83,7 @@
 $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){

Index: currency.pl
===================================================================
RCS file: currency.pl
diff -N currency.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ currency.pl 20 Sep 2006 21:44:36 -0000      1.2
@@ -0,0 +1,42 @@
+#!/usr/bin/perl
+
+# $Id: currency.pl,v 1.2 2006/09/20 21:44:36 tgarip1957 Exp $
+
+#written by address@hidden
+#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');

Index: neworderbiblio.pl
===================================================================
RCS file: neworderbiblio.pl
diff -N neworderbiblio.pl
--- neworderbiblio.pl   5 Sep 2006 21:21:21 -0000       1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -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/\"/\&quot\;/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} = address@hidden;
-    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             => address@hidden,
-    loopresult             => address@hidden,
-    numbers                => address@hidden,
-    invalidsearch          => $invalidsearch,
-    'use-location-flags-p' => 1
-);
-
-output_html_with_http_headers $input, $cookie, $template->output;
-

Index: orderreceive.pl
===================================================================
RCS file: orderreceive.pl
diff -N orderreceive.pl
--- orderreceive.pl     31 Jul 2006 14:40:54 -0000      1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,189 +0,0 @@
-#!/usr/bin/perl
-
-# $Id: orderreceive.pl,v 1.2 2006/07/31 14:40:54 toins Exp $
-
-#script to recieve orders
-#written by address@hidden 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       => address@hidden,
-        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       => address@hidden,
-        date       => format_date($date),
-        name       => $booksellers[0]->{'name'},
-        supplierid => $supplierid,
-        invoice    => $invoice,
-    );
-
-}
-output_html_with_http_headers $input, $cookie, $template->output;
-

Index: parcels.pl
===================================================================
RCS file: parcels.pl
diff -N parcels.pl
--- parcels.pl  31 Jul 2006 09:29:45 -0000      1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,172 +0,0 @@
-#!/usr/bin/perl
-
-# $Id: parcels.pl,v 1.2 2006/07/31 09:29:45 toins Exp $
-
-#script to show display basket of orders
-#written by address@hidden 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=>address@hidden, 
-                     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=>address@hidden, 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;

Index: spent.pl
===================================================================
RCS file: spent.pl
diff -N spent.pl
--- spent.pl    7 Jun 2006 01:53:15 -0000       1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -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 => address@hidden,
-    total     => $total
-);
-$sth->finish;
-
-$dbh->disconnect;
-output_html_with_http_headers $input, $cookie, $template->output;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]