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

(-)a/C4/Acquisition.pm (-5 / +8 lines)
Lines 1684-1699 sub GetLateOrders { Link Here
1684
        $from .= ' AND borrowers.branchcode LIKE ? ';
1684
        $from .= ' AND borrowers.branchcode LIKE ? ';
1685
        push @query_params, $branch;
1685
        push @query_params, $branch;
1686
    }
1686
    }
1687
1688
    if ( defined $estimateddeliverydatefrom or defined $estimateddeliverydateto ) {
1689
        $from .= ' AND aqbooksellers.deliverytime IS NOT NULL ';
1690
    }
1687
    if ( defined $estimateddeliverydatefrom ) {
1691
    if ( defined $estimateddeliverydatefrom ) {
1688
        $from .= '
1692
        $from .= ' AND ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) >= ?';
1689
            AND aqbooksellers.deliverytime IS NOT NULL
1690
            AND ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) >= ?';
1691
        push @query_params, $estimateddeliverydatefrom;
1693
        push @query_params, $estimateddeliverydatefrom;
1692
    }
1694
    }
1693
    if ( defined $estimateddeliverydatefrom and defined $estimateddeliverydateto ) {
1695
    if ( defined $estimateddeliverydateto ) {
1694
        $from .= ' AND ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) <= ?';
1696
        $from .= ' AND ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) <= ?';
1695
        push @query_params, $estimateddeliverydateto;
1697
        push @query_params, $estimateddeliverydateto;
1696
    } elsif ( defined $estimateddeliverydatefrom ) {
1698
    }
1699
    if ( defined $estimateddeliverydatefrom and not defined $estimateddeliverydateto ) {
1697
        $from .= ' AND ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) <= CAST(now() AS date)';
1700
        $from .= ' AND ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) <= CAST(now() AS date)';
1698
    }
1701
    }
1699
    if (C4::Context->preference("IndependantBranches")
1702
    if (C4::Context->preference("IndependantBranches")
(-)a/acqui/lateorders.pl (-17 / +47 lines)
Lines 43-50 To know on which branch this script have to display late order. Link Here
43
43
44
=cut
44
=cut
45
45
46
use strict;
46
use Modern::Perl;
47
use warnings;
48
use CGI;
47
use CGI;
49
use C4::Bookseller qw( GetBooksellersWithLateOrders );
48
use C4::Bookseller qw( GetBooksellersWithLateOrders );
50
use C4::Auth;
49
use C4::Auth;
Lines 54-59 use C4::Context; Link Here
54
use C4::Acquisition;
53
use C4::Acquisition;
55
use C4::Letters;
54
use C4::Letters;
56
use C4::Branch; # GetBranches
55
use C4::Branch; # GetBranches
56
use Koha::DateUtils;
57
57
58
my $input = new CGI;
58
my $input = new CGI;
59
my ($template, $loggedinuser, $cookie) = get_template_and_user({
59
my ($template, $loggedinuser, $cookie) = get_template_and_user({
Lines 66-74 my ($template, $loggedinuser, $cookie) = get_template_and_user({ Link Here
66
});
66
});
67
67
68
my $booksellerid = $input->param('booksellerid') || undef; # we don't want "" or 0
68
my $booksellerid = $input->param('booksellerid') || undef; # we don't want "" or 0
69
my $delay      = $input->param('delay');
69
my $delay        = $input->param('delay');
70
71
# Get the "date from" param if !defined is today
70
my $estimateddeliverydatefrom = $input->param('estimateddeliverydatefrom');
72
my $estimateddeliverydatefrom = $input->param('estimateddeliverydatefrom');
71
my $estimateddeliverydateto   = $input->param('estimateddeliverydateto');
73
my $estimateddeliverydateto   = $input->param('estimateddeliverydateto');
74
75
my $estimateddeliverydatefrom_dt =
76
  $estimateddeliverydatefrom
77
  ? dt_from_string($estimateddeliverydatefrom)
78
  : undef;
79
80
# Get the "date to" param. If it is not defined and $delay is not defined too, it is the today's date.
81
my $estimateddeliverydateto_dt = dt_from_string($estimateddeliverydateto);
82
83
# Format the output of "date from" and "date to"
84
if ($estimateddeliverydatefrom) {
85
    $estimateddeliverydatefrom = output_pref($estimateddeliverydatefrom_dt);
86
    $estimateddeliverydatefrom =~ s/ \d\d:\d\d$//;
87
}
88
if ($estimateddeliverydateto) {
89
    $estimateddeliverydateto = output_pref($estimateddeliverydateto_dt);
90
    $estimateddeliverydateto =~ s/ \d\d:\d\d$//;
91
}
92
72
my $branch     = $input->param('branch');
93
my $branch     = $input->param('branch');
73
my $op         = $input->param('op');
94
my $op         = $input->param('op');
74
95
Lines 95-106 if ($op and $op eq "send_alert"){ Link Here
95
    }
116
    }
96
}
117
}
97
118
98
my %supplierlist = GetBooksellersWithLateOrders(
119
my @parameters = ( $delay, $branch );
99
    $delay,
120
if ($estimateddeliverydatefrom_dt) {
100
    $branch,
121
    push @parameters, $estimateddeliverydatefrom_dt->ymd();
101
    C4::Dates->new($estimateddeliverydatefrom)->output("iso"),
122
}
102
    C4::Dates->new($estimateddeliverydateto)->output("iso")
123
else {
103
);
124
    push @parameters, undef;
125
}
126
if ($estimateddeliverydateto_dt) {
127
    push @parameters, $estimateddeliverydateto_dt->ymd();
128
}
129
my %supplierlist = GetBooksellersWithLateOrders(@parameters);
104
130
105
my (@sloopy);	# supplier loop
131
my (@sloopy);	# supplier loop
106
foreach (keys %supplierlist){
132
foreach (keys %supplierlist){
Lines 113-125 $template->param(SUPPLIER_LOOP => \@sloopy); Link Here
113
$template->param(Supplier=>$supplierlist{$booksellerid}) if ($booksellerid);
139
$template->param(Supplier=>$supplierlist{$booksellerid}) if ($booksellerid);
114
$template->param(booksellerid=>$booksellerid) if ($booksellerid);
140
$template->param(booksellerid=>$booksellerid) if ($booksellerid);
115
141
116
my @lateorders = GetLateOrders(
142
@parameters =
117
    $delay,
143
  ( $delay, $booksellerid, $branch );
118
    $booksellerid,
144
if ($estimateddeliverydatefrom_dt) {
119
    $branch,
145
    push @parameters, $estimateddeliverydatefrom_dt->ymd();
120
    C4::Dates->new($estimateddeliverydatefrom)->output("iso"),
146
}
121
    C4::Dates->new($estimateddeliverydateto)->output("iso")
147
else {
122
);
148
    push @parameters, undef;
149
}
150
if ($estimateddeliverydateto_dt) {
151
    push @parameters, $estimateddeliverydateto_dt->ymd();
152
}
153
my @lateorders = GetLateOrders( @parameters );
123
154
124
my $total;
155
my $total;
125
foreach (@lateorders){
156
foreach (@lateorders){
126
- 

Return to bug 8652