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

(-)a/C4/Acquisition.pm (-5 / +8 lines)
Lines 1671-1686 sub GetLateOrders { Link Here
1671
        $from .= ' AND borrowers.branchcode LIKE ? ';
1671
        $from .= ' AND borrowers.branchcode LIKE ? ';
1672
        push @query_params, $branch;
1672
        push @query_params, $branch;
1673
    }
1673
    }
1674
1675
    if ( defined $estimateddeliverydatefrom or defined $estimateddeliverydateto ) {
1676
        $from .= ' AND aqbooksellers.deliverytime IS NOT NULL ';
1677
    }
1674
    if ( defined $estimateddeliverydatefrom ) {
1678
    if ( defined $estimateddeliverydatefrom ) {
1675
        $from .= '
1679
        $from .= ' AND ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) >= ?';
1676
            AND aqbooksellers.deliverytime IS NOT NULL
1677
            AND ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) >= ?';
1678
        push @query_params, $estimateddeliverydatefrom;
1680
        push @query_params, $estimateddeliverydatefrom;
1679
    }
1681
    }
1680
    if ( defined $estimateddeliverydatefrom and defined $estimateddeliverydateto ) {
1682
    if ( defined $estimateddeliverydateto ) {
1681
        $from .= ' AND ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) <= ?';
1683
        $from .= ' AND ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) <= ?';
1682
        push @query_params, $estimateddeliverydateto;
1684
        push @query_params, $estimateddeliverydateto;
1683
    } elsif ( defined $estimateddeliverydatefrom ) {
1685
    }
1686
    if ( defined $estimateddeliverydatefrom and not defined $estimateddeliverydateto ) {
1684
        $from .= ' AND ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) <= CAST(now() AS date)';
1687
        $from .= ' AND ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) <= CAST(now() AS date)';
1685
    }
1688
    }
1686
    if (C4::Context->preference("IndependantBranches")
1689
    if (C4::Context->preference("IndependantBranches")
(-)a/acqui/lateorders.pl (-9 / +31 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
70
my $estimateddeliverydatefrom = $input->param('estimateddeliverydatefrom');
72
my $estimateddeliverydatefrom = $input->param('estimateddeliverydatefrom');
71
my $estimateddeliverydateto   = $input->param('estimateddeliverydateto');
73
# construct the "date from" in an iso format
74
my $estimateddeliverydatefrom_iso = $estimateddeliverydatefrom
75
    ? dt_from_string($estimateddeliverydatefrom, "iso")
76
    : undef;
77
# Get the "date to" param. If it is not defined and $delay is not defined too, it is the today's date.
78
my $estimateddeliverydateto = $input->param('estimateddeliverydateto');
79
$estimateddeliverydateto = $estimateddeliverydateto
80
    ? dt_from_string($estimateddeliverydateto)
81
    : ( not defined $delay ) ? dt_from_string() : undef;
82
# construct the "date to" in an iso format
83
my $estimateddeliverydateto_iso = $estimateddeliverydateto ? dt_from_string($estimateddeliverydateto, "iso") : dt_from_string(undef, "iso");
84
85
# Format the output of "date from" and "date to"
86
if ( $estimateddeliverydatefrom ) {
87
    $estimateddeliverydatefrom = output_pref( $estimateddeliverydatefrom );
88
    $estimateddeliverydatefrom =~ s/\s.*//;
89
}
90
if ( $estimateddeliverydateto ) {
91
    $estimateddeliverydateto = output_pref( $estimateddeliverydateto );
92
    $estimateddeliverydateto =~ s/\s.*//;
93
}
94
72
my $branch     = $input->param('branch');
95
my $branch     = $input->param('branch');
73
my $op         = $input->param('op');
96
my $op         = $input->param('op');
74
97
Lines 98-105 if ($op and $op eq "send_alert"){ Link Here
98
my %supplierlist = GetBooksellersWithLateOrders(
121
my %supplierlist = GetBooksellersWithLateOrders(
99
    $delay,
122
    $delay,
100
    $branch,
123
    $branch,
101
    C4::Dates->new($estimateddeliverydatefrom)->output("iso"),
124
    $estimateddeliverydatefrom_iso,
102
    C4::Dates->new($estimateddeliverydateto)->output("iso")
125
    $estimateddeliverydateto_iso,
103
);
126
);
104
127
105
my (@sloopy);	# supplier loop
128
my (@sloopy);	# supplier loop
Lines 117-124 my @lateorders = GetLateOrders( Link Here
117
    $delay,
140
    $delay,
118
    $booksellerid,
141
    $booksellerid,
119
    $branch,
142
    $branch,
120
    C4::Dates->new($estimateddeliverydatefrom)->output("iso"),
143
    $estimateddeliverydatefrom_iso,
121
    C4::Dates->new($estimateddeliverydateto)->output("iso")
144
    $estimateddeliverydateto_iso,
122
);
145
);
123
146
124
my $total;
147
my $total;
125
- 

Return to bug 8652