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

(-)a/C4/Creators/Layout.pm (-15 / +17 lines)
Lines 35-40 sub _check_params { Link Here
35
        'scale_height',
35
        'scale_height',
36
        'callnum_split',
36
        'callnum_split',
37
        'text_justify',
37
        'text_justify',
38
        'barcode_justify',
38
        'format_string',
39
        'format_string',
39
        'layout_xml',    # FIXME: all layouts should be stored in xml format to greatly simplify handling -chris_n
40
        'layout_xml',    # FIXME: all layouts should be stored in xml format to greatly simplify handling -chris_n
40
        'creator',
41
        'creator',
Lines 69-89 sub new { Link Here
69
    my $type = ref($invocant) || $invocant;
70
    my $type = ref($invocant) || $invocant;
70
    if ( grep { $_ eq 'Labels' } @_ ) {
71
    if ( grep { $_ eq 'Labels' } @_ ) {
71
        $self = {
72
        $self = {
72
            layout_xml    => '',
73
            layout_xml      => '',
73
            units         => 'POINT',
74
            units           => 'POINT',
74
            start_label   => 1,
75
            start_label     => 1,
75
            barcode_type  => 'CODE39',
76
            barcode_type    => 'CODE39',
76
            printing_type => 'BAR',
77
            printing_type   => 'BAR',
77
            layout_name   => 'DEFAULT',
78
            layout_name     => 'DEFAULT',
78
            guidebox      => 0,
79
            guidebox        => 0,
79
            oblique_title => 1,
80
            oblique_title   => 1,
80
            font          => 'TR',
81
            font            => 'TR',
81
            font_size     => 3,
82
            font_size       => 3,
82
            scale_width   => 0.8,
83
            scale_width     => 0.8,
83
            scale_height  => 0.01,
84
            scale_height    => 0.01,
84
            callnum_split => 0,
85
            callnum_split   => 0,
85
            text_justify  => 'L',
86
            text_justify    => 'L',
86
            format_string => join( ', ', @{ PRESET_FIELDS() } ),
87
            barcode_justify => 'L',
88
            format_string   => join( ', ', @{ PRESET_FIELDS() } ),
87
            @_,
89
            @_,
88
        };
90
        };
89
    } elsif ( grep { $_ eq 'Patroncards' } @_ ) {
91
    } elsif ( grep { $_ eq 'Patroncards' } @_ ) {
(-)a/C4/Labels/Label.pm (-7 / +31 lines)
Lines 317-322 sub new { Link Here
317
        scale_height     => $params{'scale_height'},
317
        scale_height     => $params{'scale_height'},
318
        callnum_split    => $params{'callnum_split'},
318
        callnum_split    => $params{'callnum_split'},
319
        justify          => $params{'justify'},
319
        justify          => $params{'justify'},
320
        barcode_justify  => $params{'barcode_justify'},
320
        format_string    => $params{'format_string'},
321
        format_string    => $params{'format_string'},
321
        text_wrap_cols   => $params{'text_wrap_cols'},
322
        text_wrap_cols   => $params{'text_wrap_cols'},
322
        barcode          => $params{'barcode'},
323
        barcode          => $params{'barcode'},
Lines 368-377 sub create_label { Link Here
368
    if ( $self->{'printing_type'} =~ /BAR/ ) {
369
    if ( $self->{'printing_type'} =~ /BAR/ ) {
369
        barcode(
370
        barcode(
370
            $self,
371
            $self,
371
            llx            => $barcode_llx,
372
            llx             => $barcode_llx,
372
            lly            => $barcode_lly,
373
            lly             => $barcode_lly,
373
            width          => $barcode_width,
374
            width           => $barcode_width,
374
            y_scale_factor => $barcode_y_scale_factor,
375
            y_scale_factor  => $barcode_y_scale_factor,
376
            barcode_justify => $self->{'barcode_justify'},
375
        );
377
        );
376
    }
378
    }
377
    return $label_text if $label_text;
379
    return $label_text if $label_text;
Lines 516-524 sub draw_guide_box { Link Here
516
sub barcode {
518
sub barcode {
517
    my $self   = shift;
519
    my $self   = shift;
518
    my %params = @_;
520
    my %params = @_;
521
519
    $params{'barcode_data'} = ( $self->{'barcode'} || _get_label_item( $self->{'item_number'}, 1 ) )
522
    $params{'barcode_data'} = ( $self->{'barcode'} || _get_label_item( $self->{'item_number'}, 1 ) )
520
        if !$params{'barcode_data'};
523
        if !$params{'barcode_data'};
521
    $params{'barcode_type'} = $self->{'barcode_type'} if !$params{'barcode_type'};
524
    $params{'barcode_type'} = $self->{'barcode_type'} if !$params{'barcode_type'};
525
526
    my $barcode_justify = $params{'barcode_justify'} || 'L';
527
522
    my $x_scale_factor = 1;
528
    my $x_scale_factor = 1;
523
    my $num_of_bars    = length( $params{'barcode_data'} );
529
    my $num_of_bars    = length( $params{'barcode_data'} );
524
    my $tot_bar_length = 0;
530
    my $tot_bar_length = 0;
Lines 541-548 sub barcode { Link Here
541
            my $oGdB                 = GD::Barcode::Code39->new("*$params{'barcode_data'}*");
547
            my $oGdB                 = GD::Barcode::Code39->new("*$params{'barcode_data'}*");
542
            my $whole_barcode_length = ( length( $oGdB->barcode() ) * 0.9 ) + 20;
548
            my $whole_barcode_length = ( length( $oGdB->barcode() ) * 0.9 ) + 20;
543
            $x_scale_factor = ( $params{'width'} / $whole_barcode_length );
549
            $x_scale_factor = ( $params{'width'} / $whole_barcode_length );
550
551
            my $adjusted_llx  = $params{'llx'};
552
            my $barcode_width = $whole_barcode_length * $x_scale_factor;
553
554
            if ( $barcode_justify eq 'C' ) {
555
                $adjusted_llx = $params{'llx'} + ( ( $self->{'width'} - $barcode_width ) / 2 );
556
            } elsif ( $barcode_justify eq 'R' ) {
557
                $adjusted_llx = $params{'llx'} + ( $self->{'width'} - $barcode_width );
558
            }
559
544
            PDF::Reuse::Barcode::Code39(
560
            PDF::Reuse::Barcode::Code39(
545
                x             => $params{'llx'},
561
                x             => $adjusted_llx,
546
                y             => $params{'lly'},
562
                y             => $params{'lly'},
547
                value         => "*$params{barcode_data}*",
563
                value         => "*$params{barcode_data}*",
548
                xSize         => $x_scale_factor,
564
                xSize         => $x_scale_factor,
Lines 559-567 sub barcode { Link Here
559
        $bar_length     = '9.43333333333333';
575
        $bar_length     = '9.43333333333333';
560
        $tot_bar_length = ( $bar_length * $num_of_bars ) + ( $guard_length * 2 );
576
        $tot_bar_length = ( $bar_length * $num_of_bars ) + ( $guard_length * 2 );
561
        $x_scale_factor = ( $params{'width'} / $tot_bar_length ) * 0.9;
577
        $x_scale_factor = ( $params{'width'} / $tot_bar_length ) * 0.9;
578
579
        my $adjusted_llx  = $params{'llx'};
580
        my $barcode_width = $tot_bar_length * $x_scale_factor;
581
562
        eval {
582
        eval {
563
            PDF::Reuse::Barcode::COOP2of5(
583
            PDF::Reuse::Barcode::COOP2of5(
564
                x     => $params{'llx'},
584
                x     => $adjusted_llx,
565
                y     => $params{'lly'},
585
                y     => $params{'lly'},
566
                value => $params{barcode_data},
586
                value => $params{barcode_data},
567
                xSize => $x_scale_factor,
587
                xSize => $x_scale_factor,
Lines 576-584 sub barcode { Link Here
576
        $bar_length     = '13.1333333333333';
596
        $bar_length     = '13.1333333333333';
577
        $tot_bar_length = ( $bar_length * $num_of_bars ) + ( $guard_length * 2 );
597
        $tot_bar_length = ( $bar_length * $num_of_bars ) + ( $guard_length * 2 );
578
        $x_scale_factor = ( $params{'width'} / $tot_bar_length ) * 0.9;
598
        $x_scale_factor = ( $params{'width'} / $tot_bar_length ) * 0.9;
599
600
        my $adjusted_llx  = $params{'llx'};
601
        my $barcode_width = $tot_bar_length * $x_scale_factor;
602
579
        eval {
603
        eval {
580
            PDF::Reuse::Barcode::Industrial2of5(
604
            PDF::Reuse::Barcode::Industrial2of5(
581
                x     => $params{'llx'},
605
                x     => $adjusted_llx,
582
                y     => $params{'lly'},
606
                y     => $params{'lly'},
583
                value => $params{barcode_data},
607
                value => $params{barcode_data},
584
                xSize => $x_scale_factor,
608
                xSize => $x_scale_factor,
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-layout.tt (+12 lines)
Lines 184-189 Link Here
184
                        [% END %]
184
                        [% END %]
185
                    </select>
185
                    </select>
186
                </li>
186
                </li>
187
                <li>
188
                    <label for="barcode_justify">Barcode justification: </label>
189
                    <select name="barcode_justify" id="barcode_justify">
190
                        [% FOREACH barcode_justification_type IN barcode_justification_types %]
191
                            [% IF ( barcode_justification_type.selected ) %]
192
                                <option value="[% barcode_justification_type.type | html %]" selected="selected">[% PROCESS translate_justification_types type=barcode_justification_type.type %]</option>
193
                            [% ELSE %]
194
                                <option value="[% barcode_justification_type.type | html %]">[% PROCESS translate_justification_types type=barcode_justification_type.type %]</option>
195
                            [% END %]
196
                        [% END %]
197
                    </select>
198
                </li>
187
                <li>
199
                <li>
188
                    <label for="font">Font: </label>
200
                    <label for="font">Font: </label>
189
                    <select name="font" id="font">
201
                    <select name="font" id="font">
(-)a/labels/label-create-pdf.pl (+3 lines)
Lines 149-154 foreach my $item ( @{$items} ) { Link Here
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
            barcode_justify  => $layout->get_attr('barcode_justify'),
152
            format_string    => $layout->get_attr('format_string'),
153
            format_string    => $layout->get_attr('format_string'),
153
            text_wrap_cols   => $layout->get_text_wrap_cols(
154
            text_wrap_cols   => $layout->get_text_wrap_cols(
154
                label_width      => $template->get_attr('label_width'),
155
                label_width      => $template->get_attr('label_width'),
Lines 178-183 foreach my $item ( @{$items} ) { Link Here
178
            scale_height     => $layout->get_attr('scale_height'),
179
            scale_height     => $layout->get_attr('scale_height'),
179
            callnum_split    => $layout->get_attr('callnum_split'),
180
            callnum_split    => $layout->get_attr('callnum_split'),
180
            justify          => $layout->get_attr('text_justify'),
181
            justify          => $layout->get_attr('text_justify'),
182
            barcode_justify  => $layout->get_attr('barcode_justify'),
181
            format_string    => $layout->get_attr('format_string'),
183
            format_string    => $layout->get_attr('format_string'),
182
            text_wrap_cols   => $layout->get_text_wrap_cols(
184
            text_wrap_cols   => $layout->get_text_wrap_cols(
183
                label_width      => $template->get_attr('label_width'),
185
                label_width      => $template->get_attr('label_width'),
Lines 209-214 foreach my $item ( @{$items} ) { Link Here
209
        scale_height     => $layout->get_attr('scale_height'),
211
        scale_height     => $layout->get_attr('scale_height'),
210
        callnum_split    => $layout->get_attr('callnum_split'),
212
        callnum_split    => $layout->get_attr('callnum_split'),
211
        justify          => $layout->get_attr('text_justify'),
213
        justify          => $layout->get_attr('text_justify'),
214
        barcode_justify  => $layout->get_attr('barcode_justify'),
212
        format_string    => $layout->get_attr('format_string'),
215
        format_string    => $layout->get_attr('format_string'),
213
        text_wrap_cols   => $layout->get_text_wrap_cols(
216
        text_wrap_cols   => $layout->get_text_wrap_cols(
214
            label_width      => $template->get_attr('label_width'),
217
            label_width      => $template->get_attr('label_width'),
(-)a/labels/label-edit-layout.pl (-32 / +35 lines)
Lines 103-120 if ( $op eq 'edit_form' ) { Link Here
103
        $cgi->param( 'format_string', $format_string );
103
        $cgi->param( 'format_string', $format_string );
104
    }
104
    }
105
    my @params = (
105
    my @params = (
106
        barcode_type  => scalar $cgi->param('barcode_type')  || 'CODE39',
106
        barcode_type    => scalar $cgi->param('barcode_type')  || 'CODE39',
107
        printing_type => scalar $cgi->param('printing_type') || 'BAR',
107
        printing_type   => scalar $cgi->param('printing_type') || 'BAR',
108
        layout_name   => scalar $cgi->param('layout_name')   || 'DEFAULT',
108
        layout_name     => scalar $cgi->param('layout_name')   || 'DEFAULT',
109
        guidebox      => ( $cgi->param('guidebox')      ? 1 : 0 ),
109
        guidebox        => ( $cgi->param('guidebox')      ? 1 : 0 ),
110
        oblique_title => ( $cgi->param('oblique_title') ? 1 : 0 ),
110
        oblique_title   => ( $cgi->param('oblique_title') ? 1 : 0 ),
111
        font          => scalar $cgi->param('font')         || 'TR',
111
        font            => scalar $cgi->param('font')         || 'TR',
112
        font_size     => scalar $cgi->param('font_size')    || 3,
112
        font_size       => scalar $cgi->param('font_size')    || 3,
113
        scale_width   => scalar $cgi->param('scale_width')  || 0.8,
113
        scale_width     => scalar $cgi->param('scale_width')  || 0.8,
114
        scale_height  => scalar $cgi->param('scale_height') || 0.01,
114
        scale_height    => scalar $cgi->param('scale_height') || 0.01,
115
        callnum_split => ( $cgi->param('callnum_split') ? 1 : 0 ),
115
        callnum_split   => ( $cgi->param('callnum_split') ? 1 : 0 ),
116
        text_justify  => scalar $cgi->param('text_justify') || 'L',
116
        text_justify    => scalar $cgi->param('text_justify')    || 'L',
117
        format_string => scalar $cgi->param('format_string')
117
        barcode_justify => scalar $cgi->param('barcode_justify') || 'L',
118
        format_string   => scalar $cgi->param('format_string')
118
            || 'title, author, isbn, issn, itemtype, barcode, itemcallnumber',
119
            || 'title, author, isbn, issn, itemtype, barcode, itemcallnumber',
119
    );
120
    );
120
    if ($layout_id) {    # if a label_id was passed in, this is an update to an existing layout
121
    if ($layout_id) {    # if a label_id was passed in, this is an update to an existing layout
Lines 132-159 if ( $op eq 'edit_form' ) { Link Here
132
    $layout = C4::Labels::Layout->new();
133
    $layout = C4::Labels::Layout->new();
133
}
134
}
134
135
135
my $barcode_types            = _set_selected( get_barcode_types(),            $layout, 'barcode_type' );
136
my $barcode_types               = _set_selected( get_barcode_types(),            $layout, 'barcode_type' );
136
my $label_types              = _set_selected( get_label_types(),              $layout, 'printing_type' );
137
my $label_types                 = _set_selected( get_label_types(),              $layout, 'printing_type' );
137
my $font_types               = _set_selected( get_font_types(),               $layout, 'font' );
138
my $font_types                  = _set_selected( get_font_types(),               $layout, 'font' );
138
my $text_justification_types = _set_selected( get_text_justification_types(), $layout, 'text_justify' );
139
my $text_justification_types    = _set_selected( get_text_justification_types(), $layout, 'text_justify' );
140
my $barcode_justification_types = _set_selected( get_text_justification_types(), $layout, 'barcode_justify' );
141
139
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') );
140
143
141
$template->param(
144
$template->param(
142
    barcode_types            => $barcode_types,
145
    barcode_types               => $barcode_types,
143
    label_types              => $label_types,
146
    label_types                 => $label_types,
144
    font_types               => $font_types,
147
    font_types                  => $font_types,
145
    text_justification_types => $text_justification_types,
148
    text_justification_types    => $text_justification_types,
146
    fields                   => $select_text_fields,
149
    barcode_justification_types => $barcode_justification_types,
147
    field_count              => $select_text_fields_cnt,
150
    fields                      => $select_text_fields,
148
    layout_id                => $layout->get_attr('layout_id') > -1 ? $layout->get_attr('layout_id') : '',
151
    field_count                 => $select_text_fields_cnt,
149
    layout_name              => $layout->get_attr('layout_name'),
152
    layout_id                   => $layout->get_attr('layout_id') > -1 ? $layout->get_attr('layout_id') : '',
150
    guidebox                 => $layout->get_attr('guidebox'),
153
    layout_name                 => $layout->get_attr('layout_name'),
151
    oblique_title            => $layout->get_attr('oblique_title'),
154
    guidebox                    => $layout->get_attr('guidebox'),
152
    font_size                => $layout->get_attr('font_size'),
155
    oblique_title               => $layout->get_attr('oblique_title'),
153
    scale_width              => $layout->get_attr('scale_width'),
156
    font_size                   => $layout->get_attr('font_size'),
154
    scale_height             => $layout->get_attr('scale_height'),
157
    scale_width                 => $layout->get_attr('scale_width'),
155
    callnum_split            => $layout->get_attr('callnum_split'),
158
    scale_height                => $layout->get_attr('scale_height'),
156
    format_string            => $layout->get_attr('format_string'),
159
    callnum_split               => $layout->get_attr('callnum_split'),
160
    format_string               => $layout->get_attr('format_string'),
157
    layout_string => 1,    # FIXME: This should not be hard-coded; It should perhaps be yet another syspref... CN
161
    layout_string => 1,    # FIXME: This should not be hard-coded; It should perhaps be yet another syspref... CN
158
);
162
);
159
output_html_with_http_headers $cgi, $cookie, $template->output;
163
output_html_with_http_headers $cgi, $cookie, $template->output;
160
- 

Return to bug 40478