File Coverage

File:C4/Creators/Lib.pm
Coverage:10.7%

linestmtbrancondsubtimecode
1package C4::Creators::Lib;
2
3# Copyright 2009 Foundations Bible College.
4#
5# This file is part of Koha.
6#
7# Koha is free software; you can redistribute it and/or modify it under the
8# terms of the GNU General Public License as published by the Free Software
9# Foundation; either version 2 of the License, or (at your option) any later
10# version.
11#
12# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License along
17# with Koha; if not, write to the Free Software Foundation, Inc.,
18# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
12
12
12
113
78
358
use strict;
21
12
12
12
115
95
502
use warnings;
22
23
12
12
12
30552
1856
227
use autouse 'Data::Dumper' => qw(Dumper);
24
25
12
12
12
1865
94
232
use C4::Context;
26
12
12
12
136
53
1296
use C4::Debug;
27
28BEGIN {
29
12
12
12
12
853
14107
215
181
    use version; our $VERSION = qv('1.0.0_1');
30
12
12
12
1371
123
1559
    use base qw(Exporter);
31
12
33162
    our @EXPORT = qw(get_all_templates
32                     get_all_layouts
33                     get_all_profiles
34                     get_all_image_names
35                     get_batch_summary
36                     get_label_summary
37                     get_card_summary
38                     get_barcode_types
39                     get_label_types
40                     get_font_types
41                     get_text_justification_types
42                     get_output_formats
43                     get_column_names
44                     get_table_names
45                     get_unit_values
46                     html_table
47    );
48}
49
50 - 54
=head1 NAME

C4::Creators::Lib

=cut
55
56 - 58
=head1 FUNCTIONS

