uncertainprices

uncertainprice is set on z3950 or staged file import
This commit is contained in:
Paul Poulain 2009-04-28 22:51:30 +02:00 committed by Henri-Damien LAURENT
parent 5a57fb9a10
commit 862822283d
2 changed files with 247 additions and 0 deletions

129
acqui/uncertainprice.pl Executable file
View File

@ -0,0 +1,129 @@
#!/usr/bin/perl
#script to show a list of orders with uncertain prices for a bookseller
#the script also allows to edit the prices and uncheck the uncertainprice property of them
#written by john.soros@biblibre.com 01/10/2008
# Copyright 2008-2009 BibLibre SARL
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# Koha is 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
uncertainprice.pl
=head1 DESCRIPTION
This script displays all the orders with uncertain prices for a given bookseller, it also lets the user modify the unitprice and uncertainprice properties of the order
=head1 CGI PARAMETERS
=over 4
=item $booksellerid
The bookseller who we want to display the orders of.
=back
=cut
use strict;
use warnings;
use C4::Input;
use C4::Auth;
use C4::Output;
use CGI;
use C4::Bookseller qw/GetBookSellerFromId/;
use C4::Acquisition qw/GetPendingOrders GetOrder ModOrder/;
use C4::Biblio qw/GetBiblioData/;
my $input=new CGI;
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "acqui/uncertainprice.tmpl",
query => $input,
type => "intranet",
authnotrequired => 0,
flagsrequired => { acquisition => 'order_manage' },
debug => 1,
});
my $booksellerid = $input->param('booksellerid');
my $op = $input->param('op');
my $owner = $input->param('owner') || 0 ; # flag to see only "my" orders, or everyone orders
my $bookseller = &GetBookSellerFromId($booksellerid);
#show all orders that have uncertain price for the bookseller
my $pendingorders = &GetPendingOrders($booksellerid,0,$owner);
my @orders;
foreach my $order (@{$pendingorders}) {
if ( $order->{'uncertainprice'} ) {
my $bibdata = &GetBiblioData($order->{'biblionumber'});
$order->{'bibisbn'} = $bibdata->{'isbn'};
$order->{'bibpublishercode'} = $bibdata->{'publishercode'};
$order->{'bibpublicationyear'} = $bibdata->{'publicationyear'};
$order->{'bibtitle'} = $bibdata->{'title'};
$order->{'bibauthor'} = $bibdata->{'author'};
my $order_as_from_db=GetOrder($order->{ordernumber});
$order->{'quantity'} = $order_as_from_db->{'quantity'};
$order->{'listprice'} = $order_as_from_db->{'listprice'};
push(@orders, $order);
}
}
if ( $op eq 'validate' ) {
$template->param( validate => 1);
my $count = scalar(@orders);
for (my $i=0; $i < $count; $i++) {
my $order = pop(@orders);
my $ordernumber = $order->{ordernumber};
my $order_as_from_db=GetOrder($order->{ordernumber});
$order->{'listprice'} = $input->param('price'.$ordernumber);
$order->{'ecost'}= $input->param('price'.$ordernumber) - (($input->param('price'.$ordernumber) /100) * $bookseller->{'discount'});
$order->{'rrp'} = $input->param('price'.$ordernumber);
$order->{'quantity'}=$input->param('qty'.$ordernumber);
$order->{'uncertainprice'}=$input->param('uncertainprice'.$ordernumber);
ModOrder($order);
}
}
$template->param( uncertainpriceorders => \@orders,
booksellername => "".$bookseller->{'name'},
booksellerid => $bookseller->{'id'},
booksellerpostal =>$bookseller->{'postal'},
bookselleraddress1 => $bookseller->{'address1'},
bookselleraddress2 => $bookseller->{'address2'},
bookselleraddress3 => $bookseller->{'address3'},
bookselleraddress4 => $bookseller->{'address4'},
booksellerphone =>$bookseller->{'phone'},
booksellerfax => $bookseller->{'fax'},
booksellerurl => $bookseller->{'url'},
booksellercontact => $bookseller->{'contact'},
booksellercontpos => $bookseller->{'contpos'},
booksellercontphone => $bookseller->{'contphone'},
booksellercontaltphone => $bookseller->{'contaltphone'},
booksellercontfax => $bookseller->{'contfax'},
booksellercontemail => $bookseller->{'contemail'},
booksellercontnotes => $bookseller->{'contnotes'},
booksellernotes => $bookseller->{'notes'},
owner => $owner,
scriptname => "/cgi-bin/koha/acqui/uncertainprice.pl");
output_html_with_http_headers $input, $cookie, $template->output;

View File

