From b2f5cf3ad22e03bac0f195934cc9256f8c6fe577 Mon Sep 17 00:00:00 2001 From: Ryan Higgins Date: Tue, 1 Jan 2008 14:53:15 -0600 Subject: [PATCH] Further updates to acq, merging in dev_week mods. Splitting orders now on receipt. Many tmpl updates to pass correct values btwn scripts. Signed-off-by: Joshua Ferraro --- C4/Acquisition.pm | 60 +++++++++++++------ acqui/basket.pl | 14 +++-- acqui/finishreceive.pl | 46 ++++++++------ acqui/orderreceive.pl | 6 +- acqui/parcel.pl | 6 +- koha-tmpl/intranet-tmpl/prog/en/js/additem.js | 37 ++++++++++++ .../prog/en/modules/acqui/basket.tmpl | 37 +++++------- .../prog/en/modules/acqui/orderreceive.tmpl | 42 +++++++++---- .../prog/en/modules/acqui/parcel.tmpl | 33 +++++----- 9 files changed, 183 insertions(+), 98 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/js/additem.js diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 594bfcef9f..b4b2655ad1 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -374,7 +374,7 @@ sub GetOrder { &NewOrder($basket, $biblionumber, $title, $quantity, $listprice, $booksellerid, $who, $notes, $bookfund, $biblioitemnumber, $rrp, $ecost, $gst, $budget, $unitprice, $subscription, - $booksellerinvoicenumber); + $booksellerinvoicenumber, $purchaseorder); Adds a new order to the database. Any argument that isn't described below is the new value of the field with the same name in the aqorders @@ -571,6 +571,9 @@ Updates an order, to reflect the fact that it was received, at least in part. All arguments not mentioned below update the fields with the same name in the aqorders table of the Koha database. +If a partial order is received, splits the order into two. The received +portion must have a booksellerinvoicenumber. + Updates the order with bibilionumber C<$biblionumber> and ordernumber C<$ordernumber>. @@ -584,31 +587,55 @@ Also updates the book fund ID in the aqorderbreakdown table. sub ModReceiveOrder { my ( $biblionumber, $ordnum, $quantrec, $user, $cost, - $invoiceno, $freight, $rrp, $bookfund, $daterecieved + $invoiceno, $freight, $rrp, $bookfund, $datereceived ) = @_; my $dbh = C4::Context->dbh; # warn "DATE BEFORE : $daterecieved"; - $daterecieved=POSIX::strftime("%Y-%m-%d",CORE::localtime) unless $daterecieved; +# $daterecieved=POSIX::strftime("%Y-%m-%d",CORE::localtime) unless $daterecieved; # warn "DATE REC : $daterecieved"; - my $query = " - UPDATE aqorders - SET quantityreceived=?,datereceived=?,booksellerinvoicenumber=?, - unitprice=?,freight=?,rrp=? - WHERE biblionumber=? AND ordernumber=? - "; - my $sth = $dbh->prepare($query); + $datereceived = C4::Dates->output('iso') unless $datereceived; + + my $sth=$dbh->prepare("SELECT * FROM aqorders LEFT JOIN aqorderbreakdown ON aqorders.ordernumber=aqorderbreakdown.ordernumber + WHERE biblionumber=? AND aqorders.ordernumber=?"); + $sth->execute($biblionumber,$ordnum); + my $order = $sth->fetchrow_hashref(); + $sth->finish(); + + if ( $order->{quantity} > $quantrec ) { + $sth=$dbh->prepare("update aqorders + set quantityreceived=?,datereceived=?,booksellerinvoicenumber=?, + unitprice=?,freight=?,rrp=?,quantity=? + where biblionumber=? and ordernumber=?"); + $sth->execute($quantrec,$datereceived,$invoiceno,$cost,$freight,$rrp,$quantrec,$biblionumber,$ordnum); + $sth->finish; + # create a new order for the remaining items, and set its bookfund. + my $newOrder = NewOrder($order->{'basketno'},$order->{'biblionumber'},$order->{'title'}, $order->{'quantity'} - $quantrec, + $order->{'listprice'},$order->{'booksellerid'},$order->{'authorisedby'},$order->{'notes'}, + $order->{'bookfundid'},$order->{'biblioitemnumber'},$order->{'rrp'},$order->{'ecost'},$order->{'gst'}, + $order->{'budget'},$order->{'unitcost'},$order->{'sub'},'',$order->{'sort1'},$order->{'sort2'},$order->{'purchaseordernumber'}); + + $sth = $dbh->prepare("select branchcode, bookfundid from aqorderbreakdown where ordernumber=?"); + $sth->execute($ordnum); + my ($branch,$bookfund) = $sth->fetchrow_array; + $sth->finish; + $sth=$dbh->prepare(" insert into aqorderbreakdown (ordernumber, branchcode, bookfundid) values (?,?,?)"); + $sth->execute($newOrder,$branch,$bookfund); + } else { + $sth=$dbh->prepare("update aqorders + set quantityreceived=?,datereceived=?,booksellerinvoicenumber=?, + unitprice=?,freight=?,rrp=? + where biblionumber=? and ordernumber=?"); + $sth->execute($quantrec,$datereceived,$invoiceno,$cost,$freight,$rrp,$biblionumber,$ordnum); + $sth->finish; + } my $suggestionid = GetSuggestionFromBiblionumber( $dbh, $biblionumber ); if ($suggestionid) { ModStatus( $suggestionid, 'AVAILABLE', '', $biblionumber ); } - $sth->execute( $quantrec,$daterecieved, $invoiceno, $cost, $freight, $rrp, $biblionumber, - $ordnum); - $sth->finish; - # Allows libraries to change their bookfund during receiving orders # allows them to adjust budgets - if ( C4::Context->preferene("LooseBudgets") ) { + if ( C4::Context->preference("LooseBudgets") ) { my $query = " UPDATE aqorderbreakdown SET bookfundid=? @@ -618,9 +645,8 @@ sub ModReceiveOrder { $sth->execute( $bookfund, $ordnum ); $sth->finish; } - return $daterecieved; + return $datereceived; } - #------------------------------------------------------------# =head3 SearchOrder diff --git a/acqui/basket.pl b/acqui/basket.pl index 9aba35121a..c181f61ac9 100755 --- a/acqui/basket.pl +++ b/acqui/basket.pl @@ -128,6 +128,7 @@ my $toggle = 0; # my $line_total_est; # total of each line my $sub_total_est; # total of line totals +my $sub_total_rrp; # total of line totals my $gist_est; # GST my $grand_total_est; # $subttotal + $gist @@ -136,8 +137,7 @@ my @books_loop; for ( my $i = 0 ; $i < $count ; $i++ ) { my $rrp = $results[$i]->{'listprice'}; $rrp = ConvertCurrency( $results[$i]->{'currency'}, $rrp ); - - $sub_total_est += $results[$i]->{'quantity'} * $results[$i]->{'rrp'}; + $sub_total_rrp += $results[$i]->{'quantity'} * $results[$i]->{'rrp'}; $line_total = $results[$i]->{'quantity'} * $results[$i]->{'ecost'}; $sub_total += $line_total; $qty_total += $results[$i]->{'quantity'}; @@ -151,6 +151,7 @@ for ( my $i = 0 ; $i < $count ; $i++ ) { $line{color} = 'white'; $toggle = 0; } + $line{order_received} = ($results[$i]->{'quantity'} eq $results[$i]->{'quantityreceived'}); $line{publishercode} = $results[$i]->{'publishercode'}; $line{basketno} = $basketno; $line{i} = $i; @@ -163,8 +164,8 @@ for ( my $i = 0 ; $i < $count ; $i++ ) { 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 ); +$grand_total_est = $sub_total_est + sprintf( "%.2f", $sub_total_est * $prefgist ); +my $grand_total_rrp = sprintf( "%.2f", $sub_total_rrp ); $gist_est = sprintf( "%.2f", $sub_total_est * $prefgist ); $template->param( basketno => $basketno, @@ -182,12 +183,13 @@ $template->param( entrydate => format_date( $results[0]->{'entrydate'} ), books_loop => \@books_loop, count => $count, - sub_total => $sub_total, + sub_total => sprintf( "%.2f", $sub_total), gist => $gist, - grand_total => $grand_total, + grand_total => sprintf( "%.2f", $grand_total), sub_total_est => $sub_total_est, gist_est => $gist_est, grand_total_est => $grand_total_est, + grand_total_rrp => $grand_total_rrp, currency => $booksellers[0]->{'listprice'}, qty_total => $qty_total, GST => C4::Context->preference("gist"), diff --git a/acqui/finishreceive.pl b/acqui/finishreceive.pl index ad977cab22..bba6e51e0c 100755 --- a/acqui/finishreceive.pl +++ b/acqui/finishreceive.pl @@ -34,7 +34,8 @@ 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 $origquantityrec=$input->param('origquantityrec'); +my $quantityrec=$input->param('quantityrec'); my $quantity=$input->param('quantity'); my $cost=$input->param('cost'); my $invoiceno=$input->param('invoice'); @@ -43,33 +44,40 @@ my $replacement=$input->param('rrp'); my $gst=$input->param('gst'); my $freight=$input->param('freight'); my $supplierid = $input->param('supplierid'); -my $branch=$input->param('branch'); - -# if ($quantrec != 0){ -# $cost /= $quantrec; +my @branch=$input->param('homebranch'); +my @barcode=$input->param('barcode'); +my @ccode=$input->param('ccode'); +my @itemtype=$input->param('itemtype'); +my @location=$input->param('location'); +my $cnt = 0; +# if ($quantityrec != 0){ +# $cost /= $quantityrec; # } -if ($quantity != 0) { +if ($quantityrec > $origquantityrec ) { # save the quantity recieved. - $datereceived = ModReceiveOrder($biblionumber,$ordnum,$quantrec,$user,$cost,$invoiceno,$datereceived,$freight,$replacement); + $datereceived = ModReceiveOrder($biblionumber,$ordnum,$quantityrec,$user,$cost,$invoiceno,$datereceived,$freight,$replacement); # create items if the user has entered barcodes - my $barcode=$input->param('barcode'); - my @barcodes=split(/\,| |\|/,$barcode); + # my @barcodes=split(/\,| |\|/,$barcode); # foreach barcode provided, build the item MARC::Record and create the item - foreach my $bc (@barcodes) { + foreach my $bc (@barcode) { my $itemRecord = TransformKohaToMarc({ "items.replacementprice" => $replacement, "items.price" => $cost, "items.booksellerid" => $supplierid, - "items.homebranch" => $branch, - "items.holdingbranch" => $branch, - "items.barcode" => $bc, + "items.homebranch" => $branch[$cnt], + "items.holdingbranch" => $branch[$cnt], + "items.barcode" => $barcode[$cnt], + "items.ccode" => $ccode[$cnt], + "items.itype" => $itemtype[$cnt], + "items.location" => $location[$cnt], "items.loan" => 0, }); - AddItem($itemRecord,$biblionumber); + AddItem($itemRecord,$biblionumber); } - 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/"); } + 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/"); +#} diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl index bb1de0855b..546c0f4a99 100755 --- a/acqui/orderreceive.pl +++ b/acqui/orderreceive.pl @@ -36,7 +36,7 @@ It permit to write a new order as 'received'. =item supplierid to know on what supplier this script has to display receive order. -=item recieve +=item receive =item invoice the number of this invoice. @@ -114,7 +114,6 @@ if ( $count == 1 ) { my $locs = GetKohaAuthorisedValues( 'items.location' ); foreach my $thisloc (sort keys %$locs) { - warn $thisloc; my $row = { value => $thisloc, description => $locs->{$thisloc}, @@ -167,8 +166,7 @@ if ( $count == 1 ) { if ( $results[0]->{'unitprice'} == 0 ) { $results[0]->{'unitprice'} = ''; } - $results[0]->{'copyrightdate'} = - format_date( $results[0]->{'copyrightdate'} ); +# $results[0]->{'copyrightdate'} = format_date( $results[0]->{'copyrightdate'} ); # this usu fails. $template->param( branchloop => \@branchloop, count => 1, diff --git a/acqui/parcel.pl b/acqui/parcel.pl index 4e624ee090..e92814310a 100755 --- a/acqui/parcel.pl +++ b/acqui/parcel.pl @@ -131,7 +131,7 @@ my $countpendings = scalar @$pendingorders; # pending orders totals my ($totalPunitprice,$totalPquantity,$totalPecost, $totalPqtyrcvd); - +my $ordergrandtotal; my @loop_orders = (); for (my $i=0;$i<$countpendings;$i++){ my %line; @@ -151,11 +151,13 @@ for (my $i=0;$i<$countpendings;$i++){ $totalPqtyrcvd +=$line{quantityreceived}; $totalPecost += $line{ecost}; $line{ecost} = sprintf("%.2f",$line{ecost}); + $line{ordertotal} = sprintf("%.2f",$line{ecost}*$line{quantity}); $line{unitprice} = sprintf("%.2f",$line{unitprice}); $line{invoice} = $invoice; $line{gst} = $gst; $line{total} = $total; $line{supplierid} = $supplierid; + $ordergrandtotal += $line{ecost}*$line{quantity}; push @loop_orders, \%line; } $freight = $totalfreight unless $freight; @@ -164,6 +166,7 @@ $tototal=$tototal+$freight; $template->param(invoice => $invoice, datereceived => $datereceived->output('iso'), + invoicedatereceived => $datereceived->output('iso'), formatteddatereceived => $datereceived->output(), name => $booksellers[0]->{'name'}, supplierid => $supplierid, @@ -178,6 +181,7 @@ $template->param(invoice => $invoice, totalfreight => $totalfreight, totalquantity => $totalquantity, tototal => sprintf($cfstr,$tototal), + ordergrandtotal => sprintf($cfstr,$ordergrandtotal), gst => $gst, grandtot => sprintf($cfstr,$tototal+$gst), totalPunitprice => sprintf("%.2f",$totalPunitprice), diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/additem.js b/koha-tmpl/intranet-tmpl/prog/en/js/additem.js new file mode 100644 index 0000000000..ee93450703 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/js/additem.js @@ -0,0 +1,37 @@ +function countItemBlocks() { + var outeritemblock = document.getElementById('outeritemblock'); + var quantityrec = document.getElementById('quantityrec'); + var origquantityrec = document.getElementById('origquantityrec'); + var itemblockcount = outeritemblock.getElementsByTagName('div'); + var num = parseFloat(origquantityrec.value) + itemblockcount.length; + quantityrec.setAttribute('value',num); +} +function deleteItemBlock(index) { + var aDiv = document.getElementById(index); + aDiv.parentNode.removeChild(aDiv); + countItemBlocks(); +} +function cloneItemBlock(index) { + var original = document.getElementById(index); //original
+ var clone = original.cloneNode(true); + // set the attribute for the new 'div' subfields + clone.setAttribute('id',index + index);//set another id. + var NumTabIndex; + NumTabIndex = parseInt(original.getAttribute('tabindex')); + if(isNaN(NumTabIndex)) NumTabIndex = 0; + clone.setAttribute('tabindex',NumTabIndex+1); + var CloneButtonPlus; + var CloneButtonMinus; + // try{ + CloneButtonPlus = clone.getElementsByTagName('a')[0]; + CloneButtonPlus.setAttribute('onclick',"cloneItemBlock('" + index + index + "')"); + CloneButtonMinus = clone.getElementsByTagName('a')[1]; + CloneButtonMinus.setAttribute('onclick',"deleteItemBlock('" + index + index + "')"); + CloneButtonMinus.setAttribute('style',"display:inline"); + // } + //catch(e){ // do nothig if ButtonPlus & CloneButtonPlus don't exist. + //} + // insert this line on the page + original.parentNode.insertBefore(clone,original.nextSibling); + countItemBlocks(); +} diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tmpl index 25c7998814..d0e8cac1ce 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tmpl @@ -48,8 +48,8 @@ - + @@ -65,27 +65,18 @@ - - - - - - + + - + @@ -108,30 +99,32 @@ " /> " /> - - - + + --> + - + - + + - - + + +
Order&order=biblioitems.publishercode">Publisher Title&order=biblioitems.publishercode">Publisher RRP Est. Qty.

