This file is indexed.

/usr/lib/x86_64-linux-gnu/perl5/5.22/Embperl/Form/Control/grid.pm is in libembperl-perl 2.5.0-6.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
###################################################################################
#
#   Embperl - Copyright (c) 1997-2008 Gerald Richter / ecos gmbh  www.ecos.de
#   Embperl - Copyright (c) 2008-2014 Gerald Richter
#
#   You may distribute under the terms of either the GNU General Public
#   License or the Artistic License, as specified in the Perl README file.
#
#   THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
#   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
#   WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
#   $Id$
#
###################################################################################

package Embperl::Form::Control::grid ;

use strict ;
use base 'Embperl::Form::ControlMultValue' ;

use vars qw{%fdat $epreq} ;

use Embperl::Inline ;
use Data::Clone ;

# ---------------------------------------------------------------------------
#
#   new - create a new control
#


sub new

    {
    my ($class, $args) = @_ ;

    my $self = Embperl::Form::ControlMultValue -> new($args) ;
    bless $self, $class ;
    
    $self -> init ;
    
    return $self ;
    }

# ---------------------------------------------------------------------------
#
#   init - init the new control
#

sub init

    {
    my ($self) = @_ ;

    $self -> {header_bottom} = 10 if (!exists ($self -> {header_bottom})) ;
    $self -> {width} = 1 if (!$self -> {width}) ;
    
    my $flat   = $self -> {flatopt} ;
    my @flat   = split /\s*;\s*/, $flat ;
    # make sure we do not change another instance of this grid
    my $fields = $self -> {fields} = clone ($self -> {fields})  ;
    if (@flat)
        {
        foreach (@$fields)
            {
            my $name = $_ -> {name} ;
            for (my $i = 0 ; $i < @flat; $i+=3)
                {
                $_ -> {$flat[$i+1]} = $flat[$i+2] if ($name eq $flat[$i]);        
                }
            }
        }
    my $form = $self -> form ;
    my $options = $form -> {options} ;
    $form -> new_controls ($fields, $options, undef, undef, $options -> {masks}, $options -> {defaults}, 1) ;
    if ($self -> {line2})
        {
        my $ctl = [$self -> {line2}] ;
        $form -> new_controls ($ctl, $options, undef, undef, $options -> {masks}, $options -> {defaults}, 1)  ;
        $self -> {line2} = $ctl -> [0] ;
        }
        
    return $self ;
    }



# ------------------------------------------------------------------------------------------
#
#   init_data_hash
#

sub init_data_hash
    {
    my ($rowno, $fdat, $name, $fields) = @_ ;
    
    my $data ;
    map
        {
        $data = $fdat->{$name}{$_} ;
        my @data ;
        if (ref $data eq 'HASH')
            {
            $data -> {'_key'} = $_ ;    
            foreach (@$fields)
                {
                push @data, $data -> {$_ -> {name}} ;    
                }
            }
        elsif (ref $data eq 'ARRAY')
            {
            push @data, $_, @$data ;    
            }
        else
            {
            push @data, $_, $data ;    
            }
                    
        [$rowno++, @data ]
        } keys %{$fdat->{$name}} ;
    
    }

# ------------------------------------------------------------------------------------------
#
#   init_data - daten aufteilen
#

