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

(-)a/C4/Acquisition.pm (-10 / +37 lines)
Lines 338-344 sub GetBasketAsCSV { Link Here
338
338
339
=head3 GetBasketGroupAsCSV
339
=head3 GetBasketGroupAsCSV
340
340
341
=over 4
341
=over
342
342
343
&GetBasketGroupAsCSV($basketgroupid);
343
&GetBasketGroupAsCSV($basketgroupid);
344
344
Lines 966-982 C<$order> are fields from the biblio, biblioitems, aqorders tables of the Koha d Link Here
966
sub GetOrder {
966
sub GetOrder {
967
    my ($ordernumber) = @_;
967
    my ($ordernumber) = @_;
968
    my $dbh      = C4::Context->dbh;
968
    my $dbh      = C4::Context->dbh;
969
    my $query = "
969
    my $query = qq{SELECT
970
        SELECT biblioitems.*, biblio.*, aqorders.*
970
                aqorders.*,
971
        FROM   aqorders
971
                biblio.title,
972
        LEFT JOIN biblio on           biblio.biblionumber=aqorders.biblionumber
972
                biblio.author,
973
        LEFT JOIN biblioitems on       biblioitems.biblionumber=aqorders.biblionumber
973
                aqbasket.basketname,
974
        WHERE aqorders.ordernumber=?
974
                borrowers.branchcode,
975
975
                biblioitems.publicationyear,
976
    ";
976
                biblio.copyrightdate,
977
                biblioitems.editionstatement,
978
                biblioitems.isbn,
979
                biblioitems.ean,
980
                biblio.seriestitle,
981
                biblioitems.publishercode,
982
                aqorders.rrp              AS unitpricesupplier,
983
                aqorders.ecost            AS unitpricelib,
984
                aqorders.claims_count     AS claims_count,
985
                aqorders.claimed_date     AS claimed_date,
986
                aqbudgets.budget_name     AS budget,
987
                aqbooksellers.name        AS supplier,
988
                aqbooksellers.id          AS supplierid,
989
                biblioitems.publishercode AS publisher,
990
                ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) AS estimateddeliverydate,
991
                DATE(aqbasket.closedate)  AS orderdate,
992
                aqorders.quantity - COALESCE(aqorders.quantityreceived,0)                 AS quantity_to_receive,
993
                (aqorders.quantity - COALESCE(aqorders.quantityreceived,0)) * aqorders.rrp AS subtotal,
994
                DATEDIFF(CURDATE( ),closedate) AS latesince
995
                FROM aqorders LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber
996
                LEFT JOIN biblioitems ON biblioitems.biblionumber = biblio.biblionumber
997
                LEFT JOIN aqbudgets ON aqorders.budget_id = aqbudgets.budget_id,
998
                aqbasket LEFT JOIN borrowers  ON aqbasket.authorisedby = borrowers.borrowernumber
999
                LEFT JOIN aqbooksellers       ON aqbasket.booksellerid = aqbooksellers.id
1000
                WHERE aqorders.basketno = aqbasket.basketno
1001
                    AND ordernumber=?};
977
    my $sth= $dbh->prepare($query);
1002
    my $sth= $dbh->prepare($query);
978
    $sth->execute($ordernumber);
1003
    $sth->execute($ordernumber);
979
    my $data = $sth->fetchrow_hashref;
1004
    my $data = $sth->fetchrow_hashref;
1005
    $data->{orderdate} = format_date( $data->{orderdate} );
980
    $sth->finish;
1006
    $sth->finish;
981
    return $data;
1007
    return $data;
982
}
1008
}
Lines 2252-2258 sub GetContract { Link Here
2252
2278
2253
=head3 AddClaim
2279
=head3 AddClaim
2254
2280
2255
=over 4
2281
=over
2256
2282
2257
&AddClaim($ordernumber);
2283
&AddClaim($ordernumber);
2258
2284
Lines 2261-2266 Add a claim for an order Link Here
2261
=back
2287
=back
2262
2288
2263
=cut
2289
=cut
2290
2264
sub AddClaim {
2291
sub AddClaim {
2265
    my ($ordernumber) = @_;
2292
    my ($ordernumber) = @_;
2266
    my $dbh          = C4::Context->dbh;
2293
    my $dbh          = C4::Context->dbh;
(-)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_to_receive} . " = " . $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 (-41 / +69 lines)
Lines 11-34 Link Here
11
[% IF (dateformat == 'metric') %]
11
[% IF (dateformat == 'metric') %]
12
    dt_add_type_uk_date();
12
    dt_add_type_uk_date();
13
[% END %]
13
[% END %]
14
15
var late_orderst;
16
function check_uncheck() {
17
    var all_nodes = $(late_orderst.fnGetNodes());
18
    if ( $(all_nodes).find("input:checkbox[name=ordernumber]:checked").length > 0) {
19
        var booksellerid = $(all_nodes).find("input:checkbox[name=ordernumber]:checked:first").attr("data-booksellerid");
20
        $(all_nodes).find("input:checkbox[name=ordernumber][data-booksellerid!="+booksellerid+"]").attr('disabled', 'disabled');
21
    } else {
22
        $("input:checkbox[name=ordernumber]").removeAttr('disabled');
23
    }
24
}
25
14
$(document).ready(function() {
26
$(document).ready(function() {
15
    var late_orderst = $("#late_orders").dataTable($.extend(true, {}, dataTablesDefaults, {
27
28
    late_orderst = $("#late_orders").dataTable($.extend(true, {}, dataTablesDefaults, {
16
        "aoColumnDefs": [
29
        "aoColumnDefs": [
17
            { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
30
            { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
18
        ],
31
        ],
19
        "sPaginationType": "four_button"
32
        "sPaginationType": "four_button",
33
        "bAutoWidth": false,
34
        "fnDrawCallback": function() {
35
            if ( typeof late_orderst != 'undefined' ) {
36
                check_uncheck();
37
                $('input:checkbox[name=ordernumber]').bind('click', check_uncheck);
38
            };
39
        }
20
    } ) );
40
    } ) );
41
    $('#CheckAll').click(function(){ $(late_orderst.fnGetNodes()).find("td").checkCheckboxes();});
42
    $('#CheckNone').click(function(){ $(late_orderst.fnGetNodes()).find("td").unCheckCheckboxes();});
43
44
    // Generates a dynamic link for exporting the selection's data as CSV
45
    $("#ExportSelected").click(function() {
46
        var all_nodes = $(late_orderst.fnGetNodes());
47
        var selected = $(all_nodes).find("input[name='ordernumber']:checked");
48
49
        if (selected.length == 0) {
50
            alert(_("Please select at least one item to export."));
51
            return false;
52
        }
21
53
22
    $("input:checkbox[name=claim_for]").click(function(){
54
        // Building the url from currently checked boxes
23
        var booksellerid = $(this).attr('booksellerid');
55
        var url = '/cgi-bin/koha/acqui/lateorders-export.pl?op=export';
24
        if ( $("input:checkbox[name=claim_for]:checked").length > 0) {
56
        for (var i = 0; i < selected.length; i++) {
25
            $("input:checkbox[name=claim_for][booksellerid!="+booksellerid+"]").attr('disabled', true);
57
            url += '&amp;ordernumber=' + selected[i].value;
26
        } else {
27
            $("input:checkbox[name=claim_for]").attr('disabled', false);
28
        }
58
        }
59
        // And redirecting to the CSV page
60
        location.href = url;
61
        return false;
29
    });
62
    });
30
    $('#CheckAll').click(function(){ $("#late_orders td").checkCheckboxes();});
31
    $('#CheckNone').click(function(){ $("#late_orders td").unCheckCheckboxes();});
32
});
63
});
33
//]]>
64
//]]>
34
</script>
65
</script>
Lines 72-79 $(document).ready(function() { Link Here
72
	</p>
103
	</p>
73
	[% END %]
104
	[% END %]
74
    <table id="late_orders">
105
    <table id="late_orders">
75
        <thead>
106
      <thead>
76
        <tr>
107
        <tr>
108
            [% IF Supplier %]
109
                <th><a id="CheckAll" href="#">Check all</a><br /><a id="CheckNone" href="#">Uncheck all</a></th>
110
            [% ELSE %]
111
                <th></th>
112
            [% END %]
77
            <th>Order date</th>
113
            <th>Order date</th>
78
            <th>Estimated delivery date</th>
114
            <th>Estimated delivery date</th>
79
            <th>Vendor</th>
115
            <th>Vendor</th>
Lines 82-99 $(document).ready(function() { Link Here
82
            <th>Basket</th>
118
            <th>Basket</th>
83
            <th>Claims count</th>
119
            <th>Claims count</th>
84
            <th>Claimed date</th>
120
            <th>Claimed date</th>
85
            [% IF Supplier %]
86
                <th><a id="CheckAll" href="#">Check all</a><br /><a id="CheckNone" href="#">Uncheck all</a></th>
87
            [% ELSE %]
88
                <th></th>
89
            [% END %]
90
        </tr>
121
        </tr>
91
        </thead>
122
      </thead>
92
        <tbody>
123
      <tbody>
93
    [% FOREACH lateorder IN lateorders %]
124
      [% FOREACH lateorder IN lateorders %]
94
        [% UNLESS ( loop.odd ) %]<tr class="highlight">
125
        [% UNLESS ( loop.odd ) %]<tr class="highlight">
95
        [% ELSE %]<tr>[% END %]
126
        [% ELSE %]<tr>[% END %]
96
            <td>
127
            <td>
128
                <input type="checkbox" value="[% lateorder.ordernumber %]" data-booksellerid="[% lateorder.supplierid %]" name="ordernumber">
129
            </td>
130
            <td>
97
                ([% lateorder.supplierid %])
131
                ([% lateorder.supplierid %])
98
                [% lateorder.orderdate %]
132
                [% lateorder.orderdate %]
99
                ([% lateorder.latesince %] days)
133
                ([% lateorder.latesince %] days)
Lines 130-160 $(document).ready(function() { Link Here
130
            </td>
164
            </td>
131
            <td>[% lateorder.claims_count %]</td>
165
            <td>[% lateorder.claims_count %]</td>
132
            <td>[% lateorder.claimed_date %]</td>
166
            <td>[% lateorder.claimed_date %]</td>
133
            <td>
134
                [% UNLESS lateorder.budget_lock %]
135
                    <input type="checkbox" class="checkbox" name="claim_for" value="[% lateorder.ordernumber %]"  booksellerid="[% lateorder.supplierid %]"/>
136
                [% END %]
137
             </td>
138
            </td>
139
        </tr>
167
        </tr>
140
        [% END %]
168
      [% END %]
141
    </tbody>
169
      </tbody>
142
    <tfoot>
170
      <tfoot>
143
        <tr> 
171
        <tr>
144
            <th>Total</th>
172
            <th colspan="5">Total</th>
145
            <th>&nbsp;</th>
146
            <th>&nbsp;</th>
147
            <th>&nbsp;</th>
148
            <th>[% total %]</th>
173
            <th>[% total %]</th>
149
            <th>&nbsp;</th>
174
            <th colspan="3">&nbsp;</th>
150
            <th>&nbsp;</th>
151
            <th>&nbsp;</th>
152
            <td>
153
                <input type="submit" value="Claim Order" />
154
            </td>
155
        </tr>
175
        </tr>
156
    </tfoot>
176
      </tfoot>
157
    </table>
177
    </table>
178
    <div class="spacer"></div>
179
180
    <p style="display:block;">
181
        <input type="button" value="Export as CSV" id="ExportSelected" />
182
        [% UNLESS lateorder.budget_lock %]
183
            <input type="submit"  value="Claim Order" />
184
        [% END %]
185
    </p>
158
</form>
186
</form>
159
[% ELSE %]<p>There are no late orders.</p>
187
[% ELSE %]<p>There are no late orders.</p>
160
[% END %]
188
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt (-1 / +1 lines)
Lines 41-47 Link Here
41
		}
41
		}
42
		
42
		
43
		// Building the url from currently checked boxes
43
		// Building the url from currently checked boxes
44
		var url = '/cgi-bin/koha/serials/lateissues-excel.pl?supplierid=&amp;op=claims';
44
		var url = '/cgi-bin/koha/serials/lateissues-export.pl?supplierid=&amp;op=claims';
45
		for (var i = 0; i < selected.length; i++) {
45
		for (var i = 0; i < selected.length; i++) {
46
		    url += '&amp;serialid=' + selected[i].value;
46
		    url += '&amp;serialid=' + selected[i].value;
47
		}
47
		}

Return to bug 7298