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

(-)a/installer/data/mysql/en/optional/csv_profiles.sql (+1 lines)
Line 0 Link Here
1
INSERT IGNORE INTO export_format( profile, description, content, csv_separator, type ) VALUES ( "issues to claim", "default csv export for issues claims", "SUPPLIER=aqbooksellers.name|TITLE=subscription.title|ISSUE NUMBER=serial.serialseq|LATE SINCE=serial.planneddate", ",", "sql" );
(-)a/installer/data/mysql/en/optional/csv_profiles.txt (+3 lines)
Line 0 Link Here
1
csv profiles
2
3
issues to claim: Bug 10854 allows to choose a csv profile for exporting claims. This profile is the default one.
(-)a/installer/data/mysql/updatedatabase.pl (+24 lines)
Lines 7157-7162 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
7157
    SetVersion($DBversion);
7157
    SetVersion($DBversion);
7158
}
7158
}
7159
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
$DBversion = "3.13.00.XXX";
7174
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
7175
    $dbh->do(q{
7176
        INSERT IGNORE INTO export_format( profile, description, content, csv_separator, type ) VALUES ( "issues to claim", "default csv export for issues claims", "SUPPLIER=aqbooksellers.name|TITLE=subscription.title|ISSUE NUMBER=serial.serialseq|LATE SINCE=serial.planneddate", ",", "sql" )
7177
    });
7178
    print "Upgrade to $DBversion done (Bug 10854: Add the default csv profile for claiming issues)\n";
7179
    SetVersion($DBversion);
7180
}
7181
7182
7183
7160
=head1 FUNCTIONS
7184
=head1 FUNCTIONS
7161
7185
7162
=head2 TableExists($table)
7186
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt (-7 / +14 lines)
Lines 14-20 Link Here
14
         var sTable = $("#claimst").dataTable($.extend(true, {}, dataTablesDefaults, {
14
         var sTable = $("#claimst").dataTable($.extend(true, {}, dataTablesDefaults, {
15
            "sDom": 't',
15
            "sDom": 't',
16
            "aoColumnDefs": [
16
            "aoColumnDefs": [
17
                { "aTargets": [ 0,1,-1 ], "bSortable": false, "bSearchable": false }
17
                { "aTargets": [ 0,1 ], "bSortable": false, "bSearchable": false }
18
            ],
18
            ],
19
            "bPaginate": false
19
            "bPaginate": false
20
        }));
20
        }));
Lines 25-31 Link Here
25
25
26
	    // Checkboxes : Select All / None
26
	    // Checkboxes : Select All / None
27
	    $("span.checkall").html("<input type=\"checkbox\" name=\"CheckAll\"> "+_("Check All")+"</input>");
27
	    $("span.checkall").html("<input type=\"checkbox\" name=\"CheckAll\"> "+_("Check All")+"</input>");
28
	    $("span.exportSelected").html("<a id=\"ExportSelected\" href=\"/cgi-bin/koha/serials/claims.pl\"> "+_("Export selected items data") +"<\/a>");
