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

(-)a/misc/cronjobs/overdue_notices.pl (-9 / +15 lines)
Lines 276-282 my $csvfilename; Link Here
276
my $htmlfilename;
276
my $htmlfilename;
277
my $triggered = 0;
277
my $triggered = 0;
278
my $listall = 0;
278
my $listall = 0;
279
my $itemscontent = join( ',', qw( date_due title barcode author itemnumber ) );
279
my $itemscontent = join( ',', qw( itemnumber issuedate date_due title barcode author itemcallnumber branchname ) );
280
my @myborcat;
280
my @myborcat;
281
my @myborcatout;
281
my @myborcatout;
282
my $date;
282
my $date;
Lines 367-373 if ( defined $csvfilename ) { Link Here
367
    } else {
367
    } else {
368
        open $csv_fh, ">", $csvfilename or die "unable to open $csvfilename: $!";
368
        open $csv_fh, ">", $csvfilename or die "unable to open $csvfilename: $!";
369
    }
369
    }
370
    if ( $csv->combine(qw(name surname address1 address2 zipcode city country email itemcount itemsinfo)) ) {
370
    if ( $csv->combine(qw(name surname address1 address2 zipcode city country email phone cardnumber itemcount itemsinfo branchname letternumber)) ) {
371
        print $csv_fh $csv->string, "\n";
371
        print $csv_fh $csv->string, "\n";
372
    } else {
372
    } else {
373
        $verbose and warn 'combine failed on argument: ' . $csv->error_input;
373
        $verbose and warn 'combine failed on argument: ' . $csv->error_input;
Lines 381-391 if ( defined $htmlfilename ) { Link Here
381
    $html_fh = *STDOUT;
381
    $html_fh = *STDOUT;
382
  } else {
382
  } else {
383
    my $today = DateTime->now(time_zone => C4::Context->tz );
383
    my $today = DateTime->now(time_zone => C4::Context->tz );
384
    open $html_fh, ">",File::Spec->catdir ($htmlfilename,"notices-".$today->ymd().".html");
384
    open $html_fh, ">:utf8",File::Spec->catdir ($htmlfilename,"notices-".$today->ymd().".html");
385
  }
385
  }
386
  
386
  
387
  print $html_fh "<html>\n";
387
  print $html_fh "<html>\n";
388
  print $html_fh "<head>\n";
388
  print $html_fh "<head>\n";
389
  print $html_fh "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
389
  print $html_fh "<style type='text/css'>\n";
390
  print $html_fh "<style type='text/css'>\n";
390
  print $html_fh "pre {page-break-after: always;}\n";
391
  print $html_fh "pre {page-break-after: always;}\n";
391
  print $html_fh "pre {white-space: pre-wrap;}\n";
392
  print $html_fh "pre {white-space: pre-wrap;}\n";
Lines 406-415 foreach my $branchcode (@branches) { Link Here
406
    $verbose and warn sprintf "branchcode : '%s' using %s\n", $branchcode, $admin_email_address;
407
    $verbose and warn sprintf "branchcode : '%s' using %s\n", $branchcode, $admin_email_address;
407
408
408
    my $sth2 = $dbh->prepare( <<"END_SQL" );
409
    my $sth2 = $dbh->prepare( <<"END_SQL" );
409
SELECT biblio.*, items.*, issues.*, biblioitems.itemtype, TO_DAYS($date)-TO_DAYS(date_due) AS days_overdue
410
SELECT biblio.*, items.*, issues.*, biblioitems.itemtype, TO_DAYS($date)-TO_DAYS(date_due) AS days_overdue, branchname
410
  FROM issues,items,biblio, biblioitems
411
  FROM issues,items,biblio, biblioitems, branches b
411
  WHERE items.itemnumber=issues.itemnumber
412
  WHERE items.itemnumber=issues.itemnumber
412
    AND biblio.biblionumber   = items.biblionumber
413
    AND biblio.biblionumber   = items.biblionumber
414
    AND b.branchcode = items.homebranch
413
    AND biblio.biblionumber   = biblioitems.biblionumber
415
    AND biblio.biblionumber   = biblioitems.biblionumber
414
    AND issues.borrowernumber = ?
416
    AND issues.borrowernumber = ?
415
    AND TO_DAYS($date)-TO_DAYS(date_due) BETWEEN ? and ?
417
    AND TO_DAYS($date)-TO_DAYS(date_due) BETWEEN ? and ?
Lines 456-462 END_SQL Link Here
456
            # <date> <itemcount> <firstname> <lastname> <address1> <address2> <address3> <city> <postcode> <country>
458
            # <date> <itemcount> <firstname> <lastname> <address1> <address2> <address3> <city> <postcode> <country>
457
459
458
            my $borrower_sql = <<'END_SQL';
460
            my $borrower_sql = <<'END_SQL';
459
SELECT distinct(issues.borrowernumber), firstname, surname, address, address2, city, zipcode, country, email, emailpro, B_email
461
SELECT distinct(issues.borrowernumber), firstname, surname, address, address2, city, zipcode, country, email, emailpro, B_email, phone, cardnumber
460
FROM   issues,borrowers,categories
462
FROM   issues,borrowers,categories
461
WHERE  issues.borrowernumber=borrowers.borrowernumber
463
WHERE  issues.borrowernumber=borrowers.borrowernumber
462
AND    borrowers.categorycode=categories.categorycode
464
AND    borrowers.categorycode=categories.categorycode
Lines 480-486 END_SQL Link Here
480
            }
482
            }
