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

(-)a/C4/Acquisition.pm (-10 / +37 lines)
Lines 294-300 sub GetBasketAsCSV { Link Here
294
294
295
=head3 GetBasketGroupAsCSV
295
=head3 GetBasketGroupAsCSV
296
296
297
=over 4
297
=over
298
298
299
&GetBasketGroupAsCSV($basketgroupid);
299
&GetBasketGroupAsCSV($basketgroupid);
300
300
Lines 1011-1027 C<$order> are fields from the biblio, biblioitems, aqorders tables of the Koha d Link Here
1011
sub GetOrder {
1011
sub GetOrder {
1012
    my ($ordernumber) = @_;
1012
    my ($ordernumber) = @_;
1013
    my $dbh      = C4::Context->dbh;
1013
    my $dbh      = C4::Context->dbh;
1014
    my $query = "
1014
    my $query = qq{SELECT
1015
        SELECT biblioitems.*, biblio.*, aqorders.*
1015
                aqorders.*,
1016
        FROM   aqorders
1016
                biblio.title,
1017
        LEFT JOIN biblio on           biblio.biblionumber=aqorders.biblionumber
1017
                biblio.author,
1018
        LEFT JOIN biblioitems on       biblioitems.biblionumber=aqorders.biblionumber
1018
                aqbasket.basketname,
1019
        WHERE aqorders.ordernumber=?
1019
                borrowers.branchcode,
1020
1020
                biblioitems.publicationyear,
1021
    ";
1021
                biblio.copyrightdate,
1022
                biblioitems.editionstatement,
1023
                biblioitems.isbn,
1024
                biblioitems.ean,
1025
                biblio.seriestitle,
1026
                biblioitems.publishercode,
1027
                aqorders.rrp              AS unitpricesupplier,
1028
                aqorders.ecost            AS unitpricelib,
1029
                aqorders.claims_count     AS claims_count,
1030
                aqorders.claimed_date     AS claimed_date,
1031
                aqbudgets.budget_name     AS budget,
1032
                aqbooksellers.name        AS supplier,
1033
                aqbooksellers.id          AS supplierid,
1034
                biblioitems.publishercode AS publisher,
1035
                ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) AS estimateddeliverydate,
1036
                DATE(aqbasket.closedate)  AS orderdate,
1037
                aqorders.quantity - COALESCE(aqorders.quantityreceived,0)                 AS quantity_to_receive,
1038
                (aqorders.quantity - COALESCE(aqorders.quantityreceived,0)) * aqorders.rrp AS subtotal,
1039
                DATEDIFF(CURDATE( ),closedate) AS latesince
1040
                FROM aqorders LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber
1041
                LEFT JOIN biblioitems ON biblioitems.biblionumber = biblio.biblionumber
1042
                LEFT JOIN aqbudgets ON aqorders.budget_id = aqbudgets.budget_id,
1043
                aqbasket LEFT JOIN borrowers  ON aqbasket.authorisedby = borrowers.borrowernumber
1044
                LEFT JOIN aqbooksellers       ON aqbasket.booksellerid = aqbooksellers.id
1045
                WHERE aqorders.basketno = aqbasket.basketno
1046
                    AND ordernumber=?};
1022
    my $sth= $dbh->prepare($query);
1047
    my $sth= $dbh->prepare($query);
1023
    $sth->execute($ordernumber);
1048
    $sth->execute($ordernumber);
1024
    my $data = $sth->fetchrow_hashref;
1049
    my $data = $sth->fetchrow_hashref;
1050
    $data->{orderdate} = format_date( $data->{orderdate} );
1025
    $sth->finish;
1051
    $sth->finish;
1026
    return $data;
1052
    return $data;
1027
}
1053
}
Lines 2226-2232 sub GetContract { Link Here
2226
2252
2227
=head3 AddClaim
2253
=head3 AddClaim
2228
2254
2229
=over 4
2255
=over
2230
2256
2231
&AddClaim($ordernumber);
2257
&AddClaim($ordernumber);
2232
2258
Lines 2235-2240 Add a claim for an order Link Here
2235
=back
2261
=back
2236
2262
2237
=cut
2263
=cut
2264
2238
sub AddClaim {
2265
sub AddClaim {
2239
    my ($ordernumber) = @_;
2266
    my ($ordernumber) = @_;
2240
    my $dbh          = C4::Context->dbh;
2267
    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 (-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 295-301 Link Here
295
                        [% missingissue.claimdate %]
295
                        [% missingissue.claimdate %]
296
                        </td>
296
                        </td>
297
                        <td>
297
                        <td>
298
                            <a href="/cgi-bin/koha/serials/lateissues-excel.pl?supplierid=[% missingissue.supplieri %]&amp;serialid=[% missingissue.serialid %]&amp;op=claims">Export item data</a>
298
                            <a href="/cgi-bin/koha/serials/lateissues-export.pl?supplierid=[% missingissue.supplieri %]&amp;serialid=[% missingissue.serialid %]&amp;op=claims">Export item data</a>
299
                        </td>
299
                        </td>
300
                    </tr>
300
                    </tr>
301
                [% END %]</tbody>
301
                [% END %]</tbody>
(-)a/serials/lateissues-excel.pl (-8 / +7 lines)
Lines 63-73 for (my $k=0;$k<@serialid;$k++){ Link Here
63
    @missingissues = GetLateOrMissingIssues($supplierid, $serialid[$k]);
63
    @missingissues = GetLateOrMissingIssues($supplierid, $serialid[$k]);
64
64
65
    for (my $j=0;$j<@missingissues;$j++){
65
    for (my $j=0;$j<@missingissues;$j++){
66
	my @rows2 = ($missingissues[$j]->{'name'},          # lets build up a row
66
    my @rows2 = ($missingissues[$j]->{'name'},          # lets build up a row
67
	             $missingissues[$j]->{'title'},
67
                 $missingissues[$j]->{'title'},
68
                     $missingissues[$j]->{'serialseq'},
68
                 $missingissues[$j]->{'serialseq'},
69
                     $missingissues[$j]->{'planneddate'},
69
                 $missingissues[$j]->{'planneddate'},
70
                     );
70
                );
71
        push (@loop2, \@rows2);
71
        push (@loop2, \@rows2);
72
    }
72
    }
73
    $totalcount2 += scalar @missingissues;
73
    $totalcount2 += scalar @missingissues;
Lines 79-87 my $heading =''; Link Here
79
my $filename ='';
79
my $filename ='';
80
if($supplierid){
80
if($supplierid){
81
    if($missingissues[0]->{'name'}){ # if exists display supplier name in heading for neatness
81
    if($missingissues[0]->{'name'}){ # if exists display supplier name in heading for neatness
82
	# not necessarily needed as the name will appear in supplier column also
82
    # not necessarily needed as the name will appear in supplier column also
83
        $heading = "FOR $missingissues[0]->{'name'}";
83
        $heading = "FOR $missingissues[0]->{'name'}";
84
	$filename = "_$missingissues[0]->{'name'}";
84
    $filename = "_$missingissues[0]->{'name'}";
85
    }
85
    }
86
}
86
}
87
87
88
- 

Return to bug 7298