Adding parcels list to recieveorder.pl

getparcels is cutout for that matter.
Will add tomorrow the receive.pl making the proper actions.
This commit is contained in:
hdl 2006-02-14 17:07:24 +00:00
parent 7abe705bee
commit ba0fcee95a
3 changed files with 184 additions and 4 deletions

View File

@ -23,6 +23,7 @@ use C4::Context;
use C4::Date;
use MARC::Record;
use C4::Suggestions;
use Smart::Comments;
# use C4::Biblio;
use vars qw($VERSION @ISA @EXPORT);
@ -60,7 +61,8 @@ orders, converting money to different currencies, and so forth.
&updaterecorder &newordernum
&getsupplierlistwithlateorders
&getlateorders
&getparcels
&bookfunds &curconvert &getcurrencies &bookfundbreakdown
&updatecurrencies &getcurrency
@ -1115,6 +1117,42 @@ sub insertsup {
return($data->{'id'});
}
=item getparcels
($count, $results) = &getparcels($dbh, $bookseller, $order, $limit);
get a lists of parcels
Returns the count of parcels returned and a pointer on a hash list containing parcel informations as such :
Creation date
Last operation
Number of biblio
Number of items
=cut
#'
sub getparcels {
my ($bookseller, $order, $code,$datefrom,$dateto, $limit)=@_;
my $dbh = C4::Context->dbh;
my $strsth = "SELECT aqorders.booksellerinvoicenumber, datereceived, count(DISTINCT biblionumber) as biblio, sum(quantity) as itemsexpected, sum(quantityreceived) as itemsreceived from aqorders, aqbasket where aqbasket.basketno = aqorders.basketno and aqbasket.booksellerid = $bookseller and datereceived is not null ";
$strsth .= "and aqorders.booksellerinvoicenumber like \"$code%\" " if ($code);
$strsth .= "and datereceived >=".$dbh->quote($datefrom)." " if ($datefrom);
$strsth .= "and datereceived <=".$dbh->quote($dateto)." " if ($dateto);
$strsth .= "group by aqorders.booksellerinvoicenumber,datereceived ";
$strsth .= "order by $order " if ($order);
$strsth .= " LIMIT 0,$limit" if ($limit);
my $sth=$dbh->prepare($strsth);
### getparcels: $strsth
$sth->execute;
my @results;
while (my $data2=$sth->fetchrow_hashref) {
push @results, $data2;
}
$sth->finish;
return(scalar(@results), @results);
}
END { } # module clean-up code here (global destructor)
1;

View File

