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

(-)a/installer/data/mysql/atomicupdate/bug_3150_-_add_LIST_and_CART_notices.perl (+297 lines)
Line 0 Link Here
1
$DBversion = 'XXX';
2
if( CheckVersion( $DBversion ) ) {
3
    $dbh->do(q{ INSERT IGNORE INTO letter (module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES
4
        ('catalogue','LIST','','Send list',1,'Your list: [% listname %]',"
5
<p>Hi,</p>
6
7
<p>[% borrower.firstname %] [% borrower.surname %] sent you a list from our online catalog called: [% listname %].</p>
8
9
<p>Please note that the attached file is a MARC bibliographic records file which can be imported into personal bibliographic software like EndNote, Reference Manager or ProCite.</p>
10
<hr/>
11
12
<p><<comment>></p>
13
<hr/>
14
15
<ol>
16
[% FOREACH BIBLIO_RESULT IN biblios %]
17
    <li>
18
        <span>
19
            [% BIBLIO_RESULT.title %]
20
            [% IF ( BIBLIO_RESULT.subtitle ) %]
21
                [% FOREACH subtitle IN BIBLIO_RESULT.subtitle.split(' | ') %]
22
                    [% subtitle %]
23
                [% END %]
24
            [% END %]
25
            [% BIBLIO_RESULT.part_number %] [% BIBLIO_RESULT.part_name | $raw %]
26
        </span>
27
28
        <p>
29
            [% IF ( BIBLIO_RESULT.HASAUTHORS ) %]
30
                <span>Author(s): [% IF ( BIBLIO_RESULT.author ) %][% BIBLIO_RESULT.author | $raw %][% END %]
31
32
                    [% IF ( BIBLIO_RESULT.MARCAUTHORS ) %]
33
                        [% IF ( BIBLIO_RESULT.author ) %]; [% END %]
34
                        [% FOREACH MARCAUTHOR IN BIBLIO_RESULT.MARCAUTHORS %]
35
                            [% FOREACH MARCAUTHOR_SUBFIELDS_LOO IN MARCAUTHOR.MARCAUTHOR_SUBFIELDS_LOOP %]
36
                                [% MARCAUTHOR_SUBFIELDS_LOO.separator | $raw %][% MARCAUTHOR_SUBFIELDS_LOO.value | $raw %]
37
                            [% END %]
38
                            [% UNLESS ( loop.last ) %];[% END %]
39
                        [% END %]
40
                    [% END %]
41
                </span><br/>
42
            [% END %]
43
44
            [% IF ( BIBLIO_RESULT.ISBN ) %]
45
                <span>
46
                    ISBN: [% FOREACH isbn IN BIBLIO_RESULT.ISBN %]
47
                        [% isbn | $raw %]
48
                        [% UNLESS ( loop.last ) %]; [% END %]
49
                    [% END %]
50
                </span><br/>
51
            [% END %]
52
53
            [% IF BIBLIO_RESULT.publishercode %]
54
                <span>
55
                    Published by: [% BIBLIO_RESULT.publishercode | $raw %]
56
                    [% IF ( BIBLIO_RESULT.publicationyear ) %]
57
                        in [% BIBLIO_RESULT.publicationyear | $raw %]
58
                    [% END %]
59
                    [% IF ( BIBLIO_RESULT.pages ) %]
60
                        , [% BIBLIO_RESULT.pages | $raw %]
61
                    [% END %]
62
                    [% IF BIBLIO_RESULT.item('size') %]
63
                        , [% BIBLIO_RESULT.item('size') | html %]
64
                    [% END %]
65
                </span><br/>
66
            [% END %]
67
68
            [% IF BIBLIO_RESULT.collection %]
69
                <span>
70
                    Collection: [% BIBLIO_RESULT.seriestitle | $raw %]
71
                </span><br/>
72
            [% END %]
73
74
            [% IF ( BIBLIO_RESULT.subject ) %]
75
                <span>
76
                    Subject: [% BIBLIO_RESULT.subject | $raw %]
77
                <span><br/>
78
            [% END %]
79
80
            [% IF ( BIBLIO_RESULT.copyrightdate ) %]
81
                <span>
82
                    Copyright year: [% BIBLIO_RESULT.copyrightdate | $raw %]
83
                </span><br/>
84
            [% END %]
85
86
            [% IF ( BIBLIO_RESULT.notes ) %]
87
                <span>
88
                    Notes: [% BIBLIO_RESULT.notes | $raw %]
89
                </span><br/>
90
            [% END %]
91
92
            [% IF ( BIBLIO_RESULT.unititle ) %]
93
                <span>
94
                    Unified title: [% BIBLIO_RESULT.unititle | $raw %]
95
                </span><br/>
96
            [% END %]
97
98
            [% IF ( BIBLIO_RESULT.serial ) %]
99
                <span>
100
                    Serial: [% BIBLIO_RESULT.serial | $raw %]
101
                </span><br/>
102
            [% END %]
103
104
            [% IF ( BIBLIO_RESULT.dewey ) %]
105
                <span>
106
                    Dewey: [% BIBLIO_RESULT.dewey | $raw %]
107
                </span><br/>
108
            [% END %]
109
110
            [% IF ( BIBLIO_RESULT.classification ) %]
111
                <span>
112
                    Classification: [% BIBLIO_RESULT.classification | $raw %]
113
                </span><br/>
114
            [% END %]
115
116
            [% IF ( BIBLIO_RESULT.lccn ) %]
117
                <span>
118
                    LCCN: [% BIBLIO_RESULT.lccn | $raw %]
119
                </span><br/>
120
            [% END %]
121
122
            [% IF ( BIBLIO_RESULT.url ) %]
123
                <span>
124
                    URL: [% BIBLIO_RESULT.url | html %]
125
                </span>
126
            [% END %]
127
        </p>
128
129
        [% SET OPACBaseURL = Koha.Preference('OPACBaseURL') %]
130
        [% IF ( OPACBaseURL ) %]
131
            <p>In online catalog: [% OPACBaseURL | $raw %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% BIBLIO_RESULT.biblionumber | html %]</p>
132
        [% END %]
133
134
        [% IF ( BIBLIO_RESULT.ITEM_RESULTS.size ) %]
135
            <p>Items:
136
                <ul>
137
                    [% FOREACH ITEM_RESULT IN BIBLIO_RESULT.ITEM_RESULTS %]<li>
138
                        [% ITEM_RESULT.branchname | $raw %]
139
                        [% ITEM_RESULT.location | $raw %]
140
                        [% IF ITEM_RESULT.itemcallnumber %]([% ITEM_RESULT.itemcallnumber | $raw %])[% END %]
141
                        [% ITEM_RESULT.barcode | $raw %]
142
                    </li>[% END %]
143
                </ul>
144
            </p>
145
        [% END %]
146
        <hr/>
147
    </li>
148
149
[% END %]
150
</ol>", 'email','default' ),
151
        ('catalogue','CART','','Send cart',1,'Your cart',"<p>Hi,</p>
152
153
<p>[% firstname | $raw %] [% surname | $raw %] sent you a cart from our online catalog.</p>
154
155
<p>Please note that the attached file is a MARC bibliographic records file which can be imported into personal bibliographic software like EndNote, Reference Manager or ProCite.</p>
156
<hr/>
157
158
[% IF comment %]
159
    <p>[% comment | $raw %]</p>
160
    <hr/>
161
[% END %]
162
163
<ol>
164
[% FOREACH BIBLIO_RESULT IN BIBLIO_RESULTS %]
165
    <li>
166
        <span>
167
            [% BIBLIO_RESULT.title | $raw %]
168
            [% IF ( BIBLIO_RESULT.subtitle ) %]
169
                [% FOREACH subtitle IN BIBLIO_RESULT.subtitle.split(' | ') %]
170
                    [% subtitle | $raw %]
171
                [% END %]
172
            [% END %]
173
            [% BIBLIO_RESULT.part_number | $raw %] [% BIBLIO_RESULT.part_name | $raw %]
174
        </span>
175
176
        <p>
177
            [% IF ( BIBLIO_RESULT.HASAUTHORS ) %]
178
                <span>Author(s): [% IF ( BIBLIO_RESULT.author ) %][% BIBLIO_RESULT.author | $raw %][% END %]
179
180
                    [% IF ( BIBLIO_RESULT.MARCAUTHORS ) %]
181
                        [% IF ( BIBLIO_RESULT.author ) %]; [% END %]
182
                        [% FOREACH MARCAUTHOR IN BIBLIO_RESULT.MARCAUTHORS %]
183
                            [% FOREACH MARCAUTHOR_SUBFIELDS_LOO IN MARCAUTHOR.MARCAUTHOR_SUBFIELDS_LOOP %]
184
                                [% MARCAUTHOR_SUBFIELDS_LOO.separator | $raw %][% MARCAUTHOR_SUBFIELDS_LOO.value | $raw %]
185
                            [% END %]
186
                            [% UNLESS ( loop.last ) %];[% END %]
187
                        [% END %]
188
                    [% END %]
189
                </span><br/>
190
            [% END %]
191
192
            [% IF ( BIBLIO_RESULT.ISBN ) %]
193
                <span>
194
                    ISBN: [% BIBLIO_RESULT.ISBN | $raw %]
195
                </span><br/>
196
            [% END %]
197
198
            [% IF BIBLIO_RESULT.publishercode %]
199
                <span>
200
                    Published by: [% BIBLIO_RESULT.publishercode | $raw %]
201
                    [% IF ( BIBLIO_RESULT.publicationyear ) %]
202
                        in [% BIBLIO_RESULT.publicationyear | $raw %]
203
                    [% END %]
204
                    [% IF ( BIBLIO_RESULT.pages ) %]
205
                        , [% BIBLIO_RESULT.pages | $raw %]
206
                    [% END %]
207
                    [% IF BIBLIO_RESULT.item('size') %]
208
                        , [% BIBLIO_RESULT.item('size') | $raw %]
209
                    [% END %]
210
                </span><br/>
211
            [% END %]
212
213
            [% IF BIBLIO_RESULT.collection %]
214
                <span>
215
                    Collection: [% BIBLIO_RESULT.seriestitle | $raw %]
216
                </span><br/>
217
            [% END %]
218
219
            [% IF ( BIBLIO_RESULT.subject ) %]
220
                <span>
221
                    Subject: [% BIBLIO_RESULT.subject | $raw %]
222
                <span><br/>
223
            [% END %]
224
225
            [% IF ( BIBLIO_RESULT.copyrightdate ) %]
226
                <span>
227
                    Copyright year: [% BIBLIO_RESULT.copyrightdate | $raw %]
228
                </span><br/>
229
            [% END %]
230
231
            [% IF ( BIBLIO_RESULT.notes ) %]
232
                <span>
233
                    Notes: [% BIBLIO_RESULT.notes | $raw %]
234
                </span><br/>
235
            [% END %]
236
237
            [% IF ( BIBLIO_RESULT.unititle ) %]
238
                <span>
239
                    Unified title: [% BIBLIO_RESULT.unititle | $raw %]
240
                </span><br/>
241
            [% END %]
242
243
            [% IF ( BIBLIO_RESULT.serial ) %]
244
                <span>
245
                    Serial: [% BIBLIO_RESULT.serial | $raw %]
246
                </span><br/>
247
            [% END %]
248
249
            [% IF ( BIBLIO_RESULT.dewey ) %]
250
                <span>
251
                    Dewey: [% BIBLIO_RESULT.dewey | $raw %]
252
                </span><br/>
253
            [% END %]
254
255
            [% IF ( BIBLIO_RESULT.classification ) %]
256
                <span>
257
                    Classification: [% BIBLIO_RESULT.classification | $raw %]
258
                </span><br/>
259
            [% END %]
260
261
            [% IF ( BIBLIO_RESULT.lccn ) %]
262
                <span>
263
                    LCCN: [% BIBLIO_RESULT.lccn | $raw %]
264
                </span><br/>
265
            [% END %]
266
267
            [% IF ( BIBLIO_RESULT.url ) %]
268
                <span>
269
                    URL: [% BIBLIO_RESULT.url | html %]
270
                </span>
271
            [% END %]
272
        </p>
273
274
        [% SET OPACBaseURL = Koha.Preference('OPACBaseURL') %]
275
        [% IF ( OPACBaseURL ) %]
276
            <p>In online catalog: [% OPACBaseURL | $raw %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% BIBLIO_RESULT.biblionumber | html %]</p>
277
        [% END %]
278
279
        [% IF ( BIBLIO_RESULT.ITEM_RESULTS.size ) %]
280
            <p>Items:
281
                <ul>
282
                    [% FOREACH ITEM_RESULT IN BIBLIO_RESULT.ITEM_RESULTS %]<li>
283
                        [% ITEM_RESULT.branchname | $raw %]
284
                        [% ITEM_RESULT.location | $raw %]
285
                        [% IF ITEM_RESULT.itemcallnumber %]([% ITEM_RESULT.itemcallnumber | $raw %])[% END %]
286
                        [% ITEM_RESULT.barcode | $raw %]
287
                    </li>[% END %]
288
                </ul>
289
            </p>
290
        [% END %]
291
        <hr/>
292
    </li>
293
[% END %]
294
</ol>",'email','default') });
295
296
    NewVersion( $DBversion, 3150, 'Add LIST and CART notices' );
297
}
(-)a/installer/data/mysql/en/mandatory/sample_notices.yml (+7 lines)
Lines 1442-1444 tables: Link Here
1442
            - "[% ELSE %]"
1442
            - "[% ELSE %]"
1443
            - "The following item, [% biblio.title %], has correctly been renewed and is now due on [% checkout.date_due | $KohaDates as_due_date => 1 %]"
1443
            - "The following item, [% biblio.title %], has correctly been renewed and is now due on [% checkout.date_due | $KohaDates as_due_date => 1 %]"
1444
            - "[% END %]"
1444
            - "[% END %]"
1445
1446
        - module: catalogue
1447
          code: LIST
1448
          branchcode: ""
1449
          name: "Send list"
1450
          is_html: 1
1451
          title: "Your list: [% shelfname %]"
(-)a/opac/opac-sendshelf.pl (-52 / +35 lines)
Lines 71-77 if ( $email ) { Link Here
71
71
72
    my $patron = Koha::Patrons->find( $borrowernumber );
72
    my $patron = Koha::Patrons->find( $borrowernumber );
73
    my $borcat = $patron ? $patron->categorycode : q{};
73
    my $borcat = $patron ? $patron->categorycode : q{};
74
74
=pod
75
    my $shelf = Koha::Virtualshelves->find( $shelfid );
75
    my $shelf = Koha::Virtualshelves->find( $shelfid );
76
    my $contents = $shelf->get_contents;
76
    my $contents = $shelf->get_contents;
77
    my $marcflavour         = C4::Context->preference('marcflavour');
77
    my $marcflavour         = C4::Context->preference('marcflavour');
Lines 113-172 if ( $email ) { Link Here
113
        firstname      => $patron->firstname,
113
        firstname      => $patron->firstname,
114
        surname        => $patron->surname,
114
        surname        => $patron->surname,
115
    );
115
    );
116
=cut
117
    my $shelf = Koha::Virtualshelves->find( $shelfid );
118
    my $contents = $shelf->get_contents;
119
    my @biblionumbers;
116
120
117
    # Getting template result
121
    while ( my $content = $contents->next ) {
118
    my $template_res = $template2->output();
122
        push @biblionumbers, $content->biblionumber;
119
    my $body;
123
    };
120
121
    my $subject;
122
    # Analysing information and getting mail properties
123
    if ( $template_res =~ /<SUBJECT>(?<subject>.*)<END_SUBJECT>/s ) {
124
        $subject = $+{subject};
125
        $subject =~ s|\n?(.*)\n?|$1|;
126
    }
127
    else {
128
        $subject = "no subject";
129
    }
130
124
131
    my $email_header = "";
125
    my %loops = (
132
    if ( $template_res =~ /<HEADER>(.*)<END_HEADER>/s ) {
126
        biblio => \@biblionumbers,
133
        $email_header = $1;
127
    );
134
        $email_header =~ s|\n?(.*)\n?|$1|;
135
    }
136
128
137
    if ( $template_res =~ /<MESSAGE>(.*)<END_MESSAGE>/s ) {
129
    my %substitute = (
138
        $body = $1;
130
        comment => $comment,
139
        $body =~ s|\n?(.*)\n?|$1|;
131
    );
140
    }
141
132
142
    my $THE_body = <<END_OF_BODY;
133
    my $letter = C4::Letters::GetPreparedLetter (
143
$email_header
134
        module => 'catalog',
144
$body
135
        letter_code => 'LIST',
145
END_OF_BODY
136
        branchcode => $branch,
146
137
        lang => $patron->lang,
147
    try {
138
        tables => {
148
        my $email = Koha::Email->create(
139
            biblio => $biblio->biblionumber,
149
            {
140
            borrowers => $borrowernumber,
150
                to      => $email,
141
        },
151
                subject => $subject,
142
        message_transport_type => 'email',
152
            }
143
        loops => \%loops,
153
        );
144
        substitute => \%substite,
154
        $email->text_body( $THE_body );
145
    )
155
        $email->attach(
146
156
            Encode::encode( "UTF-8", $iso2709 ),
147
    C4::Letters::EnqueueLetter({
157
            content_type => 'application/octet-stream',
148
        letter => $letter,
158
            name         => 'list.iso2709',
149
        message_transport_type => 'email',
159
            disposition  => 'attachment',
150
        borrowernumber => $patron->borrowernumber,
160
        );
151
        to_address => $email,
161
        my $library = Koha::Patrons->find( $borrowernumber )->library;
152
        reply_address => $patron->first_valid_email_address,
162
        $email->transport( $library->smtp_server->transport );
153
    });
163
        $email->send_or_die;
164
        $template->param( SENT => "1" );
165
    }
166
    catch {
167
        carp "Error sending mail: $_";
168
        $template->param( error => 1 );
169
    };
170
154
171
    $template->param(
155
    $template->param(
172
        shelfid => $shelfid,
156
        shelfid => $shelfid,
173
- 

Return to bug 3150