- ">
- - - -

-

-
+ (rcvd) -

+

">

-

SubTotalSubTotal      
GST   
TOTAL ()  
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tmpl index 49aff39ec0..c82dc33b38 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tmpl @@ -1,12 +1,13 @@ Koha › Acquisitions › Receipt summary for : <!-- TMPL_VAR NAME="name" --> <!-- TMPL_IF NAME="invoice" -->invoice, <!-- TMPL_VAR NAME="invoice" --><!-- /TMPL_IF --> + - +
@@ -14,7 +15,7 @@
-

Receipt order for : Parcel (order #)

+

Receive items from : [] (order #)

@@ -23,7 +24,7 @@
Catalogue Details -
  1. Title:
  2. +
    • Title:
    • Author:
    • Copyright: @@ -32,11 +33,18 @@
    • Series:
    • -
    • +
    +
+
+ Item details (n): (add to catalogue) +
+
+
    +
  • -
  • +
  • " />
  • -
  • +
  • - +
+')">+ + ')">- +
+
" /> " /> " /> @@ -86,12 +98,16 @@
- Accounting Details -
  1. " />
  2. -
  3. " />
  4. -
  5. " />
  6. -
  7. " />
  8. -
  9. + Accounting details +
      +
    • +
    • + 1" /> + 0" /> + " /> -->
    • +
    • " />
    • +
    • " />
    • +
    • " /> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tmpl index 69885aa0dd..d02be8a1f9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tmpl @@ -1,6 +1,6 @@ Koha › Acquisitions › <!-- TMPL_IF name="date" --> - Receipt Summary for <!-- TMPL_VAR NAME="name" --> <!--TMPL_IF Name="invoice"-->Invoice <!-- TMPL_VAR NAME="invoice" --><!--/TMPL_IF --> on <!-- TMPL_VAR NAME="datereceived" --><!-- TMPL_ELSE -->Receive Orders from <!-- TMPL_VAR NAME="name" --><!-- /TMPL_IF --> + Receipt Summary for Invoice on Receive Orders from @@ -9,9 +9,9 @@
      @@ -22,15 +22,16 @@

      - Receipt Summary for [ ] on + Receipt Summary for [ ] on - Orders not yet Received from + Receive orders from

      -

      Parcel:

      +

      Invoice / Parcel:

      Received by:

      -

      On:

      +

      On:

      +

      Items in parcel

      @@ -47,7 +48,7 @@ - &biblionumber=&datereceived=&invoice=&gst=&freight=&supplierid="> + ">  /   ">
      ISBN: @@ -109,9 +110,9 @@ BASKET Summary View Record - Qty received / ordered + Still on order + Unit cost Order cost - Received cost   @@ -125,17 +126,17 @@
      Publisher : " title="MARC" rel="gb_page_center[600,500]">MARC | " title="MARC" rel="gb_page_center[600,500]">Card - / + - - &biblionumber=&datereceived=&invoice=&gst=&freight=&supplierid=">Receive + + &biblionumber=&datereceived=&invoice=&gst=&freight=&supplierid=">Receive   TOTAL - / - - + +   +   -- 2.39.5