=cut
59
60#=head2 C4::Creators::Lib::_SELECT()
61#
62# This function returns a recordset upon success and 1 upon failure. Errors are logged to the Apache log.
63#
64# examples:
65#
66# my $field_value = _SELECT(field_name, table_name, condition);
67#
68#=cut
69
70sub _SELECT {
71
0
    my @params = @_;
72
0
    my $query = "SELECT $params[0] FROM $params[1]";
73
0
    $params[2] ? $query .= " WHERE $params[2];" : $query .= ';';
74
0
    my $sth = C4::Context->dbh->prepare($query);
75# $sth->{'TraceLevel'} = 3;
76
0
    $sth->execute();
77
0
    if ($sth->err) {
78
0
        warn sprintf('Database returned the following error: %s', $sth->errstr);
79
0
        return 1;
80    }
81
0
    my $record_set = [];
82
0
    while (my $row = $sth->fetchrow_hashref()) {
83
0
        push(@$record_set, $row);
84    }
85
0
    return $record_set;
86}
87
88my $barcode_types = [
89    {type => 'CODE39', name => 'Code 39', desc => 'Translates the characters 0-9, A-Z, \'-\', \'*\', \'+\', \'$\', \'%\', \'/\', \'.\' and \' \' to a barcode pattern.', selected => 0},
90    {type => 'CODE39MOD', name => 'Code 39 + Modulo43', desc => 'Translates the characters 0-9, A-Z, \'-\', \'*\', \'+\', \'$\', \'%\', \'/\', \'.\' and \' \' to a barcode pattern. Encodes Mod 43 checksum.', selected => 0},
91    {type => 'CODE39MOD10', name => 'Code 39 + Modulo10', desc => 'Translates the characters 0-9, A-Z, \'-\', \'*\', \'+\', \'$\', \'%\', \'/\', \'.\' and \' \' to a barcode pattern. Encodes Mod 10 checksum.', selected => 0},
92    {type => 'COOP2OF5', name => 'COOP2of5', desc => 'Creates COOP2of5 barcodes from a string consisting of the numeric characters 0-9', selected => 0},
93# {type => 'EAN13', name => 'EAN13', desc => 'Creates EAN13 barcodes from a string of 12 or 13 digits. The check number (the 13:th digit) is calculated if not supplied.', selected => 0},
94# {type => 'EAN8', name => 'EAN8', desc => 'Translates a string of 7 or 8 digits to EAN8 barcodes. The check number (the 8:th digit) is calculated if not supplied.', selected => 0},
95# {type => 'IATA2of5', name => 'IATA2of5', desc => 'Creates IATA2of5 barcodes from a string consisting of the numeric characters 0-9', selected => 0},
96    {type => 'INDUSTRIAL2OF5', name => 'Industrial2of5', desc => 'Creates Industrial2of5 barcodes from a string consisting of the numeric characters 0-9', selected => 0},
97# {type => 'ITF', name => 'Interleaved2of5', desc => 'Translates the characters 0-9 to a barcodes. These barcodes could also be called 'Interleaved2of5'.', selected => 0},
98# {type => 'MATRIX2OF5', name => 'Matrix2of5', desc => 'Creates Matrix2of5 barcodes from a string consisting of the numeric characters 0-9', selected => 0},
99# {type => 'NW7', name => 'NW7', desc => 'Creates a NW7 barcodes from a string consisting of the numeric characters 0-9', selected => 0},
100# {type => 'UPCA', name => 'UPCA', desc => 'Translates a string of 11 or 12 digits to UPCA barcodes. The check number (the 12:th digit) is calculated if not supplied.', selected => 0},
101# {type => 'UPCE', name => 'UPCE', desc => 'Translates a string of 6, 7 or 8 digits to UPCE barcodes. If the string is 6 digits long, '0' is added first in the string. The check number (the 8:th digit) is calculated if not supplied.', selected => 0},
102];
103
104my $label_types = [
105    {type => 'BIB', name => 'Biblio', desc => 'Only the bibliographic data is printed.', selected => 0},
106    {type => 'BARBIB', name => 'Barcode/Biblio', desc => 'Barcode proceeds bibliographic data.', selected => 0},
107    {type => 'BIBBAR', name => 'Biblio/Barcode', desc => 'Bibliographic data proceeds barcode.', selected => 0},
108    {type => 'ALT', name => 'Alternating', desc => 'Barcode and bibliographic data are printed on alternating labels.', selected => 0},
109    {type => 'BAR', name => 'Barcode', desc => 'Only the barcode is printed.', selected => 0},
110];
111
112my $font_types = [
113    {type => 'TR', name => 'Times-Roman', selected => 0},
114    {type => 'TB', name => 'Times-Bold', selected => 0},
115    {type => 'TI', name => 'Times-Italic', selected => 0},
116    {type => 'TBI', name => 'Times-Bold-Italic', selected => 0},
117    {type => 'C', name => 'Courier', selected => 0},
118    {type => 'CB', name => 'Courier-Bold', selected => 0},
119    {type => 'CO', name => 'Courier-Oblique', selected => 0},
120    {type => 'CBO', name => 'Courier-Bold-Oblique', selected => 0},
121    {type => 'H', name => 'Helvetica', selected => 0},
122    {type => 'HB', name => 'Helvetica-Bold', selected => 0},
123    {type => 'HBO', name => 'Helvetica-Bold-Oblique', selected => 0},
124];
125
126my $text_justification_types = [
127    {type => 'L', name => 'Left', selected => 0},
128    {type => 'C', name => 'Center', selected => 0},
129    {type => 'R', name => 'Right', selected => 0},
130# {type => 'F', name => 'Full', selected => 0},
131];
132
133my $unit_values = [
134    {type => 'POINT', desc => 'PostScript Points', value => 1, selected => 0},
135    {type => 'AGATE', desc => 'Adobe Agates', value => 5.1428571, selected => 0},
136    {type => 'INCH', desc => 'US Inches', value => 72, selected => 0},
137    {type => 'MM', desc => 'SI Millimeters', value => 2.83464567, selected => 0},
138    {type => 'CM', desc => 'SI Centimeters', value => 28.3464567, selected => 0},
139];
140
141my $output_formats = [
142    {type => 'pdf', desc => 'PDF File'},
143    {type => 'csv', desc => 'CSV File'},
144];
145
146 - 152
=head2 C4::Creators::Lib::get_all_templates()

  my $templates = get_all_templates();

This function returns a reference to a hash containing all templates upon success and 1 upon failure. Errors are logged to the Apache log.

=cut
153
154sub get_all_templates {
155
0
    my %params = @_;
156
0
    my @templates = ();
157
0
    my $query = "SELECT " . ($params{'field_list'} ? $params{'field_list'} : '*') . " FROM creator_templates";
158
0
    $query .= ($params{'filter'} ? " WHERE $params{'filter'};" : ';');
159
0
    my $sth = C4::Context->dbh->prepare($query);
160
0
    $sth->execute();
161
0
    if ($sth->err) {
162
0
        warn sprintf('Database returned the following error: %s', $sth->errstr);
163
0
        return -1;
164    }
165    ADD_TEMPLATES:
166
0
    while (my $template = $sth->fetchrow_hashref) {
167
0
        push(@templates, $template);
168    }
169
0
    return \@templates;
170}
171
172 - 178
=head2 C4::Creators::Lib::get_all_layouts()

  my $layouts = get_all_layouts();

