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

(-)a/acqui/lateorders-excel.pl (-65 lines)
Lines 1-65 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-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 / +4 lines)
Lines 81-88 if ($op and $op eq "send_alert"){ Link Here
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?
84
        AddClaim ( $_ ) for @ordernums;
84
        if ( not $err ) {
85
            AddClaim ( $_ ) for @ordernums
86
        }
85
    };
87
    };
88
86
    if ( $@ ) {
89
    if ( $@ ) {
87
        $template->param(error_claim => $@);
90
        $template->param(error_claim => $@);
88
    } elsif ( defined $err->{error} and $err->{error} eq "no_email" ) {
91
    } elsif ( defined $err->{error} and $err->{error} eq "no_email" ) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt (-7 / +8 lines)
Lines 14-21 $(document).ready(function() { Link Here
14
        }
14
        }
15
    });
15
    });
16
16
17
    $("span.exportSelected").html("<a id=\"ExportSelected\" href=\"/cgi-bin/koha/acqui/lateorders.pl\"> "+_("Export selected items data") +"<\/a>");
18
19
    $('#CheckAll').click(function(){ $("#late_orders td").checkCheckboxes();});
17
    $('#CheckAll').click(function(){ $("#late_orders td").checkCheckboxes();});
20
    $('#CheckNone').click(function(){ $("#late_orders td").unCheckCheckboxes();});
18
    $('#CheckNone').click(function(){ $("#late_orders td").unCheckCheckboxes();});
21
19
Lines 29-35 $(document).ready(function() { Link Here
29
        }
27
        }
30
28
31
        // Building the url from currently checked boxes
29
        // Building the url from currently checked boxes
32
        var url = '/cgi-bin/koha/acqui/lateorders-excel.pl?op=export';
30
        var url = '/cgi-bin/koha/acqui/lateorders-export.pl?op=export';
33
        for (var i = 0; i < selected.length; i++) {
31
        for (var i = 0; i < selected.length; i++) {
34
            url += '&amp;ordernumber=' + selected[i].value;
32
            url += '&amp;ordernumber=' + selected[i].value;
35
        }
33
        }
