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

(-)a/acqui/lateorders.pl (-16 / +59 lines)
Lines 56-62 use C4::Branch; # GetBranches Link Here
56
use Koha::DateUtils;
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, $userflags) = get_template_and_user(
60
    {
60
    {
61
        template_name   => "acqui/lateorders.tt",
61
        template_name   => "acqui/lateorders.tt",
62
        query           => $input,
62
        query           => $input,
Lines 67-72 my ($template, $loggedinuser, $cookie) = get_template_and_user( Link Here
67
    }
67
    }
68
);
68
);
69
69
70
# Check if user has rights to access this page
71
my $can_claim_for_all = 0;
72
if ($userflags->{superlibrarian}
73
    or (!ref $userflags->{acquisition} and $userflags->{acquisition})
74
    or (ref $userflags->{acquisition}
75
        and $userflags->{acquisition}->{order_claim_for_all}
76
    )
77
) {
78
    $can_claim_for_all = 1;
79
}
80
81
if ( !$can_claim_for_all
82
    and (
83
        ref $userflags->{acquisition}
84
        and not $userflags->{acquisition}->{order_receive}
85
    )
86
) {
87
    # Will fail to authenticate, so redirect to login screen
88
    checkauth($input, 0, { acquisition => 'order_receive' }, "intranet");
89
}
90
70
my $booksellerid = $input->param('booksellerid') || undef; # we don't want "" or 0
91
my $booksellerid = $input->param('booksellerid') || undef; # we don't want "" or 0
71
my $delay        = $input->param('delay') // 0;
92
my $delay        = $input->param('delay') // 0;
72
93
Lines 103-124 if ( $delay and not $delay =~ /^\d{1,3}$/ ) { Link Here
103
}
124
}
104
125
105
if ($op and $op eq "send_alert"){
126
if ($op and $op eq "send_alert"){
106
    my @ordernums = $input->param("ordernumber");# FIXME: Fallback values?
127
    my @claim_for = $input->param('claim_for'); # FIXME: Fallback values?
107
    my $err;
128
    my (@ordernums, @not_claimed);
108
    eval {
129
    if (not $can_claim_for_all) {
109
        $err = SendAlerts( 'claimacquisition', \@ordernums, $input->param("letter_code") );    # FIXME: Fallback value?
130
        foreach my $ordernumber (@claim_for) {
110
        if ( not ref $err or not exists $err->{error} ) {
131
            my $order = GetOrder($ordernumber);
111
            AddClaim ( $_ ) for @ordernums;
132
            if (CanUserManageBasket($loggedinuser, $order->{basketno}, $userflags)) {
133
                push @ordernums, $ordernumber;
134
            } else {
135
                push @not_claimed, $ordernumber;
136
            }
112
        }
137
        }
113
    };
114
115
    if ( $@ ) {
116
        $template->param(error_claim => $@);
117
    } elsif ( ref $err and exists $err->{error} and $err->{error} eq "no_email" ) {
118
        $template->{VARS}->{'error_claim'} = "no_email";
119
    } else {
138
    } else {
120
        $template->{VARS}->{'info_claim'} = 1;
139
        @ordernums = @claim_for;
140
    }
141
    if (scalar @ordernums > 0) {
142
        my $err;
143
        eval {
144
            $err = SendAlerts( 'claimacquisition', \@ordernums, $input->param("letter_code") );    # FIXME: Fallback value?
145
            if ( not ref $err or not exists $err->{error} ) {
146
                foreach my $ordernumber (@ordernums) {
147
                    AddClaim($ordernumber);
148
                }
149
            }
150
        };
151
        if ( $@ ) {
152
            $template->param(error_claim => $@);
153
        } elsif ( ref $err and exists $err->{error} and $err->{error} eq "no_email" ) {
154
            $template->param(error_claim => "no_email");
155
        } else {
156
            $template->param(info_claim => 1);
157
        }
121
    }
158
    }
159
    $template->param(not_claimed => \@not_claimed);
122
}
160
}
123
161
124
my @parameters = ( $delay );
162
my @parameters = ( $delay );
Lines 157-164 if ($estimateddeliverydateto_dt) { Link Here
157
my @lateorders = GetLateOrders( @parameters );
195
my @lateorders = GetLateOrders( @parameters );
158
196
159
my $total;
197
my $total;
160
foreach (@lateorders){
198
foreach my $order (@lateorders){
161
	$total += $_->{subtotal};
199
    if ( (not $can_claim_for_all)
200
        and (not CanUserManageBasket($loggedinuser, $order->{basketno}, $userflags))
201
    ) {
202
        $order->{cannot_claim} = 1;
203
    }
204
    $total += $order->{subtotal};
162
}
205
}
163
206
164
my $letters = GetLetters({ module => "claimacquisition" });
207
my $letters = GetLetters({ module => "claimacquisition" });
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt (-1 / +15 lines)
Lines 87-92 $(document).ready(function() { Link Here
87
        <div class="error">[% error_claim %]</div>
87
        <div class="error">[% error_claim %]</div>
88
    [% END %]
88
    [% END %]
89
[% END %]
89
[% END %]
90
[% IF not_claimed.size %]
91
    <div class="error">
92
        <p>
93
            The following orders were not claimed because you are not
94
            authorised to claim for them:
95
        </p>
96
        <ul>
97
            [% FOREACH ordernumber IN not_claimed %]
98
                <li>[% ordernumber %]</li>
99
            [% END %]
100
        </ul>
101
    </div>
102
[% END %]
90
[% IF info_claim %]
103
[% IF info_claim %]
91
    <div class="dialog message">Email has been sent.</div>
104
    <div class="dialog message">Email has been sent.</div>
92
[% END %]
105
[% END %]
Lines 129-135 $(document).ready(function() { Link Here
129
        [% UNLESS ( loop.odd ) %]<tr class="highlight">
142
        [% UNLESS ( loop.odd ) %]<tr class="highlight">
130
        [% ELSE %]<tr>[% END %]
143
        [% ELSE %]<tr>[% END %]
131
            <td>
144
            <td>
145
              [% UNLESS lateorder.cannot_claim %]
132
                <input type="checkbox" value="[% lateorder.ordernumber %]" data-booksellerid="[% lateorder.supplierid %]" name="ordernumber">
146
                <input type="checkbox" value="[% lateorder.ordernumber %]" data-booksellerid="[% lateorder.supplierid %]" name="ordernumber">
147
              [% END %]
133
            </td>
148
            </td>
134
            <td>
149
            <td>
135
                <span title="[% lateorder.orderdate %]">[% lateorder.orderdate | $KohaDates %] ([% lateorder.latesince %] days)</span>
150
                <span title="[% lateorder.orderdate %]">[% lateorder.orderdate | $KohaDates %] ([% lateorder.latesince %] days)</span>
136
- 

Return to bug 7292