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 1008-1024 C<$order> are fields from the biblio, biblioitems, aqorders tables of the Koha d Link Here
1008
sub GetOrder {
1008
sub GetOrder {
1009
    my ($ordernumber) = @_;
1009
    my ($ordernumber) = @_;
1010
    my $dbh      = C4::Context->dbh;
1010
    my $dbh      = C4::Context->dbh;
1011
    my $query = "
1011
    my $query = qq{SELECT
1012
        SELECT biblioitems.*, biblio.*, aqorders.*
1012
                aqorders.*,
1013
        FROM   aqorders
1013
                biblio.title,
1014
        LEFT JOIN biblio on           biblio.biblionumber=aqorders.biblionumber
1014
                biblio.author,
1015
        LEFT JOIN biblioitems on       biblioitems.biblionumber=aqorders.biblionumber
1015
                aqbasket.basketname,
1016
        WHERE aqorders.ordernumber=?
1016
                borrowers.branchcode,
1017
1017
                biblioitems.publicationyear,
1018
    ";
1018
                biblio.copyrightdate,
1019
                biblioitems.editionstatement,
1020
                biblioitems.isbn,
1021
                biblioitems.ean,
1022
                biblio.seriestitle,
1023
                biblioitems.publishercode,
1024
                aqorders.rrp              AS unitpricesupplier,
1025
                aqorders.ecost            AS unitpricelib,
1026
                aqorders.claims_count     AS claims_count,
1027
                aqorders.claimed_date     AS claimed_date,
1028
                aqbudgets.budget_name     AS budget,
1029
                aqbooksellers.name        AS supplier,
1030
                aqbooksellers.id          AS supplierid,
1031
                biblioitems.publishercode AS publisher,
1032
                ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) AS estimateddeliverydate,
1033
                DATE(aqbasket.closedate)  AS orderdate,
1034
                aqorders.quantity - COALESCE(aqorders.quantityreceived,0)                 AS quantity_to_receive,
1035
                (aqorders.quantity - COALESCE(aqorders.quantityreceived,0)) * aqorders.rrp AS subtotal,
1036
                DATEDIFF(CURDATE( ),closedate) AS latesince
1037
                FROM aqorders LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber
1038
                LEFT JOIN biblioitems ON biblioitems.biblionumber = biblio.biblionumber
1039
                LEFT JOIN aqbudgets ON aqorders.budget_id = aqbudgets.budget_id,
1040
                aqbasket LEFT JOIN borrowers  ON aqbasket.authorisedby = borrowers.borrowernumber
1041
                LEFT JOIN aqbooksellers       ON aqbasket.booksellerid = aqbooksellers.id
1042
                WHERE aqorders.basketno = aqbasket.basketno
1043
                    AND ordernumber=?};
1019
    my $sth= $dbh->prepare($query);
1044
    my $sth= $dbh->prepare($query);
1020
    $sth->execute($ordernumber);
1045
    $sth->execute($ordernumber);
1021
    my $data = $sth->fetchrow_hashref;
1046
    my $data = $sth->fetchrow_hashref;
1047
    $data->{orderdate} = format_date( $data->{orderdate} );
1022
    $sth->finish;
1048
    $sth->finish;
1023
    return $data;
1049
    return $data;
1024
}
1050
}
Lines 2158-2164 sub GetContract { Link Here
2158
2184
2159
=head3 AddClaim
2185
=head3 AddClaim
2160
2186
2161
=over 4
2187
=over
2162
2188
2163
&AddClaim($ordernumber);
2189
&AddClaim($ordernumber);
2164
2190
Lines 2167-2172 Add a claim for an order Link Here
2167
=back
2193
=back
2168
2194
2169
=cut
2195
=cut
2196
2170
sub AddClaim {
2197
sub AddClaim {
2171
    my ($ordernumber) = @_;
2198
    my ($ordernumber) = @_;
2172
    my $dbh          = C4::Context->dbh;
2199
    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 14-37 Link Here
14
[% IF (dateformat == 'metric') %]
14
[% IF (dateformat == 'metric') %]
15
    dt_add_type_uk_date();
15
    dt_add_type_uk_date();
16
[% END %]
16
[% END %]
17
18
var late_orderst;
19
function check_uncheck() {
20
    var all_nodes = $(late_orderst.fnGetNodes());
21
    if ( $(all_nodes).find("input:checkbox[name=ordernumber]:checked").length > 0) {
22
        var booksellerid = $(all_nodes).find("input:checkbox[name=ordernumber]:checked:first").attr("data-booksellerid");
23
        $(all_nodes).find("input:checkbox[name=ordernumber][data-booksellerid!="+booksellerid+"]").attr('disabled', 'disabled');
24
    } else {
25
        $("input:checkbox[name=ordernumber]").removeAttr('disabled');
26
    }
27
}
28
17
$(document).ready(function() {
29
$(document).ready(function() {
18
    var late_orderst = $("#late_orders").dataTable($.extend(true, {}, dataTablesDefaults, {
30
31
    late_orderst = $("#late_orders").dataTable($.extend(true, {}, dataTablesDefaults, {
19
        "aoColumnDefs": [
32
        "aoColumnDefs": [
20
            { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
33
            { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
21
        ],
34
        ],
22
        "sPaginationType": "four_button"
35
        "sPaginationType": "four_button",
36
        "bAutoWidth": false,
37
        "fnDrawCallback": function() {
38
            if ( typeof late_orderst != 'undefined' ) {
39
                check_uncheck();
40
                $('input:checkbox[name=ordernumber]').bind('click', check_uncheck);
41
            };
42
        }
23
    } ) );
43
    } ) );
44
    $('#CheckAll').click(function(){ $(late_orderst.fnGetNodes()).find("td").checkCheckboxes();});
45
    $('#CheckNone').click(function(){ $(late_orderst.fnGetNodes()).find("td").unCheckCheckboxes();});
46
47
    // Generates a dynamic link for exporting the selection's data as CSV
48
    $("#ExportSelected").click(function() {
49
        var all_nodes = $(late_orderst.fnGetNodes());
50
        var selected = $(all_nodes).find("input[name='ordernumber']:checked");
51
52
        if (selected.length == 0) {
53
            alert(_("Please select at least one item to export."));
54
            return false;
55
        }
24
56
25
    $("input:checkbox[name=claim_for]").click(function(){
57
        // Building the url from currently checked boxes
26
        var booksellerid = $(this).attr('booksellerid');
58
        var url = '/cgi-bin/koha/acqui/lateorders-export.pl?op=export';
27
        if ( $("input:checkbox[name=claim_for]:checked").length > 0) {
59
        for (var i = 0; i < selected.length; i++) {
28
            $("input:checkbox[name=claim_for][booksellerid!="+booksellerid+"]").attr('disabled', true);
60
            url += '&amp;ordernumber=' + selected[i].value;
29
        } else {
30
            $("input:checkbox[name=claim_for]").attr('disabled', false);
31
        }
61
        }
62
        // And redirecting to the CSV page
63
        location.href = url;
64
        return false;
32
    });
65
    });
33
    $('#CheckAll').click(function(){ $("#late_orders td").checkCheckboxes();});
34
    $('#CheckNone').click(function(){ $("#late_orders td").unCheckCheckboxes();});
35
});
66
});
36
//]]>
67
//]]>
37
</script>
68
</script>
Lines 75-82 $(document).ready(function() { Link Here
75
	</p>
106
	</p>
76
	[% END %]
107
	[% END %]
77
    <table id="late_orders">
108
    <table id="late_orders">
78
        <thead>
109
      <thead>
79
        <tr>
110
        <tr>
111
            [% IF Supplier %]
112
                <th><a id="CheckAll" href="#">Check all</a><br /><a id="CheckNone" href="#">Uncheck all</a></th>
113
            [% ELSE %]
114
                <th></th>
115
            [% END %]
80
            <th>Order date</th>
116
            <th>Order date</th>
81
            <th>Estimated delivery date</th>
117
            <th>Estimated delivery date</th>
82
            <th>Vendor</th>
118
            <th>Vendor</th>
Lines 85-102 $(document).ready(function() { Link Here
85
            <th>Basket</th>
121
            <th>Basket</th>
86
            <th>Claims count</th>
122
            <th>Claims count</th>
87
            <th>Claimed date</th>
123
            <th>Claimed date</th>
88
            [% IF Supplier %]
89
                <th><a id="CheckAll" href="#">Check all</a><br /><a id="CheckNone" href="#">Uncheck all</a></th>
90
            [% ELSE %]
91
                <th></th>
92
            [% END %]
93
        </tr>
124
        </tr>
94
        </thead>
125
      </thead>
95
        <tbody>
126
      <tbody>
96
    [% FOREACH lateorder IN lateorders %]
127
      [% FOREACH lateorder IN lateorders %]
97
        [% UNLESS ( loop.odd ) %]<tr class="highlight">
128
        [% UNLESS ( loop.odd ) %]<tr class="highlight">
98
        [% ELSE %]<tr>[% END %]
129
        [% ELSE %]<tr>[% END %]
99
            <td>
130
            <td>
131
                <input type="checkbox" value="[% lateorder.ordernumber %]" data-booksellerid="[% lateorder.supplierid %]" name="ordernumber">
132
            </td>
133
            <td>
100
                ([% lateorder.supplierid %])
134
                ([% lateorder.supplierid %])
101
                [% lateorder.orderdate %]
135
                [% lateorder.orderdate %]
102
                ([% lateorder.latesince %] days)
136
                ([% lateorder.latesince %] days)
Lines 133-163 $(document).ready(function() { Link Here
133
            </td>
167
            </td>
134
            <td>[% lateorder.claims_count %]</td>
168
            <td>[% lateorder.claims_count %]</td>
135
            <td>[% lateorder.claimed_date %]</td>
169
            <td>[% lateorder.claimed_date %]</td>
136
            <td>
137
                [% UNLESS lateorder.budget_lock %]
138
                    <input type="checkbox" class="checkbox" name="claim_for" value="[% lateorder.ordernumber %]"  booksellerid="[% lateorder.supplierid %]"/>
139
                [% END %]
140
             </td>
141
            </td>
142
        </tr>
170
        </tr>
143
        [% END %]
171
      [% END %]
144
    </tbody>
172
      </tbody>
145
    <tfoot>
173
      <tfoot>
146
        <tr> 
174
        <tr>
147
            <th>Total</th>
175
            <th colspan="5">Total</th>
148
            <th>&nbsp;</th>
149
            <th>&nbsp;</th>
150
            <th>&nbsp;</th>
151
            <th>[% total %]</th>
176
            <th>[% total %]</th>
152
            <th>&nbsp;</th>
177
            <th colspan="3">&nbsp;</th>
153
            <th>&nbsp;</th>
154
            <th>&nbsp;</th>
155
            <td>
156
                <input type="submit" value="Claim Order" />
157
            </td>
158
        </tr>
178
        </tr>
159
    </tfoot>
179
      </tfoot>
160
    </table>
180
    </table>
181
    <div class="spacer"></div>
182
183
    <p style="display:block;">
184
        <input type="button" value="Export as CSV" id="ExportSelected" />
185
        [% UNLESS lateorder.budget_lock %]
186
            <input type="submit"  value="Claim Order" />
187
        [% END %]
188
    </p>
161
</form>
189
</form>
162
[% ELSE %]<p>There are no late orders.</p>
190
[% ELSE %]<p>There are no late orders.</p>
163
[% END %]
191
[% 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