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

(-)a/C4/Letters.pm (-1 / +1 lines)
Lines 119-125 sub GetLetterTemplates { Link Here
119
    my $dbh       = C4::Context->dbh;
119
    my $dbh       = C4::Context->dbh;
120
    my $letters   = $dbh->selectall_hashref(
120
    my $letters   = $dbh->selectall_hashref(
121
        q|
121
        q|
122
            SELECT module, code, branchcode, name, is_html, title, content, message_transport_type
122
            SELECT module, code, branchcode, name, fee, is_html, title, content, message_transport_type
123
            FROM letter
123
            FROM letter
124
            WHERE module = ?
124
            WHERE module = ?
125
            AND code = ?
125
            AND code = ?
(-)a/installer/data/mysql/atomicupdate/bug12769_NoticeFeeManagement.sql (+4 lines)
Line 0 Link Here
1
ALTER TABLE  `letter` add  `fee` decimal(10,2) DEFAULT NULL AFTER `message_transport_type`;
2
INSERT INTO `systempreferences` (variable,value,options,explanation,type)
3
VALUES ('defaultnoticefee','0',NULL,' set up how much cost the sending of a notice',NULL),
4
('noticefeenote', '', NULL, 'Set up the notice fee note in the accountlines table', NULL);
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 1393-1398 CREATE TABLE `letter` ( -- table for all notice templates in Koha Link Here
1393
  `title` varchar(200) NOT NULL default '', -- subject line of the notice
1393
  `title` varchar(200) NOT NULL default '', -- subject line of the notice
1394
  `content` text, -- body text for the notice or slip
1394
  `content` text, -- body text for the notice or slip
1395
  `message_transport_type` varchar(20) NOT NULL DEFAULT 'email', -- transport type for this notice
1395
  `message_transport_type` varchar(20) NOT NULL DEFAULT 'email', -- transport type for this notice
1396
  `fee` decimal(10,2) DEFAULT NULL, -- set up the cost of sending a notice
1396
  PRIMARY KEY  (`module`,`code`, `branchcode`, `message_transport_type`),
1397
  PRIMARY KEY  (`module`,`code`, `branchcode`, `message_transport_type`),
1397
  CONSTRAINT `message_transport_type_fk` FOREIGN KEY (`message_transport_type`)
1398
  CONSTRAINT `message_transport_type_fk` FOREIGN KEY (`message_transport_type`)
1398
  REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE
1399
  REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE
(-)a/installer/data/mysql/sysprefs.sql (+2 lines)
Lines 104-109 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
104
('DefaultLongOverdueChargeValue', NULL, NULL, "Charge a lost item to the borrower's account when the LOST value of the item changes to n.", 'integer'),
104
('DefaultLongOverdueChargeValue', NULL, NULL, "Charge a lost item to the borrower's account when the LOST value of the item changes to n.", 'integer'),
105
('DefaultLongOverdueDays', NULL, NULL, "Set the LOST value of an item when the item has been overdue for more than n days.", 'integer'),
105
('DefaultLongOverdueDays', NULL, NULL, "Set the LOST value of an item when the item has been overdue for more than n days.", 'integer'),
106
('DefaultLongOverdueLostValue', NULL, NULL, "Set the LOST value of an item to n when the item has been overdue for more than defaultlongoverduedays days.", 'integer'),
106
('DefaultLongOverdueLostValue', NULL, NULL, "Set the LOST value of an item to n when the item has been overdue for more than defaultlongoverduedays days.", 'integer'),
107
('defaultnoticefee','0',NULL,' set up how much cost the sending of a notice',NULL),
107
('defaultSortField','relevance','relevance|popularity|call_number|pubdate|acqdate|title|author','Specify the default field used for sorting','Choice'),
108
('defaultSortField','relevance','relevance|popularity|call_number|pubdate|acqdate|title|author','Specify the default field used for sorting','Choice'),
108
('defaultSortOrder','dsc','asc|dsc|az|za','Specify the default sort order','Choice'),
109
('defaultSortOrder','dsc','asc|dsc|az|za','Specify the default sort order','Choice'),
109
('delimiter',';',';|tabulation|,|/|\\|#||','Define the default separator character for exporting reports','Choice'),
110
('delimiter',';',';|tabulation|,|/|\\|#||','Define the default separator character for exporting reports','Choice'),
Lines 221-226 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
221
('NotesBlacklist','',NULL,'List of notes fields that should not appear in the title notes/description separator of details','free'),
222
('NotesBlacklist','',NULL,'List of notes fields that should not appear in the title notes/description separator of details','free'),
222
('NotHighlightedWords','and|or|not',NULL,'List of words to NOT highlight when OpacHitHighlight is enabled','free'),
223
('NotHighlightedWords','and|or|not',NULL,'List of words to NOT highlight when OpacHitHighlight is enabled','free'),
223
('NoticeCSS','',NULL,'Notices CSS url.','free'),
224
('NoticeCSS','',NULL,'Notices CSS url.','free'),
225
('noticefeenote', '', NULL, 'Set up the notice fee note in the "accountlines" table', NULL),
224
('NotifyBorrowerDeparture','30',NULL,'Define number of days before expiry where circulation is warned about patron account expiry','Integer'),
226
('NotifyBorrowerDeparture','30',NULL,'Define number of days before expiry where circulation is warned about patron account expiry','Integer'),
225
('NovelistSelectEnabled','0',NULL,'Enable Novelist Select content.  Requires Novelist Profile and Password','YesNo'),
227
('NovelistSelectEnabled','0',NULL,'Enable Novelist Select content.  Requires Novelist Profile and Password','YesNo'),
226
('NovelistSelectPassword',NULL,NULL,'Enable Novelist user Profile','free'),
228
('NovelistSelectPassword',NULL,NULL,'Enable Novelist user Profile','free'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+8 lines)
Lines 626-631 Circulation: Link Here
626
                  yes: Charge
626
                  yes: Charge
627
                  no: "Don't Charge"
627
                  no: "Don't Charge"
628
            - the replacement price when a patron loses an item.
628
            - the replacement price when a patron loses an item.
629
        -
630
            - Set up how much cost the sending of a notice to
631
            - pref: DefaultNoticeFee
632
              class: integer
633
        -
634
            - Set up the notice fee note in the "accountlines" table to
635
            - pref: NoticeFeeNote
636
629
    Self Checkout:
637
    Self Checkout:
630
        -
638
        -
631
            - "Include the following JavaScript on all pages in the web-based self checkout:"
639
            - "Include the following JavaScript on all pages in the web-based self checkout:"
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt (+6 lines)
Lines 336-341 $(document).ready(function() { Link Here
336
                                    [% END %]
336
                                    [% END %]
337
                </select>
337
                </select>
338
            </li>
338
            </li>
339
            [% IF (module == "circulation") %]
340
            <li>
341
              <label for="code" >Notice fee:</label>
342
              <input type="text" id="fee" name="fee" size="7" maxlength="7" value="[% IF ( modify ) %][% fee %][% END %]"/>
343
            </li>
344
            [% END %]
339
            <li>
345
            <li>
340
              [% IF adding %]
346
              [% IF adding %]
341
                  <label for="code" class="required">Code:</label>
347
                  <label for="code" class="required">Code:</label>
(-)a/misc/cronjobs/advance_notices.pl (-10 / +47 lines)
Lines 244-251 UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { Link Here
244
        
244
        
245
        if ( $borrower_preferences->{'wants_digest'} ) {
245
        if ( $borrower_preferences->{'wants_digest'} ) {
246
            # cache this one to process after we've run through all of the items.
246
            # cache this one to process after we've run through all of the items.
247
            $due_digest->{ $upcoming->{borrowernumber} }->{email} = $from_address;
247
            my $digest = $due_digest->{$upcoming->{'borrowernumber'}} ||= {};
248
            $due_digest->{ $upcoming->{borrowernumber} }->{count}++;
248
            $digest->{email} ||= $from_address;
249
            $digest->{count}++;
250
            $digest->{itemnumber} = $upcoming->{'itemnumber'};
249
        } else {
251
        } else {
250
            my $biblio = C4::Biblio::GetBiblioFromItemNumber( $upcoming->{'itemnumber'} );
252
            my $biblio = C4::Biblio::GetBiblioFromItemNumber( $upcoming->{'itemnumber'} );
251
            my $letter_type = 'DUE';
253
            my $letter_type = 'DUE';
Lines 267-273 UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { Link Here
267
                                      message_transport_type => $transport,
269
                                      message_transport_type => $transport,
268
                                    } )
270
                                    } )
269
                    or warn "no letter of type '$letter_type' found. Please see sample_notices.sql";
271
                    or warn "no letter of type '$letter_type' found. Please see sample_notices.sql";
270
                push @letters, $letter if $letter;
272
                push @letters, $letter;
273
                if ($letter){
274
                    noticefine($upcoming->{'borrowernumber'}, $upcoming->{'itemnumber'}, $letter_type, $upcoming->{'branchcode'}, $transport, $letter );
275
                }
271
            }
276
            }
272
        }
277
        }
273
    } else {
278
    } else {
Lines 278-285 UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { Link Here
278
283
279
        if ( $borrower_preferences->{'wants_digest'} ) {
284
        if ( $borrower_preferences->{'wants_digest'} ) {
280
            # cache this one to process after we've run through all of the items.
285
            # cache this one to process after we've run through all of the items.
281
            $upcoming_digest->{ $upcoming->{borrowernumber} }->{email} = $from_address;
286
            my $digest = $upcoming_digest->{$upcoming->{'borrowernumber'}} ||= {};
282
            $upcoming_digest->{ $upcoming->{borrowernumber} }->{count}++;
287
            $digest->{email} ||= $from_address;
288
            $digest->{count}++;
289
            $digest->{itemnumber} = $upcoming->{'itemnumber'};
283
        } else {
290
        } else {
284
            my $biblio = C4::Biblio::GetBiblioFromItemNumber( $upcoming->{'itemnumber'} );
291
            my $biblio = C4::Biblio::GetBiblioFromItemNumber( $upcoming->{'itemnumber'} );
285
            my $letter_type = 'PREDUE';
292
            my $letter_type = 'PREDUE';
Lines 301-307 UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { Link Here
301
                                      message_transport_type => $transport,
308
                                      message_transport_type => $transport,
302
                                    } )
309
                                    } )
303
                    or warn "no letter of type '$letter_type' found. Please see sample_notices.sql";
310
                    or warn "no letter of type '$letter_type' found. Please see sample_notices.sql";
304
                push @letters, $letter if $letter;
311
                push @letters, $letter;
312
                if ($letter){
313
                    noticefine($upcoming->{'borrowernumber'}, $upcoming->{'itemnumber'}, $letter_type, $upcoming->{'branchcode'}, $transport, $letter );
314
                }
305
            }
315
            }
