From 3897417124928309fe35749456f08274d875ec65 Mon Sep 17 00:00:00 2001 From: tipaul Date: Fri, 5 Aug 2005 15:50:46 +0000 Subject: [PATCH] adding some fields available for Letters --- C4/Letters.pm | 15 +- admin/letter.pl | 16 ++ .../default/en/help/admin/letter.tmpl | 137 +++++++++++++----- 3 files changed, 126 insertions(+), 42 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index 10b545c5b5..d535158a3a 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -195,7 +195,6 @@ sub findrelatedto { sub sendalerts { my ($type,$externalid,$letter)=@_; - warn "sendalerts : ($type,$externalid,$letter)"; my $dbh=C4::Context->dbh; if ($type eq 'issue') { # warn "sending issues..."; @@ -205,15 +204,24 @@ sub sendalerts { my $sth=$dbh->prepare("select biblionumber from subscription where subscriptionid=?"); $sth->execute($externalid); my ($biblionumber)=$sth->fetchrow; + # parsing branch info + my $userenv = C4::Context->userenv; + parseletter($letter,'branches',$userenv->{branch}); + # parsing librarian name + $letter->{content} =~ s/<>/$userenv->{firstname}/g; + $letter->{content} =~ s/<>/$userenv->{surname}/g; + $letter->{content} =~ s/<>/$userenv->{emailaddress}/g; + # parsing biblio information parseletter($letter,'biblio',$biblionumber); parseletter($letter,'biblioitems',$biblionumber); # find the list of borrowers to alert my $alerts = getalert('','issue',$externalid); foreach (@$alerts) { + # and parse borrower ... my $innerletter = $letter; my $borinfo = getmember('',$_->{'borrowernumber'}); parseletter($innerletter,'borrowers',$_->{'borrowernumber'}); - my $userenv = C4::Context->userenv; + # ... then send mail if ($borinfo->{emailaddress}) { my %mail = ( To => $borinfo->{emailaddress}, From => $userenv->{emailaddress}, @@ -233,6 +241,7 @@ sub sendalerts { - $table : the Koha table to parse. - $pk : the primary key to query on the $table table parse all fields from a table, and replace values in title & content with the appropriate value + (not exported sub, used only internally) =cut sub parseletter { my ($letter,$table,$pk) = @_; @@ -245,6 +254,8 @@ sub parseletter { $sth = $dbh->prepare("select * from biblioitems where biblionumber=?"); } elsif ($table eq 'borrowers') { $sth = $dbh->prepare("select * from borrowers where borrowernumber=?"); + } elsif ($table eq 'branches') { + $sth = $dbh->prepare("select * from branches where branchcode=?"); } $sth->execute($pk); # store the result in an hash diff --git a/admin/letter.pl b/admin/letter.pl index 1d69bf9d74..417efc88ed 100755 --- a/admin/letter.pl +++ b/admin/letter.pl @@ -108,11 +108,27 @@ if ($op eq 'add_form') { } # build field list my @SQLfieldname; + my %line = ('value' => "LibrarianFirstname", 'text' => 'LibrarianFirstname'); + push @SQLfieldname, \%line; + my %line = ('value' => "LibrarianSurname", 'text' => 'LibrarianSurname'); + push @SQLfieldname, \%line; + my %line = ('value' => "LibrarianEmailaddress", 'text' => 'LibrarianEmailaddress'); + push @SQLfieldname, \%line; + my $sth2=$dbh->prepare("SHOW COLUMNS from branches"); + $sth2->execute; + my %line = ('value' => "", 'text' => '---BRANCHES---'); + push @SQLfieldname, \%line; + while ((my $field) = $sth2->fetchrow_array) { + my %line = ('value' => "branches.".$field, 'text' => "branches.".$field); + push @SQLfieldname, \%line; + } my $sth2=$dbh->prepare("SHOW COLUMNS from biblio"); $sth2->execute; my %line = ('value' => "", 'text' => '---BIBLIO---'); + push @SQLfieldname, \%line; while ((my $field) = $sth2->fetchrow_array) { + # note : %line is redefined, otherwise \%line contains the same value for every entry of the list my %line = ('value' => "biblio.".$field, 'text' => "biblio.".$field); push @SQLfieldname, \%line; } diff --git a/koha-tmpl/intranet-tmpl/default/en/help/admin/letter.tmpl b/koha-tmpl/intranet-tmpl/default/en/help/admin/letter.tmpl index 55a4536757..bd6c20bf0a 100644 --- a/koha-tmpl/intranet-tmpl/default/en/help/admin/letter.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/help/admin/letter.tmpl @@ -5,45 +5,102 @@

In this part of Koha, you can define "letters".

Letters will be used everytime you want to sent something to someone (through mail or paper). For example, sending a mail for overdues use letter that you can put as parameters. Sending a mail to a borrower when a suggestion is validated uses a letter too.

Letter contains specific "meta-tags" that are related to fields that will be replaced by a value at runtime. Here is a list of fields that can be used :

-

General

-
    -
  • date
  • -
  • LibraryName
  • -
-

catalogue information

-
    -
  • biblio.biblionumber
  • -
  • biblio.title
  • -
  • biblio.unititle
  • -
  • biblio.notes
  • -
  • biblio.serial
  • -
  • biblio.seriestitle
  • -
  • biblio.copyrightdate
  • -
  • biblio.abstract
  • -
  • biblioitems.volume
  • -
  • biblioitems.number
  • -
  • biblioitems.classification
  • -
  • biblioitems.itemtype
  • -
  • biblioitems.isbn
  • -
  • biblioitems.issn
  • -
  • biblioitems.dewey
  • -
  • biblioitems.subclass
  • -
  • biblioitems.publicationyear
  • -
  • biblioitems.publishercode
  • -
  • biblioitems.volumedate
  • -
  • biblioitems.volumedesc
  • -
  • biblioitems.illus
  • -
  • biblioitems.pages
  • -
  • biblioitems.notes
  • -
  • biblioitems.size
  • -
  • biblioitems.place
  • -
  • biblioitems.lccn
  • -
  • biblioitems.url
  • -
  • items.content
  • -
+ + + + + + + + + +
GeneralCatalogue information
+

Library information

+
  • branches.branchname
  • +
  • branches.branchaddress1
  • +
  • branches.branchaddress2
  • +
  • branches.branchaddress3
  • +
  • branches.branchphone
  • +
  • branches.branchfax
  • +
  • branches.branchemail
  • + +

    Librarian information

    +
  • LibrarianFirstname
  • +
  • LibrarianSurname
  • +
  • LibrarianEmailaddress
  • + +

    Borrower information

    +
  • borrowernumber
  • +
  • cardnumber
  • +
  • surname
  • +
  • firstname
  • +
  • title
  • +
  • othernames
  • +
  • initials
  • +
  • streetaddress
  • +
  • city
  • +
  • phone
  • +
  • emailaddress
  • +
  • faxnumber
  • +
  • textmessaging
  • +
  • altphone
  • +
  • dateofbirth
  • +
  • branchcode
  • +
  • dateenrolled
  • +
  • gonenoaddress
  • +
  • lost
  • +
  • debarred
  • +
  • contactname
  • +
  • borrowernotes
  • +
  • area
  • +
  • sex
  • +
  • expiry
  • +
  • altnotes
  • +
  • altrelationship
  • +
  • streetcity
  • +
  • phoneday
  • +
  • physstreet
  • +
  • password
  • +
  • flags
  • +
  • userid
  • +
  • homezipcode
  • +
  • zipcode
  • +
  • sort2
  • +
  • sort2
  • +
    +

    Catalogue information

    +
  • biblio.biblionumber
  • +
  • biblio.title
  • +
  • biblio.unititle
  • +
  • biblio.notes
  • +
  • biblio.serial
  • +
  • biblio.seriestitle
  • +
  • biblio.copyrightdate
  • +
  • biblio.abstract
  • +
    +
  • biblioitems.volume
  • +
  • biblioitems.number
  • +
  • biblioitems.classification
  • +
  • biblioitems.itemtype
  • +
  • biblioitems.isbn
  • +
  • biblioitems.issn
  • +
  • biblioitems.dewey
  • +
  • biblioitems.subclass
  • +
  • biblioitems.publicationyear
  • +
  • biblioitems.publishercode
  • +
  • biblioitems.volumedate
  • +
  • biblioitems.volumedesc
  • +
  • biblioitems.illus
  • +
  • biblioitems.pages
  • +
  • biblioitems.notes
  • +
  • biblioitems.size
  • +
  • biblioitems.place
  • +
  • biblioitems.lccn
  • +
  • biblioitems.url
  • +
    +
  • items.content
  • +

    (items.content will contain one or more item informations, coming from items table)

    -

    borrower information

    -

    put borrower fields here

    - -All fields must be included in << and >>, like : <<biblio.title>> +

    All fields must be included in << and >>, like : <<biblio.title>>

    +
    \ No newline at end of file -- 2.39.5