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

(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 1388-1393 CREATE TABLE `letter` ( -- table for all notice templates in Koha Link Here
1388
  `title` varchar(200) NOT NULL default '', -- subject line of the notice
1388
  `title` varchar(200) NOT NULL default '', -- subject line of the notice
1389
  `content` text, -- body text for the notice or slip
1389
  `content` text, -- body text for the notice or slip
1390
  `message_transport_type` varchar(20) NOT NULL DEFAULT 'email', -- transport type for this notice
1390
  `message_transport_type` varchar(20) NOT NULL DEFAULT 'email', -- transport type for this notice
1391
  `fee` decimal(10,2) DEFAULT NULL, -- set up the cost of sending a notice
1391
  PRIMARY KEY  (`module`,`code`, `branchcode`, `message_transport_type`),
1392
  PRIMARY KEY  (`module`,`code`, `branchcode`, `message_transport_type`),
1392
  CONSTRAINT `message_transport_type_fk` FOREIGN KEY (`message_transport_type`)
1393
  CONSTRAINT `message_transport_type_fk` FOREIGN KEY (`message_transport_type`)
1393
  REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE
1394
  REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE
(-)a/installer/data/mysql/sysprefs.sql (+2 lines)
Lines 100-105 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
100
('DefaultLongOverdueChargeValue', NULL, NULL, "Charge a lost item to the borrower's account when the LOST value of the item changes to n.", 'integer'),
100
('DefaultLongOverdueChargeValue', NULL, NULL, "Charge a lost item to the borrower's account when the LOST value of the item changes to n.", 'integer'),
101
('DefaultLongOverdueDays', NULL, NULL, "Set the LOST value of an item when the item has been overdue for more than n days.", 'integer'),
101
('DefaultLongOverdueDays', NULL, NULL, "Set the LOST value of an item when the item has been overdue for more than n days.", 'integer'),
102
('DefaultLongOverdueLostValue', NULL, NULL, "Set the LOST value of an item to n when the item has been overdue for more than defaultlongoverduedays days.", 'integer'),
102
('DefaultLongOverdueLostValue', NULL, NULL, "Set the LOST value of an item to n when the item has been overdue for more than defaultlongoverduedays days.", 'integer'),
103
('defaultnoticefee','0',NULL,' set up how much cost the sending of a notice',NULL),
103
('defaultSortField','relevance','relevance|popularity|call_number|pubdate|acqdate|title|author','Specify the default field used for sorting','Choice'),
104
('defaultSortField','relevance','relevance|popularity|call_number|pubdate|acqdate|title|author','Specify the default field used for sorting','Choice'),
104
('defaultSortOrder','dsc','asc|dsc|az|za','Specify the default sort order','Choice'),
105
('defaultSortOrder','dsc','asc|dsc|az|za','Specify the default sort order','Choice'),
105
('delimiter',';',';|tabulation|,|/|\\|#||','Define the default separator character for exporting reports','Choice'),
106
('delimiter',';',';|tabulation|,|/|\\|#||','Define the default separator character for exporting reports','Choice'),
Lines 216-221 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
216
('NotesBlacklist','',NULL,'List of notes fields that should not appear in the title notes/description separator of details','free'),
217
('NotesBlacklist','',NULL,'List of notes fields that should not appear in the title notes/description separator of details','free'),
217
('NotHighlightedWords','and|or|not',NULL,'List of words to NOT highlight when OpacHitHighlight is enabled','free'),
218
('NotHighlightedWords','and|or|not',NULL,'List of words to NOT highlight when OpacHitHighlight is enabled','free'),
218
('NoticeCSS','',NULL,'Notices CSS url.','free'),
219
('NoticeCSS','',NULL,'Notices CSS url.','free'),
220
('noticefeenote', '', NULL, 'Set up the notice fee note in the "accountlines" table', NULL),
219
('NotifyBorrowerDeparture','30',NULL,'Define number of days before expiry where circulation is warned about patron account expiry','Integer'),
221
('NotifyBorrowerDeparture','30',NULL,'Define number of days before expiry where circulation is warned about patron account expiry','Integer'),
220
('NovelistSelectEnabled','0',NULL,'Enable Novelist Select content.  Requires Novelist Profile and Password','YesNo'),
222
('NovelistSelectEnabled','0',NULL,'Enable Novelist Select content.  Requires Novelist Profile and Password','YesNo'),
221
('NovelistSelectPassword',NULL,NULL,'Enable Novelist user Profile','free'),
223
('NovelistSelectPassword',NULL,NULL,'Enable Novelist user Profile','free'),
(-)a/installer/data/mysql/updatedatabase.pl (+10 lines)
Lines 9585-9590 if ( CheckVersion($DBversion) ) { Link Here
9585
    SetVersion ($DBversion);
9585
    SetVersion ($DBversion);
9586
}
9586
}
9587
9587
9588
$DBversion = "XXX";
9589
if ( CheckVersion($DBversion) ) {
9590
    $dbh->do("ALTER TABLE  `letter` add  `fee` decimal(10,2) DEFAULT NULL");
9591
    $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
9592
       VALUES ('defaultnoticefee','0',NULL,' set up how much cost the sending of a notice',NULL),
9593
       ('noticefeenote', '', NULL, 'Set up the notice fee note in the accountlines table', NULL)");
9594
    print "Upgrade to $DBversion done (Bug 12769 - Notice fee management)\n";
9595
    SetVersion ($DBversion);
9596
}
9597
9588
=head1 FUNCTIONS
9598
=head1 FUNCTIONS
9589
9599
9590
=head2 TableExists($table)
9600
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+8 lines)
Lines 632-637 Circulation: Link Here
632
                  yes: Charge