This function returns a reference to a hash containing all layouts upon success and 1 upon failure. Errors are logged to the Apache log.

=cut
179
180sub get_all_layouts {
181
0
    my %params = @_;
182
0
    my @layouts = ();
183
0
    my $query = "SELECT " . ($params{'field_list'} ? $params{'field_list'} : '*') . " FROM creator_layouts";
184
0
    $query .= ($params{'filter'} ? " WHERE $params{'filter'};" : ';');
185
0
    my $sth = C4::Context->dbh->prepare($query);
186
0
    $sth->execute();
187
0
    if ($sth->err) {
188
0
        warn sprintf('Database returned the following error: %s', $sth->errstr);
189
0
        return -1;
190    }
191    ADD_LAYOUTS:
192
0
    while (my $layout = $sth->fetchrow_hashref) {
193
0
        push(@layouts, $layout);
194    }
195
0
    return \@layouts;
196}
197
198 - 210
=head2 C4::Creators::Lib::get_all_profiles()

  my $profiles = get_all_profiles();

  my $profiles = get_all_profiles(field_list => field_list, filter => filter_string);

This function returns an arrayref whose elements are hashes containing all profiles upon success and 1 upon failure. Errors are logged
to the Apache log. Two parameters are accepted. The first limits the field(s) returned. This parameter should be string of comma separted
fields. ie. "field_1, field_2, ...field_n" The second limits the records returned based on a string containing a valud SQL 'WHERE' filter.

NOTE: Do not pass in the keyword 'WHERE.'

=cut
211
212sub get_all_profiles {
213
0
    my %params = @_;
214
0
    my @profiles = ();
215
0
    my $query = "SELECT " . ($params{'field_list'} ? $params{'field_list'} : '*') . " FROM printers_profile";
216
0
    $query .= ($params{'filter'} ? " WHERE $params{'filter'};" : ';');
217
0
    my $sth = C4::Context->dbh->prepare($query);
218# $sth->{'TraceLevel'} = 3 if $debug;
219
0
    $sth->execute();
220
0
    if ($sth->err) {
221
0
        warn sprintf('Database returned the following error: %s', $sth->errstr);
222
0
        return -1;
223    }
224    ADD_PROFILES:
225
0
    while (my $profile = $sth->fetchrow_hashref) {
226
0
        push(@profiles, $profile);
227    }
228
0
    return \@profiles;
229}
230
231 - 233
=head2 C4::Creators::Lib::get_all_image_names()

=cut
234
235sub get_all_image_names {
236
0
    my $image_names = [];
237
0
    my $query = "SELECT image_name FROM creator_images";
238
0
    my $sth = C4::Context->dbh->prepare($query);
239# $sth->{'TraceLevel'} = 3 if $debug;
240
0
    $sth->execute();
241
0
    if ($sth->err) {
242
0
        warn sprintf('Database returned the following error: %s', $sth->errstr);
243
0
        return -1;
244    }
245
0
0
0
    grep {push @$image_names, {type => $$_[0], name => $$_[0], selected => 0}} @{$sth->fetchall_arrayref([0])};
246
0
    return $image_names;
247}
248
249 - 261
=head2 C4::Creators::Lib::get_batch_summary()

  my $batches = get_batch_summary();

  my $batches = get_batch_summary(filter => filter_string);

This function returns an arrayref whose elements are hashes containing the batch_ids of current batches along with the item count
for each batch upon success and 1 upon failure. Item counts are stored under the key '_item_count' Errors are logged to the Apache log.
One parameter is accepted which limits the records returned based on a string containing a valud SQL 'WHERE' filter.

NOTE: Do not pass in the keyword 'WHERE.'

