use C4::Output;
use C4::Dates;
use C4::Form::MessagingPreferences;
+use Koha::Database;
sub StringSearch {
my ($searchstring,$type)=@_;
};
}
- $template->param(description => $data->{'description'},
- enrolmentperiod => $data->{'enrolmentperiod'},
- enrolmentperioddate => $data->{'enrolmentperioddate'},
- upperagelimit => $data->{'upperagelimit'},
- dateofbirthrequired => $data->{'dateofbirthrequired'},
- enrolmentfee => sprintf("%.2f",$data->{'enrolmentfee'} || 0),
- overduenoticerequired => $data->{'overduenoticerequired'},
- issuelimit => $data->{'issuelimit'},
- reservefee => sprintf("%.2f",$data->{'reservefee'} || 0),
- hidelostitems => $data->{'hidelostitems'},
- category_type => $data->{'category_type'},
- SMSSendDriver => C4::Context->preference("SMSSendDriver"),
- TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"),
- "type_".$data->{'category_type'} => 1,
- branches_loop => \@branches_loop,
- BlockExpiredPatronOpacActions => $data->{'BlockExpiredPatronOpacActions'},
- );
+ $template->param(
+ description => $data->{'description'},
+ enrolmentperiod => $data->{'enrolmentperiod'},
+ enrolmentperioddate => $data->{'enrolmentperioddate'},
+ upperagelimit => $data->{'upperagelimit'},
+ dateofbirthrequired => $data->{'dateofbirthrequired'},
+ enrolmentfee => sprintf( "%.2f", $data->{'enrolmentfee'} || 0 ),
+ overduenoticerequired => $data->{'overduenoticerequired'},
+ issuelimit => $data->{'issuelimit'},
+ reservefee => sprintf( "%.2f", $data->{'reservefee'} || 0 ),
+ hidelostitems => $data->{'hidelostitems'},
+ category_type => $data->{'category_type'},
+ SMSSendDriver => C4::Context->preference("SMSSendDriver"),
+ TalkingTechItivaPhone =>
+ C4::Context->preference("TalkingTechItivaPhoneNotification"),
+ "type_" . $data->{'category_type'} => 1,
+ branches_loop => \@branches_loop,
+ BlockExpiredPatronOpacActions =>
+ $data->{'BlockExpiredPatronOpacActions'},
+ default_privacy => $data->{'default_privacy'},
+ );
+
if (C4::Context->preference('EnhancedMessagingPreferences')) {
C4::Form::MessagingPreferences::set_form_values({ categorycode => $categorycode } , $template);
}
hidelostitems=?,
overduenoticerequired=?,
category_type=?,
- BlockExpiredPatronOpacActions=?
+ BlockExpiredPatronOpacActions=?,
+ default_privacy=?
WHERE categorycode=?"
);
$sth->execute(
'overduenoticerequired',
'category_type',
'block_expired',
+ 'default_privacy',
'categorycode'
)
);
hidelostitems,
overduenoticerequired,
category_type,
- BlockExpiredPatronOpacActions
+ BlockExpiredPatronOpacActions,
+ default_privacy
)
VALUES (?,?,?,?,?,?,?,?,?,?,?,?)");
$sth->execute(
'hidelostitems',
'overduenoticerequired',
'category_type',
- 'block_expired'
+ 'block_expired',
+ 'default_privacy',
)
);
$sth->finish;
################## DELETE_CONFIRM ##################################
# called by default form, used to confirm deletion of data in DB
} elsif ($op eq 'delete_confirm') {
+ my $schema = Koha::Database->new()->schema();
$template->param(delete_confirm => 1);
- my $dbh = C4::Context->dbh;
- my $sth=$dbh->prepare("select count(*) as total from borrowers where categorycode=?");
- $sth->execute($categorycode);
- my $total = $sth->fetchrow_hashref;
- $sth->finish;
- $template->param(total => $total->{'total'});
-
- my $sth2=$dbh->prepare("SELECT * FROM categories WHERE categorycode=?");
- $sth2->execute($categorycode);
- my $data=$sth2->fetchrow_hashref;
- $sth2->finish;
- if ($total->{'total'} >0) {
- $template->param(totalgtzero => 1);
- }
-
- if ($data->{'enrolmentperioddate'} && $data->{'enrolmentperioddate'} eq '0000-00-00') {
- $data->{'enrolmentperioddate'} = undef;
- }
- $template->param( description => $data->{'description'},
- enrolmentperiod => $data->{'enrolmentperiod'},
- enrolmentperioddate => $data->{'enrolmentperioddate'},
- upperagelimit => $data->{'upperagelimit'},
- dateofbirthrequired => $data->{'dateofbirthrequired'},
- enrolmentfee => sprintf("%.2f",$data->{'enrolmentfee'} || 0),
- overduenoticerequired => $data->{'overduenoticerequired'},
- issuelimit => $data->{'issuelimit'},
- reservefee => sprintf("%.2f",$data->{'reservefee'} || 0),
- hidelostitems => $data->{'hidelostitems'},
- category_type => $data->{'category_type'},
- BlockExpiredPatronOpacActions => $data->{'BlockExpiredPatronOpacActions'},
- );
- # END $OP eq DELETE_CONFIRM
+ my $count = $schema->resultset('Borrower')->search( { categorycode => $categorycode } )->count();
+ my $category = $schema->resultset('Category')->find($categorycode);
+ $category->enrolmentperioddate( C4::Dates::format_date( $category->enrolmentperioddate() ) );
+ $template->param( category => $category, patrons_in_category => $count );
+# END $OP eq DELETE_CONFIRM
################## DELETE_CONFIRMED ##################################
# called by delete_confirm, used to effectively confirm deletion of data in DB
} elsif ($op eq 'delete_confirmed') {
reservefee => sprintf("%.2f",$results->[$i]{'reservefee'} || 0),
hidelostitems => $results->[$i]{'hidelostitems'},
category_type => $results->[$i]{'category_type'},
+ default_privacy => $results->[$i]{'default_privacy'},
"type_".$results->[$i]{'category_type'} => 1,
branches => \@selected_branches,
);
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha › Administration › Patron categories › [% IF ( add_form ) %][% IF ( categorycode ) %]Modify category '[% categorycode |html %]'[% ELSE %]New category[% END %][% END %]
[% IF ( add_validate ) %]Data recorded[% END %]
-[% IF ( delete_confirm ) %][% IF ( totalgtzero ) %]Cannot delete: category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %]
+[% IF ( delete_confirm ) %][% IF ( patrons_in_category > 0 ) %]Cannot delete: category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %]
[% IF ( delete_confirmed ) %]Category deleted[% END %]</title>
[% INCLUDE 'doc-head-close.inc' %]
[% INCLUDE 'calendar.inc' %]
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> › [% IF ( add_form ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> › [% IF ( categorycode ) %]Modify category '[% categorycode |html %]'[% ELSE %]New category[% END %][% END %]
[% IF ( add_validate ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> › Data recorded[% END %]
-[% IF ( delete_confirm ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> › [% IF ( totalgtzero ) %]Cannot delete: Category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %]
+[% IF ( delete_confirm ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> › [% IF ( patrons_in_category > 0 ) %]Cannot delete: Category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %]
[% IF ( delete_confirmed ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> › Category deleted[% END %]
[% IF ( else ) %]Patron categories[% END %]</div>
[% END %]
[% END %]
</select>
- <span>Select All if this category type must to be displayed all the time. Otherwise select librairies you want to associate with this value.
+ <span>Select <i>All branches</i> if this category type must to be displayed all the time. Otherwise select libraries you want to associate with this value.
</span>
</li>
<li><label for="block_expired">Block expired patrons</label>
Choose whether patrons of this category be blocked from public catalog actions such as renewing and placing holds when their cards have expired.
</span>
</li>
+ <li>
+ <label for="default_privacy">Default privacy: </label>
+ <select id="default_privacy" name="default_privacy">
+ [% SWITCH default_privacy %]
+ [% CASE 'forever' %]
+ <option value="default">Default</option>
+ <option value="never">Never</option>
+ <option value="forever" selected="selected">Forever</option>
+ [% CASE 'never' %]
+ <option value="default">Default</option>
+ <option value="never" selected="selected">Never</option>
+ <option value="forever">Forever</option>
+ [% CASE %]
+ <option value="default" selected="selected">Default</option>
+ <option value="never">Never</option>
+ <option value="forever">Forever</option>
+ [% END %]
+ </select>
+ <span>Controls how long a patrons checkout history is kept for new patrons of this category. "Never" anonymizes checkouts on return, and "Forever" keeps a patron's checkout history indefinitely. When set to "Default", the amount of history kept is controlled by the cronjob <i>batch_anonymise.pl</i> which should be set up by your system administrator.</span>
+ </li>
</ol>
</fieldset>
<form action="[% script_name %]" method="post">
<input type="submit" value="OK" />
</form>
-
[% END %]
[% IF ( delete_confirm ) %]
-
- <form action="[% script_name %]" method="post">
- <fieldset><legend>
- [% IF ( totalgtzero ) %]
- Category [% categorycode |html %] is in use. Deletion not possible![% ELSE %]
-Confirm deletion of category [% categorycode |html %][% END %]</legend>
+ <form action="[% script_name %]" method="post">
+ <fieldset>
+ <legend>
+ [% IF ( patrons_in_category > 0 ) %]
+ Category [% categorycode |html %] is in use. Deletion not possible!
+ [% ELSE %]
+ Confirm deletion of category [% categorycode |html %]
+ [% END %]
+ </legend>
[% IF ( totalgtzero ) %]<div class="dialog alert"><strong>This category is used [% total %] times</strong>. Deletion not possible</div>[% END %]
<table>
<tr><th scope="row">Receives overdue notices: </th><td>[% IF ( overduenoticerequired ) %]Yes[% ELSE %]No[% END %]</td></tr>
<tr><th scope="row">Lost items in staff client</th><td>[% IF ( hidelostitems ) %]Hidden by default[% ELSE %]Shown[% END %]</td></tr>
<tr><th scope="row">Hold fee: </th><td>[% reservefee %]</td></tr>
+ <tr>
+ <th scope="row">Default privacy: </th>
+ <td>
+ [% SWITCH category.default_privacy %]
+ [% CASE 'default' %]
+ Default
+ [% CASE 'never' %]
+ Never
+ [% CASE 'forever' %]
+ Forever
+ [% END %]
+ </td>
+ </tr>
</table>
<fieldset class="action">[% IF ( totalgtzero ) %]
<input type="submit" value="OK" /></form>
<th scope="col">Messaging</th>
[% END %]
<th scope="col">Branches limitations</th>
+ <th scope="col">Default privacy</th>
<th scope="col"> </th>
<th scope="col"> </th>
</tr>
No limitation
[% END %]
</td>
+ <td>
+ [% SWITCH loo.default_privacy %]
+ [% CASE 'default' %]
+ Default
+ [% CASE 'never' %]
+ Never
+ [% CASE 'forever' %]
+ Forever
+ [% END %]
+ </td>
<td><a href="[% loo.script_name %]?op=add_form&categorycode=[% loo.categorycode |uri %]">Edit</a></td>
<td><a href="[% loo.script_name %]?op=delete_confirm&categorycode=[% loo.categorycode |uri %]">Delete</a></td>
</tr>