632
                  yes: Charge
633
                  no: "Don't Charge"
633
                  no: "Don't Charge"
634
            - the replacement price when a patron loses an item.
634
            - the replacement price when a patron loses an item.
635
        -
636
            - Set up how much cost the sending of a notice to
637
            - pref: DefaultNoticeFee
638
              class: integer
639
        -
640
            - Set up the notice fee note in the "accountlines" table to
641
            - pref: NoticeFeeNote
642
635
    Self Checkout:
643
    Self Checkout:
636
        -
644
        -
637
            - "Include the following JavaScript on all pages in the web-based self checkout:"
645
            - "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 331-336 $(document).ready(function() { Link Here
331
                                    [% END %]
331
                                    [% END %]
332
                </select>
332
                </select>
333
            </li>
333
            </li>
334
            [% IF (module == "circulation") %]
335
            <li>
336
              <label for="code" >Notice fee:</label>
337
              <input type="text" id="fee" name="fee" size="7" maxlength="7" value="[% IF ( modify ) %][% fee %][% END %]"/>
338
            </li>
339
            [% END %]
334
            <li>
340
            <li>
335
              [% IF adding %]
341
              [% IF adding %]
336
                  <label for="code" class="required">Code:</label>
342
                  <label for="code" class="required">Code:</label>
(-)a/misc/cronjobs/advance_notices.pl (+35 lines)
Lines 245-250 UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { Link Here
245
            my $digest = $due_digest->{$upcoming->{'borrowernumber'}} ||= {};
245
            my $digest = $due_digest->{$upcoming->{'borrowernumber'}} ||= {};
246
            $digest->{email} ||= $from_address;
246
            $digest->{email} ||= $from_address;
247
            $digest->{count}++;
247
            $digest->{count}++;
248
            $digest->{itemnumber} = $upcoming->{'itemnumber'};
248
        } else {
249
        } else {
249
            my $biblio = C4::Biblio::GetBiblioFromItemNumber( $upcoming->{'itemnumber'} );
250
            my $biblio = C4::Biblio::GetBiblioFromItemNumber( $upcoming->{'itemnumber'} );
250
            my $letter_type = 'DUE';
251
            my $letter_type = 'DUE';
Lines 267-272 UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { Link Here
267
                                    } )
268
                                    } )
268
                    or warn "no letter of type '$letter_type' found. Please see sample_notices.sql";