@ -0,0 +1,118 @@
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
<title>Koha &rsaquo; Orders with uncertain prices for Vendor <!-- TMPL_VAR name="booksellername" --></title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<script type="text/javascript" src="<!-- TMPL_VAR NAME='themelang' -->/js/acq.js"></script>
<script type="text/javascript">
//<![CDATA[
function check(form) {
form.submit();
}
//]]>
</script>
</head>
<body>
<!-- TMPL_INCLUDE NAME="header.inc" -->
<!-- TMPL_INCLUDE NAME="acquisitions-search.inc" -->
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo;<a href="/cgi-bin/koha/acqui/supplier.pl?supplierid=<!-- TMPL_VAR NAME="booksellerid" -->"><!-- TMPL_VAR NAME="booksellername" --></a> &rsaquo; Uncertain prices for vendor: <!-- TMPL_VAR NAME="booksellername" --></div>
<div id="doc" class="yui-t7">
<div id="bd">
<div id="yui-main">
<!-- TMPL_IF name="validate" -->
<META HTTP-EQUIV=Refresh CONTENT="0; URL=<!-- TMPL_VAR name="scriptname" -->?booksellerid=<!-- TMPL_VAR NAME="booksellerid" -->">
<!-- TMPL_ELSE -->
<h1>Orders with uncertain prices for vendor <a href="/cgi-bin/koha/acqui/supplier.pl?supplierid=<!-- TMPL_VAR NAME="booksellerid" -->"><!--TMPL_VAR name="booksellername" --></a> <a href="/cgi-bin/koha/acqui/supplier.pl?supplierid=<!-- TMPL_VAR NAME="booksellerid" -->&op=enter">(edit)</a></h1>
<!-- TMPL_IF name="owner" -->
<a href="/cgi-bin/koha/acqui/uncertainprice.pl?booksellerid=<!-- TMPL_VAR NAME="booksellerid" -->">View everyone orders</a>
<!-- TMPL_ELSE -->
<a href="/cgi-bin/koha/acqui/uncertainprice.pl?booksellerid=<!-- TMPL_VAR NAME="booksellerid" -->&owner=1">View only my orders</a>
<!-- /TMPL_IF -->
<h2>Contact information</h2>
<p><strong>Postal address: </strong>
<!-- TMPL_VAR name="booksellerpostal" --></p>
<!-- TMPL_IF name="bookselleraddress1" -->
<p><strong>Address 1: </strong>
<!-- TMPL_VAR name="bookselleraddress1" --></p>
<!-- /TMPL_IF -->
<!-- TMPL_IF name="bookselleraddress2" -->
<p><strong>Address 2: </strong>
<!-- TMPL_VAR name="bookselleraddress2" --></p>
<!-- /TMPL_IF -->
<!-- TMPL_IF name="bookselleraddress3" -->
<p><strong>Address 3: </strong>
<!-- TMPL_VAR name="bookselleraddress3" --></p>
<!-- /TMPL_IF -->
<!-- TMPL_IF name="bookselleraddress4" -->
<p><strong>Address 4: </strong>
<!-- TMPL_VAR name="bookselleraddress4" --></p>
<!-- /TMPL_IF -->
<p><strong>Telephone: </strong>
<!--TMPL_VAR name="booksellerphone" --></p>
<p><strong>Fax: </strong>
<!--TMPL_VAR name="booksellerfax" --></p>
<p><strong>Web: </strong>
<a href="<!--TMPL_VAR name="booksellerurl" -->"><!--TMPL_VAR name="booksellerurl" --></a></p>
<p><dl>
<dt><strong>Contact: </strong></dt>
<dd><strong>Name: </strong><!--TMPL_VAR name="booksellercontact" --></dd>
<dd><strong>Position: </strong><!--TMPL_VAR name="booksellercontpos" --></dd>
<dd><strong>Telephone: </strong><!--TMPL_VAR name="booksellercontphone" --></dd>
<!-- TMPL_IF name="booksellercontaltphone" -->
<dd><strong>Alternate phone: </strong><!--TMPL_VAR name="booksellercontaltphone" --></dd>
<!-- /TMPL_IF -->
<dd><strong>e-mail: </strong><!--TMPL_VAR name="booksellercontemail" --></dd>
<!-- TMPL_IF name="booksellercontnotes" -->
<dd><strong>notes: </strong><!--TMPL_VAR name="booksellercontnotes" --></dd>
<!-- /TMPL_IF -->
</dl></p>
<!-- TMPL_IF name="booksellernotes" -->
<p><strong>Notes: </strong>
<!--TMPL_VAR name="booksellernotes" --></p>
<!-- /TMPL_IF -->
<h2>Orders with uncertain prices</h2>
<form action="<!-- TMPL_VAR name="scriptname" -->" method="post" name="uncertainprices">
<input type="hidden" name="booksellerid" value="<!-- TMPL_VAR name="booksellerid" -->" />
<input type="hidden" name="op" value="validate" />
<table>
<tr>
<th>order information</th>
<th>basket name</th>
<th>uncertain price</th>
<th>price</th>
<th>quantity</th>
</tr>
<!-- TMPL_LOOP name="uncertainpriceorders" -->
<tr>
<td>
<!-- TMPL_VAR name="bibtitle" --> / <!-- TMPL_VAR name="bibauthor" --> <br /> <!-- TMPL_VAR name="bibpublishercode" -->, <!-- TMPL_VAR name="bibpublicationyear" --><br /><!-- TMPL_VAR name="bibisbn" --><br />
<a href="neworderempty.pl?ordnum=<!-- TMPL_VAR name="ordernumber" -->&booksellerid=<!-- TMPL_VAR name="booksellerid" -->&basketno=<!-- TMPL_VAR name="basketno" -->">
edit
</a>
</td>
<td>
<!-- TMPL_VAR name="basketname" -->
</td>
<td>
<input type="checkbox" name="uncertainprice<!-- TMPL_VAR name="ordernumber" -->" value="1" checked>
</td>
<td>
<input type="text" size="10" name="price<!-- TMPL_VAR name="ordernumber"-->" value="<!-- TMPL_VAR name="listprice" -->"
onChange="uncheckbox(this.form, <!-- TMPL_VAR name="ordernumber" -->);" />
</td>
<td>
<input type="text" size="10" name="qty<!-- TMPL_VAR name="ordernumber"-->" value="<!-- TMPL_VAR name="quantity" -->"
onChange="uncheckbox(this.form, <!-- TMPL_VAR name="ordernumber" -->);" />
</td>
</tr>
<!-- /TMPL_LOOP -->
</table>
<input type="button" value="Save" onclick="check(this.form)" />
</form>
<!-- /TMPL_IF -->
</div>
</div>
</div>
</body>
</html>