# 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
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# test comment
use strict;
+#use warnings; FIXME - Bug 2505
use C4::Auth;
use CGI;
use C4::Context;
-
+use C4::Reports;
use C4::Output;
use C4::Koha;
use C4::Circulation;
my $output = $input->param("output");
my $basename = $input->param("basename");
my $mime = $input->param("MIME");
-my $del = $input->param("sep");
#warn "calcul : ".$calc;
my ($template, $borrowernumber, $cookie)
query => $input,
type => "intranet",
authnotrequired => 0,
- flagsrequired => {reports => 1},
+ flagsrequired => {reports => '*'},
debug => 1,
});
+our $sep = $input->param("sep");
+$sep = "\t" if ($sep eq 'tabulation');
$template->param(do_it => $do_it,
DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
);
if ($do_it) {
- # warn "line=$line, col=$column, pod=$podsp, rod=$rodsp, aod=$aodsp, calc=$calc, filters=@filters\n";
my $results =
calculate( $line, $column, $podsp, $rodsp, $aodsp, $calc, \@filters );
if ( $output eq "screen" ) {
);
my $cols = @$results[0]->{loopcol};
my $lines = @$results[0]->{looprow};
- my $sep;
- $sep = C4::Context->preference("delimiter");
print @$results[0]->{line} . "/" . @$results[0]->{column} . $sep;
foreach my $col (@$cols) {
print $col->{coltitle} . $sep;
-multiple => 0
);
- $req = $dbh->prepare("SELECT DISTINCTROW bookfundid,bookfundname FROM aqbookfund ORDER BY bookfundname");
+ $req = $dbh->prepare("SELECT DISTINCTROW budget_code, budget_name FROM aqbudgets ORDER BY budget_name");
$req->execute;
undef @select;
undef %select;
push @select, "";
- $select{''} = "All Funds";
+ $select{''} = "All budgets";
while ( my ( $value, $desc ) = $req->fetchrow ) {
push @select, $value;
-multiple => 0
);
- my @dels = ( C4::Context->preference("delimiter") );
- my $CGIsepChoice = CGI::scrolling_list(
- -name => 'sep',
- -id => 'sep',
- -values => \@dels,
- -size => 1,
- -multiple => 0
- );
+ my $CGIsepChoice = GetDelimiterChoices;
$template->param(
CGIBookSeller => $CGIBookSellers,
$linefilter[0] = @$filters[4] if ( $line =~ /bookseller/ );
$linefilter[0] = @$filters[5] if ( $line =~ /itemtype/ );
- $linefilter[0] = @$filters[6] if ( $line =~ /bookfund/ );
+ $linefilter[0] = @$filters[6] if ( $line =~ /budget/ );
$linefilter[0] = @$filters[7] if ( $line =~ /sort1/ );
$linefilter[0] = @$filters[8] if ( $line =~ /sort2/ );
# $colfilter[1] = @$filters[5] if ( $column =~ /acquired/ );
$colfilter[0] = @$filters[4] if ( $column =~ /bookseller/ );
$colfilter[0] = @$filters[5] if ( $column =~ /itemtype/ );
- $colfilter[0] = @$filters[6] if ( $column =~ /bookfund/ );
+ $colfilter[0] = @$filters[6] if ( $column =~ /budget/ );
$colfilter[0] = @$filters[7] if ( $column =~ /sort1/ );
$colfilter[0] = @$filters[8] if ( $column =~ /sort2/ );
my $strsth;
$strsth .=
- "SELECT DISTINCTROW $linefield FROM (aqorders, aqbasket,aqorderbreakdown)
+ "SELECT DISTINCTROW $linefield FROM (aqorders, aqbasket )
LEFT JOIN items ON (aqorders.biblionumber= items.biblionumber)
LEFT JOIN biblioitems ON (aqorders.biblionumber= biblioitems.biblionumber)
+ LEFT JOIN aqbudgets ON (aqorders.budget_id = aqbudgets.budget_id )
+
LEFT JOIN aqbooksellers ON (aqbasket.booksellerid=aqbooksellers.id) WHERE (aqorders.basketno=aqbasket.basketno)
- AND (aqorderbreakdown.ordernumber=aqorders.ordernumber) AND $line IS NOT NULL ";
+ AND $line IS NOT NULL AND $line <> '' ";
# LEFT JOIN aqorderdelivery ON (aqorders.ordernumber =aqorderdelivery.ordernumber )
$colfield .= "Year($column)";
}
- elsif ( ( $column =~ /deliverydate/ ) and ( $rodsp == 1 ) ) {
+ elsif ( ( $column =~ /received/ ) and ( $rodsp == 1 ) ) {
#Display by day
$colfield .= "dayname($column)";
}
- elsif ( ( $column =~ /deliverydate/ ) and ( $rodsp == 2 ) ) {
+ elsif ( ( $column =~ /received/ ) and ( $rodsp == 2 ) ) {
#Display by Month
$colfield .= "monthname($column)";
}
- elsif ( ( $column =~ /deliverydate/ ) and ( $rodsp == 3 ) ) {
+ elsif ( ( $column =~ /received/ ) and ( $rodsp == 3 ) ) {
#Display by Year
$colfield .= "Year($column)";
my $strsth2;
$strsth2 .=
- "SELECT distinctrow $colfield FROM (aqorders, aqbasket,aqorderbreakdown)
+ "SELECT distinctrow $colfield FROM (aqorders, aqbasket )
LEFT JOIN items ON (aqorders.biblionumber= items.biblionumber)
LEFT JOIN biblioitems ON (aqorders.biblionumber= biblioitems.biblionumber)
+ LEFT JOIN aqbudgets ON (aqorders.budget_id = aqbudgets.budget_id )
+
LEFT JOIN aqbooksellers ON (aqbasket.booksellerid=aqbooksellers.id)
- WHERE (aqorders.basketno=aqbasket.basketno) AND (aqorderbreakdown.ordernumber=aqorders.ordernumber)
- AND $column IS NOT NULL";
+ WHERE (aqorders.basketno=aqbasket.basketno) AND
+ $column IS NOT NULL AND $column <> '' ";
# LEFT JOIN aqorderdelivery ON (aqorders.ordernumber =aqorderdelivery.ordernumber )
$strsth2 .= " AND $column LIKE ? ";
}
}
+
+
$strsth2 .= " GROUP BY $colfield";
$strsth2 .= " ORDER BY $colfield";
-# warn "MASON:. $strsth2";
-
my $sth2 = $dbh->prepare($strsth2);
+
if ( (@colfilter) and ($colfilter[1]) ) {
$sth2->execute( $colfilter[0], $colfilter[1] );
}
my %cell;
if ($celvalue) {
$cell{coltitle} = $celvalue;
- #warn "\$cell{coltitle} = $celvalue\n";
push @loopcol, \%cell;
}
}
-
# warn "fin des titres colonnes";
my $i = 0;
# warn "init table...\n";
foreach my $row (@loopline) {
foreach my $col (@loopcol) {
- #warn " init table : $row->{rowtitle} / $col->{coltitle} \n";
$table{ $row->{rowtitle} }->{ $col->{coltitle} } = 0;
}
$table{ $row->{rowtitle} }->{totalrow} = 0;
$strcalc .= "SUM( aqorders.quantity ) " if ( $process == 1 );
$strcalc .= "SUM( aqorders.quantity * aqorders.listprice ) "
if ( $process == 2 );
- $strcalc .= "FROM (aqorders, aqbasket,aqorderbreakdown)
+ $strcalc .= "FROM (aqorders, aqbasket )
LEFT JOIN items ON (aqorders.biblionumber= items.biblionumber)
LEFT JOIN biblioitems ON (aqorders.biblionumber= biblioitems.biblionumber)
- LEFT JOIN aqbooksellers ON (aqbasket.booksellerid=aqbooksellers.id) WHERE (aqorders.basketno=aqbasket.basketno)
- AND (aqorderbreakdown.ordernumber=aqorders.ordernumber) ";
+ LEFT JOIN aqbudgets ON (aqorders.budget_id = aqbudgets.budget_id )
+
+ LEFT JOIN aqbooksellers ON (aqbasket.booksellerid=aqbooksellers.id)
+ WHERE (aqorders.basketno=aqbasket.basketno) ";
# LEFT JOIN aqorderdelivery ON (aqorders.ordernumber =aqorderdelivery.ordernumber )
$strcalc .= " AND aqbasket.closedate <= '" . @$filters[1] . "'"
if ( @$filters[1] );
@$filters[2] =~ s/\*/%/g if ( @$filters[2] );
- $strcalc .= " AND aqorderbreakdown.datereceived >= '" . @$filters[2] . "'"
+ $strcalc .= " AND aqorders.datereceived >= '" . @$filters[2] . "'"
if ( @$filters[2] );
@$filters[3] =~ s/\*/%/g if ( @$filters[3] );
- $strcalc .= " AND aqorderbreakdown.datereceived <= '" . @$filters[3] . "'"
+ $strcalc .= " AND aqorders.datereceived <= '" . @$filters[3] . "'"
if ( @$filters[3] );
# @$filters[4] =~ s/\*/%/g if ( @$filters[4] );
# $strcalc .= " AND aqbasket.closedate >= '" . @$filters[4] . "'"
$strcalc .= " AND biblioitems.itemtype LIKE '" . @$filters[5] . "'"
if ( @$filters[5] );
@$filters[6] =~ s/\*/%/g if ( @$filters[6] );
- $strcalc .= " AND aqorderbreakdown.bookfundid LIKE '" . @$filters[6] . "'"
+ $strcalc .= " AND aqbudgets.budget_code LIKE '" . @$filters[6] . "'"
if ( @$filters[6] );
@$filters[7] =~ s/\*/%/g if ( @$filters[7] );
$strcalc .= " AND aqorders.sort1 LIKE '" . @$filters[7] . "'"
@$filters[8] =~ s/\*/%/g if ( @$filters[8] );
$strcalc .= " AND aqorders.sort2 LIKE '" . @$filters[8] . "'"
if ( @$filters[8] );
+
+ $strcalc .= " AND aqorders.datecancellationprinted is NULL ";
+
$strcalc .= " GROUP BY $linefield, $colfield ORDER BY $linefield,$colfield";
# warn $strcalc . "\n";
+
my $dbcalc = $dbh->prepare($strcalc);
$dbcalc->execute;
# warn "filling table";
my $emptycol;
while ( my ( $row, $col, $value ) = $dbcalc->fetchrow ) {
- #warn "filling table $row / $col / $value ";
- $emptycol = 1 if ( $col eq undef );
- $col = "zzEMPTY" if ( $col eq undef );
- $row = "zzEMPTY" if ( $row eq undef );
+ next if ($row eq undef || $col eq undef);
+
+# warn "filling table $row / $col / $value ";
+
+ $emptycol = 1 if ( !defined($col) );
+ $col = "zzEMPTY" if ( !defined($col) );
+ $row = "zzEMPTY" if ( !defined($row) );
$table{$row}->{$col} += $value;
$table{$row}->{totalrow} += $value;