View | Details | Raw Unified | Return to bug 6254
Collapse All | Expand All

(-)a/admin/categorie.pl (-43 / +23 lines)
Lines 45-50 use C4::Branch; Link Here
45
use C4::Output;
45
use C4::Output;
46
use C4::Dates;
46
use C4::Dates;
47
use C4::Form::MessagingPreferences;
47
use C4::Form::MessagingPreferences;
48
use Koha::Database;
48
49
49
sub StringSearch  {
50
sub StringSearch  {
50
	my ($searchstring,$type)=@_;
51
	my ($searchstring,$type)=@_;
Lines 188-223 if ($op eq 'add_form') { Link Here
188
################## DELETE_CONFIRM ##################################
189
################## DELETE_CONFIRM ##################################
189
# called by default form, used to confirm deletion of data in DB
190
# called by default form, used to confirm deletion of data in DB
190
} elsif ($op eq 'delete_confirm') {
191
} elsif ($op eq 'delete_confirm') {
192
    my $schema = Koha::Database->new()->schema();
191
	$template->param(delete_confirm => 1);
193
	$template->param(delete_confirm => 1);
192
194
193
	my $dbh = C4::Context->dbh;
195
    my $count = $schema->resultset('Borrower')->search( { categorycode => $categorycode } )->count();
194
	my $sth=$dbh->prepare("select count(*) as total from borrowers where categorycode=?");
196
    my $category = $schema->resultset('Category')->find($categorycode);
195
	$sth->execute($categorycode);
197
    $category->enrolmentperioddate( C4::Dates::format_date( $category->enrolmentperioddate() ) );
196
	my $total = $sth->fetchrow_hashref;
198
    $template->param( category => $category, patrons_in_category => $count );
197
	$sth->finish;
199
# END $OP eq DELETE_CONFIRM
198
	$template->param(total => $total->{'total'});
199
	
200
	my $sth2=$dbh->prepare("select categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,hidelostitems,overduenoticerequired,category_type from categories where categorycode=?");
201
	$sth2->execute($categorycode);
202
	my $data=$sth2->fetchrow_hashref;
203
	$sth2->finish;
204
	if ($total->{'total'} >0) {
205
		$template->param(totalgtzero => 1);
206
	}
207
208
        $template->param(       description             => $data->{'description'},
209
                                enrolmentperiod         => $data->{'enrolmentperiod'},
210
                                enrolmentperioddate     => C4::Dates::format_date($data->{'enrolmentperioddate'}),
211
                                upperagelimit           => $data->{'upperagelimit'},
212
                                dateofbirthrequired     => $data->{'dateofbirthrequired'},
213
                                enrolmentfee            =>  sprintf("%.2f",$data->{'enrolmentfee'}),
214
                                overduenoticerequired   => $data->{'overduenoticerequired'},
215
                                issuelimit              => $data->{'issuelimit'},
216
                                reservefee              =>  sprintf("%.2f",$data->{'reservefee'}),
217
                                hidelostitems           => $data->{'hidelostitems'},
218
                                category_type           => $data->{'category_type'},
219
                                );
220
													# END $OP eq DELETE_CONFIRM
221
################## DELETE_CONFIRMED ##################################
200
################## DELETE_CONFIRMED ##################################
222
# called by delete_confirm, used to effectively confirm deletion of data in DB
201
# called by delete_confirm, used to effectively confirm deletion of data in DB
223
} elsif ($op eq 'delete_confirmed') {
202
} elsif ($op eq 'delete_confirmed') {
Lines 243-263 if ($op eq 'add_form') { Link Here
243
        while ( my $branch = $sth->fetchrow_hashref ) {
222
        while ( my $branch = $sth->fetchrow_hashref ) {
244
            push @selected_branches, $branch;
223
            push @selected_branches, $branch;
245
        }
224
        }
246
		my %row = (
225
        my %row = (
247
		        categorycode            => $results->[$i]{'categorycode'},
226
            branches              => \@selected_branches,
248
				description             => $results->[$i]{'description'},
227
            categorycode          => $results->[$i]{'categorycode'},
249
				enrolmentperiod         => $results->[$i]{'enrolmentperiod'},
228
            description           => $results->[$i]{'description'},
250
				enrolmentperioddate     => C4::Dates::format_date($results->[$i]{'enrolmentperioddate'}),
229
            enrolmentperiod       => $results->[$i]{'enrolmentperiod'},
251
				upperagelimit           => $results->[$i]{'upperagelimit'},
230
            upperagelimit         => $results->[$i]{'upperagelimit'},
252
				dateofbirthrequired     => $results->[$i]{'dateofbirthrequired'},
231
            dateofbirthrequired   => $results->[$i]{'dateofbirthrequired'},
253
				enrolmentfee            => sprintf("%.2f",$results->[$i]{'enrolmentfee'}),
232
            overduenoticerequired => $results->[$i]{'overduenoticerequired'},
254
				overduenoticerequired   => $results->[$i]{'overduenoticerequired'},
233
            issuelimit            => $results->[$i]{'issuelimit'},
255
				issuelimit              => $results->[$i]{'issuelimit'},
234
            hidelostitems         => $results->[$i]{'hidelostitems'},
256
				reservefee              => sprintf("%.2f",$results->[$i]{'reservefee'}),
235
            category_type         => $results->[$i]{'category_type'},
257
                                hidelostitems           => $results->[$i]{'hidelostitems'},
236
            default_privacy       => $results->[$i]{'default_privacy'},
258
				category_type           => $results->[$i]{'category_type'},
237
            enrolmentfee          => sprintf( "%.2f", $results->[$i]{'enrolmentfee'} ),
259
                "type_".$results->[$i]{'category_type'} => 1,
238
            reservefee            => sprintf( "%.2f", $results->[$i]{'reservefee'} ),
260
                branches                => \@selected_branches,
239
            enrolmentperioddate   => C4::Dates::format_date( $results->[$i]{'enrolmentperioddate'} ),
240
            "type_" . $results->[$i]{'category_type'} => 1,
261
        );
241
        );
262
        if (C4::Context->preference('EnhancedMessagingPreferences')) {
242
        if (C4::Context->preference('EnhancedMessagingPreferences')) {
263
            my $brief_prefs = _get_brief_messaging_prefs($results->[$i]{'categorycode'});
243
            my $brief_prefs = _get_brief_messaging_prefs($results->[$i]{'categorycode'});
(-)a/installer/data/mysql/updatedatabase.pl (-1 / +1 lines)
Lines 7914-7920 if ( CheckVersion($DBversion) ) { Link Here
7914
7914
7915
$DBversion = "3.15.00.XXX";
7915
$DBversion = "3.15.00.XXX";
7916
if(CheckVersion($DBversion)) {
7916
if(CheckVersion($DBversion)) {
7917
    $dbh->do("ALTER TABLE categories ADD default_privacy ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default'");
7917
    $dbh->do("ALTER TABLE categories ADD default_privacy ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default' AFTER categorycode");
7918
    print "Upgrade to $DBversion done (Bug 6254 - can't set patron privacy by default)\n";
7918
    print "Upgrade to $DBversion done (Bug 6254 - can't set patron privacy by default)\n";
7919
    SetVersion($DBversion);
7919
    SetVersion($DBversion);
7920
}
7920
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt (-36 / +51 lines)
Lines 1-7 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Administration &rsaquo; Patron categories &rsaquo; [% IF ( add_form ) %][% IF ( categorycode ) %]Modify category '[% categorycode |html %]'[% ELSE %]New category[% END %][% END %]
2
<title>Koha &rsaquo; Administration &rsaquo; Patron categories &rsaquo; [% IF ( add_form ) %][% IF ( categorycode ) %]Modify category '[% categorycode |html %]'[% ELSE %]New category[% END %][% END %]
3
[% IF ( add_validate ) %]Data recorded[% END %]
3
[% IF ( add_validate ) %]Data recorded[% END %]
4
[% IF ( delete_confirm ) %][% IF ( totalgtzero ) %]Cannot delete: category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %]
4
[% IF ( delete_confirm ) %][% IF ( patrons_in_category > 0 ) %]Cannot delete: category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %]
5
[% IF ( delete_confirmed ) %]Category deleted[% END %]</title>
5
[% IF ( delete_confirmed ) %]Category deleted[% END %]</title>
6
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'calendar.inc' %]
7
[% INCLUDE 'calendar.inc' %]
Lines 113-119 Link Here
113
113
114
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; [% IF ( add_form ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> &rsaquo; [% IF ( categorycode ) %]Modify category '[% categorycode |html %]'[% ELSE %]New category[% END %][% END %]
114
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; [% IF ( add_form ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> &rsaquo; [% IF ( categorycode ) %]Modify category '[% categorycode |html %]'[% ELSE %]New category[% END %][% END %]
115
[% IF ( add_validate ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> &rsaquo; Data recorded[% END %]
115
[% IF ( add_validate ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> &rsaquo; Data recorded[% END %]
116
[% IF ( delete_confirm ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> &rsaquo; [% IF ( totalgtzero ) %]Cannot delete: Category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %]
116
[% IF ( delete_confirm ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> &rsaquo; [% IF ( patrons_in_category > 0 ) %]Cannot delete: Category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %]
117
[% IF ( delete_confirmed ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> &rsaquo; Category deleted[% END %]
117
[% IF ( delete_confirmed ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> &rsaquo; Category deleted[% END %]
118
[% IF ( else ) %]Patron categories[% END %]</div>
118
[% IF ( else ) %]Patron categories[% END %]</div>
119
119
Lines 200-206 Link Here
200
              [% END %]
200
              [% END %]
201
            [% END %]
201
            [% END %]
202
        </select>
202
        </select>
203
        <span>Select All if this category type must to be displayed all the time. Otherwise select librairies you want to associate with this value.
203
        <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.
204
        </span>
204
        </span>
205
    </li>
205
    </li>
206
    <li>
206
    <li>
Lines 242-284 Link Here
242
	<form action="[% script_name %]" method="post">
242
	<form action="[% script_name %]" method="post">
243
		<input type="submit" value="OK" />
243
		<input type="submit" value="OK" />
244
	</form>
244
	</form>
245
246
[% END %]
245
[% END %]
247
246
248
[% IF ( delete_confirm ) %]
247
[% IF ( delete_confirm ) %]
249
	
248
    <form action="[% script_name %]" method="post">
250
    	<form action="[% script_name %]" method="post">
249
        <fieldset>
251
	<fieldset><legend>    	
250
            <legend>    	
252
	[% IF ( totalgtzero ) %]
251
                [% IF ( patrons_in_category > 0 ) %]
253
	Category [% categorycode |html %] is in use.  Deletion not possible![% ELSE %]
252
                    Category [% categorycode |html %] is in use.  Deletion not possible!
254
Confirm deletion of category [% categorycode |html %][% END %]</legend>
253
                [% ELSE %]
254
                    Confirm deletion of category [% categorycode |html %]
255
                [% END %]
256
            </legend>
255
257
256
[% IF ( totalgtzero ) %]<div class="dialog alert"><strong>This category is used [% total %] times</strong>. Deletion not possible</div>[% END %]
258
            [% IF ( patrons_in_category > 0 ) %]
257
	<table>
259
                <div class="dialog alert"><strong>This category is used [% patrons_in_category %] times</strong>. Deletion not possible</div>
258
	<tr><th scope="row">Category code: </th><td>[% categorycode |html %]</td></tr>
260
            [% END %]
259
	<tr><th scope="row">Description: </th><td>[% description |html %]</td></tr>
261
260
	<tr><th scope="row">Enrollment period: </th>
262
            <table>
261
		<td>
263
                <tr><th scope="row">Category code: </th><td>[% categorycode |html %]</td></tr>
262
			[% IF ( enrolmentperiod ) %]
264
                <tr><th scope="row">Description: </th><td>[% description |html %]</td></tr>
263
				[% enrolmentperiod %] months
265
                <tr><th scope="row">Enrollment period: </th>
264
			[% ELSE %]
266
                    <td>
265
				until [% enrolmentperioddate %]
267
                        [% IF ( enrolmentperiod ) %]
266
			[% END %]
268
                            [% enrolmentperiod %] months
267
		</td>
269
                        [% ELSE %]
268
	</tr>
270
                            until [% enrolmentperioddate %]
269
	<tr><th scope="row">Age required: </th><td>[% dateofbirthrequired %] years</td></tr>
271
                        [% END %]
270
	<tr><th scope="row">Upperage limit: </th><td>[% upperagelimit %] years</td></tr>
272
                    </td>
271
	<tr><th scope="row">Enrollment fee: </th><td>[% enrolmentfee %]</td></tr>
273
                </tr>
272
	<tr><th scope="row">Receives overdue notices: </th><td>[% IF ( overduenoticerequired ) %]Yes[% ELSE %]No[% END %]</td></tr>
274
                <tr><th scope="row">Age required: </th><td>[% category.dateofbirthrequired %] years</td></tr>
273
	<tr><th scope="row">Lost items in staff client</th><td>[% IF ( hidelostitems ) %]Hidden by default[% ELSE %]Shown[% END %]</td></tr>
275
                <tr><th scope="row">Upperage limit: </th><td>[% category.upperagelimit %] years</td></tr>
274
	<tr><th scope="row">Hold fee: </th><td>[% reservefee %]</td></tr>
276
                <tr><th scope="row">Enrollment fee: </th><td>[% category.enrolmentfee | format('%.02f') %]</td></tr>
275
</table>
277
                <tr><th scope="row">Receives overdue notices: </th><td>[% IF ( category.overduenoticerequired ) %]Yes[% ELSE %]No[% END %]</td></tr>
276
		<fieldset class="action">[% IF ( totalgtzero ) %]
278
                <tr><th scope="row">Lost items in staff client</th><td>[% IF ( category.hidelostitems ) %]Hidden by default[% ELSE %]Shown[% END %]</td></tr>
277
<input type="submit" value="OK" /></form>
279
                <tr><th scope="row">Hold fee: </th><td>[% category.reservefee | format('%.02f') %]</td></tr>
278
		[% ELSE %]
280
                <tr><th scope="row">Default privacy: </th><td>[% category.default_privacy %]</td></tr>
279
			<input type="hidden" name="op" value="delete_confirmed" />
281
            </table>
280
            <input type="hidden" name="categorycode" value="[% categorycode |html %]" /> <input type="submit" value="Delete this category" /> <a class="cancel" href="/cgi-bin/koha/admin/categorie.pl">Cancel</a>
282
281
		[% END %]</fieldset></fieldset></form>
283
            <fieldset class="action">
284
                [% IF ( patrons_in_category > 0 ) %]
285
                    <input type="submit" value="OK" /></form>
286
                [% ELSE %]
287
                    <input type="hidden" name="op" value="delete_confirmed" />
288
                    <input type="hidden" name="categorycode" value="[% categorycode |html %]" /> <input type="submit" value="Delete this category" /> <a class="cancel" href="/cgi-bin/koha/admin/categorie.pl">Cancel</a>
289
                [% END %]
290
            </fieldset>
291
    </fieldset>
292
</form>
282
[% END %]
293
[% END %]
283
294
284
[% IF ( delete_confirmed ) %]
295
[% IF ( delete_confirmed ) %]
Lines 319-324 Confirm deletion of category [% categorycode |html %][% END %]</legend> Link Here
319
            <th scope="col">Messaging</th>
330
            <th scope="col">Messaging</th>
320
            [% END %]
331
            [% END %]
321
            <th scope="col">Branches limitations</th>
332
            <th scope="col">Branches limitations</th>
333
            <th scope="col">Default privacy</th>
322
            <th scope="col">&nbsp; </th>
334
            <th scope="col">&nbsp; </th>
323
            <th scope="col">&nbsp; </th>
335
            <th scope="col">&nbsp; </th>
324
        </tr>
336
        </tr>
Lines 392-397 Confirm deletion of category [% categorycode |html %][% END %]</legend> Link Here
392
                                No limitation
404
                                No limitation
393
                            [% END %]
405
                            [% END %]
394
                        </td>
406
                        </td>
407
                        <td>
408
                            [% loo.default_privacy %]
409
                        </td>
395
                        <td><a href="[% loo.script_name %]?op=add_form&amp;categorycode=[% loo.categorycode |uri %]">Edit</a></td>
410
                        <td><a href="[% loo.script_name %]?op=add_form&amp;categorycode=[% loo.categorycode |uri %]">Edit</a></td>
396
                        <td><a href="[% loo.script_name %]?op=delete_confirm&amp;categorycode=[% loo.categorycode |uri %]">Delete</a></td>
411
                        <td><a href="[% loo.script_name %]?op=delete_confirm&amp;categorycode=[% loo.categorycode |uri %]">Delete</a></td>
397
		</tr>
412
		</tr>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt (-2 / +1 lines)
Lines 202-208 function CheckAttributeTypeForm(f) { Link Here
202
                  [% END %]
202
                  [% END %]
203
                [% END %]
203
                [% END %]
204
            </select>
204
            </select>
205
            <span>Select All if this attribute type must to be displayed all the time. Otherwise select librairies you want to associate with this value.
205
            <span>Select All if this attribute type must to be displayed all the time. Otherwise select libraries you want to associate with this value.
206
            </span>
206
            </span>
207
        </li>
207
        </li>
208
        <li>
208
        <li>
209
- 

Return to bug 6254