=cut
262
263sub get_batch_summary {
264
0
    my %params = @_;
265
0
    my @batches = ();
266
0
    my $query = "SELECT DISTINCT batch_id FROM creator_batches WHERE creator=?";
267
0
    $query .= ($params{'filter'} ? " AND $params{'filter'};" : ';');
268
0
    my $sth = C4::Context->dbh->prepare($query);
269# $sth->{'TraceLevel'} = 3;
270
0
    $sth->execute($params{'creator'});
271
0
    if ($sth->err) {
272
0
        warn sprintf('Database returned the following error on attempted SELECT: %s', $sth->errstr);
273
0
        return -1;
274    }
275    ADD_BATCHES:
276
0
    while (my $batch = $sth->fetchrow_hashref) {
277
0
        my $query = "SELECT count(batch_id) FROM creator_batches WHERE batch_id=? AND creator=?;";
278
0
        my $sth1 = C4::Context->dbh->prepare($query);
279
0
        $sth1->execute($batch->{'batch_id'}, $params{'creator'});
280
0
        if ($sth1->err) {
281
0
            warn sprintf('Database returned the following error on attempted SELECT count: %s', $sth1->errstr);
282
0
            return -1;
283        }
284
0
        my $count = $sth1->fetchrow_arrayref;
285
0
        $batch->{'_item_count'} = @$count[0];
286
0
        push(@batches, $batch);
287    }
288
0
    return \@batches;
289}
290
291 - 303
=head2 C4::Creators::Lib::get_label_summary()

  my $labels = get_label_summary();

  my $labels = get_label_summary(items => @item_list);

This function returns an arrayref whose elements are hashes containing the label_ids of current labels along with the item count
for each label upon success and 1 upon failure. Item counts are stored under the key '_item_count' Errors are logged to the Apache log.
One parameter is accepted which limits the records returned based on a string containing a valud SQL 'WHERE' filter.

NOTE: Do not pass in the keyword 'WHERE.'

=cut
304
305sub get_label_summary {
306
0
    my %params = @_;
307
0
    my $label_number = 0;
308
0
    my @label_summaries = ();
309
0
    my $query = " SELECT b.title, b.author, bi.itemtype, i.barcode, i.biblionumber, i.itype
310                      FROM creator_batches AS c LEFT JOIN items AS i ON (c.item_number=i.itemnumber)
311                      LEFT JOIN biblioitems AS bi ON (i.biblioitemnumber=bi.biblioitemnumber)
312                      LEFT JOIN biblio AS b ON (bi.biblionumber=b.biblionumber)
313                      WHERE itemnumber=? AND batch_id=?;
314                  ";
315
0
    my $sth = C4::Context->dbh->prepare($query);
316
0
0
    foreach my $item (@{$params{'items'}}) {
317
0
        $label_number++;
318
0
        $sth->execute($item->{'item_number'}, $params{'batch_id'});
319
0
        if ($sth->err) {
320
0
            warn sprintf('Database returned the following error on attempted SELECT: %s', $sth->errstr);
321
0
            return -1;
322        }
323
0
        my $record = $sth->fetchrow_hashref;
324
0
        my $label_summary;
325
0
        $label_summary->{'_label_number'} = $label_number;
326
0
        $record->{'author'} =~ s/[^\.|\w]$// if $record->{'author'}; # strip off ugly trailing chars... but not periods or word chars
327
0
        $record->{'title'} =~ s/\W*$//; # strip off ugly trailing chars
328        # FIXME contructing staff interface URLs should be done *much* higher up the stack - for the most part, C4 module code
329        # should not know that it's part of a web app
330
0
        $record->{'title'} = '<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=' . $record->{'biblionumber'} . '"> ' . $record->{'title'} . '</a>';
331
0
        $label_summary->{'_summary'} = $record->{'title'} . " | " . ($record->{'author'} ? $record->{'author'} : 'N/A');
332
0
        $label_summary->{'_item_type'} = C4::Context->preference("item-level_itypes") ? $record->{'itype'} : $record->{'itemtype'};
333
0
        $label_summary->{'_barcode'} = $record->{'barcode'};
334
0
        $label_summary->{'_item_number'} = $item->{'item_number'};
335
0
        $label_summary->{'_label_id'} = $item->{'label_id'};
336
0
        push (@label_summaries, $label_summary);
337    }
338
0
    return \@label_summaries;
339}
340
341 - 353
=head2 C4::Creators::Lib::get_card_summary()

  my $cards = get_card_summary();

  my $cards = get_card_summary(items => @item_list);

This function returns an arrayref whose elements are hashes containing the label_ids of current cards along with the item count
for each card upon success and 1 upon failure. Item counts are stored under the key '_item_count' Errors are logged to the Apache log.
One parameter is accepted which limits the records returned based on a string containing a valud SQL 'WHERE' filter.

NOTE: Do not pass in the keyword 'WHERE.'

