-my $op = $input->param('op');
-
-my ($template, $borrowernumber, $cookie)
- = get_template_and_user({template_name => "admin/branches.tmpl",
- query => $input,
- type => "intranet",
- authnotrequired => 0,
- flagsrequired => {parameters => 1, management => 1},
- debug => 1,
- });
-if ($op) {
- $template->param(script_name => $script_name,
- $op => 1); # we show only the TMPL_VAR names $op
-} else {
- $template->param(script_name => $script_name,
- else => 1); # we show only the TMPL_VAR names $op
-}
-$template->param(action => $script_name);
-if ($op eq 'add') {
- # If the user has pressed the "add new branch" button.
- heading("Branches: Add Branch");
- $template->param('heading-branches-add-branch-p' => 1);
- $template->param('use-heading-flags-p' => 1);
- editbranchform();
-
-} elsif ($op eq 'edit') {
- # if the user has pressed the "edit branch settings" button.
- heading("Branches: Edit Branch");
- $template->param('heading-branches-edit-branch-p' => 1);
- $template->param('use-heading-flags-p' => 1);
- $template->param(add => 1);
- editbranchform($branchcode);
-} elsif ($op eq 'add_validate') {
- # confirm settings change...
- my $params = $input->Vars;
- unless ($params->{'branchcode'} && $params->{'branchname'}) {
- default ("Cannot change branch record: You must specify a Branchname and a Branchcode");
- } else {
- setbranchinfo($params);
- $template->param(else => 1);
- default ("Branch record changed for branch: $params->{'branchname'}");
- }
-} elsif ($op eq 'delete') {
- # if the user has pressed the "delete branch" button.
- my $message = checkdatabasefor($branchcode);
- if ($message) {
- $template->param(else => 1);
- default($message);
- } else {
- $template->param(branchname => $branchname);
- $template->param(delete_confirm => 1);
- $template->param(branchcode => $branchcode);
- }
-} elsif ($op eq 'delete_confirmed') {
- # actually delete branch and return to the main screen....
- deletebranch($branchcode);
- $template->param(else => 1);
- default("The branch \"$branchname\" ($branchcode) has been deleted.");
-} elsif ($op eq 'editcategory') {
- # If the user has pressed the "add new category" or "modify" buttons.
- heading("Branches: Edit Category");
- $template->param('heading-branches-edit-category-p' => 1);
- $template->param('use-heading-flags-p' => 1);
- editcatform($categorycode);
-} elsif ($op eq 'addcategory_validate') {
- # confirm settings change...
- my $params = $input->Vars;
- unless ($params->{'categorycode'} && $params->{'categoryname'}) {
- default ("Cannot change branch record: You must specify a Branchname and a Branchcode");
- } else {
- setcategoryinfo($params);
- $template->param(else => 1);
- default ("Category record changed for category $params->{'categoryname'}");
- }
-} elsif ($op eq 'delete_category') {
- # if the user has pressed the "delete branch" button.
- my $message = checkcategorycode($categorycode);
- if ($message) {
- $template->param(else => 1);
- default($message);
- } else {
- $template->param(delete_category => 1);
- $template->param(categorycode => $categorycode);
- }
-} elsif ($op eq 'categorydelete_confirmed') {
- # actually delete branch and return to the main screen....
- deletecategory($categorycode);
- $template->param(else => 1);
- default("The category with code $categorycode has been deleted.");
-
-} else {
- # if no operation has been set...
- default();
-}