#!/usr/local/bin/perl ############################################################################### # Program : main.cgi # Author : Eric Deutsch # $Id$ # # Description : This script authenticates the user, and then # displays the opening access page. # # SBEAMS is Copyright (C) 2000-2005 Institute for Systems Biology # This program is governed by the terms of the GNU General Public License (GPL) # version 2 as published by the Free Software Foundation. It is provided # WITHOUT ANY WARRANTY. See the full description of GPL terms in the # LICENSE file distributed with this software. # ############################################################################### ############################################################################### # Set up all needed modules and objects ############################################################################### use strict; use Getopt::Long; use FindBin; use File::Basename; use lib "$FindBin::Bin/../../lib/perl"; use vars qw ($sbeams $sbeamsMOD $q $current_contact_id $current_username $PROG_NAME $USAGE %OPTIONS $QUIET $VERBOSE $DEBUG $TESTONLY $TABLE_NAME $PROGRAM_FILE_NAME $CATEGORY $DB_TABLE_NAME @MENU_OPTIONS); use SBEAMS::Connection qw($q $log); use SBEAMS::Connection::Settings; use SBEAMS::Connection::Tables; use SBEAMS::Connection::TabMenu; use SBEAMS::Genotyping; use SBEAMS::Genotyping::Settings; use SBEAMS::Genotyping::Tables; $sbeams = new SBEAMS::Connection; $sbeamsMOD = new SBEAMS::Genotyping; $sbeamsMOD->setSBEAMS($sbeams); # use CGI; #$q = new CGI; ############################################################################### # Set program name and usage banner for command line use ############################################################################### $PROG_NAME = $FindBin::Script; $USAGE = <Authenticate() and exit if it fails or continue if it works. ############################################################################### sub main { #### Do the SBEAMS authentication and exit if a username is not returned exit unless ($current_username = $sbeams->Authenticate( #permitted_work_groups_ref=>['xxx','yyy'], #connect_read_only=>1, #allow_anonymous_access=>1, )); #### Read in the default input parameters my %parameters; my $n_params_found = $sbeams->parse_input_parameters( q=>$q,parameters_ref=>\%parameters); #$sbeams->printDebuggingInfo($q); #### Process generic "state" parameters before we start $sbeams->processStandardParameters(parameters_ref=>\%parameters); #### Decide what action to take based on information so far if (defined($parameters{action}) && $parameters{action} eq "???") { # Some action } else { $sbeamsMOD->display_page_header(); handle_request(ref_parameters=>\%parameters); $sbeamsMOD->display_page_footer(); } } # end main ############################################################################### # Handle Request ############################################################################### sub handle_request { my %args = @_; #### Process the arguments list my $ref_parameters = $args{'ref_parameters'} || die "ref_parameters not passed"; my %parameters = %{$ref_parameters}; #### Print out the current user information $sbeams->printUserContext(); $current_contact_id = $sbeams->getCurrent_contact_id(); #### Write some welcoming text print qq~

You are successfully logged into the $DBTITLE - $SBEAMS_PART system. This module allows users to submit a new request to the Genotyping Facility, or check on the status of an existing request. Please choose your tasks from the menu bar on the left.

This system is still under active development. Please report bugs, problems, difficulties, and suggestions to kdeutsch\@systemsbiology.org.

