adapted how the individual overview is instantiated
[sgn.git] / cgi-bin / insitu / search.pl
blobca5b5ffa6caa7add593f6048240edb1740d682ef
2 use strict;
3 use CXGN::DB::Connection;
4 use CXGN::Page;
5 use CXGN::Page::FormattingHelpers qw / page_title_html info_section_html columnar_table_html /;
6 use CXGN::Insitu::Toolbar;
7 use CXGN::Insitu::Experiment;
8 use CXGN::Insitu::ExperimentSearch;
9 use CXGN::People;
10 use CXGN::People::Person;
12 my $page = CXGN::Page->new();
13 my $dbh = CXGN::DB::Connection->new();
14 $page->header();
16 print page_title_html( qq{ <a href="/insitu/">Insitu</a> Database } );
18 display_toolbar("search");
20 my $exp_search = CXGN::Insitu::ExperimentSearch->new();
21 my $exp_query = $exp_search->new_query();
23 $exp_query->debug(1);
25 $exp_search->page_size(10);
27 my %params = $page->get_all_encoded_arguments();
29 $exp_query->from_request(\%params);
31 my $result = "";
32 my @results =();
34 my $total_results=0;
35 my $page_html = "";
36 if (%params) {
37 $result = $exp_search->do_search($exp_query);
38 $total_results=$result->total_results();
39 if ($total_results <= 0 ) {
40 print "<b>No results</b>\n";
42 else {
44 while (my $r = $result->next_result()) {
45 #push @results, [ $r->[0], $r->[1], $r->[2], $r->[3], $r->[4], $r->[5], $r->[6], $r->[7], $r->[8], $r->[9] ];
46 my $experiment_id = $r->[0];
47 my $experiment = CXGN::Insitu::Experiment->new($dbh, $experiment_id);
48 my $experiment_name = $experiment->get_name();
49 my $tissue = $experiment->get_tissue();
50 my $stage = $experiment->get_stage();
51 my $experiment_image_count = $experiment->get_images();
52 my $submitter = CXGN::People::Person->new($dbh, $experiment->get_user_id());
53 my $submitter_name = $submitter->get_first_name()." ".$submitter->get_last_name();
54 push @results, [ qq { <a href="/insitu/detail/experiment.pl?experiment_id=$experiment_id&amp;action=view">$experiment_name</a> }, $stage, $tissue, $experiment_image_count, $submitter_name ];
57 $page_html = $exp_search->pagination_buttons_html($exp_query, $result);
60 my $html = "";
64 $html .= columnar_table_html( headings => [ 'Experiment', 'Stage', 'Tissue', '# images', 'Submitter' ],
65 data => \@results
67 print info_section_html( title=>"Insitu Search Results", subtitle=>"$total_results"." Results" , empty_message=>"No results" , contents=>$html.$page_html);
69 print info_section_html( title=>"Search again", contents=>"<form action=\"#\">".$exp_query->to_html()."</form><br />" );
71 $page->footer();