103 |
} |
} |
104 |
|
|
105 |
|
|
106 |
|
sub fkey_join |
107 |
|
{ |
108 |
|
my $from = shift; |
109 |
|
my $to = shift; |
110 |
|
|
111 |
|
return qq' |
112 |
|
<!-- permite buscar por nombre simbólico --> |
113 |
|
<eq> |
114 |
|
<cfield name="$from"/> |
115 |
|
<cfield name="$to"/> |
116 |
|
</eq> |
117 |
|
'; |
118 |
|
} |
119 |
|
|
120 |
sub fkey_datasource |
sub fkey_datasource |
121 |
{ |
{ |
122 |
my $database = shift; |
my $database = shift; |
185 |
|
|
186 |
my %results = ($config->varlist('.')); |
my %results = ($config->varlist('.')); |
187 |
$results{'histables'} = join ', ', @histables; |
$results{'histables'} = join ', ', @histables; |
188 |
$results{'tables'} = join( ', ', map( $_->name, @tables ), $results{'histables'}); |
# $results{'tables'} = join( ', ', map( $_->name, @tables ), $results{'histables'}); |
189 |
$results{'conditions'} = "@conditions"; |
# $results{'conditions'} = "@conditions"; |
190 |
$results{'id'} = $results{table}.'.id'; |
$results{'id'} = $results{table}.'.id'; |
191 |
|
|
192 |
$zot->add_history; |
$zot->add_history; |
193 |
push @tables, map $zot->table($_), @histables; |
push @tables, map $zot->table($_), @histables; |
194 |
|
|
195 |
my $tmp=0; |
my $tmp=0; |
196 |
|
my @result_conditions = @conditions; |
197 |
foreach my $i (0..$#{ $results{'search_by'}}) |
foreach my $i (0..$#{ $results{'search_by'}}) |
198 |
{ |
{ |
199 |
my $field = $results{'search_by'}[$i]; |
my $field = $results{'search_by'}[$i]; |
201 |
if (!$table) |
if (!$table) |
202 |
{ |
{ |
203 |
($table) = grep $_->rel($field), @tables; |
($table) = grep $_->rel($field), @tables; |
204 |
|
die ('Aieee!') if (!$table); |
205 |
my $fkey_desc = shift @{$config->fkey_desc}; |
my $fkey_desc = shift @{$config->fkey_desc}; |
206 |
$results{'fkey'}[$i] = sprintf( 'foreign_key="%sDataSource._table" foreign_key_description="%s" style="dropdown"', |
$results{'fkey'}[$i] = sprintf( 'foreign_key="%sDataSource._table" foreign_key_description="%s" style="dropdown"', |
207 |
$field, |
$field, |
208 |
$fkey_desc ); |
$fkey_desc ); |
209 |
push @datasources, fkey_datasource($config->database, $table->rel($field)); |
push @datasources, fkey_datasource($config->database, $table->rel($field)); |
210 |
|
push @result_conditions, fkey_join($table->name . ".$field", '_' . $table->rel($field) . '_data._table'); |
211 |
} |
} |
212 |
my $attr = $table->attr($field) || $zot->table($table->rel($field))->attr('id'); |
my $attr = $table->attr($field) || $zot->table($table->rel($field))->attr('id'); |
213 |
my $width = 0; |
my $width = 0; |
234 |
foreach (1..$#{ $results{'search_width'} }); |
foreach (1..$#{ $results{'search_width'} }); |
235 |
$results{'datasources'} = join '', @datasources; |
$results{'datasources'} = join '', @datasources; |
236 |
|
|
237 |
|
$results{'result_conditions'} = join '', @result_conditions; |
238 |
|
$results{'edit_conditions'} = join '', @conditions; |
239 |
|
$results{'tables'} = join ', ', map $_->name, @tables; |
240 |
|
|
241 |
foreach my $i (0..$#{ $results{'field'} }) |
foreach my $i (0..$#{ $results{'field'} }) |
242 |
{ |
{ |
243 |
$results{'fkey'}[$i] ||= ''; |
$results{'fkey'}[$i] ||= ''; |