269
                    or warn "no letter of type '$letter_type' found. Please see sample_notices.sql";
269
                push @letters, $letter;
270
                push @letters, $letter;
271
                if ($letter){
272
                    noticefine($upcoming->{'borrowernumber'}, $upcoming->{'itemnumber'}, $letter_type, $upcoming->{'branchcode'}, $transport, $letter );
273
                }
270
            }
274
            }
271
        }
275
        }
272
    } else {
276
    } else {
Lines 281-286 UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { Link Here
281
            my $digest = $upcoming_digest->{$upcoming->{'borrowernumber'}} ||= {};
285
            my $digest = $upcoming_digest->{$upcoming->{'borrowernumber'}} ||= {};
282
            $digest->{email} ||= $from_address;
286
            $digest->{email} ||= $from_address;
283
            $digest->{count}++;
287
            $digest->{count}++;
288
            $digest->{itemnumber} = $upcoming->{'itemnumber'};
284
        } else {
289
        } else {
285
            my $biblio = C4::Biblio::GetBiblioFromItemNumber( $upcoming->{'itemnumber'} );
290
            my $biblio = C4::Biblio::GetBiblioFromItemNumber( $upcoming->{'itemnumber'} );
286
            my $letter_type = 'PREDUE';
291
            my $letter_type = 'PREDUE';
Lines 303-308 UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { Link Here
303
                                    } )
308
                                    } )
304
                    or warn "no letter of type '$letter_type' found. Please see sample_notices.sql";
309
                    or warn "no letter of type '$letter_type' found. Please see sample_notices.sql";
305
                push @letters, $letter;
310
                push @letters, $letter;
311
                if ($letter){
312
                    noticefine($upcoming->{'borrowernumber'}, $upcoming->{'itemnumber'}, $letter_type, $upcoming->{'branchcode'}, $transport, $letter );
313
                }
306
            }
314
            }
307
        }
315
        }
308
    }
316
    }
Lines 343-348 PATRON: while ( my ( $borrowernumber, $digest ) = each %$upcoming_digest ) { Link Here
343
    @letters = ();
351
    @letters = ();
344
    my $count = $digest->{count};
352
    my $count = $digest->{count};
345
    my $from_address = $digest->{email};
353
    my $from_address = $digest->{email};
354
    my $itemnumber = $digest->{itemnumber};
346
355
347
    my $borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $borrowernumber,
356
    my $borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $borrowernumber,
348
                                                                                  message_name   => 'advance_notice' } );
357
                                                                                  message_name   => 'advance_notice' } );
Lines 378-383 PATRON: while ( my ( $borrowernumber, $digest ) = each %$upcoming_digest ) { Link Here
378
          )
387
          )
379
          or die "no letter of type '$letter_type' found. Please see sample_notices.sql";
388
          or die "no letter of type '$letter_type' found. Please see sample_notices.sql";
380
        push @letters, $letter;
389
        push @letters, $letter;
390
        if ($letter){
391
            noticefine($borrowernumber, $itemnumber, $letter_type, $branch_info{"branches.branchcode"}, $transport, $letter );
392
        }
381
    }
393
    }
382
394
383
    if ( @letters ) {
395
    if ( @letters ) {
Lines 403-408 PATRON: while ( my ( $borrowernumber, $digest ) = each %$due_digest ) { Link Here
403
    @letters = ();
415
    @letters = ();
404
    my $count = $digest->{count};
416
    my $count = $digest->{count};
405
    my $from_address = $digest->{email};
417
    my $from_address = $digest->{email};
418
    my $itemnumber = $digest->{itemnumber};
406
419
407
    my $borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $borrowernumber,
420
    my $borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $borrowernumber,
408
                                                                                  message_name   => 'item_due' } );
421
                                                                                  message_name   => 'item_due' } );
Lines 436-441 PATRON: while ( my ( $borrowernumber, $digest ) = each %$due_digest ) { Link Here
436
          )
449
          )
