Lines 50-58
my $units = get_unit_values();
Link Here
|
50 |
if ($op eq 'edit') { |
50 |
if ($op eq 'edit') { |
51 |
$label_template = C4::Labels::Template->retrieve(template_id => $template_id); |
51 |
$label_template = C4::Labels::Template->retrieve(template_id => $template_id); |
52 |
$profile_list = get_all_profiles(field_list => 'profile_id,printer_name,paper_bin',filter => "template_id=$template_id OR template_id=''"); |
52 |
$profile_list = get_all_profiles(field_list => 'profile_id,printer_name,paper_bin',filter => "template_id=$template_id OR template_id=''"); |
|
|
53 |
push @$profile_list, {paper_bin => 'N/A', profile_id => 0, printer_name => 'No Profile'}; |
54 |
foreach my $profile (@$profile_list) { |
55 |
if ($profile->{'profile_id'} == $label_template->get_attr('profile_id')) { |
56 |
$profile->{'selected'} = 1; |
57 |
} |
58 |
else { |
59 |
$profile->{'selected'} = 0; |
60 |
} |
61 |
} |
53 |
} |
62 |
} |
54 |
elsif ($op eq 'save') { |
63 |
elsif ($op eq 'save') { |
55 |
my @params = ( profile_id => $cgi->param('profile_id') || '', |
64 |
my @params = ( profile_id => $cgi->param('profile_id'), |
56 |
template_code => $cgi->param('template_code') || 'DEFAULT_TEMPLATE', |
65 |
template_code => $cgi->param('template_code') || 'DEFAULT_TEMPLATE', |
57 |
template_desc => $cgi->param('template_desc') || 'Default description', |
66 |
template_desc => $cgi->param('template_desc') || 'Default description', |
58 |
page_width => $cgi->param('page_width') || 0, |
67 |
page_width => $cgi->param('page_width') || 0, |
Lines 69-78
elsif ($op eq 'save') {
Link Here
|
69 |
row_gap => $cgi->param('row_gap') || 0, |
78 |
row_gap => $cgi->param('row_gap') || 0, |
70 |
units => $cgi->param('units') || 'POINT', |
79 |
units => $cgi->param('units') || 'POINT', |
71 |
); |
80 |
); |
72 |
if ($template_id) { # if a label_id was passed in, this is an update to an existing layout |
81 |
if ($template_id) { # if a template_id was passed in, this is an update to an existing template |
73 |
$label_template = C4::Labels::Template->retrieve(template_id => $template_id); |
82 |
$label_template = C4::Labels::Template->retrieve(template_id => $template_id); |
74 |
if ($cgi->param('profile_id') && ($label_template->get_attr('template_id') != $cgi->param('profile_id'))) { |
83 |
if ($cgi->param('profile_id') && ($label_template->get_attr('template_id') != $cgi->param('profile_id'))) { |
75 |
if ($label_template->get_attr('profile_id') > 0) { # no need to get the old one if there was no profile associated |
84 |
# Release the old profile if one is currently associated |
|
|
85 |
if ($label_template->get_attr('profile_id') > 0) { |
76 |
my $old_profile = C4::Labels::Profile->retrieve(profile_id => $label_template->get_attr('profile_id')); |
86 |
my $old_profile = C4::Labels::Profile->retrieve(profile_id => $label_template->get_attr('profile_id')); |
77 |
$old_profile->set_attr(template_id => 0); |
87 |
$old_profile->set_attr(template_id => 0); |
78 |
$old_profile->save(); |
88 |
$old_profile->save(); |
Lines 81-103
elsif ($op eq 'save') {
Link Here
|
81 |
$new_profile->set_attr(template_id => $label_template->get_attr('template_id')); |
91 |
$new_profile->set_attr(template_id => $label_template->get_attr('template_id')); |
82 |
$new_profile->save(); |
92 |
$new_profile->save(); |
83 |
} |
93 |
} |
|
|
94 |
elsif ($cgi->param('profile_id') == 0) { # Disassociate any printer profile from the template |
95 |
if ($label_template->get_attr('profile_id') > 0) { |
96 |
my $old_profile = C4::Labels::Profile->retrieve(profile_id => $label_template->get_attr('profile_id')); |
97 |
$old_profile->set_attr(template_id => 0); |
98 |
$old_profile->save(); |
99 |
} |
100 |
} |
84 |
|
101 |
|
85 |
# if ($cgi->param('profile_id')) { |
|
|
86 |
# my $old_profile = ($label_template->get_attr('profile_id') ? C4::Labels::Profile->retrieve(profile_id => $label_template->get_attr('profile_id')) : undef); |
87 |
# my $new_profile = C4::Labels::Profile->retrieve(profile_id => $cgi->param('profile_id')); |
88 |
# if ($label_template->get_attr('template_id') != $new_profile->get_attr('template_id')) { |
89 |
# $new_profile->set_attr(template_id => $label_template->get_attr('template_id')); |
90 |
# $new_profile->save(); |
91 |
# if ($old_profile) { |
92 |
# $old_profile->set_attr(template_id => 0); |
93 |
# $old_profile->save(); |
94 |
# } |
95 |
# } |
96 |
# } |
97 |
$label_template->set_attr(@params); |
102 |
$label_template->set_attr(@params); |
98 |
$label_template->save(); |
103 |
$label_template->save(); |
99 |
} |
104 |
} |
100 |
else { # if no label_id, this is a new layout so insert it |
105 |
else { # if no template_id, this is a new template so insert it |
101 |
$label_template = C4::Labels::Template->new(@params); |
106 |
$label_template = C4::Labels::Template->new(@params); |
102 |
my $template_id = $label_template->save(); |
107 |
my $template_id = $label_template->save(); |
103 |
if ($cgi->param('profile_id')) { |
108 |
if ($cgi->param('profile_id')) { |
Lines 111-120
elsif ($op eq 'save') {
Link Here
|
111 |
} |
116 |
} |
112 |
else { # if we get here, this is a new layout |
117 |
else { # if we get here, this is a new layout |
113 |
$label_template = C4::Labels::Template->new(); |
118 |
$label_template = C4::Labels::Template->new(); |
114 |
} |
119 |
$profile_list = get_all_profiles(field_list => 'profile_id,printer_name,paper_bin',filter => "template_id=''"); |
115 |
if ($template_id) { |
120 |
push @$profile_list, {paper_bin => 'N/A', profile_id => 0, printer_name => 'No Profile'}; |
116 |
foreach my $profile (@$profile_list) { |
121 |
foreach my $profile (@$profile_list) { |
117 |
if ($profile->{'profile_id'} == $label_template->get_attr('profile_id')) { |
122 |
if ($profile->{'profile_id'} == 0) { |
118 |
$profile->{'selected'} = 1; |
123 |
$profile->{'selected'} = 1; |
119 |
} |
124 |
} |
120 |
else { |
125 |
else { |
121 |
- |
|
|