306
        }
316
        }
307
    }
317
    }
Lines 341-346 PATRON: while ( my ( $borrowernumber, $digest ) = each %$upcoming_digest ) { Link Here
341
    @letters = ();
351
    @letters = ();
342
    my $count = $digest->{count};
352
    my $count = $digest->{count};
343
    my $from_address = $digest->{email};
353
    my $from_address = $digest->{email};
354
    my $itemnumber = $digest->{itemnumber};
344
355
345
    my $borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $borrowernumber,
356
    my $borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $borrowernumber,
346
                                                                                  message_name   => 'advance_notice' } );
357
                                                                                  message_name   => 'advance_notice' } );
Lines 373-380 PATRON: while ( my ( $borrowernumber, $digest ) = each %$upcoming_digest ) { Link Here
373
                message_transport_type => $transport,
384
                message_transport_type => $transport,
374
            }
385
            }
375
          )
386
          )
376
          or warn "no letter of type '$letter_type' found. Please see sample_notices.sql";
387
          or die "no letter of type '$letter_type' found. Please see sample_notices.sql";
377
        push @letters, $letter if $letter;
388
        push @letters, $letter;
389
        if ($letter){
390
            noticefine($borrowernumber, $itemnumber, $letter_type, $branch_info{"branches.branchcode"}, $transport, $letter );
391
        }