=cut
354
355sub get_card_summary {
356
0
    my %params = @_;
357
0
    my $card_number = 0;
358
0
    my @card_summaries = ();
359
0
    my $query = "SELECT CONCAT_WS(', ', surname, firstname) AS name, cardnumber FROM borrowers WHERE borrowernumber=?;";
360
0
    my $sth = C4::Context->dbh->prepare($query);
361
0
0
    foreach my $item (@{$params{'items'}}) {
362
0
        $card_number++;
363
0
        $sth->execute($item->{'borrower_number'});
364
0
        if ($sth->err) {
365
0
            warn sprintf('Database returned the following error on attempted SELECT: %s', $sth->errstr);
366
0
            return -1;
367        }
368
0
        my $record = $sth->fetchrow_hashref;
369
0
        my $card_summary->{'_card_number'} = $card_number;
370
0
        $card_summary->{'_summary'} = $record->{'name'};
371
0
        $card_summary->{'borrowernumber'} = $item->{'borrower_number'};
372
0
        $card_summary->{'_label_id'} = $item->{'label_id'};
373
0
        push (@card_summaries, $card_summary);
374    }
375
0
    return \@card_summaries;
376}
377
378 - 384
=head2 C4::Creators::Lib::get_barcode_types()

  my $barcode_types = get_barcode_types();

This function returns a reference to an array of hashes containing all barcode types along with their name and description.

=cut
385
386sub get_barcode_types {
387
0
    return $barcode_types;
388}
389
390 - 396
=head2 C4::Creators::Lib::get_label_types()

  my $label_types = get_label_types();

This function returns a reference to an array of hashes containing all label types along with their name and description.

=cut
397
398sub get_label_types {
399
0
    return $label_types;
400}
401
402 - 408
=head2 C4::Creators::Lib::get_font_types()

  my $font_types = get_font_types();

This function returns a reference to an array of hashes containing all font types along with their name and description.

=cut
409
410sub get_font_types {
411
0
    return $font_types;
412}
413
414 - 420
=head2 C4::Creators::Lib::get_text_justification_types()

  my $text_justification_types = get_text_justification_types();

This function returns a reference to an array of hashes containing all text justification types along with their name and description.

=cut
421
422sub get_text_justification_types {
423
0
    return $text_justification_types;
424}
425
426 - 434
=head2 C4::Creators::Lib::get_unit_values()

  my $unit_values = get_unit_values();

This function returns a reference to an array of  hashes containing all unit types along with their description and multiplier.
NOTE: All units are relative to a PostScript Point.
There are 72 PS points to the inch.

=cut
435
436sub get_unit_values {
437
0
    return $unit_values;
438}
439
440 - 446
=head2 C4::Creators::Lib::get_output_formats()

  my $label_output_formats = get_output_formats();

This function returns a reference to an array of hashes containing all label output formats along with their description.

=cut
447
448sub get_output_formats {
449
0
    return $output_formats;
450}
451
452 - 456
=head2 C4::Creators::Lib::get_column_names($table_name)

Return an arrayref of an array containing the column names of the supplied table.

=cut
457
458sub get_column_names {
459
0
    my $table = shift;
460
0
    my $dbh = C4::Context->dbh();
461
0
    my $column_names = [];
462
0
    my $sth = $dbh->column_info(undef,undef,$table,'%');
463
0
    while (my $info = $sth->fetchrow_hashref()){
464
0
        $$column_names[$info->{'ORDINAL_POSITION'}] = $info->{'COLUMN_NAME'};
465    }
466
0
    return $column_names;
467}
468
469 - 473
=head2 C4::Creators::Lib::get_table_names($search_term)

Return an arrayref of an array containing the table names which contain the supplied search term.

=cut
474
475sub get_table_names {
476
0
    my $search_term = shift;
477
0
    my $dbh = C4::Context->dbh();
478
0
    my $table_names = [];
479
0
    my $sth = $dbh->table_info(undef,undef,"%$search_term%");
480
0
    while (my $info = $sth->fetchrow_hashref()){
481
0
        push (@$table_names, $info->{'TABLE_NAME'});
482    }
483
0
    return $table_names;
484}
485
486 - 522
=head2 C4::Creators::Lib::html_table()

