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

(-)a/C4/Acquisition.pm (-8 / +25 lines)
Lines 881-897 C<$order> are fields from the biblio, biblioitems, aqorders tables of the Koha d Link Here
881
sub GetOrder {
881
sub GetOrder {
882
    my ($ordernumber) = @_;
882
    my ($ordernumber) = @_;
883
    my $dbh      = C4::Context->dbh;
883
    my $dbh      = C4::Context->dbh;
884
    my $query = "
884
    my $query = qq{SELECT biblio.*,biblioitems.*,
885
        SELECT biblioitems.*, biblio.*, aqorders.*
885
                aqorders.*,
886
        FROM   aqorders
886
                aqbudgets.*,
887
        LEFT JOIN biblio on           biblio.biblionumber=aqorders.biblionumber
887
                aqbasket.*,
888
        LEFT JOIN biblioitems on       biblioitems.biblionumber=aqorders.biblionumber
888
                aqorders.rrp              AS unitpricesupplier,
889
        WHERE aqorders.ordernumber=?
889
                aqorders.ecost            AS unitpricelib,
890
890
                aqorders.claims_count     AS claims_count,
891
    ";
891
                aqorders.claimed_date     AS claimed_date,
892
                aqbudgets.budget_name     AS budget,
893
                aqbooksellers.name        AS supplier,
894
                aqbooksellers.id          AS supplierid,
895
                biblioitems.publishercode AS publisher,
896
                ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) AS estimateddeliverydate,
897
                DATE(aqbasket.closedate)  AS orderdate,
898
                aqorders.quantity - IFNULL(aqorders.quantityreceived,0)                 AS quantity,
899
                (aqorders.quantity - IFNULL(aqorders.quantityreceived,0)) * aqorders.rrp AS subtotal,
900
                DATEDIFF(CURDATE( ),closedate) AS latesince
901
                FROM aqorders LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber
902
                LEFT JOIN biblioitems ON biblioitems.biblionumber = biblio.biblionumber
903
                LEFT JOIN aqbudgets ON aqorders.budget_id = aqbudgets.budget_id,
904
                aqbasket LEFT JOIN borrowers  ON aqbasket.authorisedby = borrowers.borrowernumber
905
                LEFT JOIN aqbooksellers       ON aqbasket.booksellerid = aqbooksellers.id
906
                WHERE aqorders.basketno = aqbasket.basketno
907
                    AND ordernumber=?};
892
    my $sth= $dbh->prepare($query);
908
    my $sth= $dbh->prepare($query);
893
    $sth->execute($ordernumber);
909
    $sth->execute($ordernumber);
894
    my $data = $sth->fetchrow_hashref;
910
    my $data = $sth->fetchrow_hashref;
911
    $data->{orderdate} = format_date( $data->{orderdate} );
895
    $sth->finish;
912
    $sth->finish;
896
    return $data;
913
    return $data;
897
}
914
}
(-)a/acqui/lateorders-export.pl (+65 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";
65
(-)a/acqui/lateorders.pl (-1 / +2 lines)
Lines 78-84 if ( $delay and not $delay =~ /^\d{1,3}$/ ) { Link Here
78
}
78
}
79
79
80
if ($op and $op eq "send_alert"){
80
if ($op and $op eq "send_alert"){
81
    my @ordernums = $input->param("claim_for");# FIXME: Fallback values?
81
    my @ordernums = $input->param("ordernumber");# FIXME: Fallback values?
82
    my $err;
82
    my $err;
83
    eval {
83
    eval {
84
        $err = SendAlerts( 'claimacquisition', \@ordernums, $input->param("letter_code") );    # FIXME: Fallback value?
84
        $err = SendAlerts( 'claimacquisition', \@ordernums, $input->param("letter_code") );    # FIXME: Fallback value?
Lines 86-91 if ($op and $op eq "send_alert"){ Link Here
86
            AddClaim ( $_ ) for @ordernums;
86
            AddClaim ( $_ ) for @ordernums;
87
        }
87
        }
88
    };
88
    };
89
89
    if ( $@ ) {
90
    if ( $@ ) {
90
        $template->param(error_claim => $@);
91
        $template->param(error_claim => $@);
91
    } elsif ( ref $err and exists $err->{error} and $err->{error} eq "no_email" ) {
92
    } 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 13-33 Link Here
13
$(document).ready(function() {
13
$(document).ready(function() {
14
    var late_orderst = $("#late_orders").dataTable($.extend(true, {}, dataTablesDefaults, {
14
    var late_orderst = $("#late_orders").dataTable($.extend(true, {}, dataTablesDefaults, {
15
        "aoColumnDefs": [
15
        "aoColumnDefs": [
16
            { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
16
            { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
17
        ],
17
        ],
18
        "sPaginationType": "four_button"
18
        "sPaginationType": "four_button",
19
        "bAutoWidth": false,
19
    } ) );
20
    } ) );
20
21
21
    $("input:checkbox[name=claim_for]").click(function(){
22
    $("input:checkbox[name=ordernumber]").click(function(){
22
        var booksellerid = $(this).attr('booksellerid');
23
        var booksellerid = $(this).attr('booksellerid');
23
        if ( $("input:checkbox[name=claim_for]:checked").length > 0) {
24
        if ( $("input:checkbox[name=ordernumber]:checked").length > 0) {
24
            $("input:checkbox[name=claim_for][booksellerid!="+booksellerid+"]").attr('disabled', true);
25
            $("input:checkbox[name=ordernumber][booksellerid!="+booksellerid+"]").attr('disabled', true);
25
        } else {
26
        } else {
26
            $("input:checkbox[name=claim_for]").attr('disabled', false);
27
            $("input:checkbox[name=ordernumber]").attr('disabled', false);
27
        }
28
        }
28
    });
29
    });
30
29
    $('#CheckAll').click(function(){ $("#late_orders td").checkCheckboxes();});
31
    $('#CheckAll').click(function(){ $("#late_orders td").checkCheckboxes();});
30
    $('#CheckNone').click(function(){ $("#late_orders td").unCheckCheckboxes();});
32
    $('#CheckNone').click(function(){ $("#late_orders td").unCheckCheckboxes();});
33
34
    // Generates a dynamic link for exporting the selection's data as CSV
35
    $("#ExportSelected").click(function() {
36
        var selected = $("input[name='ordernumber']:checked");
37
38
        if (selected.length == 0) {
39
            alert(_('Please select at least one item to export.'));
40
            return false;
41
        }
42
43
        // Building the url from currently checked boxes
44
        var url = '/cgi-bin/koha/acqui/lateorders-export.pl?op=export';
45
        for (var i = 0; i < selected.length; i++) {
46
            url += '&amp;ordernumber=' + selected[i].value;
47
        }
48
        // And redirecting to the CSV page
49
        location.href = url;
50
        return false;
51
    });
31
});
52
});
32
//]]>
53
//]]>
33
</script>
54
</script>
Lines 71-78 $(document).ready(function() { Link Here
71
	</p>
92
	</p>
72
	[% END %]
93
	[% END %]
73
    <table id="late_orders">
94
    <table id="late_orders">
74
        <thead>
95
      <thead>
75
        <tr>
96
        <tr>
97
            [% IF Supplier %]
98
                <th><a id="CheckAll" href="#">Check all</a><br /><a id="CheckNone" href="#">Uncheck all</a></th>
99
            [% ELSE %]
100
                <th></th>
101
            [% END %]
76
            <th>Order date</th>
102
            <th>Order date</th>
77
            <th>Estimated delivery date</th>
103
            <th>Estimated delivery date</th>
78
            <th>Vendor</th>
104
            <th>Vendor</th>
Lines 81-98 $(document).ready(function() { Link Here
81
            <th>Basket</th>
107
            <th>Basket</th>
82
            <th>Claims count</th>
108
            <th>Claims count</th>
83
            <th>Claimed date</th>
109
            <th>Claimed date</th>
84
            [% IF Supplier %]
85
                <th><a id="CheckAll" href="#">Check all</a><br /><a id="CheckNone" href="#">Uncheck all</a></th>
86
            [% ELSE %]
87
                <th></th>
88
            [% END %]
89
        </tr>
110
        </tr>
90
        </thead>
111
      </thead>
91
        <tbody>
112
      <tbody>
92
    [% FOREACH lateorder IN lateorders %]
113
      [% FOREACH lateorder IN lateorders %]
93
        [% UNLESS ( loop.odd ) %]<tr class="highlight">
114
        [% UNLESS ( loop.odd ) %]<tr class="highlight">
94
        [% ELSE %]<tr>[% END %]
115
        [% ELSE %]<tr>[% END %]
95
            <td>
116
            <td>
117
                <input type="checkbox" value="[% lateorder.ordernumber %]" booksellerid="[% lateorder.supplierid %]" name="ordernumber">
118
            </td>
119
            <td>
96
                ([% lateorder.supplierid %])
120
                ([% lateorder.supplierid %])
97
                [% lateorder.orderdate %]
121
                [% lateorder.orderdate %]
98
                ([% lateorder.latesince %] days)
122
                ([% lateorder.latesince %] days)
Lines 129-145 $(document).ready(function() { Link Here
129
            </td>
153
            </td>
130
            <td>[% lateorder.claims_count %]</td>
154
            <td>[% lateorder.claims_count %]</td>
131
            <td>[% lateorder.claimed_date %]</td>
155
            <td>[% lateorder.claimed_date %]</td>
132
            <td>
133
                [% UNLESS lateorder.budget_lock %]
134
                    <input type="checkbox" class="checkbox" name="claim_for" value="[% lateorder.ordernumber %]"  booksellerid="[% lateorder.supplierid %]"/>
135
                [% END %]
136
             </td>
137
            </td>
138
        </tr>
156
        </tr>
139
        [% END %]
157
      [% END %]
140
    </tbody>
158
      </tbody>
141
    <tfoot>
159
      <tfoot>
142
        <tr> 
160
        <tr>
143
            <th>Total</th>
161
            <th>Total</th>
144
            <th>&nbsp;</th>
162
            <th>&nbsp;</th>
145
            <th>&nbsp;</th>
163
            <th>&nbsp;</th>
Lines 149-159 $(document).ready(function() { Link Here
149
            <th>&nbsp;</th>
167
            <th>&nbsp;</th>
150
            <th>&nbsp;</th>
168
            <th>&nbsp;</th>
151
            <td>
169
            <td>
152
                <input type="submit" value="Claim Order" />
170
              <input type="submit" value="Claim Order" />
153
            </td>
171
            </td>
154
        </tr>
172
        </tr>
155
    </tfoot>
173
      </tfoot>
156
    </table>
174
    </table>
175
    <div class="spacer"></div>
176
177
    <p style="display:block;">
178
        <input type="button" value="Export as CSV" id="ExportSelected" />
179
        [% UNLESS lateorder.budget_lock %]
180
            <input type="submit"  value="Claim Order" />
181
        [% END %]
182
    </p>
157
</form>
183
</form>
158
[% ELSE %]<p>There are no late orders.</p>
184
[% ELSE %]<p>There are no late orders.</p>
159
[% END %]
185
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt (-2 / +2 lines)
Lines 42-48 Link Here
42
		}
42
		}
43
		
43
		
44
		// Building the url from currently checked boxes
44
		// Building the url from currently checked boxes
45
		var url = '/cgi-bin/koha/serials/lateissues-excel.pl?supplierid=&amp;op=claims';
45
		var url = '/cgi-bin/koha/serials/lateissues-export.pl?supplierid=&amp;op=claims';
46
		for (var i = 0; i < selected.length; i++) {
46
		for (var i = 0; i < selected.length; i++) {
47
		    url += '&amp;serialid=' + selected[i].value;
47
		    url += '&amp;serialid=' + selected[i].value;
48
		}
48
		}
Lines 312-318 Link Here
312
                        [% missingissue.claimdate %]
312
                        [% missingissue.claimdate %]
313
                        </td>
313
                        </td>
314
                        <td>
314
                        <td>
315
                            <a href="/cgi-bin/koha/serials/lateissues-excel.pl?supplierid=[% missingissue.supplieri %]&amp;serialid=[% missingissue.serialid %]&amp;op=claims">Export item data</a>
315
                            <a href="/cgi-bin/koha/serials/lateissues-export.pl?supplierid=[% missingissue.supplieri %]&amp;serialid=[% missingissue.serialid %]&amp;op=claims">Export item data</a>
316
                        </td>
316
                        </td>
317
                    </tr>
317
                    </tr>
318
                [% END %]</tbody>
318
                [% END %]</tbody>

Return to bug 7298