sub init_data
    {
    my ($self, $req) = @_ ;
    
    my $fdat  = $req -> {docdata} || \%fdat ;
    my $ldap    = $req->{ldap};
    my $name    = $self->{name} ;
    my $rowno   = 1 ;
    my $fields  = $self -> {fields} ;
    my @entries = ref $fdat->{$name} eq 'ARRAY'?@{$fdat->{$name}}:
                  ref $fdat->{$name} eq 'HASH' ?init_data_hash ($rowno, $fdat, $name, $fields):
                                                split("\t",$fdat->{$name});
    my $line2   = $self -> {line2} ;
    my $order   = $self -> {order} ;
    my $order_desc   = $self -> {order_desc} ;
    
    if ($order)
        {
        if ($order !~ /^\d+$/)
            {
            my $i = 1 ;        
            foreach (@$fields)
                {
                $order = $i if ($_ -> {name} eq $order) ;
                $i++ ;
                }
            }

        if ($order_desc)
            {
            @entries = sort { $b -> [$order] cmp $a -> [$order] } @entries ;
            }
        else
            {
            @entries = sort { $a -> [$order] cmp $b -> [$order] } @entries ;
            }
        }

    my $coloffset = defined ($self -> {coloffset})?$self -> {coloffset}:1 ;
    my $data;
    my $i = 0 ;
    my $j ;
    my $col ;
    my $colval ;
    my @rowclass ;
    foreach my $entry (@entries)
        {
        $data = ref $entry eq 'ARRAY'?$entry:[$ldap?ecos::LdapBase -> splitAttrValue($entry):$entry];
        if (ref $self -> {rowclass} eq 'CODE')
            {
            $rowclass[$i] = &{$self -> {rowclass}}($data, $self) ;
            }
        #my $co = $coloffset ;
        #shift @$data while ($co-- > 0) ;
        $j = 0 ;
        foreach my $field ((@$fields, ($line2?($line2):())))
            {
            $col = exists $field -> {col}?$field -> {col}:$j ;
            if ($colval = $field -> {colval})
                {
                $fdat->{"__${name}_${j}_$i"} = $data->[$col+$coloffset] =~ /\Q$colval\E/?1:0 ;
                }
            else
                {
                $fdat->{"__${name}_${j}_$i"} = $data->[$col+$coloffset] ;
                }
            
            if ($field -> can ('init_data'))
                {
                local $field->{name} = "__${name}_${j}_$i" ;
                local $field -> {fullid} = "$self->{fullid}_${j}_$i" ;
                local $field->{dataprefix} ;
                $field -> init_data ($req, $self)  ;
                }
            $j++ ;    
            }
        $i++ ;
        }
    $fdat->{"__${name}_max"} = $i?$i:1;
    $self -> {rowclasses} ||= \@rowclass ;
    }

# ------------------------------------------------------------------------------------------
#
#   init_markup
#

sub init_markup
    {
    my ($self, $req, $grid, $method) = @_ ;
    
    my $fdat  = $req -> {docdata} || \%fdat ;
    my $name    = $self->{name} ;
    my $i ;
    my $j ;
    my $max = $fdat->{"__${name}_max"} ;
    my $fields  = $self -> {fields} ;
    my $line2   = $self -> {line2} ;

    foreach $i (0..$max, '%row%')
        {
        $j = 0 ;
        foreach my $field ((@$fields, ($line2?($line2):())))
            {
            if ($field -> can ('init_markup'))
                {
                local $field->{name} = "__${name}_${j}_$i" ;
                local $field -> {fullid} = "$self->{fullid}_${j}_$i" ;
                local $field->{dataprefix} ;
                $field -> init_markup ($req, $self, 'show_control')  ;
                }
            $j++ ;    
            }
        }
    }

# ------------------------------------------------------------------------------------------
#
#   prepare_fdat_sub - wird aufgerufen nachdem die einzelen Controls abgearbeitet sind abd
#                   bevor die daten zusammenfuehrt werden
#

sub prepare_fdat_sub
    {
    my ($self, $req) = @_ ;
    
    }
    
# ------------------------------------------------------------------------------------------
#
#   prepare_fdat - daten zusammenfuehren
#

