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

(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-downloadshelf.tt (-21 / +30 lines)
Lines 7-35 Link Here
7
</script>
7
</script>
8
</head>
8
</head>
9
<body id="opac-downloadlist" style="padding:1em;">
9
<body id="opac-downloadlist" style="padding:1em;">
10
<div id="userdownloadshelf" class="container">[% IF ( format ) %]
10
<div id="userdownloadshelf" class="container">
11
    <p>Your download should begin automatically.</p>
11
[% UNLESS ( invalidlist ) %]
12
[% ELSE %]
12
	[% IF ( format ) %]
13
<form method="post" action="/cgi-bin/koha/opac-downloadshelf.pl">
13
	    <p>Your download should begin automatically.</p>
14
<fieldset class="rows">
14
	[% ELSE %]
15
	<ol><li><label for="format">Download list:</label>
15
	<form method="post" action="/cgi-bin/koha/opac-downloadshelf.pl">
16
        <select name="format" id="format">
16
	<fieldset class="rows">
17
	    <option value="">-- Choose Format --</option>
17
		<ol><li><label for="format">Download list:</label>
18
	    <option value="iso2709">iso2709</option>
18
	        <select name="format" id="format">
19
	    <option value="ris">RIS</option>
19
		    <option value="">-- Choose Format --</option>
20
	    <option value="bibtex">BibTex</option>
20
		    <option value="iso2709">iso2709</option>
21
	    [% FOREACH csv_profile IN csv_profiles %]
21
		    <option value="ris">RIS</option>
22
	    <option value="[% csv_profile.export_format_id %]">CSV - [% csv_profile.profile %]</option>
22
		    <option value="bibtex">BibTex</option>
23
	    [% END %]
23
		    [% FOREACH csv_profile IN csv_profiles %]
24
		    <option value="[% csv_profile.export_format_id %]">CSV - [% csv_profile.profile %]</option>
25
		    [% END %]
24
26
25
	</select></li></ol>
27
		</select></li></ol>
26
</fieldset>
28
	</fieldset>
27
<fieldset class="action">	<input type="hidden" name="shelfid" value="[% shelfid %]" />
29
	<fieldset class="action">	<input type="hidden" name="shelfid" value="[% shelfid %]" />
28
	<input type="submit" name="save" value="Go" /></fieldset>
30
		<input type="submit" name="save" value="Go" /></fieldset>
29
    </form>
31
	    </form>
30
32
31
    <p><a class="button close" href="/cgi-bin/koha/opac-shelves.pl">Back to lists</a></p>
33
	    <p><a class="button close" href="/cgi-bin/koha/opac-shelves.pl">Back to lists</a></p>
32
34
33
[% END %]</div>
35
	[% END %]
36
[% ELSE %]
37
	<div class="dialog alert">
38
		<p>You do not have permission to download this list.</p>
39
	</div>
40
	<p><a class="button close" href="/cgi-bin/koha/opac-shelves.pl">Back to lists</a></p>
41
[% END %]
42
</div>
34
</body>
43
</body>
35
</html>
44
</html>
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-sendshelfform.tt (-18 / +23 lines)
Lines 20-44 Link Here
20
    [% END %]
20
    [% END %]
21
    
21
    
22
[% ELSE %]
22
[% ELSE %]
23
    [% IF ( invalidlist ) %]
24
        <div class="dialog alert">
25
        <p>You do not have permission to send this list.</p>
26
        </div>
27
        <p><a class="button close" href="/cgi-bin/koha/opac-shelves.pl">Back to lists</a></p>
28
    [% ELSE %]
29
        <form action="[% url %]" method="post" id="sendshelfform">
23
30
24
<form action="[% url %]" method="post" id="sendshelfform">
31
        <fieldset class="rows">
25
32
        <legend>Sending your list</legend>
26
<fieldset class="rows"> 
33
        <ol>   <li>
27
<legend>Sending your list</legend>
34
                <label for="email">Email Address:</label>
28
<ol>   <li>
35
                <input type="text" id="email" name="email" size="43" class="focus" />
29
        <label for="email">Email Address:</label>
36
            </li>
30
        <input type="text" id="email" name="email" size="43" class="focus" />
37
            <li>
31
    </li>
38
                    <label for="comment">Comment:</label>
32
    <li>
39
                    <textarea id="comment" name="comment" rows="4" cols="40"></textarea>
33
            <label for="comment">Comment:</label>
40
            </li>
34
            <textarea id="comment" name="comment" rows="4" cols="40"></textarea>
41
            <li>
35
    </li>
42
                <input type="hidden" name="shelfid" value="[% shelfid %]" />
36
    <li>
43
            </li></ol></fieldset>
37
        <input type="hidden" name="shelfid" value="[% shelfid %]" />
44
               <fieldset class="action"> <input type="submit" value="Send" /> <a class="cancel close" href="#">Cancel</a> </fieldset>
38
    </li></ol></fieldset>
45
        </form>
39
       <fieldset class="action"> <input type="submit" value="Send" /> <a class="cancel close" href="#">Cancel</a> </fieldset>
46
    [% END %]
40
</form>
41
42
[% END %]</div>
47
[% END %]</div>
43
</body>
48
</body>
44
</html>
49
</html>
(-)a/opac/opac-downloadshelf.pl (-39 / +46 lines)
Lines 48-99 my $shelfid = $query->param('shelfid'); Link Here
48
my $format  = $query->param('format');
48
my $format  = $query->param('format');
49
my $dbh     = C4::Context->dbh;
49
my $dbh     = C4::Context->dbh;
50
50
51
if ($shelfid && $format) {
51
if ( ShelfPossibleAction( (defined($borrowernumber) ? $borrowernumber : -1), $shelfid, 'view' ) ) {
52
53
    my @shelf               = GetShelf($shelfid);
54
    my ($items, $totitems)  = GetShelfContents($shelfid);
55
    my $marcflavour         = C4::Context->preference('marcflavour');
56
    my $output;
57
58
   # CSV 
59
    if ($format =~ /^\d+$/) {
60
        my @biblios;
61
        foreach (@$items) {
62
            push @biblios, $_->{biblionumber};
63
        }
64
        $output = marc2csv(\@biblios, $format);
65
            
66
    # Other formats
67
    } else {
68
        foreach my $biblio (@$items) {
69
            my $biblionumber = $biblio->{biblionumber};
70
52
71
            my $record = GetMarcBiblio($biblionumber, 1);
53
    if ($shelfid && $format) {
72
            next unless $record;
73
54
74
            if ($format eq 'iso2709') {
55
        my @shelf               = GetShelf($shelfid);
75
                $output .= $record->as_usmarc();
56
        my ($items, $totitems)  = GetShelfContents($shelfid);
76
            }
57
        my $marcflavour         = C4::Context->preference('marcflavour');
77
            elsif ($format eq 'ris' ) {
58
        my $output;
78
                $output .= marc2ris($record);
59
60
       # CSV
61
        if ($format =~ /^\d+$/) {
62
            my @biblios;
63
            foreach (@$items) {
64
                push @biblios, $_->{biblionumber};
79
            }
65
            }
80
            elsif ($format eq 'bibtex') {
66
            $output = marc2csv(\@biblios, $format);
81
                $output .= marc2bibtex($record, $biblionumber);
67
                
68
        # Other formats
69
        } else {
70
            foreach my $biblio (@$items) {
71
                my $biblionumber = $biblio->{biblionumber};
72
73
                my $record = GetMarcBiblio($biblionumber, 1);
74
                next unless $record;
75
76
                if ($format eq 'iso2709') {
77
                    $output .= $record->as_usmarc();
78
                }
79
                elsif ($format eq 'ris' ) {
80
                    $output .= marc2ris($record);
81
                }
82
                elsif ($format eq 'bibtex') {
83
                    $output .= marc2bibtex($record, $biblionumber);
84
                }
82
            }
85
            }
83
        }
86
        }
84
    }
85
87
86
    # If it was a CSV export we change the format after the export so the file extension is fine
88
        # If it was a CSV export we change the format after the export so the file extension is fine
87
    $format = "csv" if ($format =~ m/^\d+$/);
89
        $format = "csv" if ($format =~ m/^\d+$/);
90
91
        print $query->header(
92
    	-type => 'application/octet-stream',
93
    	-'Content-Transfer-Encoding' => 'binary',
94
    	-attachment=>"shelf.$format");
95
        print $output;
88
96
89
    print $query->header(
97
    } else {
90
	-type => 'application/octet-stream',
98
        $template->param(csv_profiles => GetCsvProfilesLoop());
91
	-'Content-Transfer-Encoding' => 'binary',
99
        $template->param(shelfid => $shelfid); 
92
	-attachment=>"shelf.$format");
100
        output_html_with_http_headers $query, $cookie, $template->output;
93
    print $output;
101
    }
94
102
95
} else {
103
} else {
96
    $template->param(csv_profiles => GetCsvProfilesLoop());
104
    $template->param(invalidlist => 1); 
97
    $template->param(shelfid => $shelfid); 
98
    output_html_with_http_headers $query, $cookie, $template->output;
105
    output_html_with_http_headers $query, $cookie, $template->output;
99
}
106
}
(-)a/opac/opac-sendshelf.pl (-1 / +9 lines)
Lines 51-56 my $email = $query->param('email'); Link Here
51
51
52
my $dbh          = C4::Context->dbh;
52
my $dbh          = C4::Context->dbh;
53
53
54
if ( ShelfPossibleAction( (defined($borrowernumber) ? $borrowernumber : -1), $shelfid, 'view' ) ) {
55
54
if ( $email ) {
56
if ( $email ) {
55
    my $email_from = C4::Context->preference('KohaAdminEmailAddress');
57
    my $email_from = C4::Context->preference('KohaAdminEmailAddress');
56
    my $comment    = $query->param('comment');
58
    my $comment    = $query->param('comment');
Lines 177-179 END_OF_BODY Link Here
177
                    );
179
                    );
178
    output_html_with_http_headers $query, $cookie, $template->output;
180
    output_html_with_http_headers $query, $cookie, $template->output;
179
}
181
}
180
- 
182
183
} else {
184
    $template->param( invalidlist => 1,
185
                      url     => "/cgi-bin/koha/opac-sendshelf.pl",
186
    );
187
    output_html_with_http_headers $query, $cookie, $template->output;
188
}

Return to bug 3140