show search archive and burn media CGI interface
[BackupPC.git] / lib / BackupPC / CGI / SearchArchives.pm
1 ####################################################################
2 #  SearchArchives.pm - module for searching through archived files #
3 #                      via a sqlite database                       #
4 ####################################################################
5 package BackupPC::CGI::SearchArchives;
6
7
8 use strict;
9 use BackupPC::CGI::Lib qw(:all);
10 use BackupPC::SearchLib;
11 use Data::Dumper;
12 use HTML::FillInForm;
13 use vars qw($Cgi %In $MyURL $User %Conf $TopDir $BinDir $bpc);
14
15 sub action() {
16         my $hosts_html = "";
17
18     
19         BackupPC::CGI::Lib::NewRequest();
20         my @hosts = BackupPC::SearchLib::getUnits();
21
22         foreach my $host (@hosts) {
23                 $hosts_html .= "<option value=" . $host->{'id'} . "> " . $host->{'share'} . " </option>\n";
24         }
25
26         sub date_from_to_html {
27                 my $name = shift || return;
28                 return qq{
29                         <input type="text" name="${name}_year_from" size="4">
30                         <input type="text" name="${name}_month_from" size="2">
31                         <input type="text" name="${name}_day_from" size="2">
32                         -
33                         <input type="text" name="${name}_year_to" size="4">
34                         <input type="text" name="${name}_month_to" size="2">
35                         <input type="text" name="${name}_day_to" size="2">
36                 };
37         }
38
39         my $form .= qq{
40 <form name="searchForm" method="GET" action="$MyURL">
41 <p>
42         Filename:
43         <input type="text" name="search_filename" size="50">
44         &nbsp;
45         on share
46         &nbsp;
47         <select name="search_share">$hosts_html</select>
48         &nbsp;show&nbsp;
49         <select name="burned">
50         <option value="">all</a>
51         <option value="burned">burned</a>
52         <option value="pending">pending</a>
53         </select>
54         files
55         &nbsp;&nbsp;&nbsp;
56         <input type="submit" value="Search">
57 </p>
58
59 <p style="color:gray;">
60         file(s) between:
61         } . date_from_to_html('search') . qq{
62         &nbsp;&nbsp;
63         backups between:
64         } . date_from_to_html('search_backup') . qq{
65         (yyyy-mm-dd)
66 </p>
67
68 <p style="color: gray;">
69         <input type="checkbox" name="use_hest"> use faster full-text search engine
70 </p>
71
72 <input type="hidden" value="search" name="action">
73 <input type="hidden" value="results" name="search_results">
74 </form>
75         };
76
77         my $html = eval(q{ ${h1("Search")}});
78
79         if ( !defined($In{search_results}) ) {
80                 $html .= eval(q{ ${h2("Search criteria")}});
81
82                 $html .= $form;
83         } else {
84                 $html .= eval(q{ ${h2("Search results")}});
85
86                 my $fif = new HTML::FillInForm;
87                 $html .= $fif->fill(scalarref => \$form, fdat => \%In);
88
89                 $html .= BackupPC::SearchLib::displayGrid( \%In );
90         }
91
92         Header( eval("qq{$Lang->{Search_archive}}"), "", 1, "", $html );
93         Trailer();
94 }
95
96 1;