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

(-)a/C4/Patroncards/Patroncard.pm (-1 / +83 lines)
Lines 24-30 use autouse 'Data::Dumper' => qw(Dumper); Link Here
24
use Text::Wrap qw(wrap);
24
use Text::Wrap qw(wrap);
25
#use Font::TTFMetrics;
25
#use Font::TTFMetrics;
26
26
27
use C4::Creators::Lib qw(get_font_types);
27
use C4::Creators::Lib qw(get_font_types get_unit_values);
28
use C4::Creators::PDF qw(StrWidth);
28
use C4::Creators::PDF qw(StrWidth);
29
use C4::Patroncards::Lib qw(unpack_UTF8 text_alignment leading box get_borrower_attributes);
29
use C4::Patroncards::Lib qw(unpack_UTF8 text_alignment leading box get_borrower_attributes);
30
30
Lines 69-74 sub draw_barcode { Link Here
69
sub draw_guide_box {
69
sub draw_guide_box {
70
    my ($self, $pdf) = @_;
70
    my ($self, $pdf) = @_;
71
    warn sprintf('No pdf object passed in.') and return -1 if !$pdf;
71
    warn sprintf('No pdf object passed in.') and return -1 if !$pdf;
72
72
    my $obj_stream = "q\n";                            # save the graphic state
73
    my $obj_stream = "q\n";                            # save the graphic state
73
    $obj_stream .= "0.5 w\n";                          # border line width
74
    $obj_stream .= "0.5 w\n";                          # border line width
74
    $obj_stream .= "1.0 0.0 0.0  RG\n";                # border color red
75
    $obj_stream .= "1.0 0.0 0.0  RG\n";                # border color red
Lines 79-84 sub draw_guide_box { Link Here
79
    $pdf->Add($obj_stream);
80
    $pdf->Add($obj_stream);
80
}
81
}
81
82
83
sub draw_guide_grid {
84
    my ($self, $pdf) = @_;
85
    warn sprintf('No pdf object passed in.') and return -1 if !$pdf;
86
87
    # Set up the grid in user defied units
88
    my $units = get_unit_values();
89
    my $unitvalue = 1;
90
    my $unitdesc = '';
91
    foreach my $un (@$units){
92
        if ($un->{'type'} eq $self->{'layout'}->{'units'}) {
93
            $unitvalue = $un->{'value'};
94
            $unitdesc = $un->{'desc'};
95
        }
96
    }
97
98
    my $obj_stream = "q\n";   # save the graphic state
99
    my $x = $self->{'llx'};
100
    my $y = $self->{'lly'};
101
102
    my $cnt = 0;
103
    for ( $x = $self->{'llx'}/$unitvalue; $x <= ($self->{'llx'} + $self->{'width'})/$unitvalue; $x++) {
104
        my $xx = $x*$unitvalue;
105
        my $yy = $y + $self->{'height'};
106
        if ( ($cnt % 10) && ! ($cnt % 5) ) {
107
            $obj_stream .= "0.0 1.0 0.0  RG\n";
108
            $obj_stream .= "0 w\n";
109
        } elsif ( $cnt % 5 ) {
110
            $obj_stream .= "0.0 1.0 1.0  RG\n";
111
            $obj_stream .= "0 w\n";
112
        } else {
113
            $obj_stream .= "0.0 0.0 1.0  RG\n";
114
            $obj_stream .= "0 w\n";
115
        }
116
        $cnt ++;
117
118
        $obj_stream .= "$xx $y m\n";
119
        $obj_stream .= "$xx $yy l\n";
120
121
        $obj_stream .= "s\n";
122
    }
123
124
    $x = $self->{'llx'};
125
    $y = $self->{'lly'};
126
    $cnt = 0;
127
    for ( $y = $self->{'lly'}/$unitvalue; $y <= ($self->{'lly'} + $self->{'height'})/$unitvalue; $y++) {
128
129
        my $xx = $x + $self->{'width'};
130
        my $yy = $y*$unitvalue;
131
132
        if ( ($cnt % 10) && ! ($cnt % 5) ) {
133
            $obj_stream .= "0.0 1.0 0.0  RG\n";
134
            $obj_stream .= "0 w\n";
135
        } elsif ( $cnt % 5 ) {
136
            $obj_stream .= "0.0 1.0 1.0  RG\n";
137
            $obj_stream .= "0 w\n";
138
        } else {
139
            $obj_stream .= "0.0 0.0 1.0  RG\n";
140
            $obj_stream .= "0 w\n";
141
        }
142
        $cnt ++;
143
144
        $obj_stream .= "$x $yy m\n";
145
        $obj_stream .= "$xx $yy l\n";
146
        $obj_stream .= "s\n";
147
    }
148
149
    $obj_stream .= "Q\n"; # restore the graphic state
150
    $pdf->Add($obj_stream);
151
152
    # Add info about units
153
    my $strbottom = "0/0 $unitdesc";
154
    my $strtop = sprintf('%.2f', $self->{'width'}/$unitvalue) .'/'. sprintf('%.2f', $self->{'height'}/$unitvalue);
155
    my $font_size = 6;
156
    $pdf->Font( 'Courier' );
157
    $pdf->FontSize( $font_size );
158
    my $strtop_len = $pdf->StrWidth($strtop) * 1.5;
159
    $pdf->Text( $self->{'llx'} + 2, $self->{'lly'} + 2, "0/0 $unitdesc");
160
    $pdf->Text( $self->{'llx'} + $self->{'width'} - $strtop_len , $self->{'lly'} + $self->{'height'} - $font_size , $strtop );
161
}
162
163
82
sub draw_text {
164
sub draw_text {
83
    my ($self, $pdf, %params) = @_;
165
    my ($self, $pdf, %params) = @_;
84
    warn sprintf('No pdf object passed in.') and return -1 if !$pdf;
166
    warn sprintf('No pdf object passed in.') and return -1 if !$pdf;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-layout.tt (+10 lines)
Lines 176-181 Link Here
176
                                    <input type="radio" name="guide_box" id="guide_box" value="0" checked="checked" />Off
176
                                    <input type="radio" name="guide_box" id="guide_box" value="0" checked="checked" />Off
177
                                    [% END %]
177
                                    [% END %]
178
                                </li>
178
                                </li>
179
                                <li>
180
                                    <label for="guide_grid">Guide grid:</label>
181
                                    [% IF ( guide_grid ) %]
182
                                    <input type="radio" name="guide_grid" id="guide_grid" value="1" checked="checked" />On
183
                                    <input type="radio" name="guide_grid" id="guide_grid" value="0" />Off
184
                                    [% ELSE %]
185
                                    <input type="radio" name="guide_grid" id="guide_grid" value="1" />On
186
                                    <input type="radio" name="guide_grid" id="guide_grid" value="0" checked="checked" />Off
187
                                    [% END %]
188
                                </li>
179
                                </ol>
189
                                </ol>
180
                                </fieldset>
190
                                </fieldset>
181
                                </li>
191
                                </li>
(-)a/patroncards/create-pdf.pl (-2 / +3 lines)
Lines 155-162 foreach my $item (@{$items}) { Link Here
155
                text_wrap_cols          => 30, #FIXME: hardcoded,
155
                text_wrap_cols          => 30, #FIXME: hardcoded,
156
        );
156
        );
157
157
158
        $patron_card->draw_guide_box($pdf) if $print_layout_xml->{'guide_box'};
158
        $patron_card->draw_guide_box($pdf) if $layout_xml->{'guide_box'};
159
        $patron_card->draw_barcode($pdf) if $print_layout_xml->{'barcode'};
159
        $patron_card->draw_guide_grid($pdf) if $layout_xml->{'guide_grid'};
160
        $patron_card->draw_barcode($pdf) if $layout_xml->{'barcode'};
160
161
161
#       Do image foo and place binary image data into layout hash
162
#       Do image foo and place binary image data into layout hash
162
        my $image_data = {};
163
        my $image_data = {};
(-)a/patroncards/edit-layout.pl (-1 / +2 lines)
Lines 156-161 if ($op eq 'edit') { Link Here
156
            layout_name     => $layout->get_attr('layout_name'),
156
            layout_name     => $layout->get_attr('layout_name'),
157
            page_side       => ($layout_xml->{'page_side'} eq 'F' ? 0 : 1),
157
            page_side       => ($layout_xml->{'page_side'} eq 'F' ? 0 : 1),
158
            guide_box       => $layout_xml->{'guide_box'},
158
            guide_box       => $layout_xml->{'guide_box'},
159
            guide_grid      => $layout_xml->{'guide_grid'},
159
            units           => $units,
160
            units           => $units,
160
            @barcode,
161
            @barcode,
161
            barcode_type    => _set_selected($layout_xml->{'barcode'}->[0]->{'type'}, $barcode_types),
162
            barcode_type    => _set_selected($layout_xml->{'barcode'}->[0]->{'type'}, $barcode_types),
Lines 218-223 elsif ($op eq 'save') { Link Here
218
            $layout->{'units'} = $cgi->param($parameter) if $parameter eq 'units';
219
            $layout->{'units'} = $cgi->param($parameter) if $parameter eq 'units';
219
            $layout->{'page_side'} = $cgi->param($parameter) if $parameter eq 'page_side';
220
            $layout->{'page_side'} = $cgi->param($parameter) if $parameter eq 'page_side';
220
            $layout->{'guide_box'} = $cgi->param($parameter) if $parameter eq 'guide_box';
221
            $layout->{'guide_box'} = $cgi->param($parameter) if $parameter eq 'guide_box';
222
            $layout->{'guide_grid'} = $cgi->param($parameter) if $parameter eq 'guide_grid';
221
        }
223
        }
222
    }
224
    }
223
    $layout->{'text'} = $text_lines;
225
    $layout->{'text'} = $text_lines;
224
- 

Return to bug 18541