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

(-)a/C4/Creators/Layout.pm (-18 / +18 lines)
Lines 36-42 sub _check_params { Link Here
36
        'callnum_split',
36
        'callnum_split',
37
        'text_justify',
37
        'text_justify',
38
        'format_string',
38
        'format_string',
39
        'layout_xml',           # FIXME: all layouts should be stored in xml format to greatly simplify handling -chris_n
39
        'layout_xml',    # FIXME: all layouts should be stored in xml format to greatly simplify handling -chris_n
40
        'creator',
40
        'creator',
41
        'units',
41
        'units',
42
        'start_label',
42
        'start_label',
Lines 67-89 sub new { Link Here
67
        return -1;
67
        return -1;
68
    }
68
    }
69
    my $type = ref($invocant) || $invocant;
69
    my $type = ref($invocant) || $invocant;
70
    if (grep {$_ eq 'Labels'} @_) {
70
    if ( grep { $_ eq 'Labels' } @_ ) {
71
       $self = {
71
        $self = {
72
            layout_xml      =>      '',
72
            layout_xml    => '',
73
            units           =>      'POINT',
73
            units         => 'POINT',
74
            start_label     =>      1,
74
            start_label   => 1,
75
            barcode_type    =>      'CODE39',
75
            barcode_type  => 'CODE39',
76
            printing_type   =>      'BAR',
76
            printing_type => 'BAR',
77
            layout_name     =>      'DEFAULT',
77
            layout_name   => 'DEFAULT',
78
            guidebox        =>      0,
78
            guidebox      => 0,
79
            oblique_title   =>      1,
79
            oblique_title => 1,
80
            font            =>      'TR',
80
            font          => 'TR',
81
            font_size       =>      3,
81
            font_size     => 3,
82
            scale_width     =>      0.8,
82
            scale_width   => 0.8,
83
            scale_height    =>      0.01,
83
            scale_height  => 0.01,
84
            callnum_split   =>      0,
84
            callnum_split => 0,
85
            text_justify    =>      'L',
85
            text_justify  => 'L',
86
            format_string   =>      join(', ', @{ PRESET_FIELDS() }),
86
            format_string => join( ', ', @{ PRESET_FIELDS() } ),
87
            @_,
87
            @_,
88
        };
88
        };
89
    }
89
    }
