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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+1 lines)
Lines 416-421 Circulation: Link Here
416
                  cron: "command-line option"
416
                  cron: "command-line option"
417
                  item-issuebranch: "checkout library"
417
                  item-issuebranch: "checkout library"
418
                  item-homebranch: "item home library"
418
                  item-homebranch: "item home library"
419
                  patron-homebranch: "patron home library"
419
            - .
420
            - .
420
        -
421
        -
421
            - Include up to
422
            - Include up to
(-)a/misc/cronjobs/overdue_notices.pl (-8 / +20 lines)
Lines 69-75 overdue_notices.pl Link Here
69
   --date         <yyyy-mm-dd>     Emulate overdues run for this date.
69
   --date         <yyyy-mm-dd>     Emulate overdues run for this date.
70
   --email        <email_type>     Type of email that will be used.
70
   --email        <email_type>     Type of email that will be used.
71
                                   Can be 'email', 'emailpro' or 'B_email'. Repeatable.
71
                                   Can be 'email', 'emailpro' or 'B_email'. Repeatable.
72
   --frombranch                    Organize and send overdue notices by home library (item-homebranch) or checkout library (item-issuebranch).
72
   --frombranch                    Organize and send overdue notices by home library (item-homebranch) or checkout library (item-issuebranch) or patron home library (patron-homebranch).
73
                                   This option is only used, if the OverdueNoticeFrom system preference is set to 'command-line option'.
73
                                   This option is only used, if the OverdueNoticeFrom system preference is set to 'command-line option'.
74
                                   Defaults to item-issuebranch.
74
                                   Defaults to item-issuebranch.
75
75
Lines 184-190 Allows to specify which type of email will be used. Can be email, emailpro or B_ Link Here
184
184
185
=item B<--frombranch>
185
=item B<--frombranch>
186
186
187
Organize overdue notices either by checkout library (item-issuebranch) or item home library (item-homebranch).
187
Organize overdue notices either by checkout library (item-issuebranch) or item home library (item-homebranch)  or patron home library (patron-homebranch).
188
This option is only used, if the OverdueNoticeFrom system preference is set to use 'command-line option'.
188
This option is only used, if the OverdueNoticeFrom system preference is set to use 'command-line option'.
189
Defaults to checkout library (item-issuebranch).
189
Defaults to checkout library (item-issuebranch).
190
190
Lines 341-351 if ( defined $csvfilename && $csvfilename =~ /^-/ ) { Link Here
341
    warn qq(using "$csvfilename" as filename, that seems odd);
341
    warn qq(using "$csvfilename" as filename, that seems odd);
342
}
342
}
343
343
344
die "--frombranch takes item-homebranch or item-issuebranch only"
344
die "--frombranch takes item-homebranch or item-issuebranch or patron-homebranch only"
345
    unless ( $frombranch eq 'item-issuebranch'
345
    unless ( $frombranch eq 'item-issuebranch'
346
        || $frombranch eq 'item-homebranch' );
346
        || $frombranch eq 'item-homebranch' || $frombranch eq 'patron-homebranch');
347
$frombranch = C4::Context->preference('OverdueNoticeFrom') ne 'cron' ? C4::Context->preference('OverdueNoticeFrom') : $frombranch;
347
$frombranch = C4::Context->preference('OverdueNoticeFrom') ne 'cron' ? C4::Context->preference('OverdueNoticeFrom') : $frombranch;
348
my $owning_library = ( $frombranch eq 'item-homebranch' ) ? 1 : 0;
348
my $owning_library = ( $frombranch eq 'item-homebranch' ) ? 1 : 0;
349
my $patron_homelibrary = ( $frombranch eq 'patron-homebranch' ) ? 1 : 0;
349
350
350
my @overduebranches    = C4::Overdues::GetBranchcodesWithOverdueRules();    # Branches with overdue rules
351
my @overduebranches    = C4::Overdues::GetBranchcodesWithOverdueRules();    # Branches with overdue rules
351
my @branches;                                    # Branches passed as parameter with overdue rules
352
my @branches;                                    # Branches passed as parameter with overdue rules
Lines 446-451 elsif ( defined $text_filename ) { Link Here
446
  }
447
  }
