View | Details | Raw Unified | Return to bug 6984
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reserves_stats.tt (-14 / +14 lines)
Lines 89-106 Link Here
89
                <td><input type="radio" name="Line" value="reservestatus" /></td>
89
                <td><input type="radio" name="Line" value="reservestatus" /></td>
90
                <td><input type="radio" name="Column" value="reservestatus" checked="checked" /></td>
90
                <td><input type="radio" name="Column" value="reservestatus" checked="checked" /></td>
91
                <td>
91
                <td>
92
				<input type="checkbox" name="filter_reservestatus_or_1" value="1"> Asked</input>
92
				<input type="checkbox" name="filter_reservestatus_or_1" value="1" /> Asked
93
				<input type="checkbox" name="filter_reservestatus_or_2" value="2"> Processing</input>
93
				<input type="checkbox" name="filter_reservestatus_or_2" value="2" /> Processing
94
				<input type="checkbox" name="filter_reservestatus_or_3" value="3"> Waiting</input>
94
				<input type="checkbox" name="filter_reservestatus_or_3" value="3" /> Waiting
95
				<input type="checkbox" name="filter_reservestatus_or_4" value="4"> Satisfied</input>
95
				<input type="checkbox" name="filter_reservestatus_or_4" value="4" /> Satisfied
96
				<input type="checkbox" name="filter_reservestatus_or_5" value="5"> Cancelled</input>
96
				<input type="checkbox" name="filter_reservestatus_or_5" value="5" /> Cancelled
97
				</td>
97
				</td>
98
             </tr>
98
             </tr>
99
             <tr class="highlight">
99
             <tr class="highlight">
100
                <td>Hold Date</td>
100
                <td>Hold Date</td>
101
                <td><input type="radio" name="Line" value="reservedate" /></td>
101
                <td><input type="radio" name="Line" value="reservedate" /></td>
102
                <td><input type="radio" name="Column" value="reservedate" /></td>
102
                <td><input type="radio" name="Column" value="reservedate" /></td>
103
                <td><label for="reservedate_begin">From</label> <input type="text"  size="10" id="filter_reservedate_begin" name="filter_reservedate_begin" />
103
                <td><label for="filter_reservedate_begin">From</label> <input type="text"  size="10" id="filter_reservedate_begin" name="filter_reservedate_begin" />
104
                    <img src="[% themelang %]/lib/calendar/cal.gif" alt="Show Calendar" border="0" id="openreservedateFrom" style="cursor: pointer;" />
104
                    <img src="[% themelang %]/lib/calendar/cal.gif" alt="Show Calendar" border="0" id="openreservedateFrom" style="cursor: pointer;" />
105
                   <script type="text/javascript">
105
                   <script type="text/javascript">
106
				   //<![CDATA[ 
106
				   //<![CDATA[ 
Lines 424-430 Link Here
424
            <td><input type="radio" name="Column" value="items.itype" /></td>
424
            <td><input type="radio" name="Column" value="items.itype" /></td>
425
           <td><select name="filter_items.itype" id="itype">
425
           <td><select name="filter_items.itype" id="itype">
426
               <option value=""> </option>
426
               <option value=""> </option>
427
               [% FOREACH itypeloo IN itypeloop %]
427
               [% FOREACH itypeloo IN itemtypeloop %]
428
                 [% IF ( itypeloo.selected ) %]<option value="[% itypeloo.code %]" selected="selected">[% itypeloo.description %]</option>[% ELSE %]<option value="[% itypeloo.code %]">[% itypeloo.description %]</option>[% END %]
428
                 [% IF ( itypeloo.selected ) %]<option value="[% itypeloo.code %]" selected="selected">[% itypeloo.description %]</option>[% ELSE %]<option value="[% itypeloo.code %]">[% itypeloo.description %]</option>[% END %]
429
               [% END %]
429
               [% END %]
430
               </select>
430
               </select>
Lines 444-452 Link Here
444
        </tr>
444
        </tr>
445
        <tr class="highlight">
445
        <tr class="highlight">
446
            <td>Holding Library</td>
446
            <td>Holding Library</td>
