3 #written 7/3/2002 by Finlay
4 #script to display reports
9 use C4::Circulation::Circ2;
12 # get all the data ....
15 my $secondary='#ffffcc';
18 my $itm = $input->param('itm');
19 my $bi = $input->param('bi');
20 my $bib = $input->param('bib');
21 my $branches = getbranches(\%env);
23 my $idata = itemdatanum($itm);
24 my $data = bibitemdata($bi);
26 my $homebranch = $branches->{$idata->{'homebranch'}}->{'branchname'};
27 my $holdingbranch = $branches->{$idata->{'holdingbranch'}}->{'branchname'};
29 my ($lastmove, $message) = lastmove($itm);
35 $count = issuessince($itm , 0);
37 $lastdate = $lastmove->{'datearrived'};
38 $count = issuessince($itm ,$lastdate);
47 print startmenu('report');
52 <FONT SIZE=6><em><a href=/cgi-bin/koha/detail.pl?bib=$bib&type=intra>$data->{'title'} ($data->{'author'})</a></em></FONT><P>
54 <img src="/images/holder.gif" width=16 height=200 align=left>
55 <TABLE CELLSPACING=0 CELLPADDING=5 border=1 width=440 >
56 <TR VALIGN=TOP><td bgcolor="99cc33" background="/images/background-mem.gif">
57 <B>BARCODE $idata->{'barcode'}</b></TD>
62 <b>Home Branch: </b> $homebranch <br>
63 <b>Current Branch: </b> $holdingbranch<br>
64 <b>Date arrived at current branch: </b> $lastdate <br>
65 <b>Number of issues since since the above date :</b> $count <br>
67 <table cellspacing =0 cellpadding=5 border=1 width = 440>
68 <TR><TD > <b>Branch</b></td> <TD > <b>No. of Issues</b></td> <td><b>Last seen at branch</b></td></TR>
71 foreach my $branchcode (keys %$branches) {
72 my $issues = issuesat($itm, $branchcode);
73 my $date = lastseenat($itm, $branchcode);
74 my $seen = slashdate($date);
76 <TR><TD > <b>$branches->{$branchcode}->{'branchname'}</b></td>
77 <TD > <b> $issues </b></td> <td><b> $seen</b></td></TR>
88 print endmenu('report');
92 ##############################################
93 # This stuff should probably go into C4::Search
101 my $itm = $dbh->quote("$itemnumber");
102 my $query = "select * from items where itemnumber=$itm";
103 my $sth=$dbh->prepare($query);
105 my $data=$sth->fetchrow_hashref;
114 my $var1 = $dbh->quote($itemnumber);
115 my $sth =$dbh->prepare("select max(branchtransfers.datearrived) from branchtransfers where branchtransfers.itemnumber=$var1");
117 my ($date) = $sth->fetchrow_array;
118 return(0, "Item has no branch transfers record") if not $date;
119 my $var2 = $dbh->quote($date);
120 $sth=$dbh->prepare("Select * from branchtransfers where branchtransfers.itemnumber=$var1 and branchtransfers.datearrived=$var2");
122 my ($data) = $sth->fetchrow_hashref;
123 return(0, "Item has no branch transfers record") if not $data;
130 my ($itemnumber, $date)=@_;
132 my $itm = $dbh->quote($itemnumber);
133 my $dat = $dbh->quote($date);
134 my $sth=$dbh->prepare("Select count(*) from issues where issues.itemnumber=$itm and issues.timestamp > $dat");
136 my $count=$sth->fetchrow_hashref;
139 return($count->{'count(*)'});
143 my ($itemnumber, $brcd)=@_;
145 my $itm = $dbh->quote($itemnumber);
146 my $brc = $dbh->quote($brcd);
147 my $query = "Select count(*) from issues where itemnumber=$itm and branchcode = $brc";
148 my $sth=$dbh->prepare($query);
150 my ($count)=$sth->fetchrow_array;
157 my ($itemnumber, $brcd)=@_;
159 my $itm = $dbh->quote($itemnumber);
160 my $brc = $dbh->quote($brcd);
161 my $query = "Select max(timestamp) from issues where itemnumber=$itm and branchcode = $brc";
162 my $sth=$dbh->prepare($query);
164 my ($date1)=$sth->fetchrow_array;
166 $query = "Select max(datearrived) from branchtransfers where itemnumber=$itm and tobranch = $brc";
167 my $sth=$dbh->prepare($query);
169 my ($date2)=$sth->fetchrow_array;
176 if ($date1 < $date2) {
185 #####################################################
192 my ($yr, $mo, $da, $hr, $mi) = (substr($date, 0, 4), substr($date, 4, 2), substr($date, 6, 2), substr($date, 8, 2), substr($date, 10, 2));
193 return "$hr:$mi $da/$mo/$yr";