~; my $html_ref = $sbeams->getMainPageTabMenu( cgi => $q ); print qq~
$$html_ref ~; my $content; my $project_id = $sbeams->getCurrent_project_id(); if ( $project_id ) { my $sql = qq~ SELECT experiment_id FROM $TBGT_EXPERIMENT WHERE project_id = $project_id ~; $content = '

Experiment Information

'; $content .= '[Show summary/Show details/Facility summary]'; my @experiment_rows = $sbeams->selectOneColumn($sql); #### If there are experiments, display the status of each, either in an #### overall summary, or detailed view if (@experiment_rows) { if ($parameters{expt_format} eq "details") { #make summary view $content .= make_detailed_experiment_summary_html(exp_results_set_aref => \@experiment_rows); } elsif ($parameters{expt_format} eq "facility") { #make full facility review $content .= make_facility_summary_html(exp_results_set_aref => \@experiment_rows); } else { #make detailed view $content .= make_experiment_summary_html(exp_results_set_aref => \@experiment_rows); } } else { if ($project_id == -99) { $content .= qq~ You do not have access to this project. Contact the owner of this project if you want to have access.\n ~; } else { $content .= qq~ No genotyping experiments registered in this project. \n~; } } } #### Finish the table $content .= qq~ ~; print $content; } # end handle_request ############################################################################### # make_experiment_summary_html # # Return a block of html to print a experimental summary ############################################################################### sub make_experiment_summary_html { my %args = @_; my $results_set_array_ref = $args{exp_results_set_aref}; my @rows = @{$results_set_array_ref}; my $content .= qq~ ~; my $experiment_status_counter = 0; foreach my $row (@rows) { my ($experiment_id) = $row; #### Select summary info from experiment_status my $sql = qq~ SELECT E.experiment_tag,E.experiment_description, ESS.experiment_status_state_name, ES.estimated_completion_date FROM $TBGT_EXPERIMENT_STATUS ES INNER JOIN $TBGT_EXPERIMENT E ON ( ES.experiment_id = E.experiment_id ) INNER JOIN $TBGT_EXPERIMENT_STATUS_STATE ESS ON ( ES.experiment_status_state_id = ESS.experiment_status_state_id) WHERE ES.experiment_id = '$experiment_id' AND E.record_status != 'D' ORDER BY E.experiment_tag ~; my @experiment_status_rows = $sbeams->selectSeveralColumns($sql); $experiment_status_counter++; if (($experiment_status_counter % 2) == 1){ $content .= " \n"; }else{ $content .= " \n"; } foreach my $experiment_status_row (@experiment_status_rows) { my ($experiment_tag,$experiment_description,$experiment_status_state_name,$est_completion_date) = @{$experiment_status_row}; $content .= qq~ ~; } $content .= qq~ ~; } return $content; } # end make_experiment_summary_html ############################################################################### # make_detailed_experiment_summary_html # # Return a block of html to print a detailed experimental summary ############################################################################### sub make_detailed_experiment_summary_html { my %args = @_; my $results_set_array_ref = $args{exp_results_set_aref}; my @rows = @{$results_set_array_ref}; my $content .= qq~
Name Description Status Estimated
Completion Date
View/Edit
Record
   $experiment_tag    $experiment_description    $experiment_status_state_name    $est_completion_date [View/Edit]
~; my $experiment_status_counter = 0; foreach my $row (@rows) { my ($experiment_id) = $row; #### Select summary info from experiment_status my $sql = qq~ SELECT E.experiment_tag,E.experiment_description, convert(varchar(10),ES.initial_request_date,121), ESS.experiment_status_state_name, ES.file_formats_approved, convert(varchar(10),ES.DNA_delivery_date,121), ES.DNA_quality_approved, convert(varchar(10),ES.preliminary_checks_completed_date,121), convert(varchar(10),ES.estimated_completion_date,121) FROM $TBGT_EXPERIMENT_STATUS ES INNER JOIN $TBGT_EXPERIMENT E ON ( ES.experiment_id = E.experiment_id ) INNER JOIN $TBGT_EXPERIMENT_STATUS_STATE ESS ON ( ES.experiment_status_state_id = ESS.experiment_status_state_id) WHERE ES.experiment_id = '$experiment_id' AND E.record_status != 'D' ORDER BY E.experiment_tag ~; my @experiment_status_rows = $sbeams->selectSeveralColumns($sql); $experiment_status_counter++; if (($experiment_status_counter % 2) == 1){ $content .= " \n"; }else{ $content .= " \n"; } foreach my $experiment_status_row (@experiment_status_rows) { my ($experiment_tag,$experiment_description,$initial_request_date, $experiment_status_state_name,$file_formats_approved, $dna_delivery_date,$dna_quality_approved, $prechecks_completion_date,$est_completion_date) = @{$experiment_status_row}; $content .= qq~ ~; } $content .= qq~ ~; } return $content; } #end make_detailed_experiment_summary_html ############################################################################### # make_facility_summary_html # # Return a block of html to print a facility summary ############################################################################### sub make_facility_summary_html { my %args = @_; # my $results_set_array_ref = $args{exp_results_set_aref}; # my @rows = @{$results_set_array_ref}; my $content .= qq~
Name Description Status Summary Submission Date Uploaded Files DNA
Delivery
Date
DNA Quality Pre-checks
Completion
Date
Estimated
Completion
Date
View/Edit
Record
$experiment_tag $experiment_description $experiment_status_state_name $initial_request_date $file_formats_approved $dna_delivery_date $dna_quality_approved $prechecks_completion_date $est_completion_date [View/Edit]
~; my $experiment_status_counter = 0; # foreach my $row (@rows) { # my ($experiment_id) = $row; #### Select summary info from experiment_status my $sql = qq~ SELECT E.experiment_tag,E.experiment_description, ESS.experiment_status_state_name, ES.estimated_completion_date FROM $TBGT_EXPERIMENT_STATUS ES INNER JOIN $TBGT_EXPERIMENT E ON ( ES.experiment_id = E.experiment_id ) INNER JOIN $TBGT_EXPERIMENT_STATUS_STATE ESS ON ( ES.experiment_status_state_id = ESS.experiment_status_state_id) WHERE ESS.experiment_status_state_name != 'Complete' AND E.record_status != 'D' ORDER BY ES.estimated_completion_date ~; my @experiment_status_rows = $sbeams->selectSeveralColumns($sql); $experiment_status_counter++; if (($experiment_status_counter % 2) == 1){ $content .= " \n"; }else{ $content .= " \n"; } foreach my $experiment_status_row (@experiment_status_rows) { my ($experiment_tag,$experiment_description,$experiment_status_state_name,$est_completion_date) = @{$experiment_status_row}; $content .= qq~ ~; $content .= qq~ ~; } return $content; } # end make_facility_summary_html
Name Description Status Estimated
Completion Date
   $experiment_tag    $experiment_description    $experiment_status_state_name    $est_completion_date