[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] koha acqui/lateorders.pl C4/Letters.pm koha-tmp... [rel_3_0]
From: |
Henri-Damien LAURENT |
Subject: |
[Koha-cvs] koha acqui/lateorders.pl C4/Letters.pm koha-tmp... [rel_3_0] |
Date: |
Wed, 13 Dec 2006 14:14:12 +0000 |
CVSROOT: /cvsroot/koha
Module name: koha
Branch: rel_3_0
Changes by: Henri-Damien LAURENT <hdl> 06/12/13 14:14:12
Modified files:
acqui : lateorders.pl
C4 : Letters.pm
koha-tmpl/intranet-tmpl/prog/en/acqui: lateorders.tmpl
Log message:
adding letter system for lateorders.
The layout can still get improved.
I wonder if the left sidebar would not be hideable.
I would like to be able to hide also the claimorder column. If someone
can help.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/lateorders.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.6&r2=1.6.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Letters.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.4.2.4&r2=1.4.2.5
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/acqui/lateorders.tmpl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.2&r2=1.2.2.1
Patches:
Index: acqui/lateorders.pl
===================================================================
RCS file: /cvsroot/koha/koha/acqui/lateorders.pl,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -u -b -r1.6 -r1.6.2.1
--- acqui/lateorders.pl 26 Jul 2006 09:57:33 -0000 1.6
+++ acqui/lateorders.pl 13 Dec 2006 14:14:11 -0000 1.6.2.1
@@ -15,7 +15,7 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
-# $Id: lateorders.pl,v 1.6 2006/07/26 09:57:33 toins Exp $
+# $Id: lateorders.pl,v 1.6.2.1 2006/12/13 14:14:11 hdl Exp $
=head1 NAME
@@ -51,23 +51,23 @@
use C4::Output;
use C4::Interface::CGI::Output;
use C4::Context;
-use HTML::Template;
use C4::Acquisition;
+use C4::Letters;
-my $query = new CGI;
+my $input = new CGI;
my ($template, $loggedinuser, $cookie)
= get_template_and_user(
{template_name => "acqui/lateorders.tmpl",
- query => $query,
+ query => $input,
type => "intranet",
authnotrequired => 0,
flagsrequired => {acquisition => 1},
debug => 1,
});
-my $supplierid = $query->param('supplierid');
-my $delay = $query->param('delay');
-my $branch = $query->param('branch');
+my $supplierid = $input->param('supplierid');
+my $delay = $input->param('delay');
+my $branch = $input->param('branch');
#default value for delay
$delay = 30 unless $delay;
@@ -112,6 +112,20 @@
foreach my $lateorder (@lateorders){
$total+=$lateorder->{subtotal};
}
+
+my @letters;
+my $letters=GetLetters("claimacquisition");
+foreach (keys %$letters){
+ push @letters ,{code=>$_,name=>$letters->{$_}};
+}
+
+$template->param(letters=>address@hidden) if (@letters);
+my $op=$input->param("op");
+if ($op eq "send_alert"){
+ my @ordernums=$input->param("claim_for");
+ SendAlerts('claimacquisition',address@hidden,$input->param("letter_code"));
+}
+
$template->param(delay=>$delay) if ($delay);
$template->param(
branchloop => address@hidden,
@@ -120,4 +134,4 @@
total=>$total,
intranetcolorstylesheet =>
C4::Context->preference("intranetcolorstylesheet"),
);
-output_html_with_http_headers $query, $cookie, $template->output;
+output_html_with_http_headers $input, $cookie, $template->output;
Index: C4/Letters.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Letters.pm,v
retrieving revision 1.4.2.4
retrieving revision 1.4.2.5
diff -u -b -r1.4.2.4 -r1.4.2.5
--- C4/Letters.pm 30 Oct 2006 09:51:17 -0000 1.4.2.4
+++ C4/Letters.pm 13 Dec 2006 14:14:12 -0000 1.4.2.5
@@ -24,6 +24,7 @@
use Date::Manip;
use C4::Suggestions;
use C4::Members;
+use C4::Log;
require Exporter;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@@ -222,7 +223,7 @@
=cut
-sub sendalerts {
+sub SendAlerts {
my ($type,$externalid,$letter)address@hidden;
my $dbh=C4::Context->dbh;
if ($type eq 'issue') {
@@ -262,6 +263,90 @@
}
}
}
+ elsif ($type eq 'claimacquisition') {
+# warn "sending issues...";
+ my $letter = getletter('claimacquisition',$letter);
+ # prepare the letter...
+ # search the biblionumber
+ my $strsth="select aqorders.*,aqbasket.*,biblio.*,biblioitems.*
from aqorders LEFT JOIN aqbasket on aqbasket.basketno=aqorders.basketno LEFT
JOIN biblio on aqorders.biblionumber=biblio.biblionumber LEFT JOIN biblioitems
on aqorders.biblioitemnumber=biblioitems.biblioitemnumber where
aqorders.ordernumber IN (".join(",",@$externalid).")";
+ my $sthorders=$dbh->prepare($strsth);
+ $sthorders->execute;
+ my $dataorders=$sthorders->fetchall_arrayref({});
+
parseletter($letter,'aqbooksellers',$dataorders->[0]->{booksellerid});
+ my $sthbookseller = $dbh->prepare("select * from aqbooksellers
where id=?");
+ $sthbookseller->execute($dataorders->[0]->{booksellerid});
+ my $databookseller=$sthbookseller->fetchrow_hashref;
+ # 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;
+ foreach my $data (@$dataorders){
+ my $line=$1 if ($letter->{content}=~m/(<<.*>>)/);
+ foreach my $field (keys %$data){
+ $line =~ s/(<<[^\.]+.$field>>)/$data->{$field}/;
+ }
+ $letter->{content}=~ s/(<<.*>>)/$line\n\1/;
+ }
+ $letter->{content} =~ s/<<[^>]*>>//g;
+ my $innerletter = $letter;
+ # ... then send mail
+ if ($databookseller->{bookselleremail}||$databookseller->{contemail}) {
+ my %mail = ( To =>
$databookseller->{bookselleremail}.($databookseller->{contemail}?",".$databookseller->{contemail}:""),
+ From => $userenv->{emailaddress},
+ Subject => "".$innerletter->{title},
+ Message => "".$innerletter->{content},
+ );
+ sendmail(%mail);
+ warn "sending to $mail{To} From $mail{From} subj
$mail{Subject} Mess $mail{Message}";
+ }
+ if (C4::Context->preference("Activate_Log")){
+ logaction($userenv->{number},"Acquisition","Send Acquisition claim
letter","","order list :
".join(",",@$externalid)."\n$innerletter->{title}\n$innerletter->{content}")
+ }
+ warn "sending to From $userenv->{emailaddress} subj
$innerletter->{title} Mess $innerletter->{content}";
+ }
+ elsif ($type eq 'claimserial') {
+# warn "sending issues...";
+ my $letter = getletter('claimserial',$letter);
+ # prepare the letter...
+ # search the biblionumber
+ my $strsth="select serial.*,subscription.* from serial LEFT
JOIN subscription on serial.subscriptionid=subscription.subscriptionid LEFT
JOIN biblio on serial.biblionumber=biblio.biblionumber where serial.serialid IN
(".join(",",@$externalid).")";
+ my $sthorders=$dbh->prepare($strsth);
+ $sthorders->execute;
+ my $dataorders=$sthorders->fetchall_arrayref({});
+
parseletter($letter,'aqbooksellers',$dataorders->[0]->{booksellerid});
+ my $sthbookseller = $dbh->prepare("select * from aqbooksellers
where id=?");
+ $sthbookseller->execute($dataorders->[0]->{aqbooksellerid});
+ my $databookseller=$sthbookseller->fetchrow_hashref;
+ # 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;
+ foreach my $data (@$dataorders){
+ my $line=$1 if ($letter->{content}=~m/(<<.*>>)/);
+ foreach my $field (keys %$data){
+ $line =~ s/(<<[^\.]+.$field>>)/$data->{$field}/;
+ }
+ $letter->{content}=~ s/(<<.*>>)/$line\n\1/;
+ }
+ $letter->{content} =~ s/<<[^>]*>>//g;
+ my $innerletter = $letter;
+ # ... then send mail
+ if ($databookseller->{bookselleremail}||$databookseller->{contemail}) {
+ my %mail = ( To =>
$databookseller->{bookselleremail}.($databookseller->{contemail}?",".$databookseller->{contemail}:""),
+ From => $userenv->{emailaddress},
+ Subject => "".$innerletter->{title},
+ Message => "".$innerletter->{content},
+ );
+ sendmail(%mail);
+ }
+ warn "sending to From $userenv->{emailaddress} subj
$innerletter->{title} Mess $innerletter->{content}";
+ }
}
=head2
@@ -285,6 +370,8 @@
$sth = $dbh->prepare("select * from borrowers where
borrowernumber=?");
} elsif ($table eq 'branches') {
$sth = $dbh->prepare("select * from branches where
branchcode=?");
+ } elsif ($table eq 'aqbooksellers') {
+ $sth = $dbh->prepare("select * from aqbooksellers where id=?");
}
$sth->execute($pk);
# store the result in an hash
Index: koha-tmpl/intranet-tmpl/prog/en/acqui/lateorders.tmpl
===================================================================
RCS file:
/cvsroot/koha/koha/koha-tmpl/intranet-tmpl/prog/en/acqui/lateorders.tmpl,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -b -r1.2 -r1.2.2.1
--- koha-tmpl/intranet-tmpl/prog/en/acqui/lateorders.tmpl 20 Jan 2006
16:04:42 -0000 1.2
+++ koha-tmpl/intranet-tmpl/prog/en/acqui/lateorders.tmpl 13 Dec 2006
14:14:12 -0000 1.2.2.1
@@ -4,7 +4,6 @@
<h1 ><!-- TMPL_IF name="Supplier" --><!-- TMPL_VAR name="Supplier" --> :
<!--/TMPL_IF -->Late issues</h1>
<div id="acqui_lateorders">
- <form action="lateorders.pl" method="post">
<table>
<tr>
<th>Supplier</th>
@@ -19,9 +18,11 @@
<th>Total cost</th>
<th>Budget</th>
<th> </th>
+ <th> </th>
</tr>
<tr>
<td class="doNotPrint">
+ <form action="lateorders.pl" method="post">
<!-- TMPL_VAR
name="CGIsupplier" -->
</td>
<td> </td>
@@ -42,8 +43,20 @@
</td>
+
<td class="doNotPrint">
<input type="submit"
value="filter" />
+ </form>
+ </td>
+ <td class="doNotPrint">
+ <form name="claim" method="post">
+ <input type="hidden" name="op" value="send_alert" />
+ <select name="letter_code" >
+ <!--TMPL_LOOP Name="letters"-->
+ <option value="<!--TMPL_VAR
Name="code"-->"><!--TMPL_VAR Name="name"--></option>
+ <!--/TMPL_LOOP -->
+ </select>
+ <input type="submit"
value="Claim Order" />
</td>
</tr>
<!-- TMPL_LOOP name="lateorders" -->
@@ -86,6 +99,9 @@
<td class="doNotPrint">
</td>
+ <td class="doNotPrint">
+ <input type="checkbox"
name="claim_for" value="<!--TMPL_VAR Name="ordernumber" -->" />
+ </td>
</tr>
<!-- /TMPL_LOOP -->
<tr>
@@ -103,9 +119,15 @@
<th>
<!-- TMPL_VAR name="total" -->
</th>
+ <td colspan="2">
+
+ </td>
+ <td>
+ <input type="submit"
value="Claim Order" />
+ </form>
+ </td>
</tr>
</table>
- </form>
</div>
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] koha acqui/lateorders.pl C4/Letters.pm koha-tmp... [rel_3_0],
Henri-Damien LAURENT <=