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

(-)a/C4/Acquisition.pm (-8 / +25 lines)
Lines 842-858 C<$order> are fields from the biblio, biblioitems, aqorders tables of the Koha d Link Here
842
sub GetOrder {
842
sub GetOrder {
843
    my ($ordernumber) = @_;
843
    my ($ordernumber) = @_;
844
    my $dbh      = C4::Context->dbh;
844
    my $dbh      = C4::Context->dbh;
845
    my $query = "
845
    my $query = qq{SELECT biblio.*,biblioitems.*,
846
        SELECT biblioitems.*, biblio.*, aqorders.*
846
                aqorders.*,
847
        FROM   aqorders
847
                aqbudgets.*,
848
        LEFT JOIN biblio on           biblio.biblionumber=aqorders.biblionumber
848
                aqbasket.*,
849
        LEFT JOIN biblioitems on       biblioitems.biblionumber=aqorders.biblionumber
849
                aqorders.rrp              AS unitpricesupplier,
850
        WHERE aqorders.ordernumber=?
850
                aqorders.ecost            AS unitpricelib,
851
851
                aqorders.claims_count     AS claims_count,
852
    ";
852
                aqorders.claimed_date     AS claimed_date,
853
                aqbudgets.budget_name     AS budget,
854
                aqbooksellers.name        AS supplier,
855
                aqbooksellers.id          AS supplierid,
856
                biblioitems.publishercode AS publisher,
857
                ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) AS estimateddeliverydate,
858
                DATE(aqbasket.closedate)  AS orderdate,
859
                aqorders.quantity - IFNULL(aqorders.quantityreceived,0)                 AS quantity,
860
                (aqorders.quantity - IFNULL(aqorders.quantityreceived,0)) * aqorders.rrp AS subtotal,
861
                DATEDIFF(CURDATE( ),closedate) AS latesince
862
                FROM aqorders LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber
863
                LEFT JOIN biblioitems ON biblioitems.biblionumber = biblio.biblionumber
864
                LEFT JOIN aqbudgets ON aqorders.budget_id = aqbudgets.budget_id,
865
                aqbasket LEFT JOIN borrowers  ON aqbasket.authorisedby = borrowers.borrowernumber
866
                LEFT JOIN aqbooksellers       ON aqbasket.booksellerid = aqbooksellers.id
867
                WHERE aqorders.basketno = aqbasket.basketno
868
                    AND ordernumber=?};
853
    my $sth= $dbh->prepare($query);
869
    my $sth= $dbh->prepare($query);
854
    $sth->execute($ordernumber);
870
    $sth->execute($ordernumber);
855
    my $data = $sth->fetchrow_hashref;
871
    my $data = $sth->fetchrow_hashref;
872
    $data->{orderdate} = format_date( $data->{orderdate} );
856
    $sth->finish;
873
    $sth->finish;
857
    return $data;
874
    return $data;
858
}
875
}
(-)a/acqui/lateorders-excel.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 / +1 lines)
Lines 77-83 unless ($delay =~ /^\d{1,3}$/) { Link Here
77
}
77
}
78
78
79
if ($op and $op eq "send_alert"){
79
if ($op and $op eq "send_alert"){
80
    my @ordernums = $input->param("claim_for");# FIXME: Fallback values?
80
    my @ordernums = $input->param("ordernumber");# FIXME: Fallback values?
81
    my $err;
81
    my $err;
82
    eval {
82
    eval {
83
        $err = SendAlerts( 'claimacquisition', \@ordernums, $input->param("letter_code") );    # FIXME: Fallback value?
83
        $err = SendAlerts( 'claimacquisition', \@ordernums, $input->param("letter_code") );    # FIXME: Fallback value?
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt (-28 / +50 lines)
Lines 5-20 Link Here
5
<script type="text/javascript">
5
<script type="text/javascript">
6
//<![CDATA[
6
//<![CDATA[
7
$(document).ready(function() {
7
$(document).ready(function() {
8
    $("input:checkbox[name=claim_for]").click(function(){
8
    $("input:checkbox[name=ordernumber]").click(function(){
9
        var booksellerid = $(this).attr('booksellerid');
9
        var booksellerid = $(this).attr('booksellerid');
10
        if ( $("input:checkbox[name=claim_for]:checked").length > 0) {
10
        if ( $("input:checkbox[name=ordernumber]:checked").length > 0) {
11
            $("input:checkbox[name=claim_for][booksellerid!="+booksellerid+"]").attr('disabled', true);
11
            $("input:checkbox[name=ordernumber][booksellerid!="+booksellerid+"]").attr('disabled', true);
12
        } else {
12
        } else {
13
            $("input:checkbox[name=claim_for]").attr('disabled', false);
13
            $("input:checkbox[name=ordernumber]").attr('disabled', false);
14
        }
14
        }
15
    });
15
    });
16
17
    $("span.exportSelected").html("<a id=\"ExportSelected\" href=\"/cgi-bin/koha/acqui/lateorders.pl\"> "+_("Export selected items data") +"<\/a>");
18
16
    $('#CheckAll').click(function(){ $("#late_orders td").checkCheckboxes();});
19
    $('#CheckAll').click(function(){ $("#late_orders td").checkCheckboxes();});
17
    $('#CheckNone').click(function(){ $("#late_orders td").unCheckCheckboxes();});
20
    $('#CheckNone').click(function(){ $("#late_orders td").unCheckCheckboxes();});
21
22
    // Generates a dynamic link for exporting the selection's data as CSV
23
    $("#ExportSelected").click(function() {
24
        var selected = $("input[name='ordernumber']:checked");
25
26
        if (selected.length == 0) {
27
            alert(_('Please select at least one item to export.'));
28
            return false;
29
        }
30
31
        // Building the url from currently checked boxes
32
        var url = '/cgi-bin/koha/acqui/lateorders-excel.pl?op=export';
33
        for (var i = 0; i < selected.length; i++) {
34
            url += '&amp;ordernumber=' + selected[i].value;
35
        }
36
        // And redirecting to the CSV page
37
        location.href = url;
38
        return false;
39
    });
18
});
40
});
19
//]]>
41
//]]>
20
</script>
42
</script>
Lines 59-64 $(document).ready(function() { Link Here
59
	[% END %]
81
	[% END %]
60
    <table id="late_orders">
82
    <table id="late_orders">
61
        <tr>
83
        <tr>
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 %]
62
            <th>Order Date</th>
89
            <th>Order Date</th>
63
            <th>Vendor</th>
90
            <th>Vendor</th>
64
            <th>Information</th>
91
            <th>Information</th>
Lines 66-81 $(document).ready(function() { Link Here
66
            <th>Basket</th>
93
            <th>Basket</th>
67
            <th>Claims count</th>
94
            <th>Claims count</th>
68
            <th>Claimed date</th>
95
            <th>Claimed date</th>
69
            [% IF Supplier %]
70
                <th><a id="CheckAll" href="#">Check all</a><br /><a id="CheckNone" href="#">Uncheck all</a></th>
71
            [% ELSE %]
72
                <th></th>
73
            [% END %]
74
        </tr>
96
        </tr>
75
    [% FOREACH lateorder IN lateorders %]
97
    [% FOREACH lateorder IN lateorders %]
76
        [% UNLESS ( loop.odd ) %]<tr class="highlight">
98
        [% UNLESS ( loop.odd ) %]<tr class="highlight">
77
        [% ELSE %]<tr>[% END %]
99
        [% ELSE %]<tr>[% END %]
78
            <td>
100
            <td>
101
                <input type="checkbox" value="[% lateorder.ordernumber %]" booksellerid="[% lateorder.supplierid %]" name="ordernumber">
102
            </td>
103
            <td>
79
                ([% lateorder.supplierid %])
104
                ([% lateorder.supplierid %])
80
                [% lateorder.orderdate %]
105
                [% lateorder.orderdate %]
81
                ([% lateorder.latesince %] days)
106
                ([% lateorder.latesince %] days)
Lines 107-133 $(document).ready(function() { Link Here
107
            </td>
132
            </td>
108
            <td>[% lateorder.claims_count %]</td>
133
            <td>[% lateorder.claims_count %]</td>
109
            <td>[% lateorder.claimed_date %]</td>
134
            <td>[% lateorder.claimed_date %]</td>
110
            <td>
111
                [% UNLESS lateorder.budget_lock %]
112
                    <input type="checkbox" class="checkbox" name="claim_for" value="[% lateorder.ordernumber %]"  booksellerid="[% lateorder.supplierid %]"/>
113
                [% END %]
114
             </td>
115
            </td>
116
        </tr>
135
        </tr>
117
        [% END %]
136
        [% END %]
118
        <tr> 
137
        <tfoot>
119
            <th>Total</th>
138
            <tr>
120
            <th colspan="2">&nbsp;</th>
139
                <th>Total</th>
121
            <th>[% total %]</th>
140
                <th colspan="3">&nbsp;</th>
122
            <th>&nbsp;</th>
141
                <th>[% total %]</th>
123
            <th>&nbsp;</th>
142
                <th>&nbsp;</th>
124
            <th>&nbsp;</th>
143
                <th>&nbsp;</th>
125
            <td>
144
                <th>&nbsp;</th>
126
                <input type="submit" value="Claim Order" />
145
            </tr>
127
            </td>
146
        </tfoot>
128
        </tr>
129
    </table>
147
    </table>
130
     </form>
148
    <div class="spacer"></div>
149
    <p style="display:block;"><span class="exportSelected"></span></p>
150
    [% UNLESS lateorder.budget_lock %]
151
        <p style="display:block;"><input type="submit"  value="Claim Order" /></p>
152
    [% END %]
153
</form>
131
[% ELSE %]<p>There are no late orders.</p>
154
[% ELSE %]<p>There are no late orders.</p>
132
[% END %]
155
[% END %]
133
</div>
156
</div>
134
- 

Return to bug 7298