[MKDoc-commit] Added list of centres to survey reminder email.
sam at mkdoc.demon.co.uk
sam at mkdoc.demon.co.uk
Mon May 15 00:46:51 BST 2006
Log Message:
-----------
Added list of centres to survey reminder email.
Tags:
----
mkdoc-1-6
Modified Files:
--------------
mkd/tools:
ufi_survey_mailer.pl
-------------- next part --------------
Index: ufi_survey_mailer.pl
===================================================================
RCS file: /var/spool/cvs/mkd/tools/Attic/ufi_survey_mailer.pl,v
retrieving revision 1.1.2.10
retrieving revision 1.1.2.11
diff -Ltools/ufi_survey_mailer.pl -Ltools/ufi_survey_mailer.pl -u -r1.1.2.10 -r1.1.2.11
--- tools/ufi_survey_mailer.pl
+++ tools/ufi_survey_mailer.pl
@@ -44,6 +44,34 @@
return $self->{user};
}
+# pull the list of centres which need to be updated by this user
+sub centres {
+ my $self = shift;
+ my $dbh = $self->{dbh};
+ my $user = $self->{user};
+ my $period_id = $self->{mi_survey_period_id};
+
+ # get all centres for this user
+ my $all = $dbh->selectall_arrayref(
+ 'SELECT Centre_Details.Centre_ID, Centre_Details.Centre_Name
+ FROM Centre_Details, Editor_Centre
+ WHERE Centre_Details.Centre_ID = Editor_Centre.Centre_ID AND
+ Editor_ID = ?', undef, $user->id);
+
+ # filter out the ones with responses for this period
+ my $done = $dbh->selectcol_arrayref(
+ 'SELECT Centre_ID
+ FROM MI_Survey
+ WHERE MI_Survey_Period_ID = ? AND Centre_ID IN (' .
+ join(',', ('?') x @$all) . ')',
+ undef, $period_id, map { $_->[0] } @$all);
+
+ my %done = map { ($_, 1) } @$done;
+ my @remaining = map { $_->[1] } grep { not $done{$_->[0]} } @$all;
+
+ return \@remaining;
+}
+
sub send {
my $self = shift;
my $mail = new Petal::Mail (
@@ -200,7 +228,10 @@
print " $user->{Email}\n";
- UFI::MI::SurveyReminder->new(user => $user)->send();
+ UFI::MI::SurveyReminder->new(user => $user,
+ dbh => $dbh,
+ mi_survey_period_id => $current->{id}
+ )->send();
}
}
More information about the MKDoc-commit
mailing list