sub prepare_fdat
    {
    my ($self, $req) = @_ ;
    
    return if ($self -> is_readonly ($req)) ;
   
    my $fdat  = $req -> {form} || \%fdat ;
    my $ldap    = $req->{ldap};
    my $name    = $self->{name} ;
    return if (!exists $fdat->{"__${name}_max"}) ;

    my $fields  = $self -> {fields} ;
    my $line2   = $self -> {line2} ;
    my $max     = $fdat->{"__${name}_max"} ;

    my @rows;
    my $j ;
    my $i ;
    my $val ;
    my $col ;
    my $colval ;
    my %orders ;
    my $order ;
    for (my $i = 0; $i < $max; $i++)
        {
        my $ok = 0 ;
        my $j = 0 ;
        foreach my $field (@$fields, $line2?($line2):())
            {
            if ((ref ($field) =~ /::/) && $field -> can ('prepare_fdat'))
                {
                local $field->{name} = "__${name}_${j}_$i" ;
                local $field -> {fullid} = "$self->{fullid}_${j}_$i" ;
                local $field->{dataprefix} ;
                $field -> prepare_fdat ($req)  ;
                }
            $ok++ ;
            $j++ ;
            }
        
        next if (!$ok) ;

        $order = $fdat->{"__${name}_#row#_$i"} ;
        next if (!defined($order)) ;
        $order = $i + 10000 if (!defined($order)) ;
        $orders{$order} = $i ;
        }

    $self -> prepare_fdat_sub ($req) if ((ref ($self) =~ /::/));

    my $coloffset = defined ($self -> {coloffset})?$self -> {coloffset}:1 ;
    foreach my $order (sort { $a <=> $b } keys %orders)
        {
        $i = $orders{$order} ;
        $j = 0 ;
        my $empty = 1 ;
        my @data = $coloffset?($i+1):() ;
        foreach my $field (@$fields)
            {
            $col = exists $field -> {col}?$field -> {col}:$j ;
            if ($colval = $field -> {colval})
                {
                $data[$col+$coloffset] .= $colval if ($fdat->{"__${name}_${j}_$i"}) ;
                }
            else
                {
                $data[$col+$coloffset] = $fdat->{"__${name}_${j}_$i"} ;
                }
            $empty = 0 if ($data[$col+$coloffset] ne '') ;
            $j++ ;
            }
        $val = $ldap?ecos::LdapBase -> joinAttrValue(\@data):\@data ;
        push @rows, $val if (!$empty) ;    
        }
    if ($self -> {datatype} eq 'hash')
        {
        $fdat->{$name} = { map { ($_->[1] => $_->[2]) } @rows } ;
        }
    else
        {
        $fdat->{$name} = \@rows ;
        }
        
    foreach my $key (keys %$fdat)
        {
        delete $fdat->{$key} if ($key =~ /^__\Q$name\E_/) ;
        }

    }

# ------------------------------------------------------------------------------------------
#
#   get_display_text - returns the text that should be displayed
#

sub get_display_text
    {
    my ($self, $req, $value) = @_ ;
    
    return '' if (!ref $value) ;
    
    my $name       = $self -> {name} ;
    my $fields     = $self -> {'fields'};
    my $showfields = $req -> {'grid_gtf_' . $name} ;
    my $allfields  = $req -> {'grid_gta_' . $name} ;
    if (!$showfields)
        {
        my $fdat = $req -> {docdata} || \%Embperl::fdat ;
        my $max    = $fdat -> {"__${name}_max"}  ||= 0 ;
        my $flat   = $self -> {flat} ;
        my @flat   = split /\s*;\s*/, $flat ;
        my $i = 0 ;
        my @fields ;
        my %fields ;
        foreach my $field (@$fields)
            {
            $fields{$field -> {name}} = $i ;
            push @fields, $field -> {name} ;
            $i++ ;
            }
        @fields = @flat if (@flat) ;
        $req -> {'grid_gtf_' . $name} = $showfields = \@fields ;
        $req -> {'grid_gta_' . $name} = $allfields  = \%fields ;
        }
        
    my @data ;
    my $fieldname ;
    my $j ;
    my @row ;
    my $field ;
    my $text ;
    foreach $fieldname (@$showfields)
        {
        $j     = $allfields -> {$fieldname}  ;
        $field = $fields -> [$j] ;
        next if $field -> is_hidden ;
        $text = $field -> get_display_text ($req, $value -> [$j+1]) ; 
        push @row, $text if ($text ne '') ;
        }
    return join (', ', @row) ;
    }
