Bug 13603 - autoBarcode setting hbyymmincr not taking month into account when looking...
[koha.git] / labels / label-manage.pl
blob4ee8779db93389d67d710c0abfa39741ed64c2fd
1 #!/usr/bin/perl
3 # Copyright 2006 Katipo Communications.
4 # Parts Copyright 2009 Foundations Bible College.
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
11 # version.
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with Koha; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 use strict;
22 use warnings;
23 use vars qw($debug);
25 use CGI qw ( -utf8 );
26 use Data::Dumper;
28 use C4::Auth qw(get_template_and_user);
29 use C4::Output qw(output_html_with_http_headers);
30 use C4::Creators;
31 use C4::Labels;
33 my $cgi = new CGI;
34 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
36 template_name => "labels/label-manage.tt",
37 query => $cgi,
38 type => "intranet",
39 authnotrequired => 0,
40 flagsrequired => { catalogue => 1 },
41 debug => 1,
45 my $db_rows = {};
46 my $display_columns = { layout => [ # db column => {col label is link?
47 {layout_id => {label => 'Layout ID', link_field => 0}},
48 {layout_name => {label => 'Layout', link_field => 0}},
49 {barcode_type => {label => 'Barcode Type', link_field => 0}},
50 {printing_type => {label => 'Print Type', link_field => 0}},
51 {format_string => {label => 'Fields to Print',link_field => 0}},
52 {select => {label => 'Select', value => 'layout_id'}},
54 template => [ {template_id => {label => 'Template ID', link_field => 0}},
55 {template_code => {label => 'Template Name', link_field => 0}},
56 {template_desc => {label => 'Description', link_field => 0}},
57 {select => {label => 'Select', value => 'template_id'}},
59 profile => [ {profile_id => {label => 'Profile ID', link_field => 0}},
60 {printer_name => {label => 'Printer Name', link_field => 0}},
61 {paper_bin => {label => 'Paper Bin', link_field => 0}},
62 {_template_code => {label => 'Template Name', link_field => 0}}, # this display column does not have a corrisponding db column in the profile table, hence the underscore
63 {select => {label => 'Select', value => 'profile_id'}},
65 batch => [ {batch_id => {label => 'Batch ID', link_field => 0}},
66 {_item_count => {label => 'Item Count', link_field => 0}},
67 {select => {label => 'Select', value => 'batch_id'}},
71 my $label_element = $cgi->param('label_element') || 'template'; # default to template managment
72 my $op = $cgi->param('op') || 'none';
73 my $element_id = $cgi->param('element_id') || undef;
74 my $error = $cgi->param('error') || 0;
76 my $branch_code = ($label_element eq 'batch' ? C4::Context->userenv->{'branch'} : '');
78 if ($op eq 'delete') {
79 if ($label_element eq 'layout') {$error = C4::Labels::Layout::delete(layout_id => $element_id);}
80 elsif ($label_element eq 'template') {$error = C4::Labels::Template::delete(template_id => $element_id);}
81 elsif ($label_element eq 'profile') {$error = C4::Labels::Profile::delete(profile_id => $element_id);}
82 elsif ($label_element eq 'batch') {$error = C4::Labels::Batch::delete(batch_id => $element_id, branch_code => $branch_code);}
83 else {} # FIXME: Some error trapping code
86 if ($label_element eq 'layout') {$db_rows = get_all_layouts(table_name => 'creator_layouts', filter => 'creator=\'Labels\'');}
87 elsif ($label_element eq 'template') {$db_rows = get_all_templates(table_name => 'creator_templates', filter => 'creator=\'Labels\'');}
88 elsif ($label_element eq 'profile') {$db_rows = get_all_profiles(table_name => 'printers_profile', filter => 'creator=\'Labels\'');}
89 elsif ($label_element eq 'batch') {$db_rows = get_batch_summary(filter => "branch_code=\'$branch_code\' OR branch_code=\'NB\'", creator => 'Labels');}
90 else {} # FIXME: Some error trapping code
92 my $table = html_table($display_columns->{$label_element}, $db_rows);
94 $template->param(error => $error) if ($error) && ($error ne 0);
95 $template->param(print => 1) if ($label_element eq 'batch');
96 $template->param(
97 op => $op,
98 element_id => $element_id,
99 table_loop => $table,
100 label_element => $label_element,
103 output_html_with_http_headers $cgi, $cookie, $template->output;