@ -30,9 +30,17 @@ use C4::Interface::CGI::Output;
use C4::Database;
use HTML::Template;
use C4::Acquisition;
use Smart::Comments;
my $input=new CGI;
my $supplierid=$input->param('supplierid');
my $order=$input->param('orderby');
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 ($count,@booksellers)=bookseller($supplierid);
my ($template, $loggedinuser, $cookie)
@ -44,6 +52,71 @@ my ($template, $loggedinuser, $cookie)
debug => 1,
});
$resultsperpage = 20 unless ($resultsperpage);
my ($count,@results)=getparcels($supplierid, $order, $code,$datefrom,$dateto);
# multi page display gestion
$startfrom=0 unless ($startfrom);
if ($count>$resultsperpage){
my $displaynext=0;
my $displayprev=$startfrom;
if(($count - ($startfrom+$resultsperpage)) > 0 ) {
$displaynext = 1;
}
my @numbers = ();
if ($count>$resultsperpage) {
for (my $i=1; $i<$count/$resultsperpage+1; $i++) {
if ($i<16) {
my $highlight=0;
($startfrom/$resultsperpage==($i-1)) && ($highlight=1);
push @numbers, { number => $i,
highlight => $highlight ,
# searchdata=> "test",
startfrom => ($i-1)*$resultsperpage};
}
}
}
my $from = $startfrom*$resultsperpage+1;
my $to;
if($count < (($startfrom+1)*$resultsperpage))
{
$to = $count;
} else {
$to = (($startfrom+1)*$resultsperpage);
}
$template->param(numbers=>\@numbers,
displaynext=>$displaynext,
displayprev=>$displayprev,
nextstartfrom=>(($startfrom+$resultsperpage<$count)?$startfrom+$resultsperpage:$count),
prevstartfrom=>(($startfrom-$resultsperpage>0)?$startfrom-$resultsperpage:0)
);
}
my @loopres;
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{datereceived}=$results[$i]->{datereceived};
$cell{bibcount}=$results[$i]->{biblio};
$cell{reccount}=$results[$i]->{itemsreceived};
$cell{itemcount}=$results[$i]->{itemsexpected};
push @loopres, \%cell;
}
$template->param(searchresults=>\@loopres, count=>$count) if ($count);
$template->param(orderby=>$order, filter=>$code, datefrom=>$datefrom,dateto=>$dateto, resultsperpage=>$resultsperpage);
$template->param(
name => $booksellers[0]->{'name'},
supplierid => $supplierid,

View File

@ -1,13 +1,82 @@
<!-- TMPL_INCLUDE name="acquisitions-top.inc" -->
<div id="mainbloc">
<h1 class="acquisition">Receive Orders From Supplier <a href="/cgi-bin/koha/acqui/supplier.pl?supplierid=<!-- TMPL_VAR NAME="supplierid" -->"><!-- TMPL_VAR NAME="name" --></a></h1>
<!-- TMPL_IF NAME="count" --><p> <!-- TMPL_VAR NAME="count" --> parcels found</p><!--/TMPL_IF-->
<div id="resultnumber">
<!-- Row of numbers corresponding to search result pages -->
<!-- TMPL_IF NAME="displayprev" -->
<a href="recieveorder.pl?supplierid=<!-- TMPL_VAR NAME="supplierid" -->&amp;startfrom=<!-- TMPL_VAR NAME="prevstartfrom" --><!--TMPL_IF Name="datefrom"-->&amp;datefrom=<!--TMPL_VAR Name="datefrom"--><!--/TMPL_IF--><!--TMPL_IF Name="dateto"-->&amp;dateto=<!--TMPL_VAR Name="dateto"--><!--/TMPL_IF--><!--TMPL_IF Name="code"-->&amp;filter=<!--TMPL_VAR Name="code"--><!--/TMPL_IF--><!--TMPL_IF Name="orderby"-->&amp;orderby=<!--TMPL_VAR Name="orderby"--><!--/TMPL_IF--><!--TMPL_IF Name="resultsperpage"-->&amp;resultsperpage=<!--TMPL_VAR Name="resultsperpage"--><!--/TMPL_IF-->&amp;type=intra"><img src="<!-- TMPL_VAR NAME="themelang" -->/images/numbers/prev.gif" border="0"></a>
<!-- TMPL_ELSE -->
<img src="<!-- TMPL_VAR NAME="themelang" -->/images/numbers/placeholder.gif" border="0">
<!-- /TMPL_IF -->
<!-- TMPL_LOOP NAME="numbers" -->
<!-- TMPL_IF NAME="highlight" -->
<img src="<!-- TMPL_VAR NAME="themelang" -->/images/numbers/<!-- TMPL_VAR NAME="number" -->-highlight.gif">
<!-- TMPL_ELSE -->
<a href="recieveorder.pl?supplierid=<!-- TMPL_VAR NAME="supplierid" -->&amp;startfrom=<!-- TMPL_VAR NAME="startfrom" --><!--TMPL_IF Name="datefrom"-->&amp;datefrom=<!--TMPL_VAR Name="datefrom"--><!--/TMPL_IF--><!--TMPL_IF Name="dateto"-->&amp;dateto=<!--TMPL_VAR Name="dateto"--><!--/TMPL_IF--><!--TMPL_IF Name="code"-->&amp;filter=<!--TMPL_VAR Name="code"--><!--/TMPL_IF--><!--TMPL_IF Name="orderby"-->&amp;orderby=<!--TMPL_VAR Name="orderby"--><!--/TMPL_IF--><!--TMPL_IF Name="resultsperpage"-->&amp;resultsperpage=<!--TMPL_VAR Name="resultsperpage"--><!--/TMPL_IF-->&amp;type=intra"><img src="<!-- TMPL_VAR NAME="themelang" -->/images/numbers/<!-- TMPL_VAR NAME="number" -->.gif" border="0"></a>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
<!-- TMPL_IF NAME="displaynext" -->
<a href="recieveorder.pl?supplierid=<!-- TMPL_VAR NAME="supplierid" -->&amp;startfrom=<!-- TMPL_VAR NAME="nextstartfrom" --><!--TMPL_IF Name="datefrom"-->&amp;datefrom=<!--TMPL_VAR Name="datefrom"--><!--/TMPL_IF--><!--TMPL_IF Name="dateto"-->&amp;dateto=<!--TMPL_VAR Name="dateto"--><!--/TMPL_IF--><!--TMPL_IF Name="code"-->&amp;filter=<!--TMPL_VAR Name="code"--><!--/TMPL_IF--><!--TMPL_IF Name="orderby"-->&amp;orderby=<!--TMPL_VAR Name="orderby"--><!--/TMPL_IF--><!--TMPL_IF Name="resultsperpage"-->&amp;resultsperpage=<!--TMPL_VAR Name="resultsperpage"--><!--/TMPL_IF-->&amp;type=intra"><img src="<!-- TMPL_VAR NAME="themelang" -->/images/numbers/next.gif" border="0"></a>
<!-- TMPL_ELSE -->
<img src="<!-- TMPL_VAR NAME="themelang" -->/images/numbers/placeholder.gif" border="0">
<!-- /TMPL_IF -->
</div>
<div id="resultlist">
<!-- Search Results Table -->
<!-- TMPL_IF NAME="count" -->
<form method="post" action="recieveorder.pl">
<table>
<tr>
<th class="acquisition">Number</th><th class="acquisition">Code</th><th class="acquisition">Date Received</th><th class="acquisition">Item Count</th><th class="acquisition">Biblio count</th><th class="acquisition">Items expected</th>
</tr>
<tr>
<th class="acquisition">&nbsp;<input type="hidden" name="supplierid" value=<!-- TMPL_VAR NAME="supplierid" -->></th><th class="acquisition"><input type="text" size="20" name="filter" value="<!-- TMPL_VAR NAME="filter" -->"></th>
<th class="acquisition">From :<input type="text" size="9" name="datefrom" value="<!-- TMPL_VAR NAME="datefrom" -->"> <p>To :<input type="text" size="9" name="dateto" value="<!-- TMPL_VAR NAME="dateto" -->"></th><th class="acquisition">&nbsp;</th><th class="acquisition">Sort by :<select name="orderby" size="1">
<option value="aqorders.booksellerinvoicenumber"> Code</option>
<option value="datereceived"> Date Received</option>
<option value="datereceived desc"> Date Received reverse</option>
<option value="aqorders.booksellerinvoicenumber desc"> Code reverse</option>
</select><br />
Results per page :<select name="resultsperpage" value ="<!--TMPL_VAR Name="resultsperpage"-->" size="1">
<option value="20">20</option>
<option value="30">30</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
</th><th class="acquisition"><input type="submit" class="button acquisition" value="Filter">
</th>
</tr>
<!-- Actual Search Results -->
<!-- TMPL_LOOP NAME="searchresults" -->
<tr>
<td <!-- TMPL_IF NAME="even" -->class="hilighted"<!-- /TMPL_IF -->>
<a href="/cgi-bin/koha/acqui/receive.pl?type=intra&amp;supplierid=<!-- TMPL_VAR NAME="supplierid" ESCAPE=URL -->&amp;datereceived=<!-- TMPL_VAR NAME="datereceived" ESCAPE=URL -->"<!--TMPL_IF Name="code"-->&amp;code=<!--TMPL_VAR Name="Code" ESCAPE=URL --><!--/TMPL_IF-->>
<!-- TMPL_VAR NAME="number" -->
</a>
</td>
<td <!-- TMPL_IF NAME="even" -->class="hilighted"<!-- /TMPL_IF -->>
<!--TMPL_IF Name="code"--><!--TMPL_VAR Name="code" --><!--/TMPL_IF-->
</td>
<td <!-- TMPL_IF NAME="even" -->class="hilighted"<!-- /TMPL_IF -->> <!-- TMPL_VAR NAME="datereceived" --> </td>
<td <!-- TMPL_IF NAME="even" -->class="hilighted"<!-- /TMPL_IF -->> <!-- TMPL_VAR NAME="reccount" --> </td>
<td <!-- TMPL_IF NAME="even" -->class="hilighted"<!-- /TMPL_IF -->><!-- TMPL_VAR NAME="bibcount" -->
</td>
<td <!-- TMPL_IF NAME="even" -->class="hilighted"<!-- /TMPL_IF -->><!-- TMPL_VAR NAME="itemcount" -->
</td>
</tr>
<!-- /TMPL_LOOP -->
</table>
</form>
<!--/TMPL_IF-->
<div id="bloc25">
<h2 class="acquisition"> Receive a new Parcel </h2>
<form method="get" action="receive.pl">
<p>
<input type="hidden" name="supplierid" value=<!-- TMPL_VAR NAME="supplierid" -->>
<h2 class="acquisition">Supplier invoice information</h2>
<p>
<label>Supplier Invoice Number</label>
<label>Parcel Code</label>
<input type="text" size="20" name="invoice">
</p>
<p>