29
28
30
        $("#CheckAll").click(function() {
29
        $("#CheckAll").click(function() {
31
            $("#claimst tr:visible :checkbox").attr('checked', $("#CheckAll").is(':checked'));
30
            $("#claimst tr:visible :checkbox").attr('checked', $("#CheckAll").is(':checked'));
Lines 46-51 Link Here
46
		for (var i = 0; i < selected.length; i++) {
45
		for (var i = 0; i < selected.length; i++) {
47
		    url += '&amp;serialid=' + selected[i].value;
46
		    url += '&amp;serialid=' + selected[i].value;
48
		}
47
		}
48
        url += '&amp;csv_profile=' + $("#csv_profile_for_export option:selected").val();
49
		// And redirecting to the CSV page
49
		// And redirecting to the CSV page
50
		location.href = url;
50
		location.href = url;
51
		return false;
51
		return false;
Lines 259-265 Link Here
259
                    <th>Status</th>
259
                    <th>Status</th>
260
                    <th>Since</th>
260
                    <th>Since</th>
261
                    <th>Claim date</th>
261
                    <th>Claim date</th>
262
                <th>Begin claim</th>
263
                </tr></thead>
262
                </tr></thead>
264
                <tbody>[% FOREACH missingissue IN missingissues %]
263
                <tbody>[% FOREACH missingissue IN missingissues %]
265
                    <tr>
264
                    <tr>
Lines 294-306 Link Here
294
                        <td>
293
                        <td>
295
                        [% missingissue.claimdate %]
294
                        [% missingissue.claimdate %]
296
                        </td>
295
                        </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>
299
                        </td>
300
                    </tr>
296
                    </tr>
301
                [% END %]</tbody>
297
                [% END %]</tbody>
302
            </table>
298
            </table>
303
	     <p><span class="exportSelected"></span></p>
299
300
        [% IF csv_profiles %]
301
          <p>
302
            <span class="exportSelected"><a id="ExportSelected" href="/cgi-bin/koha/serials/claims.pl">Export selected items data</a></span>
303
            using the following csv profile:
304
            <select id="csv_profile_for_export">
305
              [% FOR csv IN csv_profiles %]
306
                <option value="[% csv.export_format_id %]">[% csv.profile %]</option>
307
               [% END %]
308
            </select>
309
          </p>
310
        [% END %]
304
311
305
[% IF ( letter ) %]
312
[% IF ( letter ) %]
306
        <fieldset class="action"> <label for="letter_code">Select notice:</label>
313
        <fieldset class="action"> <label for="letter_code">Select notice:</label>
(-)a/serials/claims.pl (+2 lines)
Lines 28-33 use C4::Bookseller qw( GetBookSeller ); Link Here
28
use C4::Context;
28
use C4::Context;
29
use C4::Letters;
29
use C4::Letters;
30
use C4::Branch;    # GetBranches GetBranchesLoop
30
use C4::Branch;    # GetBranches GetBranchesLoop
31
use C4::Csv qw( GetCsvProfiles );
31
32
32
my $input = CGI->new;
33
my $input = CGI->new;
33
34
Lines 98-103 $template->param( Link Here
98
        claimletter => $claimletter,
99
        claimletter => $claimletter,
99
        supplierloop => \@supplierinfo,
100
        supplierloop => \@supplierinfo,
100
        branchloop   => $branchloop,
101
        branchloop   => $branchloop,
102
        csv_profiles => C4::Csv::GetCsvProfiles( "sql" ),
101
        (uc(C4::Context->preference("marcflavour"))) => 1
103
        (uc(C4::Context->preference("marcflavour"))) => 1
102
        );
104
        );
103
output_html_with_http_headers $input, $cookie, $template->output;
105
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/serials/lateissues-excel.pl (-91 / +44 lines)
Lines 15-130 Link Here
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
17
18
use strict;
18
use Modern::Perl;
19
use warnings;
20
use CGI;
19
use CGI;
21
use C4::Auth;
20
use C4::Auth;
22
use C4::Serials;
21
use C4::Serials;
23
use C4::Acquisition;
22
use C4::Acquisition;
24
use C4::Output;
23
use C4::Output;
25
use C4::Context;
24
use C4::Context;
25
use C4::Csv qw( GetCsvProfile );
26
26
27
# use Date::Manip;
28
use Text::CSV_XS;
27
use Text::CSV_XS;
29
28
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;
29
my $query = new CGI;
45
my $supplierid = $query->param('supplierid');
30
my $supplierid = $query->param('supplierid');
46
my @serialid = $query->param('serialid');
31
my @serialids = $query->param('serialid');
47
my $op = $query->param('op') || q{};
32
my $op = $query->param('op') || q{};
48
my $serialidcount = @serialid;
49
33
50
my @loop1;
34
my $csv_profile_id = $query->param('csv_profile');
51
my @lateissues;
35
my $csv_profile = C4::Csv::GetCsvProfile( $csv_profile_id );
52
if($op ne 'claims'){
36
die "There is no valid csv profile given" unless $csv_profile;
53
    @lateissues = GetLateIssues($supplierid);
37
54
    for my $issue (@lateissues){
38
my $csv = Text::CSV_XS->new({
55
        push @loop1,
39
    'quote_char'  => '"',
56
      [ $issue->{'name'}, $issue->{'title'}, $issue->{'serialseq'}, $issue->{'planneddate'},];
40
    'escape_char' => '"',
57
    }
41
    'sep_char'    => $csv_profile->{csv_separator},
42
    'binary'      => 1
43
});
44
45
my $content = $csv_profile->{content};
46
my ( @headers, @fields );
47
while ( $content =~ /
48
    ([^=]+) # header
49
    =
50
    ([^\|]+) # fieldname (table.row or row)
51
    \|? /gxms
52
) {
53
    push @headers, $1;
54
    my $field = $2;
55
    $field =~ s/[^\.]*\.?//; # Remove the table name if exists.
56
    push @fields, $field;
58
}
57
}
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
58
65
    for (my $j=0;$j<@missingissues;$j++){
59
my @rows;
66
	my @rows2 = ($missingissues[$j]->{'name'},          # lets build up a row
60
for my $serialid ( @serialids ) {
67
	             $missingissues[$j]->{'title'},
61
    my @missingissues = GetLateOrMissingIssues($supplierid, $serialid);
68
                     $missingissues[$j]->{'serialseq'},
62
    my $issue = $missingissues[0];
69
                     $missingissues[$j]->{'planneddate'},
63
    my @row;
70
                     );
64
    for my $field ( @fields ) {
71
        push (@loop2, \@rows2);
65
        push @row, $issue->{$field};
72
    }
66
    }
73
    $totalcount2 += scalar @missingissues;
67
    push @rows, \@row;
74
    # update claim date to let one know they have looked at this missing item
75
    updateClaim($serialid[$k]);
76
}
77
68
78
my $heading ='';
69
    # update claim date to let one know they have looked at this missing item
79
my $filename ='';
70
    updateClaim($serialid);
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
}
71
}
87
72
88
print $query->header(
73
print $query->header(
89
        -type       => 'application/vnd.ms-excel',
74
    -type       => 'plain/text',
90
        -attachment => "claims".$filename.".csv",
75
    -attachment => "serials-claims.csv",
91
    );
76
);
92
93
if($op ne 'claims'){
94
    print "LATE ISSUES ".$heading."\n\n";
95
    print "SUPPLIER,TITLE,ISSUE NUMBER,LATE SINCE\n";
96
77
97
    for my $row ( @loop1 ) {
78
print join( $csv_profile->{csv_separator}, @headers ) . "\n";
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
79
128
} else {
80
for my $row ( @rows ) {
129
    print ",,Total Number Missing, $totalcount2\n";
81
    $csv->combine(@$row);
82
    my $string = $csv->string;
83
    print $string, "\n";
130
}
84
}
131
- 

Return to bug 10854