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

(-)a/C4/Circulation.pm (-48 lines)
Lines 88-94 BEGIN { Link Here
88
        &GetSoonestRenewDate
88
        &GetSoonestRenewDate
89
        &GetLatestAutoRenewDate
89
        &GetLatestAutoRenewDate
90
		&GetItemIssue
90
		&GetItemIssue
91
		&GetItemIssues
92
		&GetIssuingCharges
91
		&GetIssuingCharges
93
        &GetBranchBorrowerCircRule
92
        &GetBranchBorrowerCircRule
94
        &GetBranchItemRule
93
        &GetBranchItemRule
Lines 2573-2625 sub GetIssues { Link Here
2573
    return $rv ? $sth->fetchall_arrayref({}) : undef;
2572
    return $rv ? $sth->fetchall_arrayref({}) : undef;
2574
}
2573
}
2575
2574
2576
=head2 GetItemIssues
2577
2578
  $issues = &GetItemIssues($itemnumber, $history);
2579
2580
Returns patrons that have issued a book
2581
2582
C<$itemnumber> is the itemnumber
2583
C<$history> is false if you just want the current "issuer" (if any)
2584
and true if you want issues history from old_issues also.
2585
2586
Returns reference to an array of hashes
2587
2588
=cut
2589
2590
sub GetItemIssues {
2591
    my ( $itemnumber, $history ) = @_;
2592
    
2593
    my $today = DateTime->now( time_zome => C4::Context->tz);  # get today date
2594
    $today->truncate( to => 'minute' );
2595
    my $sql = "SELECT * FROM issues
2596
              JOIN borrowers USING (borrowernumber)
2597
              JOIN items     USING (itemnumber)
2598
              WHERE issues.itemnumber = ? ";
2599
    if ($history) {
2600
        $sql .= "UNION ALL
2601
                 SELECT * FROM old_issues
2602
                 LEFT JOIN borrowers USING (borrowernumber)
2603
                 JOIN items USING (itemnumber)
2604
                 WHERE old_issues.itemnumber = ? ";
2605
    }
2606
    $sql .= "ORDER BY date_due DESC";
2607
    my $sth = C4::Context->dbh->prepare($sql);
2608
    if ($history) {
2609
        $sth->execute($itemnumber, $itemnumber);
2610
    } else {
2611
        $sth->execute($itemnumber);
2612
    }
2613
    my $results = $sth->fetchall_arrayref({});
2614
    foreach (@$results) {
2615
        my $date_due = dt_from_string($_->{date_due},'sql');
2616
        $date_due->truncate( to => 'minute' );
2617
2618
        $_->{overdue} = (DateTime->compare($date_due, $today) == -1) ? 1 : 0;
2619
    }
2620
    return $results;
2621
}
2622
2623
=head2 GetBiblioIssues
2575
=head2 GetBiblioIssues
2624
2576
2625
  $issues = GetBiblioIssues($biblionumber);
2577
  $issues = GetBiblioIssues($biblionumber);
(-)a/catalogue/issuehistory.pl (-18 / +4 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,$biblio,$barcode);
52
if ($itemnumber){
51
$issues = GetBiblioIssues($biblionumber);
53
	$issues=GetItemIssues($itemnumber);
52
my $biblio = GetBiblio($biblionumber);
54
	$biblio=GetBiblioFromItemNumber($itemnumber);
53
my $total  = scalar @$issues;
55
	$biblionumber=$biblio->{biblionumber};
54
$template->param(%$biblio);
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
55
70
$template->param(
56
$template->param(
71
    total        => scalar @$issues,
57
    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