437
          or die "no letter of type '$letter_type' found. Please see sample_notices.sql";
450
          or die "no letter of type '$letter_type' found. Please see sample_notices.sql";
438
        push @letters, $letter;
451
        push @letters, $letter;
452
        if ($letter){
453
            noticefine($borrowernumber, $itemnumber, $letter_type, $branch_info{"branches.branchcode"}, $transport, $letter );
454
        }
439
    }
455
    }
440
456
441
    if ( @letters ) {
457
    if ( @letters ) {
Lines 499-504 sub format_date { Link Here
499
    return output_pref($dt);
515
    return output_pref($dt);
500
}
516
}
501
517
518
sub noticefine {
519
    my ($borrowernumber, $itemnumber, $code, $branchcode, $message_transport_type, $letter ) = @_;
520
521
    my $letterFee = C4::Letters::getletter( 'circulation', $code, $branchcode, $message_transport_type);
522
523
    if ($letterFee) {
524
        my $sendfee;
525
        if ($letter->{'fee'}){
526
            $sendfee = $letter->{'fee'};
527
        } else {
528
            $sendfee = C4::Context->preference('DefaultNoticeFee');
529
        }
530
531
        if ($sendfee > 0){
532
            C4::Accounts::manualinvoice($borrowernumber, "", "", "F", $sendfee, C4::Context->preference('NoticeFeeNote'));
533
        }
534
    }
535
}
536
502
=head2 get_branch_info
537
=head2 get_branch_info
503
538
504
=cut
539
=cut
(-)a/misc/cronjobs/overdue_notices.pl (-2 / +13 lines)
Lines 486-492 END_SQL Link Here
486
            # <date> <itemcount> <firstname> <lastname> <address1> <address2> <address3> <city> <postcode> <country>
486
            # <date> <itemcount> <firstname> <lastname> <address1> <address2> <address3> <city> <postcode> <country>
487
487
488
            my $borrower_sql = <<'END_SQL';
488
            my $borrower_sql = <<'END_SQL';
489
SELECT issues.borrowernumber, firstname, surname, address, address2, city, zipcode, country, email, emailpro, B_email, smsalertnumber, phone, cardnumber,
489
SELECT issues.borrowernumber, issues.itemnumber, firstname, surname, address, address2, city, zipcode, country, email, emailpro, B_email, smsalertnumber, phone, cardnumber,
490
TO_DAYS(?)-TO_DAYS(date_due) as difference, date_due
490
TO_DAYS(?)-TO_DAYS(date_due) as difference, date_due
491
FROM   issues,borrowers,categories
491
FROM   issues,borrowers,categories
492
WHERE  issues.borrowernumber=borrowers.borrowernumber
492
WHERE  issues.borrowernumber=borrowers.borrowernumber
Lines 570-575 END_SQL Link Here
570
570
571
                my $letter = C4::Letters::getletter( 'circulation', $overdue_rules->{"letter$i"}, $branchcode );
571
                my $letter = C4::Letters::getletter( 'circulation', $overdue_rules->{"letter$i"}, $branchcode );
572
572
573
573
                unless ($letter) {
574
                unless ($letter) {
574
                    $verbose and warn "Message '$overdue_rules->{letter$i}' content not found";
575
                    $verbose and warn "Message '$overdue_rules->{letter$i}' content not found";
575
576
Lines 577-583 END_SQL Link Here
577
                    # FIXME : Does this mean a letter must be defined in order to trigger a debar ?
578
                    # FIXME : Does this mean a letter must be defined in order to trigger a debar ?
578
                    next PERIOD;
579
                    next PERIOD;
579
                }
580
                }
580
    
581
                my $sendfee;
582
                if ($letter->{'fee'}){
583
                    $sendfee = $letter->{'fee'};
584
                } else {
585
                    $sendfee = C4::Context->preference('DefaultNoticeFee');
586
                }
587
588
                if ($sendfee > 0){
589
                    C4::Accounts::manualinvoice($borrowernumber, "", "", "F", $sendfee, C4::Context->preference('NoticeFeeNote'));
590
                }
591
581
                if ( $overdue_rules->{"debarred$i"} ) {
592
                if ( $overdue_rules->{"debarred$i"} ) {
582
    
593
    
583
                    #action taken is debarring
594
                    #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 246-254 sub add_validate { Link Here
246
    my $oldmodule     = $input->param('oldmodule');
253
    my $oldmodule     = $input->param('oldmodule');
247
    my $code          = $input->param('code');
254
    my $code          = $input->param('code');
248
    my $name          = $input->param('name');
255
    my $name          = $input->param('name');
256
    my $fee           = $input->param('fee');
249
    my @mtt           = $input->param('message_transport_type');
257
    my @mtt           = $input->param('message_transport_type');
250
    my @title         = $input->param('title');
258
    my @title         = $input->param('title');
251
    my @content       = $input->param('content');
259
    my @content       = $input->param('content');
260
261
    my $insertfee = $fee;
262
    if (defined($fee) and $fee eq ''){
263
        $insertfee = undef;
264
    }
265
252
    for my $mtt ( @mtt ) {
266
    for my $mtt ( @mtt ) {
253
        my $is_html = $input->param("is_html_$mtt");
267
        my $is_html = $input->param("is_html_$mtt");
254
        my $title   = shift @title;
268
        my $title   = shift @title;
Lines 266-287 sub add_validate { Link Here
266
            next;
280
            next;
267
        }
281
        }
268
        elsif ( $letter and $letter->{message_transport_type} eq $mtt ) {
282
        elsif ( $letter and $letter->{message_transport_type} eq $mtt ) {
269
            $dbh->do(
283
            if (defined($fee)){
270
                q{
284
                $dbh->do(q{UPDATE letter SET branchcode = ?, module = ?, name = ?, is_html = ?, title = ?, content = ?, fee = ?
271
                    UPDATE letter
285
                    WHERE branchcode = ? AND module = ? AND code = ? AND message_transport_type = ?}, undef,
272
                    SET branchcode = ?, module = ?, name = ?, is_html = ?, title = ?, content = ?
286
                    $branchcode, $module, $name, $is_html || 0, $title, $content, $insertfee, $branchcode, $oldmodule, $code, $mtt);
273
                    WHERE branchcode = ? AND module = ? AND code = ? AND message_transport_type = ?
287
            } else {
274
                },
288
                $dbh->do(q{UPDATE letter SET branchcode = ?, module = ?, name = ?, is_html = ?, title = ?, content = ?
275
                undef,
289
                    WHERE branchcode = ? AND module = ? AND code = ? AND message_transport_type = ?}, undef,
276
                $branchcode, $module, $name, $is_html || 0, $title, $content,
290
                    $branchcode, $module, $name, $is_html || 0, $title, $content, $branchcode, $oldmodule, $code, $mtt);
277
                $branchcode, $oldmodule, $code, $mtt
291
            }
278
            );
279
        } else {
292
        } else {
280
            $dbh->do(
293
            if (defined($fee) and $fee != ''){
281
                q{INSERT INTO letter (branchcode,module,code,name,is_html,title,content,message_transport_type) VALUES (?,?,?,?,?,?,?,?)},
294
                $dbh->do(q{INSERT INTO letter (branchcode,module,code,name,is_html,title,content,message_transport_type, fee) VALUES (?,?,?,?,?,?,?,?,?)},undef,
282
                undef,
295
                    $branchcode, $module, $code, $name, $is_html || 0, $title, $content, $mtt, $fee);
283
                $branchcode, $module, $code, $name, $is_html || 0, $title, $content, $mtt
296
            } else {
284
            );
297
                $dbh->do(q{INSERT INTO letter (branchcode,module,code,name,is_html,title,content,message_transport_type) VALUES (?,?,?,?,?,?,?,?)},undef,
298
                    $branchcode, $module, $code, $name, $is_html || 0, $title, $content, $mtt);
299
            }
285
        }
300
        }
286
    }
301
    }
287
    # set up default display
302
    # set up default display
288
- 

Return to bug 12769