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

(-)a/C4/Circulation.pm (-48 lines)
Lines 89-95 BEGIN { Link Here
89
        &GetSoonestRenewDate
89
        &GetSoonestRenewDate
90
        &GetLatestAutoRenewDate
90
        &GetLatestAutoRenewDate
91
		&GetItemIssue
91
		&GetItemIssue
92
		&GetItemIssues
93
		&GetIssuingCharges
92
		&GetIssuingCharges
94
        &GetBranchBorrowerCircRule
93
        &GetBranchBorrowerCircRule
95
        &GetBranchItemRule
94
        &GetBranchItemRule
Lines 2513-2565 sub GetOpenIssue { Link Here
2513
2512
2514
}
2513
}
2515
2514
2516
=head2 GetItemIssues
2517
2518
  $issues = &GetItemIssues($itemnumber, $history);
2519
2520
Returns patrons that have issued a book
2521
2522
C<$itemnumber> is the itemnumber
2523
C<$history> is false if you just want the current "issuer" (if any)
2524
and true if you want issues history from old_issues also.
2525
2526
Returns reference to an array of hashes
2527
2528
=cut
2529
2530
sub GetItemIssues {
2531
    my ( $itemnumber, $history ) = @_;
2532
    
2533
    my $today = DateTime->now( time_zome => C4::Context->tz);  # get today date
2534
    $today->truncate( to => 'minute' );
2535
    my $sql = "SELECT * FROM issues
2536
              JOIN borrowers USING (borrowernumber)
2537
              JOIN items     USING (itemnumber)
2538
              WHERE issues.itemnumber = ? ";
2539
    if ($history) {
2540
        $sql .= "UNION ALL
2541
                 SELECT * FROM old_issues
2542
                 LEFT JOIN borrowers USING (borrowernumber)
2543
                 JOIN items USING (itemnumber)
2544
                 WHERE old_issues.itemnumber = ? ";
2545
    }
2546
    $sql .= "ORDER BY date_due DESC";
2547
    my $sth = C4::Context->dbh->prepare($sql);
2548
    if ($history) {
2549
        $sth->execute($itemnumber, $itemnumber);
2550
    } else {
2551
        $sth->execute($itemnumber);
2552
    }
2553
    my $results = $sth->fetchall_arrayref({});
2554
    foreach (@$results) {
2555
        my $date_due = dt_from_string($_->{date_due},'sql');
2556
        $date_due->truncate( to => 'minute' );
2557
2558
        $_->{overdue} = (DateTime->compare($date_due, $today) == -1) ? 1 : 0;
2559
    }
2560
    return $results;
2561
}
2562
2563
=head2 GetBiblioIssues
2515
=head2 GetBiblioIssues
2564
2516
2565
  $issues = GetBiblioIssues($biblionumber);
2517
  $issues = GetBiblioIssues($biblionumber);
(-)a/catalogue/issuehistory.pl (-19 / +3 lines)
Lines 42-71 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
42
my $params = $query->Vars;
42
my $params = $query->Vars;
43
43
44
my $biblionumber = $params->{'biblionumber'};
44
my $biblionumber = $params->{'biblionumber'};
45
my $itemnumber   = $params->{'itemnumber'};
46
45
47
if (C4::Context->preference("HidePatronName")) {
46
if (C4::Context->preference("HidePatronName")) {
48
   $template->param(HidePatronName => 1);
47
   $template->param(HidePatronName => 1);
49
}
48
}
50
49
51
my ($issues,$biblio,$barcode);
50
my $issues = GetBiblioIssues($biblionumber);
52
if ($itemnumber){
51
my $biblio = GetBiblio($biblionumber);
53
	$issues=GetItemIssues($itemnumber);
52
$template->param(%$biblio);
54
	$biblio=GetBiblioFromItemNumber($itemnumber);
55
	$biblionumber=$biblio->{biblionumber};
56
	$barcode=$issues->[0]->{barcode};
57
	$template->param(
58
		%$biblio,
59
		barcode=> $barcode,
60
	);
61
} else {
62
	$issues = GetBiblioIssues($biblionumber);
63
        my $biblio = GetBiblio($biblionumber);
64
	my $total  = scalar @$issues;
65
	$template->param(
66
               %{$biblio},
67
	);
68
} 
69
53
70
$template->param(
54
$template->param(
71
    total        => scalar @$issues,
55
    total        => scalar @$issues,
(-)a/t/db_dependent/Circulation/issue.t (-6 lines)
Lines 46-52 can_ok( Link Here
46
      GetBiblioIssues
46
      GetBiblioIssues
47
      GetIssuingCharges
47
      GetIssuingCharges
48
      GetItemIssue
48
      GetItemIssue
49
      GetItemIssues
50
      GetOpenIssue
49
      GetOpenIssue
51
      GetRenewCount
50
      GetRenewCount
52
      GetUpcomingDueIssues
51
      GetUpcomingDueIssues
Lines 224-233 is( GetBiblioIssues(), undef, "GetBiblio Issues without parameters" ); Link Here
224
is(GetItemIssue,undef,"Without parameter GetItemIssue returns undef");
223
is(GetItemIssue,undef,"Without parameter GetItemIssue returns undef");
225
#is(GetItemIssue($item_id1),{},"Item1's issues");
224
#is(GetItemIssue($item_id1),{},"Item1's issues");
226
225
227
#Test GetItemIssues
228
#FIXME: this routine currently doesn't work be
229
#is_deeply (GetItemIssues,{},"Without parameter, GetItemIssue returns all the issues");
230
231
#Test GetOpenIssue
226
#Test GetOpenIssue
232
is( GetOpenIssue(), undef, "Without parameter GetOpenIssue returns undef" );
227
is( GetOpenIssue(), undef, "Without parameter GetOpenIssue returns undef" );
233
is( GetOpenIssue(-1), undef,
228
is( GetOpenIssue(-1), undef,
234
- 

Return to bug 17679