sub sendalerts {
my ($type,$externalid,$letter)=@_;
- warn "sendalerts : ($type,$externalid,$letter)";
my $dbh=C4::Context->dbh;
if ($type eq 'issue') {
# warn "sending issues...";
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/<<LibrarianFirstname>>/$userenv->{firstname}/g;
+ $letter->{content} =~ s/<<LibrarianSurname>>/$userenv->{surname}/g;
+ $letter->{content} =~ s/<<LibrarianEmailaddress>>/$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},
- $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) = @_;
$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
}
# 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;
}
<p>In this part of Koha, you can define "letters".</p>
<p>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.</p>
<p>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 :</p>
-<p>General</p>
-<ul>
- <li>date</li>
- <li>LibraryName</li>
-</ul>
-<p>catalogue information</p>
-<ul>
- <li>biblio.biblionumber</li>
- <li>biblio.title</li>
- <li>biblio.unititle</li>
- <li>biblio.notes</li>
- <li>biblio.serial</li>
- <li>biblio.seriestitle</li>
- <li>biblio.copyrightdate</li>
- <li>biblio.abstract</li>
- <li>biblioitems.volume</li>
- <li>biblioitems.number</li>
- <li>biblioitems.classification</li>
- <li>biblioitems.itemtype</li>
- <li>biblioitems.isbn</li>
- <li>biblioitems.issn</li>
- <li>biblioitems.dewey</li>
- <li>biblioitems.subclass</li>
- <li>biblioitems.publicationyear</li>
- <li>biblioitems.publishercode</li>
- <li>biblioitems.volumedate</li>
- <li>biblioitems.volumedesc</li>
- <li>biblioitems.illus</li>
- <li>biblioitems.pages</li>
- <li>biblioitems.notes</li>
- <li>biblioitems.size</li>
- <li>biblioitems.place</li>
- <li>biblioitems.lccn</li>
- <li>biblioitems.url</li>
- <li>items.content</li>
-</ul>
+<table>
+<tr>
+ <th>General</th>
+ <th>Catalogue information</th>
+</tr>
+<tr valign="top">
+ <td>
+ <h2>Library information</h2>
+ <li>branches.branchname</li>
+ <li>branches.branchaddress1</li>
+ <li>branches.branchaddress2</li>
+ <li>branches.branchaddress3</li>
+ <li>branches.branchphone</li>
+ <li>branches.branchfax</li>
+ <li>branches.branchemail</li>
+
+ <h2>Librarian information</h2>
+ <li>LibrarianFirstname</li>
+ <li>LibrarianSurname</li>
+ <li>LibrarianEmailaddress</li>
+
+ <h2>Borrower information</h2>
+ <li>borrowernumber</li>
+ <li>cardnumber</li>
+ <li>surname</li>
+ <li>firstname</li>
+ <li>title</li>
+ <li>othernames</li>
+ <li>initials</li>
+ <li>streetaddress</li>
+ <li>city</li>
+ <li>phone</li>
+ <li>emailaddress</li>
+ <li>faxnumber</li>
+ <li>textmessaging</li>
+ <li>altphone</li>
+ <li>dateofbirth</li>
+ <li>branchcode</li>
+ <li>dateenrolled</li>
+ <li>gonenoaddress</li>
+ <li>lost</li>
+ <li>debarred</li>
+ <li>contactname</li>
+ <li>borrowernotes</li>
+ <li>area</li>
+ <li>sex</li>
+ <li>expiry</li>
+ <li>altnotes</li>
+ <li>altrelationship</li>
+ <li>streetcity</li>
+ <li>phoneday</li>
+ <li>physstreet</li>
+ <li>password</li>
+ <li>flags</li>
+ <li>userid</li>
+ <li>homezipcode</li>
+ <li>zipcode</li>
+ <li>sort2</li>
+ <li>sort2</li>
+ </td>
+ <td>
+ <h2>Catalogue information</h2>
+ <li>biblio.biblionumber</li>
+ <li>biblio.title</li>
+ <li>biblio.unititle</li>
+ <li>biblio.notes</li>
+ <li>biblio.serial</li>
+ <li>biblio.seriestitle</li>
+ <li>biblio.copyrightdate</li>
+ <li>biblio.abstract</li>
+ <br/>
+ <li>biblioitems.volume</li>
+ <li>biblioitems.number</li>
+ <li>biblioitems.classification</li>
+ <li>biblioitems.itemtype</li>
+ <li>biblioitems.isbn</li>
+ <li>biblioitems.issn</li>
+ <li>biblioitems.dewey</li>
+ <li>biblioitems.subclass</li>
+ <li>biblioitems.publicationyear</li>
+ <li>biblioitems.publishercode</li>
+ <li>biblioitems.volumedate</li>
+ <li>biblioitems.volumedesc</li>
+ <li>biblioitems.illus</li>
+ <li>biblioitems.pages</li>
+ <li>biblioitems.notes</li>
+ <li>biblioitems.size</li>
+ <li>biblioitems.place</li>
+ <li>biblioitems.lccn</li>
+ <li>biblioitems.url</li>
+ <br/>
+ <li>items.content</li>
+ </td>
+</tr>
+</table>
<p>(items.content will contain one or more item informations, coming from items table)</p>
-<p>borrower information</p>
-<p>put borrower fields here</p>
-
-All fields must be included in << and >>, like : <<biblio.title>>
+<p>All fields must be included in << and >>, like : <<biblio.title>></p>
+<br/>
<!-- TMPL_INCLUDE name="help-bottom.inc" -->
\ No newline at end of file