bug 3222: messaging preferences for patron categories
Add the ability to set the default circulation messages preferences for a patron category. When the EnhancedMessagingPreferences syspref is ON, the administrator will be able to define default patron messaging preferences for a patron category. When a new patron record is created (either manually or via a patron import), the new patron's preferences will be copied from the default for that patron's category. Signed-off-by: Daniel Sweeney <daniel.sweeney@liblime.com> Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
This commit is contained in:
parent
224a0a1bac
commit
a1200e6498
2 changed files with 56 additions and 0 deletions
|
@ -41,6 +41,7 @@ use CGI;
|
|||
use C4::Context;
|
||||
use C4::Auth;
|
||||
use C4::Output;
|
||||
use C4::Form::MessagingPreferences;
|
||||
|
||||
sub StringSearch {
|
||||
my ($searchstring,$type)=@_;
|
||||
|
@ -106,6 +107,9 @@ if ($op eq 'add_form') {
|
|||
category_type => $data->{'category_type'},
|
||||
"type_".$data->{'category_type'} => 1,
|
||||
);
|
||||
if (C4::Context->preference('EnhancedMessagingPreferences')) {
|
||||
C4::Form::MessagingPreferences::set_form_values({ categorycode => $categorycode } , $template);
|
||||
}
|
||||
# END $OP eq ADD_FORM
|
||||
################## ADD_VALIDATE ##################################
|
||||
# called by add_form, used to insert/modify data in DB
|
||||
|
@ -122,6 +126,10 @@ if ($op eq 'add_form') {
|
|||
$sth->execute(map { $input->param($_) } ('categorycode','description','enrolmentperiod','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','overduenoticerequired','category_type'));
|
||||
$sth->finish;
|
||||
}
|
||||
if (C4::Context->preference('EnhancedMessagingPreferences')) {
|
||||
C4::Form::MessagingPreferences::handle_form_action($input,
|
||||
{ categorycode => $input->param('categorycode') }, $template);
|
||||
}
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=categorie.pl\"></html>";
|
||||
exit;
|
||||
|
||||
|
@ -188,6 +196,10 @@ if ($op eq 'add_form') {
|
|||
category_type => $results->[$i]{'category_type'},
|
||||
"type_".$results->[$i]{'category_type'} => 1,
|
||||
toggle => $toggle );
|
||||
if (C4::Context->preference('EnhancedMessagingPreferences')) {
|
||||
my $brief_prefs = _get_brief_messaging_prefs($results->[$i]{'categorycode'});
|
||||
$row{messaging_prefs} = $brief_prefs if @$brief_prefs;
|
||||
}
|
||||
push @loop, \%row;
|
||||
if ( $toggle eq 0 )
|
||||
{
|
||||
|
@ -215,3 +227,23 @@ if ($op eq 'add_form') {
|
|||
} #---- END $OP eq DEFAULT
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
|
||||
exit 0;
|
||||
|
||||
sub _get_brief_messaging_prefs {
|
||||
my $categorycode = shift;
|
||||
my $messaging_options = C4::Members::Messaging::GetMessagingOptions();
|
||||
my $results = [];
|
||||
PREF: foreach my $option ( @$messaging_options ) {
|
||||
my $pref = C4::Members::Messaging::GetMessagingPreferences( { categorycode => $categorycode,
|
||||
message_name => $option->{'message_name'} } );
|
||||
next unless @{$pref->{'transports'}};
|
||||
my $brief_pref = { message_attribute_id => $option->{'message_attribute_id'},
|
||||
message_name => $option->{'message_name'},
|
||||
};
|
||||
foreach my $transport ( @{$pref->{'transports'}} ) {
|
||||
push @{ $brief_pref->{'transports'} }, { transport => $transport };
|
||||
}
|
||||
push @$results, $brief_pref;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
|
|
@ -133,6 +133,12 @@
|
|||
</li></ol>
|
||||
</fieldset>
|
||||
|
||||
<!-- TMPL_IF NAME="EnhancedMessagingPreferences" -->
|
||||
<fieldset>
|
||||
<h4>Default messaging preferences for this patron category</h4>
|
||||
<!-- TMPL_INCLUDE NAME="messaging-preference-form.inc" -->
|
||||
</fieldset>
|
||||
<!-- /TMPL_IF -->
|
||||
<fieldset class="action"><input type="button" value="Save" onclick="Check(this.form);" /> </fieldset>
|
||||
</form>
|
||||
|
||||
|
@ -221,6 +227,9 @@ Confirm Deletion of Category <!-- TMPL_VAR NAME="categorycode" escape="html" -->
|
|||
<th scope="col">Enrollment fee</th>
|
||||
<th scope="col">Overdue</th>
|
||||
<th scope="col">Hold fee</th>
|
||||
<!-- TMPL_IF NAME="EnhancedMessagingPreferences" -->
|
||||
<th scope="col">Messaging</th>
|
||||
<!-- /TMPL_IF -->
|
||||
<th scope="col" colspan="2"> </th>
|
||||
</tr>
|
||||
<!-- TMPL_LOOP NAME="loop" -->
|
||||
|
@ -243,6 +252,21 @@ Confirm Deletion of Category <!-- TMPL_VAR NAME="categorycode" escape="html" -->
|
|||
<td><!-- TMPL_VAR NAME="enrolmentfee" --></td>
|
||||
<td><!-- TMPL_IF NAME="overduenoticerequired" -->Yes<!-- TMPL_ELSE -->No<!-- /TMPL_IF --></td>
|
||||
<td><!-- TMPL_VAR NAME="reservefee" --></td>
|
||||
<!-- TMPL_IF NAME="EnhancedMessagingPreferences" -->
|
||||
<td>
|
||||
<!-- TMPL_IF NAME="messaging_prefs" -->
|
||||
<!-- TMPL_LOOP NAME="messaging_prefs" -->
|
||||
<!-- TMPL_VAR NAME="message_name" --> :
|
||||
<!-- TMPL_LOOP NAME="transports" -->
|
||||
<!-- TMPL_VAR NAME="transport" -->
|
||||
<!-- /TMPL_LOOP -->
|
||||
<!-- /TMPL_LOOP -->
|
||||
<br />
|
||||
<!-- TMPL_ELSE -->
|
||||
none
|
||||
<!-- /TMPL_IF -->
|
||||
</td>
|
||||
<!-- /TMPL_IF -->
|
||||
<td><a href="<!-- TMPL_VAR NAME="script_name" -->?op=add_form&categorycode=<!-- TMPL_VAR NAME="categorycode" escape="url" -->">Edit</a></td>
|
||||
<td><a href="<!-- TMPL_VAR NAME="script_name" -->?op=delete_confirm&categorycode=<!-- TMPL_VAR NAME="categorycode" escape="url" -->">Delete</a></td>
|
||||
</tr>
|
||||
|
|
Loading…
Reference in a new issue