(-)a/C4/Labels/Label.pm (-37 / +67 lines)
Lines 225-256 sub _BIB { Link Here
225
225
226
sub _BAR {
226
sub _BAR {
227
    my $self = shift;
227
    my $self = shift;
228
    my $barcode_llx = $self->{'llx'} + $self->{'left_text_margin'};     # this places the bottom left of the barcode the left text margin distance to right of the left edge of the label ($llx)
228
    my $barcode_llx =
229
    my $barcode_lly = $self->{'lly'} + $self->{'top_text_margin'};      # this places the bottom left of the barcode the top text margin distance above the bottom of the label ($lly)
229
        $self->{'llx'} +
230
    my $barcode_width = $self->{'scale_width'} * $self->{'width'};      # You can choose the width of barcode, default value is 0.8 : 80% of the label width
230
        $self->{'left_text_margin'}
231
    my $barcode_y_scale_factor = $self->{'scale_height'} * $self->{'height'};      # You can choose the height of barcode, default value is 0.01 : 10% of the label height
231
        ; # this places the bottom left of the barcode the left text margin distance to right of the left edge of the label ($llx)
232
    my $barcode_lly =
233
        $self->{'lly'} +
234
        $self->{'top_text_margin'}
235
        ; # this places the bottom left of the barcode the top text margin distance above the bottom of the label ($lly)
236
    my $barcode_width = $self->{'scale_width'} * $self->{'width'}
237
        ;    # You can choose the width of barcode, default value is 0.8 : 80% of the label width
238
    my $barcode_y_scale_factor = $self->{'scale_height'} * $self->{'height'}
239
        ;    # You can choose the height of barcode, default value is 0.01 : 10% of the label height
232
    return 0, 0, 0, $barcode_llx, $barcode_lly, $barcode_width, $barcode_y_scale_factor;
240
    return 0, 0, 0, $barcode_llx, $barcode_lly, $barcode_width, $barcode_y_scale_factor;
233
}
241
}
234
242
235
sub _BIBBAR {
243
sub _BIBBAR {
236
    my $self = shift;
244
    my $self = shift;
237
    my $barcode_llx = $self->{'llx'} + $self->{'left_text_margin'};     # this places the bottom left of the barcode the left text margin distance to right of the left edge of the label ($self->{'llx'})
245
    my $barcode_llx =
238
    my $barcode_lly = $self->{'lly'} + $self->{'top_text_margin'};      # this places the bottom left of the barcode the top text margin distance above the bottom of the label ($lly)
246
        $self->{'llx'} +
239
    my $barcode_width = $self->{'scale_width'} * $self->{'width'};      # You can choose the width of barcode, default value is 0.8 : 80% of the label width
247
        $self->{'left_text_margin'}
240
    my $barcode_y_scale_factor = $self->{'scale_height'} * $self->{'height'};       # You can choose the height of barcode, default value is 0.01 : 10% of the label height
248
        ; # this places the bottom left of the barcode the left text margin distance to right of the left edge of the label ($self->{'llx'})
241
    my $line_spacer = ($self->{'font_size'} * 1);       # number of pixels between text rows (This is actually leading: baseline to baseline minus font size. Recommended starting point is 20% of font size.).
249
    my $barcode_lly =
242
    my $text_lly = ($self->{'lly'} + ($self->{'height'} - $self->{'top_text_margin'}));
250
        $self->{'lly'} +
251
        $self->{'top_text_margin'}
252
        ; # this places the bottom left of the barcode the top text margin distance above the bottom of the label ($lly)
253
    my $barcode_width = $self->{'scale_width'} * $self->{'width'}
254
        ;    # You can choose the width of barcode, default value is 0.8 : 80% of the label width
255
    my $barcode_y_scale_factor = $self->{'scale_height'} * $self->{'height'}
256
        ;    # You can choose the height of barcode, default value is 0.01 : 10% of the label height
257
    my $line_spacer = ( $self->{'font_size'} * 1 )
258
        ; # number of pixels between text rows (This is actually leading: baseline to baseline minus font size. Recommended starting point is 20% of font size.).
259
    my $text_lly = ( $self->{'lly'} + ( $self->{'height'} - $self->{'top_text_margin'} ) );
243
    return $self->{'llx'}, $text_lly, $line_spacer, $barcode_llx, $barcode_lly, $barcode_width, $barcode_y_scale_factor;
260
    return $self->{'llx'}, $text_lly, $line_spacer, $barcode_llx, $barcode_lly, $barcode_width, $barcode_y_scale_factor;
244
}
261
}
245
262
246
sub _BARBIB {
263
sub _BARBIB {
247
    my $self = shift;
264
    my $self = shift;
248
    my $barcode_llx = $self->{'llx'} + $self->{'left_text_margin'};                             # this places the bottom left of the barcode the left text margin distance to right of the left edge of the label ($self->{'llx'})
265
    my $barcode_llx =
249
    my $barcode_lly = ($self->{'lly'} + $self->{'height'}) - $self->{'top_text_margin'};        # this places the bottom left of the barcode the top text margin distance below the top of the label ($self->{'lly'})
266
        $self->{'llx'} +
250
    my $barcode_width = $self->{'scale_width'} * $self->{'width'};                              # You can choose the width of barcode, default value is 0.8 : 80% of the label width
267
        $self->{'left_text_margin'}
251
    my $barcode_y_scale_factor = $self->{'scale_height'} * $self->{'height'};                   # You can choose the height of barcode, default value is 0.01 : 10% of the label height
268
        ; # this places the bottom left of the barcode the left text margin distance to right of the left edge of the label ($self->{'llx'})
252
    my $line_spacer = ($self->{'font_size'} * 1);                               # number of pixels between text rows (This is actually leading: baseline to baseline minus font size. Recommended starting point is 20% of font size.).
269
    my $barcode_lly =
253
    my $text_lly = (($self->{'lly'} + $self->{'height'}) - $self->{'top_text_margin'} - (($self->{'lly'} + $self->{'height'}) - $barcode_lly));
270
        ( $self->{'lly'} + $self->{'height'} ) -
271
        $self->{'top_text_margin'}
272
        ; # this places the bottom left of the barcode the top text margin distance below the top of the label ($self->{'lly'})
273
    my $barcode_width = $self->{'scale_width'} * $self->{'width'}
274
        ;    # You can choose the width of barcode, default value is 0.8 : 80% of the label width
275
    my $barcode_y_scale_factor = $self->{'scale_height'} * $self->{'height'}
276
        ;    # You can choose the height of barcode, default value is 0.01 : 10% of the label height
277
    my $line_spacer = ( $self->{'font_size'} * 1 )
278
        ; # number of pixels between text rows (This is actually leading: baseline to baseline minus font size. Recommended starting point is 20% of font size.).
279
    my $text_lly =
280
        ( ( $self->{'lly'} + $self->{'height'} ) -
281
            $self->{'top_text_margin'} -
282
            ( ( $self->{'lly'} + $self->{'height'} ) - $barcode_lly ) );
254
    return $self->{'llx'}, $text_lly, $line_spacer, $barcode_llx, $barcode_lly, $barcode_width, $barcode_y_scale_factor;
283
    return $self->{'llx'}, $text_lly, $line_spacer, $barcode_llx, $barcode_lly, $barcode_width, $barcode_y_scale_factor;
255
}
284
}
256
285
Lines 258-285 sub new { Link Here
258
    my ($invocant, %params) = @_;
287
    my ($invocant, %params) = @_;
259
    my $type = ref($invocant) || $invocant;
288
    my $type = ref($invocant) || $invocant;
260
    my $self = {
289
    my $self = {
261
        batch_id                => $params{'batch_id'},
290
        batch_id         => $params{'batch_id'},
262
        item_number             => $params{'item_number'},
291
        item_number      => $params{'item_number'},
263
        llx                     => $params{'llx'},
292
        llx              => $params{'llx'},
264
        lly                     => $params{'lly'},
293
        lly              => $params{'lly'},
265
        height                  => $params{'height'},
294
        height           => $params{'height'},
266
        width                   => $params{'width'},
295
        width            => $params{'width'},
267
        top_text_margin         => $params{'top_text_margin'},
296
        top_text_margin  => $params{'top_text_margin'},
268
        left_text_margin        => $params{'left_text_margin'},
297
        left_text_margin => $params{'left_text_margin'},
269
        barcode_type            => $params{'barcode_type'},
298
        barcode_type     => $params{'barcode_type'},
270
        printing_type           => $params{'printing_type'},
299
        printing_type    => $params{'printing_type'},
271
        guidebox                => $params{'guidebox'},
300
        guidebox         => $params{'guidebox'},
272
        oblique_title           => $params{'oblique_title'},
301
        oblique_title    => $params{'oblique_title'},
273
        font                    => $params{'font'},
302
        font             => $params{'font'},
274
        font_size               => $params{'font_size'},
303
        font_size        => $params{'font_size'},
275
        scale_width             => $params{'scale_width'},
304
        scale_width      => $params{'scale_width'},
276
        scale_height            => $params{'scale_height'},
305
        scale_height     => $params{'scale_height'},
277
        callnum_split           => $params{'callnum_split'},
306
        callnum_split    => $params{'callnum_split'},
278
        justify                 => $params{'justify'},
307
        justify          => $params{'justify'},
279
        format_string           => $params{'format_string'},
308
        format_string    => $params{'format_string'},
280
        text_wrap_cols          => $params{'text_wrap_cols'},
309
        text_wrap_cols   => $params{'text_wrap_cols'},
281
        barcode                 => $params{'barcode'},
310
        barcode          => $params{'barcode'},
282
    };
311
    };
312
283
    if ($self->{'guidebox'}) {
313
    if ($self->{'guidebox'}) {
284
        $self->{'guidebox'} = _guide_box($self->{'llx'}, $self->{'lly'}, $self->{'width'}, $self->{'height'});
314
        $self->{'guidebox'} = _guide_box($self->{'llx'}, $self->{'lly'}, $self->{'width'}, $self->{'height'});
285
    }
315
    }
(-)a/installer/data/mysql/atomicupdate/update-BZ_10762.pl (-10 / +14 lines)
Lines 1-23 Link Here
1
use Modern::Perl;
1
use Modern::Perl;
2
2
3
return {
3
return {
4
    bug_number => "10762",
4
    bug_number  => "10762",
5
    description => "Add 2 columns in 'creator_layouts' which define the width and height of barcodes",
5
    description => "Add 2 columns in 'creator_layouts' which define the width and height of barcodes",
6
    up => sub {
6
    up          => sub {
7
        my ($args) = @_;
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
        unless ( column_exists ( 'creator_layouts', 'scale_width' )) {
9
        unless ( column_exists( 'creator_layouts', 'scale_width' ) ) {
10
            $dbh->do( q {
10
            $dbh->do(
11
                q {
11
                ALTER TABLE creator_layouts
12
                ALTER TABLE creator_layouts
12
                    ADD COLUMN scale_width FLOAT default 0.8 NOT NULL AFTER font_size
13
                    ADD COLUMN scale_width FLOAT default 0.8 NOT NULL AFTER font_size
13
            });
14
            }
15
            );
14
        }
16
        }
15
        unless ( column_exists ( 'creator_layouts', 'scale_height')) {
17
        unless ( column_exists( 'creator_layouts', 'scale_height' ) ) {
16
            $dbh->do( q {
18
            $dbh->do(
19
                q {
17
                ALTER TABLE creator_layouts
20
                ALTER TABLE creator_layouts
18
                    ADD COLUMN scale_height FLOAT default 0.01 NOT NULL AFTER scale_width
21
                    ADD COLUMN scale_height FLOAT default 0.01 NOT NULL AFTER scale_width
19
            });
22
            }
23
            );
20
        }
24
        }
21
        say $out "Table creator_layouts updated with 2 new columns";
25
        say $out "Table creator_layouts updated with 2 new columns";
22
    },
26
    },
23
}
27
    }
(-)a/labels/label-create-pdf.pl (-63 / +72 lines)
Lines 131-183 foreach my $item (@{$items}) { Link Here
131
    my ($barcode_llx, $barcode_lly, $barcode_width, $barcode_y_scale_factor) = 0,0,0,0;
131
    my ($barcode_llx, $barcode_lly, $barcode_width, $barcode_y_scale_factor) = 0,0,0,0;
132
    if ($layout->get_attr('printing_type') eq 'ALT') {  # we process the ALT style printing type here because it is not an atomic printing type
132
    if ($layout->get_attr('printing_type') eq 'ALT') {  # we process the ALT style printing type here because it is not an atomic printing type
133
        my $label_a = C4::Labels::Label->new(
133
        my $label_a = C4::Labels::Label->new(
134
                                        batch_id            => $batch_id,
134
            batch_id         => $batch_id,
135
                                        item_number         => $item->{'item_number'},
135
            item_number      => $item->{'item_number'},
136
                                        llx                 => $llx,
136
            llx              => $llx,
137
                                        lly                 => $lly,
137
            lly              => $lly,
138
                                        width               => $template->get_attr('label_width'),
138
            width            => $template->get_attr('label_width'),
139
                                        height              => $template->get_attr('label_height'),
139
            height           => $template->get_attr('label_height'),
140
                                        top_text_margin     => $template->get_attr('top_text_margin'),
140
            top_text_margin  => $template->get_attr('top_text_margin'),
141
                                        left_text_margin    => $template->get_attr('left_text_margin'),
141
            left_text_margin => $template->get_attr('left_text_margin'),
142
                                        barcode_type        => $layout->get_attr('barcode_type'),
142
            barcode_type     => $layout->get_attr('barcode_type'),
143
                                        printing_type       => 'BIB',
143
            printing_type    => 'BIB',
144
                                        guidebox            => $layout->get_attr('guidebox'),
144
            guidebox         => $layout->get_attr('guidebox'),
145
                                        oblique_title       => $layout->get_attr('oblique_title'),
145
            oblique_title    => $layout->get_attr('oblique_title'),
146
                                        font                => $layout->get_attr('font'),
146
            font             => $layout->get_attr('font'),
147
                                        font_size           => $layout->get_attr('font_size'),
147
            font_size        => $layout->get_attr('font_size'),
148
                                        scale_width         => $layout->get_attr('scale_width'),
148
            scale_width      => $layout->get_attr('scale_width'),
149
                                        scale_height        => $layout->get_attr('scale_height'),
149
            scale_height     => $layout->get_attr('scale_height'),
150
                                        callnum_split       => $layout->get_attr('callnum_split'),
150
            callnum_split    => $layout->get_attr('callnum_split'),
151
                                        justify             => $layout->get_attr('text_justify'),
151
            justify          => $layout->get_attr('text_justify'),
152
                                        format_string       => $layout->get_attr('format_string'),
152
            format_string    => $layout->get_attr('format_string'),
153
                                        text_wrap_cols      => $layout->get_text_wrap_cols(label_width => $template->get_attr('label_width'), left_text_margin => $template->get_attr('left_text_margin')),
153
            text_wrap_cols   => $layout->get_text_wrap_cols(
154
                                          );
154
                label_width      => $template->get_attr('label_width'),
155
                left_text_margin => $template->get_attr('left_text_margin')
156
            ),
157
        );
155
        $pdf->Add($label_a->draw_guide_box) if $layout->get_attr('guidebox');
158
        $pdf->Add($label_a->draw_guide_box) if $layout->get_attr('guidebox');
156
        my $label_a_text = $label_a->create_label();
159
        my $label_a_text = $label_a->create_label();
157
        _print_text($label_a_text);
160
        _print_text($label_a_text);
158
        ($row_count, $col_count, $llx, $lly) = _calc_next_label_pos($row_count, $col_count, $llx, $lly);
161
        ($row_count, $col_count, $llx, $lly) = _calc_next_label_pos($row_count, $col_count, $llx, $lly);
159
        my $label_b = C4::Labels::Label->new(
162
        my $label_b = C4::Labels::Label->new(
160
                                        batch_id            => $batch_id,
163
            batch_id         => $batch_id,
161
                                        item_number         => $item->{'item_number'},
164
            item_number      => $item->{'item_number'},
162
                                        llx                 => $llx,
165
            llx              => $llx,
163
                                        lly                 => $lly,
166
            lly              => $lly,
164
                                        width               => $template->get_attr('label_width'),
167
            width            => $template->get_attr('label_width'),
165
                                        height              => $template->get_attr('label_height'),
168
            height           => $template->get_attr('label_height'),
166
                                        top_text_margin     => $template->get_attr('top_text_margin'),
169
            top_text_margin  => $template->get_attr('top_text_margin'),
167
                                        left_text_margin    => $template->get_attr('left_text_margin'),
170
            left_text_margin => $template->get_attr('left_text_margin'),
168
                                        barcode_type        => $layout->get_attr('barcode_type'),
171
            barcode_type     => $layout->get_attr('barcode_type'),
169
                                        printing_type       => 'BAR',
172
            printing_type    => 'BAR',
170
                                        guidebox            => $layout->get_attr('guidebox'),
173
            guidebox         => $layout->get_attr('guidebox'),
171
                                        oblique_title       => $layout->get_attr('oblique_title'),
174
            oblique_title    => $layout->get_attr('oblique_title'),
172
                                        font                => $layout->get_attr('font'),
175
            font             => $layout->get_attr('font'),
173
                                        font_size           => $layout->get_attr('font_size'),
176
            font_size        => $layout->get_attr('font_size'),
174
                                        scale_width         => $layout->get_attr('scale_width'),
177
            scale_width      => $layout->get_attr('scale_width'),
175
                                        scale_height        => $layout->get_attr('scale_height'),
178
            scale_height     => $layout->get_attr('scale_height'),
176
                                        callnum_split       => $layout->get_attr('callnum_split'),
179
            callnum_split    => $layout->get_attr('callnum_split'),
177
                                        justify             => $layout->get_attr('text_justify'),
180
            justify          => $layout->get_attr('text_justify'),
178
                                        format_string       => $layout->get_attr('format_string'),
181
            format_string    => $layout->get_attr('format_string'),
179
                                        text_wrap_cols      => $layout->get_text_wrap_cols(label_width => $template->get_attr('label_width'), left_text_margin => $template->get_attr('left_text_margin')),
182
            text_wrap_cols   => $layout->get_text_wrap_cols(
180
                                          );
183
                label_width      => $template->get_attr('label_width'),
184
                left_text_margin => $template->get_attr('left_text_margin')
185
            ),
186
        );
181
        $pdf->Add($label_b->draw_guide_box) if $layout->get_attr('guidebox');
187
        $pdf->Add($label_b->draw_guide_box) if $layout->get_attr('guidebox');
182
        my $label_b_text = $label_b->create_label();
188
        my $label_b_text = $label_b->create_label();
183
        ($row_count, $col_count, $llx, $lly) = _calc_next_label_pos($row_count, $col_count, $llx, $lly);
189
        ($row_count, $col_count, $llx, $lly) = _calc_next_label_pos($row_count, $col_count, $llx, $lly);
Lines 186-212 foreach my $item (@{$items}) { Link Here
186
    else {
192
    else {
187
    }
193
    }
188
        my $label = C4::Labels::Label->new(
194
        my $label = C4::Labels::Label->new(
189
                                        batch_id            => $batch_id,
195
            batch_id         => $batch_id,
190
                                        item_number         => $item->{'item_number'},
196
            item_number      => $item->{'item_number'},
191
                                        llx                 => $llx,
197
            llx              => $llx,
192
                                        lly                 => $lly,
198
            lly              => $lly,
193
                                        width               => $template->get_attr('label_width'),
199
            width            => $template->get_attr('label_width'),
194
                                        height              => $template->get_attr('label_height'),
200
            height           => $template->get_attr('label_height'),
195
                                        top_text_margin     => $template->get_attr('top_text_margin'),
201
            top_text_margin  => $template->get_attr('top_text_margin'),
196
                                        left_text_margin    => $template->get_attr('left_text_margin'),
202
            left_text_margin => $template->get_attr('left_text_margin'),
197
                                        barcode_type        => $layout->get_attr('barcode_type'),
203
            barcode_type     => $layout->get_attr('barcode_type'),
198
                                        printing_type       => $layout->get_attr('printing_type'),
204
            printing_type    => $layout->get_attr('printing_type'),
199
                                        guidebox            => $layout->get_attr('guidebox'),
205
            guidebox         => $layout->get_attr('guidebox'),
200
                                        oblique_title       => $layout->get_attr('oblique_title'),
206
            oblique_title    => $layout->get_attr('oblique_title'),
201
                                        font                => $layout->get_attr('font'),
207
            font             => $layout->get_attr('font'),
202
                                        font_size           => $layout->get_attr('font_size'),
208
            font_size        => $layout->get_attr('font_size'),
203
                                        scale_width         => $layout->get_attr('scale_width'),
209
            scale_width      => $layout->get_attr('scale_width'),
204
                                        scale_height        => $layout->get_attr('scale_height'),
210
            scale_height     => $layout->get_attr('scale_height'),
205
                                        callnum_split       => $layout->get_attr('callnum_split'),
211
            callnum_split    => $layout->get_attr('callnum_split'),
206
                                        justify             => $layout->get_attr('text_justify'),
212
            justify          => $layout->get_attr('text_justify'),
207
                                        format_string       => $layout->get_attr('format_string'),
213
            format_string    => $layout->get_attr('format_string'),
208
                                        text_wrap_cols      => $layout->get_text_wrap_cols(label_width => $template->get_attr('label_width'), left_text_margin => $template->get_attr('left_text_margin')),
214
            text_wrap_cols   => $layout->get_text_wrap_cols(
209
                                          );
215
                label_width      => $template->get_attr('label_width'),
216
                left_text_margin => $template->get_attr('left_text_margin')
217
            ),
218
        );
210
        $pdf->Add($label->draw_guide_box) if $layout->get_attr('guidebox');
219
        $pdf->Add($label->draw_guide_box) if $layout->get_attr('guidebox');
211
        $label->{'barcode'} = $item->{'item_number'} if ($from and $to);
220
        $label->{'barcode'} = $item->{'item_number'} if ($from and $to);
212
        my $label_text = $label->create_label();
221
        my $label_text = $label->create_label();
(-)a/labels/label-edit-layout.pl (-28 / +29 lines)
Lines 105-122 elsif ($op eq 'save') { Link Here
105
        $cgi->param('format_string', $format_string);
105
        $cgi->param('format_string', $format_string);
106
    }
106
    }
107
    my @params = (
107
    my @params = (
108
                    barcode_type    => scalar $cgi->param('barcode_type') || 'CODE39',
108
        barcode_type  => scalar $cgi->param('barcode_type')  || 'CODE39',
109
                    printing_type   => scalar $cgi->param('printing_type') || 'BAR',
109
        printing_type => scalar $cgi->param('printing_type') || 'BAR',
110
                    layout_name     => scalar $cgi->param('layout_name') || 'DEFAULT',
110
        layout_name   => scalar $cgi->param('layout_name')   || 'DEFAULT',
111
                    guidebox        => ($cgi->param('guidebox') ? 1 : 0),
111
        guidebox      => ( $cgi->param('guidebox')      ? 1 : 0 ),
112
                    oblique_title   => ($cgi->param('oblique_title') ? 1 : 0),
112
        oblique_title => ( $cgi->param('oblique_title') ? 1 : 0 ),
113
                    font            => scalar $cgi->param('font') || 'TR',
113
        font          => scalar $cgi->param('font')         || 'TR',
114
                    font_size       => scalar $cgi->param('font_size') || 3,
114
        font_size     => scalar $cgi->param('font_size')    || 3,
115
                    scale_width     => scalar $cgi->param('scale_width') || 0.8,
115
        scale_width   => scalar $cgi->param('scale_width')  || 0.8,
116
                    scale_height    => scalar $cgi->param('scale_height') || 0.01,
116
        scale_height  => scalar $cgi->param('scale_height') || 0.01,
117
                    callnum_split   => ($cgi->param('callnum_split') ? 1 : 0),
117
        callnum_split => ( $cgi->param('callnum_split') ? 1 : 0 ),
118
                    text_justify    => scalar $cgi->param('text_justify') || 'L',
118
        text_justify  => scalar $cgi->param('text_justify') || 'L',
119
                    format_string   => scalar $cgi->param('format_string') || 'title, author, isbn, issn, itemtype, barcode, itemcallnumber',
119
        format_string => scalar $cgi->param('format_string')
120
            || 'title, author, isbn, issn, itemtype, barcode, itemcallnumber',
120
    );
121
    );
121
    if ($layout_id) {   # if a label_id was passed in, this is an update to an existing layout
122
    if ($layout_id) {   # if a label_id was passed in, this is an update to an existing layout
122
        $layout = C4::Labels::Layout->retrieve(layout_id => $layout_id);
123
        $layout = C4::Labels::Layout->retrieve(layout_id => $layout_id);
Lines 141-161 my $text_justification_types = _set_selected(get_text_justification_types(), $la Link Here
141
my ($select_text_fields, $select_text_fields_cnt) = _select_format_string($layout->get_attr('format_string'));
142
my ($select_text_fields, $select_text_fields_cnt) = _select_format_string($layout->get_attr('format_string'));
142
143
143
$template->param(
144
$template->param(
144
        barcode_types   => $barcode_types,
145
    barcode_types            => $barcode_types,
145
        label_types     => $label_types,
146
    label_types              => $label_types,
146
        font_types      => $font_types,
147
    font_types               => $font_types,
147
        text_justification_types    => $text_justification_types,
148
    text_justification_types => $text_justification_types,
148
        fields          => $select_text_fields,
149
    fields                   => $select_text_fields,
149
        field_count     => $select_text_fields_cnt,
150
    field_count              => $select_text_fields_cnt,
150
        layout_id       => $layout->get_attr('layout_id') > -1 ? $layout->get_attr('layout_id') : '',
151
    layout_id                => $layout->get_attr('layout_id') > -1 ? $layout->get_attr('layout_id') : '',
151
        layout_name     => $layout->get_attr('layout_name'),
152
    layout_name              => $layout->get_attr('layout_name'),
152
        guidebox        => $layout->get_attr('guidebox'),
153
    guidebox                 => $layout->get_attr('guidebox'),
153
        oblique_title   => $layout->get_attr('oblique_title'),
154
    oblique_title            => $layout->get_attr('oblique_title'),
154
        font_size       => $layout->get_attr('font_size'),
155
    font_size                => $layout->get_attr('font_size'),
155
        scale_width     => $layout->get_attr('scale_width'),
156
    scale_width              => $layout->get_attr('scale_width'),
156
        scale_height    => $layout->get_attr('scale_height'),
157
    scale_height             => $layout->get_attr('scale_height'),
157
        callnum_split   => $layout->get_attr('callnum_split'),
158
    callnum_split            => $layout->get_attr('callnum_split'),
158
        format_string   => $layout->get_attr('format_string'),
159
    format_string            => $layout->get_attr('format_string'),
159
        layout_string   => 1,   # FIXME: This should not be hard-coded; It should perhaps be yet another syspref... CN
160
    layout_string => 1,    # FIXME: This should not be hard-coded; It should perhaps be yet another syspref... CN
160
);
161
);
161
output_html_with_http_headers $cgi, $cookie, $template->output;
162
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/t/db_dependent/Labels/t_Label.t (-17 / +16 lines)
Lines 54-66 my $branch_1 = $builder->build( { source => 'Branch' } )->{branchcode}; Link Here
54
my $category_1 = $builder->build( { source => 'Category' } )->{categorycode};
54
my $category_1 = $builder->build( { source => 'Category' } )->{categorycode};
55
55
56
# Add an item type
56
# Add an item type
57
my $itemtype =
57
my $itemtype = $builder->build( { source => 'Itemtype', value => { notforloan => undef } } )->{itemtype};
58
  $builder->build( { source => 'Itemtype', value => { notforloan => undef } } )
59
  ->{itemtype};
60
58
61
t::lib::Mocks::mock_userenv({ branchcode => $branch_1 });
59
t::lib::Mocks::mock_userenv( { branchcode => $branch_1 } );
62
60
63
my $bibnum = $builder->build_sample_biblio({ frameworkcode => $frameworkcode })->biblionumber;
61
my $bibnum = $builder->build_sample_biblio( { frameworkcode => $frameworkcode } )->biblionumber;
64
62
65
# Create a helper item instance for testing
63
# Create a helper item instance for testing
66
my $item = $builder->build_sample_item(
64
my $item = $builder->build_sample_item(
Lines 124-145 my $label_info = { Link Here
124
        label_width      => $dummy_template_values->{'label_width'},
122
        label_width      => $dummy_template_values->{'label_width'},
125
        left_text_margin => $dummy_template_values->{'left_text_margin'}
123
        left_text_margin => $dummy_template_values->{'left_text_margin'}
126
    ),
124
    ),
127
    scale_width => $dummy_template_values->{barcode_width},
125
    scale_width  => $dummy_template_values->{barcode_width},
128
    scale_height => $dummy_template_values->{barcode_height},
126
    scale_height => $dummy_template_values->{barcode_height},
129
};
127
};
130
128
131
my $format_string = '100a 245a';
129
my $format_string  = '100a 245a';
132
my $barcode_width = $label_info->{scale_width} * $label_info->{width};
130
my $barcode_width  = $label_info->{scale_width} * $label_info->{width};
133
my $barcode_height = $label_info->{scale_height} * $label_info->{height};
131
my $barcode_height = $label_info->{scale_height} * $label_info->{height};
134
my $label = C4::Labels::Label->new(%$label_info, format_string => $format_string);
132
my $label          = C4::Labels::Label->new( %$label_info, format_string => $format_string );
135
my $label_text = $label->create_label();
133
my $label_text     = $label->create_label();
136
ok( defined $label_text, 'Label Text Value defined.' );
134
ok( defined $label_text, 'Label Text Value defined.' );
137
my $label_csv_data = $label->csv_data();
135
my $label_csv_data = $label->csv_data();
138
is_deeply( $label_csv_data,
136
is_deeply(
139
    [ sprintf( "%s %s", $item->biblio->author, $item->biblio->title ) ] );
137
    $label_csv_data,
138
    [ sprintf( "%s %s", $item->biblio->author, $item->biblio->title ) ]
139
);
140
140
141
$format_string = '100a 245a,enumchron copynumber';
141
$format_string  = '100a 245a,enumchron copynumber';
142
$label = C4::Labels::Label->new(%$label_info, format_string => $format_string);
142
$label          = C4::Labels::Label->new( %$label_info, format_string => $format_string );
143
$label_csv_data = $label->csv_data();
143
$label_csv_data = $label->csv_data();
144
is_deeply(
144
is_deeply(
145
    $label_csv_data,
145
    $label_csv_data,
Lines 148-155 is_deeply( Link Here
148
        sprintf( "%s %s", $item->enumchron,      $item->copynumber )
148
        sprintf( "%s %s", $item->enumchron,      $item->copynumber )
149
    ]
149
    ]
150
);
150
);
151
is($barcode_width, '2.104',);
151
is( $barcode_width,  '2.104', );
152
is($barcode_height, '0.01',);
152
is( $barcode_height, '0.01', );
153
153
154
$schema->storage->txn_rollback();
154
$schema->storage->txn_rollback();
155
155
156
- 

Return to bug 10762