1 ;

__EMBPERL__

[# ---------------------------------------------------------------------------
#
#   show_control_readonly - output readonly grid
#]

[$ sub xshow_control_readonly ($self, $req)

    my $name     = $self -> {name} ;
    my $max    = $fdat{"__${name}_max"}  ||= 0 ;

    my $flat   = $self -> {flat} ;
    my @flat   = split /\s*;\s*/, $flat ;
    my $fields = $self -> {'fields'};
    my $i = 0 ;
    my @fields ;
    my %fields ;
    foreach my $field (@$fields)
        {
        $fields{$field -> {name}} = $i ;
        push @fields, $field -> {name} ;
        $i++ ;
        }
    @fields = @flat if (@flat) ;

    my @data ;
    for ($i = 0; $i < $max ; $i++)
        {
        my $j ;
        my @row ;
        foreach $fieldname (@fields)
            {
            my $field = $fields -> [$fields{$fieldname}] ;
            next if $field -> is_hidden ;
            $j = $fields{$fieldname} ;
            if ($field -> {datasrcobj})
                {
                push @row, $field -> get_option_from_value ($fdat{"__${name}_${j}_$i"}, $req) ;
                }
            else
                {
                push @row, $fdat{"__${name}_${j}_$i"} ;
                }
            }
        push @data, join (' ', @row) if (grep /\S/, @row) ;
        }
    my $value = join (' / ', @data) ;    
    $]
<div [+ do { local $escmode = 0 ; $self -> get_std_control_attr($req, '', 'readonly') } +]>[+ $value +]</div>
[$endsub$]
  

[# ---------------------------------------------------------------------------
#
#   show - output the control
#]

[$ sub show ($self, $req)

    my $name     = $self -> {name} ;
    my $span = ($self->{width_percent})  ;
    my $nsprefix = $self -> form -> {jsnamespace} ;
    my $max    = $fdat{"__${name}_max"} ||= 1 ;
    $self -> {fullid} = $req -> {uuid} . '_' . $self -> {id} ;
$]<table class="ef-element ef-element-width-[+ $self -> {width_percent} +][+ ' ' +][+ $self -> {state} +]" _ef_attach="ef_grid">
  <tr>
  <td class="ui-label-box" colspan="[+ $span +]">
  [-
    $fdat{$name} = $self -> {default} if ($fdat{$name} eq '' && exists ($self -> {default})) ;
    my $span = 0 ;
    $self -> show_grid_title ($req);
  -]
  <input type="hidden" name="__[+ $self -> {name} +]_max" class="ef-control-grid-max">
  <table class="cGridTable cBase ef-control-grid-table [+ $self -> {state} +]" >
    [- $self -> show_grid_header ($req); -]
    [- $self -> show_grid_table ($req) ; -]
  </table>
  [- $self -> show_grid_title ($req)
            if ($max > $self -> {header_bottom} && !$self -> {disable_controls}) -]
  <table class="ef-control-grid-newrow" style="display: none">
    [-
    local $req -> {epf_no_script} = 1 ;
    $self -> show_grid_table_row ($req, '%row%') ;
    -]
  </table>
  </td>
  </tr>
  </table>
[$endsub$]
  

[# -----------------------------------------------------------------------------
#
#   show_grid_title - Zeigt den Titel der Tabelle an
#]

[$ sub show_grid_title ($self, $req)
$]
<table class="cBase cGridTitle [+ $self -> {state} +]">
  <tr class="cTableRow">
    <td class="cBase cGridLabelBox">[+ $self -> form -> convert_label ($self, undef, undef, $req) +]</td>
    [$if !($self -> is_readonly ($req))  && !$self -> {disable_controls} $]
    <td class="cBase cGridControlBox">
      <div>
      <span class="ui-icon ui-icon-circle-triangle-n ef-icon ef-control-grid-up" title="Zeile Hoch"></span>
      <span class="ui-icon ui-icon-circle-triangle-s ef-icon ef-control-grid-down" title="Zeile Runter"></span>
      <span class="ui-icon ui-icon-circle-plus ef-icon ef-control-grid-add" title="Zeile Hinzuf&uuml;gen"></span>
      <span class="ui-icon ui-icon-circle-minus ef-icon ef-control-grid-del" title="Markierte Zeile L&ouml;schen"></span>
      </div>
    </td>
    [$endif$]
  </tr>
</table>
[$ endsub $]
  
[# ---------------------------------------------------------------------------
#
#    show_grid_header    Erzeugt den Tabellenkopf
#]

[$ sub show_grid_header ($self, $req)

  my $fields = $self->{'fields'};
 $]
         <thead>
         <tr class="cGridHeader">
         [$ foreach my $field (@$fields) $]
            [* next if ($field -> is_hidden ) ; *]
            <td class="cGridHeader" style="[$if($width = $field->{width})$]width: [+$width+];[$endif$] [$if($width = $field->{min_width})$]min-width: [+$width+];[$endif$]" _colattr="[+ $field->{name} +]">[+ $self -> form -> convert_label ($self, $field->{name}, $field->{text}, $req) +]</td>
         [$ endforeach $]
         </tr>
         </thead>
[$ endsub $]

[# ---------------------------------------------------------------------------
#
#    show_grid_footer    Erzeugt den Tabellenfuß (Summenzeile)
#]

[$ sub show_grid_footer ($self, $req)

  my $fields = $self->{'fields'};
  my $name   = $self -> {name} ;
  my $i      = $fdat{"__${name}_footer"}  ;
  my $j      = 0 ;
 $]

 <tfoot>
         <tr class="cGridFooter">
         [$ foreach my $field (@$fields)  $]
            [* next if ($field -> is_hidden ) ; *]
            <td class="cGridFooter cGridCellReadonly">[-
                local $field -> {name}  = "__${name}_${j}_$i" ;
                local $field -> {state} = $field -> {state} . ' ' . $self -> {state} ;
                local $field -> {fullid} = "$self->{fullid}_${j}_$i" ;
                local $field->{dataprefix} ;
                $field -> show_control_readonly_array ($req) if (!$field -> {nofooter}) ; 
                $j++ ;
                -]</td>
         [$ endforeach $]
         </tr>
         </tfoot>
[$ endsub $]

[# ---------------------------------------------------------------------------
#
#    show_grid_table_row     Erzeugt eine Grid-Tabelle-Zeile
#]

[$ sub show_grid_table_row ($self, $req, $i) 

    my $fields = $self -> {fields} ;
    my $line2  = $self -> {line2} ;
    my $id     = $self -> {fullid};
    my $name   = $self -> {name} ;
    my $n      = 0 ;
    my $gridro = $self -> is_readonly ($req) ;
    my $ro ;
    my $j = 0 ;
    $]

    <tr class="cGridRow [+ $self -> {rowclasses}[$i] +]" id="[+ "$id-row-$i" +]">
        [$foreach $field (@$fields)$]
            [$if $field -> is_hidden $][-
                local $field -> {name}  = "__${name}_${j}_$i" ;
                local $field -> {state} = $self -> {state} ;
                local $field -> {fullid} = "${id}_${j}_$i" ;
                local $field->{dataprefix} ;
                $field -> show_control ($req) ;
                $j++ ;
            -][$else$]
            [- $ro = $gridro || $field -> is_readonly () ; -]
            <td class="[+ $ro?'cGridCellReadonly':'cGridCell' +]" style="[$if($width = $field->{width})$]width: [+$width+];[$endif$]">[$if $n++ == 0$]<input type="hidden" name="[+ "__${name}_#row#_$i" +]" value="[+ $i +]">[$endif$][-
                local $field -> {name}  = "__${name}_${j}_$i" ;
                local $field -> {state} = $self -> {state} ;
                local $field -> {fullid} = "${id}_${j}_$i" ;
                local $field->{dataprefix} ;
                if ($ro)
                    {
                    $field -> show_control_readonly_array ($req)
                    }
                else    
                    {
                    $field -> show_control ($req)
                    }
                $j++ ;
                -]</td>
            [$endif$]   
        [$endforeach$]     
    </tr>
    [$if $line2 $]
        [- $ro = $gridro || $line2 -> is_readonly ; -]
        [$if (!$ro || $fdat{"__${name}_${j}_$i"} !~ /^\s*$/) $]
        <tr class="cGridRow2" id="[+ "$id-row2-$i" +]">
            
            <td colspan="[+ scalar(@$fields) +]" class="[+ $ro?'cGridCellReadonly':'cGridCell' +]">[$if $n++ == 0$]<input type="hidden" name="[+ "__${name}_#row#_$i" +]" value="[+ $i +]">[$endif$][-
                local $line2 -> {name}  = "__${name}_${j}_$i" ;
                local $line2 -> {state} = $self -> {state} ;
                local $field -> {fullid} = "${id}_${j}_$i" ;
                local $field->{dataprefix} ;
                if ($ro)
                    {
                    $line2 -> show_control_readonly_array ($req)
                    }
                else    
                    {
                    $line2 -> show_control ($req)
                    }
                $j++ ;
                -]</td>
        </tr>
        [$endif$]
    [$endif$]
[$ endsub $]
             
[# ---------------------------------------------------------------------------
#
#    show_grid_table     Erzeugt eine Grid-Tabelle
#]

[$ sub show_grid_table ($self, $req) 
    my $name    = $self->{name} ;
    my $fields = $self -> {fields} ;
    my $id     = $self -> {fullid};
    my $i      = 0 ;
    my $max    = $fdat{"__${name}_max"} || 1 ;
    my $order  = $self -> {order_indices} ;
    $]

    <tbody>
    [* for ($i = 0; $i < $max ; $i++ ) { *]
        [- $self -> show_grid_table_row ($req, $order?$order -> [$i]:$i) ; -]
    [* } *]
    </tbody>
    
[$endsub$]



__END__

=pod

=head1 NAME

Embperl::Form::Control::grid - A grid control inside an Embperl Form


=head1 SYNOPSIS


=head1 DESCRIPTION

Used to create a grid control inside an Embperl Form.
See Embperl::Form on how to specify parameters.

=head2 PARAMETER

=head3 type

Needs to be 'grid'

=head3 fields

Array ref with field definitions. Should look like any normal field definition.

The following extra attributes are available:

=over

=item col

Column number inside the @data array, which should be used for this cell

=item colval

If given this value is added to the column. This allows one to have multiple
checkboxes all writing to the same column, each appending a character or
string if set.

=back

=head3 line2

field defintion wich is show in a second line, full width.

=head3  disable_controls

If true, controls for add, delete, up and down will not be shown

=head3 header_bottom

If grid has more rows as given in this parameter,
a header line is also displayed at the bottom of the
grid. Default is 10. Set to -1 to always get a
header at the bottom.

=head3 order

Number of column to use as sort key

=head3 order_desc

Sort descending

=head3 coloffset

Offset added to column number. Default: 1
If > 1, column number will set to the rownumber

=head3 flat

This can be used for readonly view of grid. Normaly readonly view will show
the content as one large string. The flat attribute can contain a semikolon
delimited list of fields that should be show in readony view. That allows
to selectivly show fields in readonly view. 
This can be used to show a readonly view of a grid inside of another grid.

=head3 flatopt

Semikolon delimited list of tripels that add special options for flat view:

<name of fields>;<option name>;<option value>


=head2 Example

     {
     name => 'provider-path',
     text => 'Suchpfad',
     type => 'grid', 
     fields =>
        [
        { name => 'active', text => 'Aktiv', type => 'checkbox', width => '30' },
        { name => 'path',   text => 'Pfad' },
        ],
    },


=head1 Author

G. Richter (richter at embperl dot org)

=head1 See Also

perl(1), Embperl, Embperl::Form