Lines 146-155 $(document).ready(function() { Link Here
146
        </tfoot>
144
        </tfoot>
147
    </table>
145
    </table>
148
    <div class="spacer"></div>
146
    <div class="spacer"></div>
149
    <p style="display:block;"><span class="exportSelected"></span></p>
147
150
    [% UNLESS lateorder.budget_lock %]
148
    <p style="display:block;">
151
        <p style="display:block;"><input type="submit"  value="Claim Order" /></p>
149
        <input type="button" value="Export as CSV" id="ExportSelected" />
152
    [% END %]
150
        [% UNLESS lateorder.budget_lock %]
151
            <input type="submit"  value="Claim Order" />
152
        [% END %]
153
    </p>
153
</form>
154
</form>
154
[% ELSE %]<p>There are no late orders.</p>
155
[% ELSE %]<p>There are no late orders.</p>
155
[% END %]
156
[% 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>
(-)a/serials/lateissues-excel.pl (-130 lines)
Lines 1-130 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 strict;
19
use warnings;
20
use CGI;
21
use C4::Auth;
22
use C4::Serials;
23
use C4::Acquisition;
24
use C4::Output;
25
use C4::Context;
26
27
# use Date::Manip;
28
use Text::CSV_XS;
29
30
31
# &Date_Init("DateFormat=non-US"); # set non-USA date, eg:19/08/2005
32
33
34
my $csv = Text::CSV_XS->new(
35
        {
36
            'quote_char'  => '"',
37
            'escape_char' => '"',
38
            'sep_char'    => ',',
39
            'binary'      => 1
40
        }
41
    );
42
43
44
my $query = new CGI;
45
my $supplierid = $query->param('supplierid');
46
my @serialid = $query->param('serialid');
47
my $op = $query->param('op') || q{};
48
my $serialidcount = @serialid;
49
50
my @loop1;
51
my @lateissues;
52
if($op ne 'claims'){
53
    @lateissues = GetLateIssues($supplierid);
54
    for my $issue (@lateissues){
55
        push @loop1,
56
      [ $issue->{'name'}, $issue->{'title'}, $issue->{'serialseq'}, $issue->{'planneddate'},];
57
    }
58
}
59
my $totalcount2 = 0;
60
my @loop2;
61
my @missingissues;
62
for (my $k=0;$k<@serialid;$k++){
63
    @missingissues = GetLateOrMissingIssues($supplierid, $serialid[$k]);
64
65
    for (my $j=0;$j<@missingissues;$j++){
66
	my @rows2 = ($missingissues[$j]->{'name'},          # lets build up a row
67
	             $missingissues[$j]->{'title'},
68
                     $missingissues[$j]->{'serialseq'},
69
                     $missingissues[$j]->{'planneddate'},
70
                     );
71
        push (@loop2, \@rows2);
72
    }
73
    $totalcount2 += scalar @missingissues;
74
    # update claim date to let one know they have looked at this missing item
75
    updateClaim($serialid[$k]);
76
}
77
78
my $heading ='';
79
my $filename ='';
80
if($supplierid){
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
83
        $heading = "FOR $missingissues[0]->{'name'}";
84
	$filename = "_$missingissues[0]->{'name'}";
85
    }
86
}
87
88
print $query->header(
89
        -type       => 'application/vnd.ms-excel',
90
        -attachment => "claims".$filename.".csv",
91
    );
92
93
if($op ne 'claims'){
94
    print "LATE ISSUES ".$heading."\n\n";
95
    print "SUPPLIER,TITLE,ISSUE NUMBER,LATE SINCE\n";
96
97
    for my $row ( @loop1 ) {
98
99
        $csv->combine(@$row);
100
        my $string = $csv->string;
101
        print $string, "\n";
102
    }
103
104
    print ",,,,,,,\n\n";
105
}
106
if($serialidcount == 1){
107
    print "MISSING ISSUE ".$heading."\n\n";
108
} else {
109
    print "MISSING ISSUES ".$heading."\n\n";
110
}
111
print "SUPPLIER,TITLE,ISSUE NUMBER,LATE SINCE\n";
112
113
for my $row ( @loop2 ) {
114
115
        $csv->combine(@$row);
116
        my $string = $csv->string;
117
        print $string, "\n";
118
    }
119
120
print ",,,,,,,\n";
121
print ",,,,,,,\n";
122
if($op ne 'claims'){
123
    my $count = scalar @lateissues;
124
    print ",,Total Number Late, $count\n";
125
}
126
if($serialidcount == 1){
127
128
} else {
129
    print ",,Total Number Missing, $totalcount2\n";
130
}
(-)a/serials/lateissues-export.pl (-1 / +130 lines)
Line 0 Link Here
0
- 
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 strict;
19
use warnings;
20
use CGI;
21
use C4::Auth;
22
use C4::Serials;
23
use C4::Acquisition;
24
use C4::Output;
25
use C4::Context;
26
27
# use Date::Manip;
28
use Text::CSV_XS;
29
30
31
# &Date_Init("DateFormat=non-US"); # set non-USA date, eg:19/08/2005
32
33
34
my $csv = Text::CSV_XS->new(
35
        {
36
            'quote_char'  => '"',
37
            'escape_char' => '"',
38
            'sep_char'    => ',',
39
            'binary'      => 1
40
        }
41
    );
42
43
44
my $query = new CGI;
45
my $supplierid = $query->param('supplierid');
46
my @serialid = $query->param('serialid');
47
my $op = $query->param('op') || q{};
48
my $serialidcount = @serialid;
49
50
my @loop1;
51
my @lateissues;
52
if($op ne 'claims'){
53
    @lateissues = GetLateIssues($supplierid);
54
    for my $issue (@lateissues){
55
        push @loop1,
56
      [ $issue->{'name'}, $issue->{'title'}, $issue->{'serialseq'}, $issue->{'planneddate'},];
57
    }
58
}
59
my $totalcount2 = 0;
60
my @loop2;
61
my @missingissues;
62
for (my $k=0;$k<@serialid;$k++){
63
    @missingissues = GetLateOrMissingIssues($supplierid, $serialid[$k]);
64
65
    for (my $j=0;$j<@missingissues;$j++){
66
	my @rows2 = ($missingissues[$j]->{'name'},          # lets build up a row
67
	             $missingissues[$j]->{'title'},
68
                     $missingissues[$j]->{'serialseq'},
69
                     $missingissues[$j]->{'planneddate'},
70
                     );
71
        push (@loop2, \@rows2);
72
    }
73
    $totalcount2 += scalar @missingissues;
74
    # update claim date to let one know they have looked at this missing item
75
    updateClaim($serialid[$k]);
76
}
77
78
my $heading ='';
79
my $filename ='';
80
if($supplierid){
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
83
        $heading = "FOR $missingissues[0]->{'name'}";
84
	$filename = "_$missingissues[0]->{'name'}";
85
    }
86
}
87
88
print $query->header(
89
        -type       => 'application/vnd.ms-excel',
90
        -attachment => "claims".$filename.".csv",
91
    );
92
93
if($op ne 'claims'){
94
    print "LATE ISSUES ".$heading."\n\n";
95
    print "SUPPLIER,TITLE,ISSUE NUMBER,LATE SINCE\n";
96
97
    for my $row ( @loop1 ) {
98
99
        $csv->combine(@$row);
100
        my $string = $csv->string;
101
        print $string, "\n";
102
    }
103
104
    print ",,,,,,,\n\n";
105
}
106
if($serialidcount == 1){
107
    print "MISSING ISSUE ".$heading."\n\n";
108
} else {
109
    print "MISSING ISSUES ".$heading."\n\n";
110
}
111
print "SUPPLIER,TITLE,ISSUE NUMBER,LATE SINCE\n";
112
113
for my $row ( @loop2 ) {
114
115
        $csv->combine(@$row);
116
        my $string = $csv->string;
117
        print $string, "\n";
118
    }
119
120
print ",,,,,,,\n";
121
print ",,,,,,,\n";
122
if($op ne 'claims'){
123
    my $count = scalar @lateissues;
124
    print ",,Total Number Late, $count\n";
125
}
126
if($serialidcount == 1){
127
128
} else {
129
    print ",,Total Number Missing, $totalcount2\n";
130
}

Return to bug 7298