9 |
use BackupPC::CGI::Lib qw(:all); |
use BackupPC::CGI::Lib qw(:all); |
10 |
use BackupPC::SearchLib; |
use BackupPC::SearchLib; |
11 |
use Data::Dumper; |
use Data::Dumper; |
12 |
|
use HTML::FillInForm; |
13 |
use vars qw($Cgi %In $MyURL $User %Conf $TopDir $BinDir $bpc); |
use vars qw($Cgi %In $MyURL $User %Conf $TopDir $BinDir $bpc); |
14 |
|
|
15 |
sub action() { |
sub action() { |
16 |
my $cont = ""; |
my $hosts_html = ""; |
|
my $host; |
|
|
my @hosts; |
|
|
my $hosts_html = ""; |
|
17 |
|
|
18 |
|
|
19 |
BackupPC::CGI::Lib::NewRequest(); |
BackupPC::CGI::Lib::NewRequest(); |
20 |
|
my @hosts = BackupPC::SearchLib::getUnits(); |
21 |
|
|
22 |
@hosts = BackupPC::SearchLib::getUnits(); |
foreach my $host (@hosts) { |
23 |
if ( !defined($In{search_results}) ) { |
$hosts_html .= "<option value=" . $host->{'id'} . "> " . $host->{'share'} . " </option>\n"; |
|
foreach $host (@hosts) { |
|
|
$hosts_html .= |
|
|
"<option value=" |
|
|
. $host->{'ID'} . "> " |
|
|
. $host->{'name'} |
|
|
. " </option>\n"; |
|
24 |
} |
} |
|
my $title = eval(q{ ${h1("Search")}}); |
|
|
my $subtitle = eval(q{ ${h2("Search criteria")}}); |
|
25 |
|
|
26 |
sub date_from_to_html { |
sub date_from_to_html { |
27 |
my $name = shift || return; |
my $name = shift || return; |
28 |
return qq{ |
return qq{ |
29 |
<table> |
<input type="text" name="${name}_day_from" size="2"> |
30 |
<tr> |
<input type="text" name="${name}_month_from" size="2"> |
31 |
<td colspan="3" align="center">from</a> |
<input type="text" name="${name}_year_from" size="4"> |
32 |
<td> </td> |
- |
33 |
<td colspan="3" align="center">to</a> |
<input type="text" name="${name}_day_to" size="2"> |
34 |
</tr> |
<input type="text" name="${name}_month_to" size="2"> |
35 |
<tr> |
<input type="text" name="${name}_year_to" size="4"> |
|
<td align="center">dd</td> |
|
|
<td align="center">mm</td> |
|
|
<td align="center">yyyy</td> |
|
|
<td align="center"> </td> |
|
|
<td align="center">dd</td> |
|
|
<td align="center">mm</td> |
|
|
<td align="center">yyyy</td> |
|
|
</tr> |
|
|
<tr> |
|
|
<td><input type="text" name="${name}_day_from" size="2"></td> |
|
|
<td><input type="text" name="${name}_month_from" size="2"></td> |
|
|
<td><input type="text" name="${name}_year_from" size="4"></td> |
|
|
<td> - </td> |
|
|
<td><input type="text" name="${name}_day_to" size="2"></td> |
|
|
<td><input type="text" name="${name}_month_to" size="2"></td> |
|
|
<td><input type="text" name="${name}_year_to" size="4"></td> |
|
|
</tr> |
|
|
</table> |
|
36 |
}; |
}; |
37 |
} |
} |
38 |
|
|
39 |
$cont .= qq{ |
my $form .= qq{ |
40 |
<form name="searchForm" method="GET" action="$MyURL"> |
<form name="searchForm" method="GET" action="$MyURL"> |
41 |
$title |
<p> |
42 |
$subtitle |
Filename: |
43 |
<table border="0" width="100%"> |
<input type="text" name="search_filename" size="50"> |
44 |
<tr> |
|
45 |
<td>Share:</td> |
on share |
46 |
<td><select name="search_host">$hosts_html</select></td> |
|
47 |
</tr> |
<select name="search_host">$hosts_html</select> |
48 |
<tr class="fviewborder"> |
|
49 |
<td>All file(s) between:</td> |
<input type="submit" value="Search"> |
50 |
<td>} . date_from_to_html('search') . qq{</td> |
</p> |
51 |
</tr> |
|
52 |
<tr> |
<p style="color:gray;"> |
53 |
<td>All backups between:</td> |
file(s) between: |
54 |
<td>} . date_from_to_html('search_backup') . qq{</td> |
} . date_from_to_html('search') . qq{ |
55 |
</tr> |
|
56 |
<tr class="fviewborder"> |
backups between: |
57 |
<td>Filename:</td> |
} . date_from_to_html('search_backup') . qq{ |
58 |
<td><input type="text" name="search_filename" size="25"></td> |
(yyyy-mm-dd) |
59 |
</tr> |
</p> |
|
</table> |
|
60 |
|
|
|
<input type="submit" value="Search"> |
|
61 |
<input type="hidden" value="search" name="action"> |
<input type="hidden" value="search" name="action"> |
62 |
<input type="hidden" value="results" name="search_results"> |
<input type="hidden" value="results" name="search_results"> |
63 |
</form> |
</form> |
64 |
}; |
}; |
65 |
} |
|
66 |
else { |
my $html = eval(q{ ${h1("Search")}}); |
67 |
$cont = eval(q{ ${h1("Search")}}); |
|
68 |
$cont .= eval(q{ ${h2("Search results")}}); |
if ( !defined($In{search_results}) ) { |
69 |
my $result; |
$html .= eval(q{ ${h2("Search criteria")}}); |
70 |
my $rows = ""; |
$html .= $form; |
71 |
|
} else { |
72 |
my ($where, $from_f, $to_f, $from_b, $to_b) = BackupPC::SearchLib::getWhere(\%In); |
$html .= eval(q{ ${h2("Search results")}}); |
73 |
|
my $fif = new HTML::FillInForm; |
74 |
my $q = $In{'search_filename'}; |
$html .= $fif->fill(scalarref => \$form, fdat => \%In); |
75 |
|
|
76 |
$cont .= "<small>"; |
my ($where, $from_f, $to_f, $from_b, $to_b) = BackupPC::SearchLib::getWhere(\%In); |
77 |
$cont .= "Filename filter: $q</br>" if ($q); |
|
78 |
$cont .= "Files date limit: $from_f - $to_f</br>" if ($from_f && $to_f); |
my $q = $In{'search_filename'}; |
79 |
$cont .= "Backup date limit: $from_b - $to_b</br>" if ($from_b && $to_b); |
|
80 |
$cont .= "</small>"; |
# DEBUG |
81 |
|
#$html .= "<small>"; |
82 |
my $grid = BackupPC::SearchLib::displayGrid( $where, 1, $In{'offset'}, $q); |
#$html .= "Filename filter: $q</br>" if ($q); |
83 |
$cont .= $grid; |
#$html .= "Files date limit: $from_f - $to_f</br>" if ($from_f || $to_f); |
84 |
} |
#$html .= "Backup date limit: $from_b - $to_b</br>" if ($from_b || $to_b); |
85 |
Header( eval("qq{$Lang->{Search_archive}}"), "", 1, "", $cont ); |
#$html .= "</small>"; |
86 |
Trailer(); |
|
87 |
|
$html .= BackupPC::SearchLib::displayGrid( $where, 1, $In{'offset'}, $q); |
88 |
|
} |
89 |
|
|
90 |
|
Header( eval("qq{$Lang->{Search_archive}}"), "", 1, "", $html ); |
91 |
|
Trailer(); |
92 |
} |
} |
93 |
|
|
94 |
1; |
1; |