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

(-)a/C4/Acquisition.pm (-8 / +25 lines)
Lines 991-1007 C<$order> are fields from the biblio, biblioitems, aqorders tables of the Koha d Link Here
991
sub GetOrder {
991
sub GetOrder {
992
    my ($ordernumber) = @_;
992
    my ($ordernumber) = @_;
993
    my $dbh      = C4::Context->dbh;
993
    my $dbh      = C4::Context->dbh;
994
    my $query = "
994
    my $query = qq{SELECT biblio.*,biblioitems.*,
995
        SELECT biblioitems.*, biblio.*, aqorders.*
995
                aqorders.*,
996
        FROM   aqorders
996
                aqbudgets.*,
997
        LEFT JOIN biblio on           biblio.biblionumber=aqorders.biblionumber
997
                aqbasket.*,
998
        LEFT JOIN biblioitems on       biblioitems.biblionumber=aqorders.biblionumber
998
                aqorders.rrp              AS unitpricesupplier,
999
        WHERE aqorders.ordernumber=?
999
                aqorders.ecost            AS unitpricelib,
1000
1000
                aqorders.claims_count     AS claims_count,
1001
    ";
1001
                aqorders.claimed_date     AS claimed_date,
1002
                aqbudgets.budget_name     AS budget,
1003
                aqbooksellers.name        AS supplier,
1004
                aqbooksellers.id          AS supplierid,
1005
                biblioitems.publishercode AS publisher,
1006
                ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) AS estimateddeliverydate,
1007
                DATE(aqbasket.closedate)  AS orderdate,
1008
                aqorders.quantity - IFNULL(aqorders.quantityreceived,0)                 AS quantity,
1009
                (aqorders.quantity - IFNULL(aqorders.quantityreceived,0)) * aqorders.rrp AS subtotal,
1010
                DATEDIFF(CURDATE( ),closedate) AS latesince
1011
                FROM aqorders LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber
1012
                LEFT JOIN biblioitems ON biblioitems.biblionumber = biblio.biblionumber
1013
                LEFT JOIN aqbudgets ON aqorders.budget_id = aqbudgets.budget_id,
1014
                aqbasket LEFT JOIN borrowers  ON aqbasket.authorisedby = borrowers.borrowernumber
1015
                LEFT JOIN aqbooksellers       ON aqbasket.booksellerid = aqbooksellers.id
1016
                WHERE aqorders.basketno = aqbasket.basketno
1017
                    AND ordernumber=?};
1002
    my $sth= $dbh->prepare($query);
1018
    my $sth= $dbh->prepare($query);
1003
    $sth->execute($ordernumber);
1019
    $sth->execute($ordernumber);
1004
    my $data = $sth->fetchrow_hashref;
1020
    my $data = $sth->fetchrow_hashref;
1021
    $data->{orderdate} = format_date( $data->{orderdate} );
1005
    $sth->finish;
1022
    $sth->finish;
1006
    return $data;
1023
    return $data;
1007
}
1024
}
(-)a/acqui/lateorders-export.pl (+64 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 2 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use Modern::Perl;
19
use CGI;
20
use C4::Auth;
21
use C4::Serials;
22
use C4::Acquisition;
23
use C4::Output;
24
use C4::Context;
25
26
use Text::CSV::Encoded;
27
use open qw/ :std :utf8 /;
28
29
my $csv = Text::CSV::Encoded->new ({
30
        encoding    => undef,
31
        quote_char  => '"',
32
        escape_char => '"',
33
        sep_char    => ',',
34
        binary      => 1,
35
    });
36
37
my $query        = new CGI;
38
my @ordernumbers = $query->param('ordernumber');
39
40
print $query->header(
41
    -type       => 'text/csv',
42
    -attachment => "lateorders.csv",
43
);
44
45
print "LATE ORDERS\n\n";
46
print "ORDER DATE,ESTIMATED DELIVERY DATE,VENDOR,INFORMATION,TOTAL COST,BASKET,CLAIMS COUNT,CLAIMED DATE\n";
47
48
for my $ordernumber ( @ordernumbers ) {
49
    my $order = GetOrder $ordernumber;
50
    $csv->combine(
51
        "(" . $$order{supplierid} . ") " . $$order{orderdate} . " (" . $$order{latesince} . " days)",
52
        $$order{estimateddeliverydate},
53
        $$order{supplier},
54
        $$order{title} . ( $$order{author} ? " Author: $$order{author}" : "" ) . ( $$order{publisher} ? " Published by: $$order{publisher}" : "" ),
55
        $$order{unitpricesupplier} . "x" . $$order{quantity} . " = " . $$order{subtotal} . " (" . $$order{budget} . ")",
56
        $$order{basketname} . " (" . $$order{basketno} . ")",
57
        $$order{claims_count},
58
        $$order{claimed_date}
59
    );
60
    my $string = $csv->string;
61
    print $string, "\n";
62
}
63
64
print ",,Total Number Late, " . scalar @ordernumbers . "\n";
(-)a/acqui/lateorders.pl (-1 / +2 lines)
Lines 101-107 if ( $delay and not $delay =~ /^\d{1,3}$/ ) { Link Here
101
}
101
}
102
102
103
if ($op and $op eq "send_alert"){
103
if ($op and $op eq "send_alert"){
104
    my @ordernums = $input->param("claim_for");# FIXME: Fallback values?
104
    my @ordernums = $input->param("ordernumber");# FIXME: Fallback values?
105
    my $err;
105
    my $err;
106
    eval {
106
    eval {
107
        $err = SendAlerts( 'claimacquisition', \@ordernums, $input->param("letter_code") );    # FIXME: Fallback value?
107
        $err = SendAlerts( 'claimacquisition', \@ordernums, $input->param("letter_code") );    # FIXME: Fallback value?
Lines 109-114 if ($op and $op eq "send_alert"){ Link Here
109
            AddClaim ( $_ ) for @ordernums;
109
            AddClaim ( $_ ) for @ordernums;
110
        }
110
        }
111
    };
111
    };
112
112
    if ( $@ ) {
113
    if ( $@ ) {
113
        $template->param(error_claim => $@);
114
        $template->param(error_claim => $@);
114
    } elsif ( ref $err and exists $err->{error} and $err->{error} eq "no_email" ) {
115
    } elsif ( ref $err and exists $err->{error} and $err->{error} eq "no_email" ) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt (-27 / +53 lines)
Lines 17-37 Link Here
17
$(document).ready(function() {
17
$(document).ready(function() {
18
    var late_orderst = $("#late_orders").dataTable($.extend(true, {}, dataTablesDefaults, {
18
    var late_orderst = $("#late_orders").dataTable($.extend(true, {}, dataTablesDefaults, {
19
        "aoColumnDefs": [
19
        "aoColumnDefs": [
20
            { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
20
            { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
21
        ],
21
        ],
22
        "sPaginationType": "four_button"
22
        "sPaginationType": "four_button",
23
        "bAutoWidth": false,
23
    } ) );
24
    } ) );
24
25
25
    $("input:checkbox[name=claim_for]").click(function(){
26
    $("input:checkbox[name=ordernumber]").click(function(){
26
        var booksellerid = $(this).attr('booksellerid');
27
        var booksellerid = $(this).attr('booksellerid');
27
        if ( $("input:checkbox[name=claim_for]:checked").length > 0) {
28
        if ( $("input:checkbox[name=ordernumber]:checked").length > 0) {
28
            $("input:checkbox[name=claim_for][booksellerid!="+booksellerid+"]").attr('disabled', true);
29
            $("input:checkbox[name=ordernumber][booksellerid!="+booksellerid+"]").attr('disabled', true);
29
        } else {
30
        } else {
30
            $("input:checkbox[name=claim_for]").attr('disabled', false);
31
            $("input:checkbox[name=ordernumber]").attr('disabled', false);
31
        }
32
        }
32
    });
33
    });
34
33
    $('#CheckAll').click(function(){ $("#late_orders td").checkCheckboxes();});
35
    $('#CheckAll').click(function(){ $("#late_orders td").checkCheckboxes();});
34
    $('#CheckNone').click(function(){ $("#late_orders td").unCheckCheckboxes();});
36
    $('#CheckNone').click(function(){ $("#late_orders td").unCheckCheckboxes();});
37
38
    // Generates a dynamic link for exporting the selection's data as CSV
39
    $("#ExportSelected").click(function() {
40
        var selected = $("input[name='ordernumber']:checked");
41
42
        if (selected.length == 0) {
43
            alert(_('Please select at least one item to export.'));
44
            return false;
45
        }
46
47
        // Building the url from currently checked boxes
48
        var url = '/cgi-bin/koha/acqui/lateorders-export.pl?op=export';
49
        for (var i = 0; i < selected.length; i++) {
50
            url += '&amp;ordernumber=' + selected[i].value;
51
        }
52
        // And redirecting to the CSV page
53
        location.href = url;
54
        return false;
55
    });
35
});
56
});
36
//]]>
57
//]]>
37
</script>
58
</script>
Lines 75-82 $(document).ready(function() { Link Here
75
	</p>
96
	</p>
76
	[% END %]
97
	[% END %]
77
    <table id="late_orders">
98
    <table id="late_orders">
78
        <thead>
99
      <thead>
79
        <tr>
100
        <tr>
101
            [% IF Supplier %]
102
                <th><a id="CheckAll" href="#">Check all</a><br /><a id="CheckNone" href="#">Uncheck all</a></th>
103
            [% ELSE %]
104
                <th></th>
105
            [% END %]
80
            <th>Order date</th>
106
            <th>Order date</th>
81
            <th>Estimated delivery date</th>
107
            <th>Estimated delivery date</th>
82
            <th>Vendor</th>
108
            <th>Vendor</th>
Lines 85-102 $(document).ready(function() { Link Here
85
            <th>Basket</th>
111
            <th>Basket</th>
86
            <th>Claims count</th>
112
            <th>Claims count</th>
87
            <th>Claimed date</th>
113
            <th>Claimed date</th>
88
            [% IF Supplier %]
89
                <th><a id="CheckAll" href="#">Check all</a><br /><a id="CheckNone" href="#">Uncheck all</a></th>
90
            [% ELSE %]
91
                <th></th>
92
            [% END %]
93
        </tr>
114
        </tr>
94
        </thead>
115
      </thead>
95
        <tbody>
116
      <tbody>
96
    [% FOREACH lateorder IN lateorders %]
117
      [% FOREACH lateorder IN lateorders %]
97
        [% UNLESS ( loop.odd ) %]<tr class="highlight">
118
        [% UNLESS ( loop.odd ) %]<tr class="highlight">
98
        [% ELSE %]<tr>[% END %]
119
        [% ELSE %]<tr>[% END %]
99
            <td>
120
            <td>
121
                <input type="checkbox" value="[% lateorder.ordernumber %]" booksellerid="[% lateorder.supplierid %]" name="ordernumber">
122
            </td>
123
            <td>
100
                ([% lateorder.supplierid %])
124
                ([% lateorder.supplierid %])
101
                [% lateorder.orderdate %]
125
                [% lateorder.orderdate %]
102
                ([% lateorder.latesince %] days)
126
                ([% lateorder.latesince %] days)
Lines 133-149 $(document).ready(function() { Link Here
133
            </td>
157
            </td>
134
            <td>[% lateorder.claims_count %]</td>
158
            <td>[% lateorder.claims_count %]</td>
135
            <td>[% lateorder.claimed_date %]</td>
159
            <td>[% lateorder.claimed_date %]</td>
136
            <td>
137
                [% UNLESS lateorder.budget_lock %]
138
                    <input type="checkbox" class="checkbox" name="claim_for" value="[% lateorder.ordernumber %]"  booksellerid="[% lateorder.supplierid %]"/>
139
                [% END %]
140
             </td>
141
            </td>
142
        </tr>
160
        </tr>
143
        [% END %]
161
      [% END %]
144
    </tbody>
162
      </tbody>
145
    <tfoot>
163
      <tfoot>
146
        <tr> 
164
        <tr>
147
            <th>Total</th>
165
            <th>Total</th>
148
            <th>&nbsp;</th>
166
            <th>&nbsp;</th>
149
            <th>&nbsp;</th>
167
            <th>&nbsp;</th>
Lines 153-163 $(document).ready(function() { Link Here
153
            <th>&nbsp;</th>
171
            <th>&nbsp;</th>
154
            <th>&nbsp;</th>
172
            <th>&nbsp;</th>
155
            <td>
173
            <td>
156
                <input type="submit" value="Claim Order" />
174
              <input type="submit" value="Claim Order" />
157
            </td>
175
            </td>
158
        </tr>
176
        </tr>
159
    </tfoot>
177
      </tfoot>
160
    </table>
178
    </table>
179
    <div class="spacer"></div>
180
181
    <p style="display:block;">
182
        <input type="button" value="Export as CSV" id="ExportSelected" />
183
        [% UNLESS lateorder.budget_lock %]
184
            <input type="submit"  value="Claim Order" />
185
        [% END %]
186
    </p>
161
</form>
187
</form>
162
[% ELSE %]<p>There are no late orders.</p>
188
[% ELSE %]<p>There are no late orders.</p>
163
[% END %]
189
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt (-2 / +2 lines)
Lines 43-49 Link Here
43
		}
43
		}
44
		
44
		
45
		// Building the url from currently checked boxes
45
		// Building the url from currently checked boxes
46
		var url = '/cgi-bin/koha/serials/lateissues-excel.pl?supplierid=&amp;op=claims';
46
		var url = '/cgi-bin/koha/serials/lateissues-export.pl?supplierid=&amp;op=claims';
47
		for (var i = 0; i < selected.length; i++) {
47
		for (var i = 0; i < selected.length; i++) {
48
		    url += '&amp;serialid=' + selected[i].value;
48
		    url += '&amp;serialid=' + selected[i].value;
49
		}
49
		}
Lines 294-300 Link Here
294
                        [% missingissue.claimdate %]
294
                        [% missingissue.claimdate %]
295
                        </td>
295
                        </td>
296
                        <td>
296
                        <td>
297
                            <a href="/cgi-bin/koha/serials/lateissues-excel.pl?supplierid=[% missingissue.supplieri %]&amp;serialid=[% missingissue.serialid %]&amp;op=claims">Export item data</a>
297
                            <a href="/cgi-bin/koha/serials/lateissues-export.pl?supplierid=[% missingissue.supplieri %]&amp;serialid=[% missingissue.serialid %]&amp;op=claims">Export item data</a>
298
                        </td>
298
                        </td>
299
                    </tr>
299
                    </tr>
300
                [% END %]</tbody>
300
                [% END %]</tbody>

Return to bug 7298