378
    }
392
    }
379
393
380
    if ( @letters ) {
394
    if ( @letters ) {
Lines 400-405 PATRON: while ( my ( $borrowernumber, $digest ) = each %$due_digest ) { Link Here
400
    @letters = ();
414
    @letters = ();
401
    my $count = $digest->{count};
415
    my $count = $digest->{count};
402
    my $from_address = $digest->{email};
416
    my $from_address = $digest->{email};
417
    my $itemnumber = $digest->{itemnumber};
403
418
404
    my $borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $borrowernumber,
419
    my $borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $borrowernumber,
405
                                                                                  message_name   => 'item_due' } );
420
                                                                                  message_name   => 'item_due' } );
Lines 430-437 PATRON: while ( my ( $borrowernumber, $digest ) = each %$due_digest ) { Link Here
430
                message_transport_type => $transport,
445
                message_transport_type => $transport,
431
            }
446
            }
432
          )
447
          )
433
          or warn "no letter of type '$letter_type' found. Please see sample_notices.sql";
448
          or die "no letter of type '$letter_type' found. Please see sample_notices.sql";
434
        push @letters, $letter if $letter;
449
        push @letters, $letter;
450
        if ($letter){
451
            noticefine($borrowernumber, $itemnumber, $letter_type, $branch_info{"branches.branchcode"}, $transport, $letter );
452
        }
