-# called by delete_confirm, used to effectively confirm deletion of data in DB
-} elsif ($op eq 'delete_confirmed') {
- $template->param(delete_confirmed => 1);
- my $dbh = C4::Context->dbh;
- my $categorycode=uc($input->param('categorycode'));
- my $sth=$dbh->prepare("delete from categories where categorycode=?");
- $sth->execute($categorycode);
- $sth->finish;
- print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=categorie.pl\"></html>";
- exit;
-
- # END $OP eq DELETE_CONFIRMED
-} else { # DEFAULT
- $template->param(else => 1);
- my @loop;
- my ($count,$results)=StringSearch($searchfield,'web');
- my $toggle = 0;
- for (my $i=0; $i < $count; $i++){
- my %row = (categorycode => $results->[$i]{'categorycode'},
- description => $results->[$i]{'description'},
- enrolmentperiod => $results->[$i]{'enrolmentperiod'},
- upperagelimit => $results->[$i]{'upperagelimit'},
- dateofbirthrequired => $results->[$i]{'dateofbirthrequired'},
- enrolmentfee => sprintf("%.2f",$results->[$i]{'enrolmentfee'}),
- overduenoticerequired => $results->[$i]{'overduenoticerequired'},
- issuelimit => $results->[$i]{'issuelimit'},
- reservefee => sprintf("%.2f",$results->[$i]{'reservefee'}),
- category_type => $results->[$i]{'category_type'},
- "type_".$results->[$i]{'category_type'} => 1,
- toggle => $toggle );
- push @loop, \%row;
- if ( $toggle eq 0 )
- {
- $toggle = 1;
- }
- else
- {
- $toggle = 0;
- }
- }
- $template->param(loop => \@loop);
- # check that I (institution) and C (child) exists. otherwise => warning to the user
- my $dbh = C4::Context->dbh;
- my $sth=$dbh->prepare("select category_type from categories where category_type='C'");
- $sth->execute;
- my ($categoryChild) = $sth->fetchrow;
- $template->param(categoryChild => $categoryChild);
- $sth=$dbh->prepare("select category_type from categories where category_type='I'");
- $sth->execute;
- my ($categoryInstitution) = $sth->fetchrow;
- $template->param(categoryInstitution => $categoryInstitution);
- $sth->finish;
-
-
-} #---- END $OP eq DEFAULT
-
-
-$template->param(intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
- intranetstylesheet => C4::Context->preference("intranetstylesheet"),
- IntranetNav => C4::Context->preference("IntranetNav"),
- );
+ # called by delete_confirm, used to effectively confirm deletion of data in DB
+}
+elsif ( $op eq 'delete_confirmed' ) {
+ $template->param( delete_confirmed => 1 );
+ my $dbh = C4::Context->dbh;
+
+ my $categorycode = uc( $input->param('categorycode') );
+
+ my $sth = $dbh->prepare("delete from categories where categorycode=?");
+
+ $sth->execute($categorycode);
+ $sth->finish;
+
+ print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=categorie.pl\"></html>";
+ exit;
+
+ # END $OP eq DELETE_CONFIRMED
+}
+else { # DEFAULT
+ $template->param( else => 1 );
+ my @loop;
+ my ( $count, $results ) = StringSearch( $searchfield, 'web' );
+
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare("
+ SELECT b.branchcode, b.branchname
+ FROM categories_branches AS cb, branches AS b
+ WHERE cb.branchcode = b.branchcode AND cb.categorycode = ?
+ ");
+
+ for ( my $i = 0 ; $i < $count ; $i++ ) {
+ $sth->execute( $results->[$i]{'categorycode'} );
+
+ my @selected_branches;
+ while ( my $branch = $sth->fetchrow_hashref ) {
+ push @selected_branches, $branch;
+ }
+
+ my $enrolmentperioddate = $results->[$i]{'enrolmentperioddate'};
+ if ( $enrolmentperioddate && $enrolmentperioddate eq '0000-00-00' ) {
+ $enrolmentperioddate = undef;
+ }
+
+ $results->[$i]{'category_type'} //= '';
+
+ my %row = (
+ branches => \@selected_branches,
+ categorycode => $results->[$i]{'categorycode'},
+ description => $results->[$i]{'description'},
+ enrolmentperiod => $results->[$i]{'enrolmentperiod'},
+ enrolmentperioddate => $enrolmentperioddate,
+ upperagelimit => $results->[$i]{'upperagelimit'},
+ dateofbirthrequired => $results->[$i]{'dateofbirthrequired'},
+ overduenoticerequired => $results->[$i]{'overduenoticerequired'},
+ issuelimit => $results->[$i]{'issuelimit'},
+ hidelostitems => $results->[$i]{'hidelostitems'},
+ category_type => $results->[$i]{'category_type'},
+ default_privacy => $results->[$i]{'default_privacy'},
+ reservefee => sprintf( "%.2f", $results->[$i]{'reservefee'} || 0 ),
+ enrolmentfee =>
+ sprintf( "%.2f", $results->[$i]{'enrolmentfee'} || 0 ),
+ "type_" . $results->[$i]{'category_type'} => 1,
+ );
+
+ 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;
+ }
+
+ $template->param( loop => \@loop );
+
+ # check that I (institution) and C (child) exists. otherwise => warning to the user
+ $sth = $dbh->prepare("select category_type from categories where category_type='C'");
+ $sth->execute;
+ my ($categoryChild) = $sth->fetchrow;
+ $template->param( categoryChild => $categoryChild );
+
+ $sth = $dbh->prepare("select category_type from categories where category_type='I'");
+ $sth->execute;
+ my ($categoryInstitution) = $sth->fetchrow;
+ $template->param( categoryInstitution => $categoryInstitution );
+ $sth->finish;
+
+} #---- END $OP eq DEFAULT