This function returns an arrayref of an array of hashes contianing the supplied data formatted suitably to
be passed off as a T::P template parameter and used to build an html table.

   my $table = html_table(header_fields, array_of_row_data);
   $template->param(
       TABLE => $table,
   );

    html example:

       <table>
            <!-- TMPL_LOOP NAME="TABLE" -->
            <!-- TMPL_IF NAME="header_fields" -->
            <tr>
            <!-- TMPL_LOOP NAME="header_fields" -->
                <th><!-- TMPL_VAR NAME="field_label" --></th>
            <!-- /TMPL_LOOP -->
            </tr>
            <!-- TMPL_ELSE -->
            <tr>
            <!-- TMPL_LOOP NAME="text_fields" -->
            <!-- TMPL_IF NAME="select_field" -->
                <td align="center"><input type="checkbox" name="action" value="<!-- TMPL_VAR NAME="field_value" -->" /></td>
            <!-- TMPL_ELSIF NAME="field_value" -->
                <td><!-- TMPL_VAR NAME="field_value" --></td>
            <!-- TMPL_ELSE -->
                <td>&nbsp;</td>
            <!-- /TMPL_IF -->
            <!-- /TMPL_LOOP -->
            </tr>
            <!-- /TMPL_IF -->
            <!-- /TMPL_LOOP -->
        </table>

=cut
523
524sub html_table {
525
0
    my $headers = shift;
526
0
    my $data = shift;
527
0
    return undef if scalar(@$data) == 0; # no need to generate a table if there is not data to display
528
0
    my $table = [];
529
0
    my $fields = [];
530
0
    my @table_columns = ();
531
0
    my ($row_index, $col_index) = (0,0);
532
0
    my $cols = 0; # number of columns to wrap on
533
0
    my $field_count = 0;
534
0
    my $select_value = undef;
535
0
    my $link_field = undef;
536    POPULATE_HEADER:
537
0
    foreach my $header (@$headers) {
538
0
        my @key = keys %$header;
539
0
        if ($key[0] eq 'select' ) {
540
0
            push (@table_columns, $key[0]);
541
0
            $$fields[$col_index] = {hidden => 0, select_field => 0, field_name => ($key[0]), field_label => $header->{$key[0]}{'label'}};
542            # do special formatting stuff....
543
0
            $select_value = $header->{$key[0]}{'value'};
544        }
545        else {
546            # do special formatting stuff....
547
0
            $link_field->{$key[0]} = ($header->{$key[0]}{'link_field'} == 1 ? 1 : 0);
548
0
            push (@table_columns, $key[0]);
549
0
            $$fields[$col_index] = {hidden => 0, select_field => 0, field_name => ($key[0]), field_label => $header->{$key[0]}{'label'}};
550        }
551
0
        $field_count++;
552
0
        $col_index++;
553    }
554
0
    $$table[$row_index] = {header_fields => $fields};
555
0
    $cols = $col_index;
556
0
    $field_count *= scalar(@$data); # total fields to be displayed in the table
557
0
    $col_index = 0;
558
0
    $row_index++;
559
0
    $fields = [];
560    POPULATE_TABLE:
561
0
    foreach my $db_row (@$data) {
562        POPULATE_ROW:
563
0
        foreach my $table_column (@table_columns) {
564
0
0
            if (grep {$table_column eq $_} keys %$db_row) {
565
0
                $$fields[$col_index] = {hidden => 0, link_field => $link_field->{$table_column}, select_field => 0, field_name => ($table_column . "_tbl"), field_value => $db_row->{$table_column}};
566
0
                $col_index++;
567
0
                next POPULATE_ROW;
568            }
569            elsif ($table_column =~ m/^_((.*)_(.*$))/) { # this a special case
570
0
                my $table_name = get_table_names($2);
571
0
                my $record_set = _SELECT($1, @$table_name[0], $2 . "_id = " . $db_row->{$2 . "_id"});
572
0
                $$fields[$col_index] = {hidden => 0, link_field => $link_field->{$table_column}, select_field => 0, field_name => ($table_column . "_tbl"), field_value => $$record_set[0]{$1}};
573
0
                $col_index++;
574
0
                next POPULATE_ROW;
575            }
576            elsif ($table_column eq 'select' ) {
577
0
                $$fields[$col_index] = {hidden => 0, select_field => 1, field_name => 'select', field_value => $db_row->{$select_value}};
578            }
579        }
580
0
        $$table[$row_index] = {text_fields => $fields};
581
0
        $col_index = 0;
582
0
        $row_index++;
583
0
        $fields = [];
584    }
585
0
    return $table;
586}
587
5881;