447
            <td><input type="radio" name="Line" value="holdingbranch" /></td>
447
            <td><input type="radio" name="Line" value="items.holdingbranch" /></td>
448
            <td><input type="radio" name="Column" value="holdingbranch" /></td>
448
            <td><input type="radio" name="Column" value="items.holdingbranch" /></td>
449
            <td><select name="filter_holdingbranch" id="holdingbranch">
449
            <td><select name="filter_items.holdingbranch" id="holdingbranch">
450
               <option value=""> </option>
450
               <option value=""> </option>
451
               [% FOREACH branchloo IN branchloop %]
451
               [% FOREACH branchloo IN branchloop %]
452
[% IF ( branchloo.selected ) %]<option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>[% ELSE %]<option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %]
452
[% IF ( branchloo.selected ) %]<option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>[% ELSE %]<option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %]
Lines 456-464 Link Here
456
        </tr>
456
        </tr>
457
        <tr>
457
        <tr>
458
            <td>Home Library</td>
458
            <td>Home Library</td>
459
            <td><input type="radio" name="Line" value="homebranch" /></td>
459
            <td><input type="radio" name="Line" value="items.homebranch" /></td>
460
            <td><input type="radio" name="Column" value="homebranch" /></td>
460
            <td><input type="radio" name="Column" value="items.homebranch" /></td>
461
            <td><select name="filter_homebranch" id="homebranch">
461
            <td><select name="filter_items.homebranch" id="homebranch">
462
               <option value=""> </option>
462
               <option value=""> </option>
463
               [% FOREACH branchloo IN branchloop %]
463
               [% FOREACH branchloo IN branchloop %]
464
[% IF ( branchloo.selected ) %]<option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>[% ELSE %]<option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %]
464
[% IF ( branchloo.selected ) %]<option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>[% ELSE %]<option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %]
Lines 494-500 Link Here
494
            <td>Item Call Number</td>
494
            <td>Item Call Number</td>
495
            <td></td>
495
            <td></td>
496
            <td></td>
496
            <td></td>
497
            <td>From <input type="text" name="filter_itemcallnumber" size="10" /> (inclusive) to <input type="text" name="fiter_itemcallnumber" size="10" /> (exclusive) </td>
497
            <td>From <input type="text" name="filter_items.itemcallnumber_begin" size="10" /> (inclusive) to <input type="text" name="filter_items.itemcallnumber_endex" size="10" /> (exclusive) </td>
498
        </tr>
498
        </tr>
499
        [% IF ( hassort1 ) %]
499
        [% IF ( hassort1 ) %]
500
        <tr><td>Patron sort1</td>
500
        <tr><td>Patron sort1</td>