481
483
482
            # $sth gets borrower info iff at least one overdue item has triggered the overdue action.
484
            # $sth gets borrower info iff at least one overdue item has triggered the overdue action.
483
	        my $sth = $dbh->prepare($borrower_sql);
485
            my $sth = $dbh->prepare($borrower_sql);
484
            $sth->execute(@borrower_parameters);
486
            $sth->execute(@borrower_parameters);
485
            $verbose and warn $borrower_sql . "\n $branchcode | " . $overdue_rules->{'categorycode'} . "\n ($mindays, $maxdays)\nreturns " . $sth->rows . " rows";
487
            $verbose and warn $borrower_sql . "\n $branchcode | " . $overdue_rules->{'categorycode'} . "\n ($mindays, $maxdays)\nreturns " . $sth->rows . " rows";
486
488
Lines 603-612 END_SQL Link Here
603
                            city           => $data->{'city'},
605
                            city           => $data->{'city'},
604
                            postcode       => $data->{'zipcode'},
606
                            postcode       => $data->{'zipcode'},
605
                            country        => $data->{'country'},
607
                            country        => $data->{'country'},
608
                            phone          => $data->{'phone'},
609
                            cardnumber     => $data->{'cardnumber'},
606
                            email          => $notice_email,
610
                            email          => $notice_email,
607
                            itemcount      => $itemcount,
611
                            itemcount      => $itemcount,
608
                            titles         => $titles,
612
                            titles         => $titles,
609
                            outputformat   => defined $csvfilename ? 'csv' : defined $htmlfilename ? 'html' : '',
613
                            outputformat   => defined $csvfilename ? 'csv' : defined $htmlfilename ? 'html' : '',
614
                            branchname     => $branch_details->{'branchname'},
615
                            letternumber   => $i
610
                        }
616
                        }
611
                      );
617
                      );
612
                }
618
                }
Lines 764-770 sub prepare_letter_for_printing { Link Here
764
    if ( exists $params->{'outputformat'} && $params->{'outputformat'} eq 'csv' ) {
770
    if ( exists $params->{'outputformat'} && $params->{'outputformat'} eq 'csv' ) {
765
        if ($csv->combine(
771
        if ($csv->combine(
766
                $params->{'firstname'}, $params->{'lastname'}, $params->{'address1'},  $params->{'address2'}, $params->{'postcode'},
772
                $params->{'firstname'}, $params->{'lastname'}, $params->{'address1'},  $params->{'address2'}, $params->{'postcode'},
767
                $params->{'city'}, $params->{'country'}, $params->{'email'}, $params->{'itemcount'}, $params->{'titles'}
773
                $params->{'city'}, $params->{'country'}, $params->{'email'}, $params->{'phone'}, $params->{'cardnumber'},
774
                $params->{'itemcount'}, $params->{'titles'}, $params->{'branchname'}, $params->{'letternumber'}
768
            )
775
            )
769
          ) {
776
          ) {
770
            return $csv->string, "\n";
777
            return $csv->string, "\n";
771
- 

Return to bug 8687