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

(-)a/C4/Acquisition.pm (-8 / +25 lines)
Lines 959-975 C<$order> are fields from the biblio, biblioitems, aqorders tables of the Koha d Link Here
959
sub GetOrder {
959
sub GetOrder {
960
    my ($ordernumber) = @_;
960
    my ($ordernumber) = @_;
961
    my $dbh      = C4::Context->dbh;
961
    my $dbh      = C4::Context->dbh;
962
    my $query = "
962
    my $query = qq{SELECT biblio.*,biblioitems.*,
963
        SELECT biblioitems.*, biblio.*, aqorders.*
963
                aqorders.*,
964
        FROM   aqorders
964
                aqbudgets.*,
965
        LEFT JOIN biblio on           biblio.biblionumber=aqorders.biblionumber
965
                aqbasket.*,
966
        LEFT JOIN biblioitems on       biblioitems.biblionumber=aqorders.biblionumber
966
                aqorders.rrp              AS unitpricesupplier,
967
        WHERE aqorders.ordernumber=?
967
                aqorders.ecost            AS unitpricelib,
968
968
                aqorders.claims_count     AS claims_count,
969
    ";
969
                aqorders.claimed_date     AS claimed_date,
970
                aqbudgets.budget_name     AS budget,
971
                aqbooksellers.name        AS supplier,
972
                aqbooksellers.id          AS supplierid,
973
                biblioitems.publishercode AS publisher,
974
                ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) AS estimateddeliverydate,
975
                DATE(aqbasket.closedate)  AS orderdate,
976
                aqorders.quantity - IFNULL(aqorders.quantityreceived,0)                 AS quantity,
977
                (aqorders.quantity - IFNULL(aqorders.quantityreceived,0)) * aqorders.rrp AS subtotal,
978
                DATEDIFF(CURDATE( ),closedate) AS latesince
979
                FROM aqorders LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber
980
                LEFT JOIN biblioitems ON biblioitems.biblionumber = biblio.biblionumber
981
                LEFT JOIN aqbudgets ON aqorders.budget_id = aqbudgets.budget_id,
982
                aqbasket LEFT JOIN borrowers  ON aqbasket.authorisedby = borrowers.borrowernumber
983
                LEFT JOIN aqbooksellers       ON aqbasket.booksellerid = aqbooksellers.id
984
                WHERE aqorders.basketno = aqbasket.basketno
985
                    AND ordernumber=?};
970
    my $sth= $dbh->prepare($query);
986
    my $sth= $dbh->prepare($query);
971
    $sth->execute($ordernumber);
987
    $sth->execute($ordernumber);
972
    my $data = $sth->fetchrow_hashref;
988
    my $data = $sth->fetchrow_hashref;
989
    $data->{orderdate} = format_date( $data->{orderdate} );
973
    $sth->finish;
990
    $sth->finish;
974
    return $data;
991
    return $data;
975
}
992
}
(-)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 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 14-34 Link Here
14
$(document).ready(function() {
14
$(document).ready(function() {
15
    var late_orderst = $("#late_orders").dataTable($.extend(true, {}, dataTablesDefaults, {
15
    var late_orderst = $("#late_orders").dataTable($.extend(true, {}, dataTablesDefaults, {
16
        "aoColumnDefs": [
16
        "aoColumnDefs": [
17
            { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
17
            { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
18
        ],
18
        ],
19
        "sPaginationType": "four_button"
19
        "sPaginationType": "four_button",
20
        "bAutoWidth": false,
20
    } ) );
21
    } ) );
21
22
22
    $("input:checkbox[name=claim_for]").click(function(){
23
    $("input:checkbox[name=ordernumber]").click(function(){
23
        var booksellerid = $(this).attr('booksellerid');
24
        var booksellerid = $(this).attr('booksellerid');
24
        if ( $("input:checkbox[name=claim_for]:checked").length > 0) {
25
        if ( $("input:checkbox[name=ordernumber]:checked").length > 0) {
25
            $("input:checkbox[name=claim_for][booksellerid!="+booksellerid+"]").attr('disabled', true);
26
            $("input:checkbox[name=ordernumber][booksellerid!="+booksellerid+"]").attr('disabled', true);
26
        } else {
27
        } else {
27
            $("input:checkbox[name=claim_for]").attr('disabled', false);
28
            $("input:checkbox[name=ordernumber]").attr('disabled', false);
28
        }
29
        }
29
    });
30
    });
31
30
    $('#CheckAll').click(function(){ $("#late_orders td").checkCheckboxes();});
32
    $('#CheckAll').click(function(){ $("#late_orders td").checkCheckboxes();});
31
    $('#CheckNone').click(function(){ $("#late_orders td").unCheckCheckboxes();});
33
    $('#CheckNone').click(function(){ $("#late_orders td").unCheckCheckboxes();});
34
35
    // Generates a dynamic link for exporting the selection's data as CSV
36
    $("#ExportSelected").click(function() {
37
        var selected = $("input[name='ordernumber']:checked");
38
39
        if (selected.length == 0) {
40
            alert(_('Please select at least one item to export.'));
41
            return false;
42
        }
43
44
        // Building the url from currently checked boxes
45
        var url = '/cgi-bin/koha/acqui/lateorders-export.pl?op=export';
46
        for (var i = 0; i < selected.length; i++) {
47
            url += '&amp;ordernumber=' + selected[i].value;
48
        }
49
        // And redirecting to the CSV page
50
        location.href = url;
51
        return false;
52
    });
32
});
53
});
33
//]]>
54
//]]>
34
</script>
55
</script>
Lines 72-79 $(document).ready(function() { Link Here
72
	</p>
93
	</p>
73
	[% END %]
94
	[% END %]
74
    <table id="late_orders">
95
    <table id="late_orders">
75
        <thead>
96
      <thead>
76
        <tr>
97
        <tr>
98
            [% IF Supplier %]
99
                <th><a id="CheckAll" href="#">Check all</a><br /><a id="CheckNone" href="#">Uncheck all</a></th>
100
            [% ELSE %]
101
                <th></th>
102
            [% END %]
77
            <th>Order date</th>
103
            <th>Order date</th>
78
            <th>Estimated delivery date</th>
104
            <th>Estimated delivery date</th>
79
            <th>Vendor</th>
105
            <th>Vendor</th>
Lines 82-99 $(document).ready(function() { Link Here
82
            <th>Basket</th>
108
            <th>Basket</th>
83
            <th>Claims count</th>
109
            <th>Claims count</th>
84
            <th>Claimed date</th>
110
            <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>
111
        </tr>
91
        </thead>
112
      </thead>
92
        <tbody>
113
      <tbody>
93
    [% FOREACH lateorder IN lateorders %]
114
      [% FOREACH lateorder IN lateorders %]
94
        [% UNLESS ( loop.odd ) %]<tr class="highlight">
115
        [% UNLESS ( loop.odd ) %]<tr class="highlight">
95
        [% ELSE %]<tr>[% END %]
116
        [% ELSE %]<tr>[% END %]
96
            <td>
117
            <td>
118
                <input type="checkbox" value="[% lateorder.ordernumber %]" booksellerid="[% lateorder.supplierid %]" name="ordernumber">
119
            </td>
120
            <td>
97
                ([% lateorder.supplierid %])
121
                ([% lateorder.supplierid %])
98
                [% lateorder.orderdate %]
122
                [% lateorder.orderdate %]
99
                ([% lateorder.latesince %] days)
123
                ([% lateorder.latesince %] days)
Lines 130-146 $(document).ready(function() { Link Here
130
            </td>
154
            </td>
131
            <td>[% lateorder.claims_count %]</td>
155
            <td>[% lateorder.claims_count %]</td>
132
            <td>[% lateorder.claimed_date %]</td>
156
            <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>
157
        </tr>
140
        [% END %]
158
      [% END %]
141
    </tbody>
159
      </tbody>
142
    <tfoot>
160
      <tfoot>
143
        <tr> 
161
        <tr>
144
            <th>Total</th>
162
            <th>Total</th>
145
            <th>&nbsp;</th>
163
            <th>&nbsp;</th>
146
            <th>&nbsp;</th>
164
            <th>&nbsp;</th>
Lines 150-160 $(document).ready(function() { Link Here
150
            <th>&nbsp;</th>
168
            <th>&nbsp;</th>
151
            <th>&nbsp;</th>
169
            <th>&nbsp;</th>
152
            <td>
170
            <td>
153
                <input type="submit" value="Claim Order" />
171
              <input type="submit" value="Claim Order" />
154
            </td>
172
            </td>
155
        </tr>
173
        </tr>
156
    </tfoot>
174
      </tfoot>
157
    </table>
175
    </table>
176
    <div class="spacer"></div>
177
178
    <p style="display:block;">
179
        <input type="button" value="Export as CSV" id="ExportSelected" />
180
        [% UNLESS lateorder.budget_lock %]
181
            <input type="submit"  value="Claim Order" />
182
        [% END %]
183
    </p>
158
</form>
184
</form>
159
[% ELSE %]<p>There are no late orders.</p>
185
[% ELSE %]<p>There are no late orders.</p>
160
[% END %]
186
[% 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 292-298 Link Here
292
                        [% missingissue.claimdate %]
292
                        [% missingissue.claimdate %]
293
                        </td>
293
                        </td>
294
                        <td>
294
                        <td>
295
                            <a href="/cgi-bin/koha/serials/lateissues-excel.pl?supplierid=[% missingissue.supplieri %]&amp;serialid=[% missingissue.serialid %]&amp;op=claims">Export item data</a>
295
                            <a href="/cgi-bin/koha/serials/lateissues-export.pl?supplierid=[% missingissue.supplieri %]&amp;serialid=[% missingissue.serialid %]&amp;op=claims">Export item data</a>
296
                        </td>
296
                        </td>
297
                    </tr>
297
                    </tr>
298
                [% END %]</tbody>
298
                [% END %]</tbody>

Return to bug 7298