(-)a/reports/reserves_stats.pl (-35 / +55 lines)
Lines 19-24 Link Here
19
19
20
20
21
use strict;
21
use strict;
22
use warnings;
22
23
23
use CGI;
24
use CGI;
24
25
Lines 74-80 my ($template, $borrowernumber, $cookie) = get_template_and_user({ Link Here
74
	flagsrequired => {reports => '*'},
75
	flagsrequired => {reports => '*'},
75
	debug => 0,
76
	debug => 0,
76
});
77
});
77
our $sep     = $input->param("sep");
78
our $sep     = $input->param("sep") || '';
78
$sep = "\t" if ($sep eq 'tabulation');
79
$sep = "\t" if ($sep eq 'tabulation');
79
$template->param(do_it => $do_it,
80
$template->param(do_it => $do_it,
80
	DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
81
	DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
Lines 169-174 my $CGIsepChoice=GetDelimiterChoices; Link Here
169
$template->param(
170
$template->param(
170
	categoryloop => $categoryloop,
171
	categoryloop => $categoryloop,
171
	itemtypeloop => \@itemtypeloop,
172
	itemtypeloop => \@itemtypeloop,
173
	locationloop => \@locations,
172
	   ccodeloop => \@ccodes,
174
	   ccodeloop => \@ccodes,
173
	  branchloop => GetBranchesLoop(C4::Context->userenv->{'branch'}),
175
	  branchloop => GetBranchesLoop(C4::Context->userenv->{'branch'}),
174
	hassort1=> $hassort1,
176
	hassort1=> $hassort1,
Lines 194-211 sub calculate { Link Here
194
# Filters
196
# Filters
195
# Checking filters
197
# Checking filters
196
#
198
#
197
	my @loopfilter;
199
    my @loopfilter;
198
	foreach my $filter (keys %$filters_hashref){
200
    foreach my $filter ( keys %$filters_hashref ) {
199
		$$filters_hashref{$filter} =~s/\*/%/;
201
        $filters_hashref->{$filter} =~ s/\*/%/;
200
		$$filters_hashref{$filter} = format_date_in_iso($$filters_hashref{$_}) if ($_=~/date/);
202
        $filters_hashref->{$filter} =
201
	}
203
          format_date_in_iso( $filters_hashref->{$filter} )
202
	#display
204
          if ( $filter =~ /date/ );
203
	@loopfilter= map{{ crit=>$_ ,filter=>($_=~/date/?
205
    }
204
											format_date($$filters_hashref{$_})
206
205
											:$$filters_hashref{$_}
207
    #display
206
										  )
208
    @loopfilter = map {
207
					  }
209
        {
208
					} sort keys %$filters_hashref;
210
            crit   => $_,
211
            filter => (
212
                $_ =~ /date/
213
                ? format_date( $filters_hashref->{$_} )
214
                : $filters_hashref->{$_}
215
            )
216
        }
217
    } sort keys %$filters_hashref;
209
218
210
219
211
220
Lines 228-234 sub calculate { Link Here
228
        if ($linefield =~ /^biblio\./ or $colfield =~ /^biblio\./ or any {$_=~/biblio/}keys %$filters_hashref);
237
        if ($linefield =~ /^biblio\./ or $colfield =~ /^biblio\./ or any {$_=~/biblio/}keys %$filters_hashref);
229
	$strcalc .= "LEFT JOIN items ON reserves.itemnumber=items.itemnumber "
238
	$strcalc .= "LEFT JOIN items ON reserves.itemnumber=items.itemnumber "
230
        if ($linefield =~ /^items\./ or $colfield =~ /^items\./ or any {$_=~/items/}keys %$filters_hashref);
239
        if ($linefield =~ /^items\./ or $colfield =~ /^items\./ or any {$_=~/items/}keys %$filters_hashref);
231
        
240
232
	my @sqlparams;
241
	my @sqlparams;
233
	my @sqlorparams;
242
	my @sqlorparams;
234
	my @sqlor;
243
	my @sqlor;
Lines 238-244 sub calculate { Link Here
238
		my $string;
247
		my $string;
239
		my $stringfield=$filter;
248
		my $stringfield=$filter;
240
		$stringfield=~s/\_[a-z_]+$//;
249
		$stringfield=~s/\_[a-z_]+$//;
241
		warn $stringfield;
242
		if ($filter=~/ /){
250
		if ($filter=~/ /){
243
			$string=$stringfield;
251
			$string=$stringfield;
244
		}
252
		}
Lines 246-251 sub calculate { Link Here
246
			 push @sqlor, qq{( }.changeifreservestatus($filter)." = ? ) ";
254
			 push @sqlor, qq{( }.changeifreservestatus($filter)." = ? ) ";
247
			 push @sqlorparams, $$filters_hashref{$filter};
255
			 push @sqlorparams, $$filters_hashref{$filter};
248
		}
256
		}
257
		elsif ($filter=~/_endex$/){
258
			$string = " $stringfield < ? ";
259
		}
249
		elsif ($filter=~/_end$/){
260
		elsif ($filter=~/_end$/){
250
			$string = " $stringfield <= ? ";
261
			$string = " $stringfield <= ? ";
251
		}
262
		}
Lines 274-280 sub calculate { Link Here
274
	$dbcalc->execute(@sqlparams,@sqlparams);
285
	$dbcalc->execute(@sqlparams,@sqlparams);
275
	my ($emptycol,$emptyrow); 
286
	my ($emptycol,$emptyrow); 
276
	my $data = $dbcalc->fetchall_hashref([qw(line col)]);
287
	my $data = $dbcalc->fetchall_hashref([qw(line col)]);
277
	my @loopline;
278
	my %cols_hash;
288
	my %cols_hash;
279
	foreach my $row (keys %$data){
289
	foreach my $row (keys %$data){
280
		push @loopline, $row;
290
		push @loopline, $row;
Lines 304-317 sub calculate { Link Here
304
	for my $col ( sort keys %cols_hash ) {
314
	for my $col ( sort keys %cols_hash ) {
305
		my $total = 0;
315
		my $total = 0;
306
		foreach my $row (@loopline) {
316
		foreach my $row (@loopline) {
307
			$total += $$data{$row}{$col}{calculation};
317
			$total += $data->{$row}{$col}{calculation} if $data->{$row}{$col}{calculation};
308
			$debug and warn "value added ".$$data{$row}{$col}{calculation}. "for line ".$row;
318
			$debug and warn "value added ".$$data{$row}{$col}{calculation}. "for line ".$row;
309
		}
319
		}
310
		push @loopfooter, {'totalcol' => $total};
320
		push @loopfooter, {'totalcol' => $total};
311
		push @loopcol, {'coltitle' => $col,
321
		push @loopcol, {'coltitle' => $col,
312
						coltitle_display=>display_value($colfield,$col)};
322
						coltitle_display=>display_value($colfield,$col)};
313
	}
323
	}
314
315
	# the header of the table
324
	# the header of the table
316
	$globalline{loopfilter}=\@loopfilter;
325
	$globalline{loopfilter}=\@loopfilter;
317
	# the core of the table
326
	# the core of the table
Lines 331-352 sub null_to_zzempty ($) { Link Here
331
	($string eq "NULL") and return 'zzEMPTY';
340
	($string eq "NULL") and return 'zzEMPTY';
332
	return $string;		# else return the valid value
341
	return $string;		# else return the valid value
333
}
342
}
334
sub display_value{
343
sub display_value {
335
	my ($crit,$value)=@_;
344
    my ( $crit, $value ) = @_;
336
	my $display_value =
345
    my $display_value =
337
		($crit =~ /ccode/   ) ? $ccodes->{$value}    :
346
        ( $crit =~ /ccode/ )         ? $ccodes->{$value}
338
		($crit =~ /location/) ? $locations->{$value} :
347
      : ( $crit =~ /location/ )      ? $locations->{$value}
339
		($crit =~ /itemtype/) ? $itemtypes->{$value}->{description} :
348
      : ( $crit =~ /itemtype/ )      ? $itemtypes->{$value}->{description}
340
		($crit =~ /branch/) ? GetBranchName($value):
349
      : ( $crit =~ /branch/ )        ? GetBranchName($value)
341
		($crit =~ /reservestatus/) ? reservestatushuman($value):
350
      : ( $crit =~ /reservestatus/ ) ? reservestatushuman($value)
342
		$value; # default fallback
351
      :                                $value;    # default fallback
343
	if ($crit =~ /(sort1|sort2)/) {
352
    if ($crit =~ /sort1/) {
344
		$display_value=GetAuthorisedValues("B$_",$value);
353
        foreach (@$Bsort1) {
345
	} elsif ($crit =~ /category/) {
354
            ($value eq $_->{authorised_value}) or next;
346
		my $element=any{$value eq $_->{categorycode}} @$categoryloop;
355
            $display_value = $_->{lib} and last;
347
		$display_value=$$element{description};
356
        }
348
	}
357
    }
349
	return $display_value;
358
    elsif ($crit =~ /sort2/) {
359
        foreach (@$Bsort2) {
360
            ($value eq $_->{authorised_value}) or next;
361
            $display_value = $_->{lib} and last;
362
        }
363
    }
364
    elsif ( $crit =~ /category/ ) {
365
        foreach (@$categoryloop) {
366
            ( $value eq $_->{categorycode} ) or next;
367
            $display_value = $_->{description} and last;
368
        }
369
    }
370
    return $display_value;
350
}
371
}
351
sub reservestatushuman{
372
sub reservestatushuman{
352
	my ($val)=@_;
373
	my ($val)=@_;
353
- 

Return to bug 6984