447
}
448
}
448
449
450
my %already_queued;
451
my %seen = map { $_ => 1 } @branches;
449
foreach my $branchcode (@branches) {
452
foreach my $branchcode (@branches) {
450
    my $calendar;
453
    my $calendar;
451
    if ( C4::Context->preference('OverdueNoticeCalendar') ) {
454
    if ( C4::Context->preference('OverdueNoticeCalendar') ) {
Lines 477-485 SELECT biblio.*, items.*, issues.*, biblioitems.itemtype, branchname Link Here
477
END_SQL
480
END_SQL
478
481
479
    if($owning_library) {
482
    if($owning_library) {
480
      $sql2 .= ' AND items.homebranch = ? ';
483
      $sql2 .= ' AND items.homebranch = ? ' unless($patron_homelibrary);
481
    } else {
484
    } else {
482
      $sql2 .= ' AND issues.branchcode = ? ';
485
      $sql2 .= ' AND issues.branchcode = ? ' unless($patron_homelibrary);
483
    }
486
    }
484
    my $sth2 = $dbh->prepare($sql2);
487
    my $sth2 = $dbh->prepare($sql2);
485
488
Lines 595-600 END_SQL Link Here
595
                    next;
598
                    next;
596
                }
599
                }
597
                $borrowernumber = $data->{'borrowernumber'};
600
                $borrowernumber = $data->{'borrowernumber'};
601
                next if ($patron_homelibrary && $already_queued{"$borrowernumber$i"});
598
                my $borr = sprintf( "%s%s%s (%s)",
602
                my $borr = sprintf( "%s%s%s (%s)",
599
                    $data->{'surname'} || '',
603
                    $data->{'surname'} || '',
600
                    $data->{'firstname'} && $data->{'surname'} ? ', ' : '',
604
                    $data->{'firstname'} && $data->{'surname'} ? ', ' : '',
Lines 603-608 END_SQL Link Here
603
                $verbose and warn "borrower $borr has items triggering level $i.\n";
607
                $verbose and warn "borrower $borr has items triggering level $i.\n";
604
608
605
                my $patron = Koha::Patrons->find( $borrowernumber );
609
                my $patron = Koha::Patrons->find( $borrowernumber );
610
                if($patron_homelibrary){
611
                    $branchcode           = $patron->branchcode;
612
                    $library              = Koha::Libraries->find($branchcode);
613
                    $admin_email_address  = $library->from_email_address;
614
                    $branch_email_address = C4::Context->preference('AddressForFailedOverdueNotices')
615
                        || $library->inbound_email_address;
616
                }
606
                @emails_to_use = ();
617
                @emails_to_use = ();
607
                my $notice_email = $patron->notice_email_address;
618
                my $notice_email = $patron->notice_email_address;
608
                unless ($nomail) {
619
                unless ($nomail) {
Lines 645-651 END_SQL Link Here
645
                    ) unless $test_mode;
656
                    ) unless $test_mode;
646
                    $verbose and warn "debarring $borr\n";
657
                    $verbose and warn "debarring $borr\n";
647
                }
658
                }
648
                my @params = ($borrowernumber,$branchcode);
659
                my @params = $patron_homelibrary ? ($borrowernumber) : ($borrowernumber, $branchcode);
649
660
650
                $sth2->execute(@params);
661
                $sth2->execute(@params);
651
                my $itemcount = 0;
662
                my $itemcount = 0;
Lines 690-695 END_SQL Link Here
690
                      $exceededPrintNoticesMaxLines = 1;
701
                      $exceededPrintNoticesMaxLines = 1;
691
                      last;
702
                      last;
692
                    }
703
                    }
704
                    next if $patron_homelibrary and ! grep {$seen{$item_info->{branchcode}}} @branches;
693
                    $j++;
705
                    $j++;
694
706
695
                    $titles .= C4::Letters::get_item_content( { item => $item_info, item_content_fields => \@item_content_fields, dateonly => 1 } );
707
                    $titles .= C4::Letters::get_item_content( { item => $item_info, item_content_fields => \@item_content_fields, dateonly => 1 } );
Lines 813-818 END_SQL Link Here
813
                        }
825
                        }
814
                    }
826
                    }
815
                }
827
                }
828
                $already_queued{"$borrowernumber$i"} = 1;
816
            }
829
            }
817
            $sth->finish;
830
            $sth->finish;
818
        }
831
        }
819
- 

Return to bug 32740