435
    }
453
    }
436
454
437
    if ( @letters ) {
455
    if ( @letters ) {
Lines 495-500 sub format_date { Link Here
495
    return output_pref($dt);
513
    return output_pref($dt);
496
}
514
}
497
515
516
sub noticefine {
517
    my ($borrowernumber, $itemnumber, $code, $branchcode, $message_transport_type, $letter ) = @_;
518
519
    my $letterFee = C4::Letters::getletter( 'circulation', $code, $branchcode, $message_transport_type);
520
521
    if ($letterFee) {
522
        my $sendfee;
523
        if ($letter->{'fee'}){
524
            $sendfee = $letter->{'fee'};
525
        } else {
526
            $sendfee = C4::Context->preference('DefaultNoticeFee');
527
        }
528
529
        if ($sendfee > 0){
530
            C4::Accounts::manualinvoice($borrowernumber, "", "", "F", $sendfee, C4::Context->preference('NoticeFeeNote'));
531
        }
532
    }
533
}
534
498
=head2 get_branch_info
535
=head2 get_branch_info
499
536
500
=cut
537
=cut
(-)a/misc/cronjobs/overdue_notices.pl (-2 / +13 lines)
Lines 501-507 END_SQL Link Here
501
            # <date> <itemcount> <firstname> <lastname> <address1> <address2> <address3> <city> <postcode> <country>
501
            # <date> <itemcount> <firstname> <lastname> <address1> <address2> <address3> <city> <postcode> <country>
502
502
503
            my $borrower_sql = <<'END_SQL';
503
            my $borrower_sql = <<'END_SQL';
504
SELECT issues.borrowernumber, firstname, surname, address, address2, city, zipcode, country, email, emailpro, B_email, smsalertnumber, phone, cardnumber,
504
SELECT issues.borrowernumber, issues.itemnumber, firstname, surname, address, address2, city, zipcode, country, email, emailpro, B_email, smsalertnumber, phone, cardnumber,
505
TO_DAYS(?)-TO_DAYS(date_due) as difference, date_due
505
TO_DAYS(?)-TO_DAYS(date_due) as difference, date_due
506
FROM   issues,borrowers,categories
506
FROM   issues,borrowers,categories
507
WHERE  issues.borrowernumber=borrowers.borrowernumber
507
WHERE  issues.borrowernumber=borrowers.borrowernumber
Lines 585-590 END_SQL Link Here
585
585
586
                my $letter = C4::Letters::getletter( 'circulation', $overdue_rules->{"letter$i"}, $branchcode );
586
                my $letter = C4::Letters::getletter( 'circulation', $overdue_rules->{"letter$i"}, $branchcode );
587
587
588
588
                unless ($letter) {
589
                unless ($letter) {
589
                    $verbose and warn qq|Message '$overdue_rules->{"letter$i"}' content not found|;
590
                    $verbose and warn qq|Message '$overdue_rules->{"letter$i"}' content not found|;
590
591
Lines 592-598 END_SQL Link Here
592
                    # FIXME : Does this mean a letter must be defined in order to trigger a debar ?
593
                    # FIXME : Does this mean a letter must be defined in order to trigger a debar ?
593
                    next PERIOD;
594
                    next PERIOD;
594
                }
595
                }
595
    
596
                my $sendfee;
597
                if ($letter->{'fee'}){
598
                    $sendfee = $letter->{'fee'};
599
                } else {
600
                    $sendfee = C4::Context->preference('DefaultNoticeFee');
601
                }
602
603
                if ($sendfee > 0){
604
                    C4::Accounts::manualinvoice($borrowernumber, "", "", "F", $sendfee, C4::Context->preference('NoticeFeeNote'));
605
                }
606
596
                if ( $overdue_rules->{"debarred$i"} ) {
607
                if ( $overdue_rules->{"debarred$i"} ) {
597
    
608
    
598
                    #action taken is debarring
609
                    #action taken is debarring
(-)a/tools/letter.pl (-20 / +34 lines)
Lines 159-168 sub add_form { Link Here
159
        # So we can only sent the first one to the template.
159
        # So we can only sent the first one to the template.
160
        for my $mtt ( @$message_transport_types ) {
160
        for my $mtt ( @$message_transport_types ) {
161
            # The letter_name
161
            # The letter_name
162
            if ( $first_flag and $letters->{$mtt}{name} ) {
162
            if ( $first_flag) {
163
                $template->param(
163
                if ($letters->{$mtt}{name}) {
164
                    letter_name=> $letters->{$mtt}{name},
164
                    $template->param(
165
                );
165
                        letter_name=> $letters->{$mtt}{name},
166
                    );
167
                }
168
                if ($letters->{$mtt}{fee}) {
169
                    $template->param(
170
                        fee => $letters->{$mtt}{fee},
171
                    );
172
                }
166
                $first_flag = 0;
173
                $first_flag = 0;
167
            }
174
            }
168
175
Lines 249-257 sub add_validate { Link Here
249
    my $oldmodule     = $input->param('oldmodule');
256
    my $oldmodule     = $input->param('oldmodule');
250
    my $code          = $input->param('code');
257
    my $code          = $input->param('code');
251
    my $name          = $input->param('name');
258
    my $name          = $input->param('name');
259
    my $fee           = $input->param('fee');
252
    my @mtt           = $input->param('message_transport_type');
260
    my @mtt           = $input->param('message_transport_type');
253
    my @title         = $input->param('title');
261
    my @title         = $input->param('title');
254
    my @content       = $input->param('content');
262
    my @content       = $input->param('content');
263
264
    my $insertfee = $fee;
265
    if (defined($fee) and $fee eq ''){
266
        $insertfee = undef;
267
    }
268
255
    for my $mtt ( @mtt ) {
269
    for my $mtt ( @mtt ) {
256
        my $is_html = $input->param("is_html_$mtt");
270
        my $is_html = $input->param("is_html_$mtt");
257
        my $title   = shift @title;
271
        my $title   = shift @title;
Lines 269-290 sub add_validate { Link Here
269
            next;
283
            next;
270
        }
284
        }
271
        elsif ( $letter and $letter->{message_transport_type} eq $mtt ) {
285
        elsif ( $letter and $letter->{message_transport_type} eq $mtt ) {
272
            $dbh->do(
286
            if (defined($fee)){
273
                q{
287
                $dbh->do(q{UPDATE letter SET branchcode = ?, module = ?, name = ?, is_html = ?, title = ?, content = ?, fee = ?
274
                    UPDATE letter
288
                    WHERE branchcode = ? AND module = ? AND code = ? AND message_transport_type = ?}, undef,
275
                    SET branchcode = ?, module = ?, name = ?, is_html = ?, title = ?, content = ?
289
                    $branchcode, $module, $name, $is_html || 0, $title, $content, $insertfee, $branchcode, $oldmodule, $code, $mtt);
276
                    WHERE branchcode = ? AND module = ? AND code = ? AND message_transport_type = ?
290
            } else {
277
                },
291
                $dbh->do(q{UPDATE letter SET branchcode = ?, module = ?, name = ?, is_html = ?, title = ?, content = ?
278
                undef,
292
                    WHERE branchcode = ? AND module = ? AND code = ? AND message_transport_type = ?}, undef,
279
                $branchcode, $module, $name, $is_html || 0, $title, $content,
293
                    $branchcode, $module, $name, $is_html || 0, $title, $content, $branchcode, $oldmodule, $code, $mtt);
280
                $branchcode, $oldmodule, $code, $mtt
294
            }
281
            );
282
        } else {
295
        } else {
283
            $dbh->do(
296
            if (defined($fee) and $fee != ''){
284
                q{INSERT INTO letter (branchcode,module,code,name,is_html,title,content,message_transport_type) VALUES (?,?,?,?,?,?,?,?)},
297
                $dbh->do(q{INSERT INTO letter (branchcode,module,code,name,is_html,title,content,message_transport_type, fee) VALUES (?,?,?,?,?,?,?,?,?)},undef,
285
                undef,
298
                    $branchcode, $module, $code, $name, $is_html || 0, $title, $content, $mtt, $fee);
286
                $branchcode, $module, $code, $name, $is_html || 0, $title, $content, $mtt
299
            } else {
287
            );
300
                $dbh->do(q{INSERT INTO letter (branchcode,module,code,name,is_html,title,content,message_transport_type) VALUES (?,?,?,?,?,?,?,?)},undef,
301
                    $branchcode, $module, $code, $name, $is_html || 0, $title, $content, $mtt);
302
            }
288
        }
303
        }
289
    }
304
    }
290
    # set up default display
305
    # set up default display
291
- 

Return to bug 12769