package SGN::View::Mason::Commands;
use strict;
use vars qw($m $c);
HTML::Mason::Component::FileBased->new(
'code' => sub {
use utf8; local $SGN::View::Mason::Commands::m = $HTML::Mason::Commands::m;
HTML::Mason::Exception::Params->throw
    ( error =>
      "Odd number of parameters passed to component expecting name/value pairs"
    ) if @_ % 2;
my ( $trial_id, $trial_name, $breeding_program_name, $location_name, $user_name, $year, $trial_type, $planting_date, $harvest_date, $trial_description, $has_plant_entries, $folder_id, $design_name, $phenotypes_fully_uploaded, $user_can_modify );
{
    my %pos;
    for ( my $x = 0; $x < @_; $x += 2 )
    {
        $pos{ $_[$x] } = $x + 1;
    }

    foreach my $arg ( qw( trial_id trial_name breeding_program_name location_name user_name ) )
    {
        HTML::Mason::Exception::Params->throw
            ( error => "no value sent for required parameter '$arg'" )
                unless exists $pos{$arg};
    }
#line 2 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
    $trial_id = $_[ $pos{'trial_id'} ];
#line 3 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
    $trial_name = $_[ $pos{'trial_name'} ];
#line 4 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
    $breeding_program_name = $_[ $pos{'breeding_program_name'} ];
#line 5 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
    $location_name = $_[ $pos{'location_name'} ];
#line 6 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
    $user_name = $_[ $pos{'user_name'} ];
#line 7 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
     $year = exists $pos{'year'} ? $_[ $pos{'year'} ] :  undef;
#line 8 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
     $trial_type = exists $pos{'trial_type'} ? $_[ $pos{'trial_type'} ] :  undef;
#line 9 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
     $planting_date = exists $pos{'planting_date'} ? $_[ $pos{'planting_date'} ] :  undef;
#line 10 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
     $harvest_date = exists $pos{'harvest_date'} ? $_[ $pos{'harvest_date'} ] :  undef;
#line 11 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
     $trial_description = exists $pos{'trial_description'} ? $_[ $pos{'trial_description'} ] :  undef;
#line 12 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
     $has_plant_entries = exists $pos{'has_plant_entries'} ? $_[ $pos{'has_plant_entries'} ] :  undef;
#line 13 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
     $folder_id = exists $pos{'folder_id'} ? $_[ $pos{'folder_id'} ] :  undef;
#line 14 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
     $design_name = exists $pos{'design_name'} ? $_[ $pos{'design_name'} ] :  undef;
#line 15 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
     $phenotypes_fully_uploaded = exists $pos{'phenotypes_fully_uploaded'} ? $_[ $pos{'phenotypes_fully_uploaded'} ] :  undef;
#line 16 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
     $user_can_modify = exists $pos{'user_can_modify'} ? $_[ $pos{'user_can_modify'} ] :  undef;
}
$m->debug_hook( $m->current_comp->path ) if ( HTML::Mason::Compiler::IN_PERL_DB() );

#line 18 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
$m->print( '
' );
#line 19 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
$m->comp(   '/util/import_javascript.mas', classes => ['jquery','jquery.dataTables']   
); #line 19 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
$m->print( '
' );
#line 20 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
$m->comp(   '/util/import_css.mas', paths => ['/documents/inc/datatables/jquery.dataTables.css']   
); #line 20 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
$m->print( '

' );
#line 22 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
  if ($user_can_modify) {
$m->print( '<button class="btn btn-sm btn-primary" style="margin:3px" id="update_trial_status_link">Update Trial Status</button>
<br/><br/>
' );
#line 25 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
 }
$m->print( '

' );
#line 28 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
$m->comp( { content => sub {
#line 28 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
$m->print( '
    <div class = "well well-sm">
        <div class = "panel panel-default">
            <div class = "panel-body">
                <table id = "trial_activities_table" class="table table-hover table-striped">
                    <thead>
                        <tr>
                            <th>Status Type</th>
                            <th>Date</th>
                            <th>Updated by</th>
                        </tr>
                    </thead>
                </table>
            </div>
        </div>
    </div>
' );
#line 44 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
} }, '/page/info_section.mas', title => "Trial Activities", collapsible=>1, collapsed=>0
 );
#line 44 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
$m->print( '

<div class="panel-body">

' );
#line 48 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
$m->comp( { content => sub {
#line 48 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
$m->print( '
' );
#line 49 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
  if ($design_name) {
$m->print( '            <p class="text-success" title="This trial has a design type saved. You can view and download this information in the Design section on this page."><small>Has Field Design&nbsp;&nbsp;</small><span class="glyphicon glyphicon-ok-sign"></span></p>
' );
#line 51 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
  } else {
$m->print( '            <p class="text-danger" title="This trial does not have a design type saved! If this happens please contact us because this should not happen!"><small>No Field Design&nbsp;&nbsp;</small><span class="glyphicon glyphicon-remove-sign"></span></p>
' );
#line 53 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
  }
$m->print( '
            <div id="trial_completion_layout_section_div">
                <div class="well well-sm">LOADING...</div>
            </div>

' );
#line 59 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
  if ($has_plant_entries) {
$m->print( '            <p class="text-success" title="This trial has plot and plant entries saved. This means that phenotypes can be recorded on the plot and plant level."><small>Has Plots<br/>And Plants&nbsp;&nbsp;</small><span class="glyphicon glyphicon-ok-sign"></span></p>
' );
#line 61 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
  } else {
$m->print( '            <p class="text-info" title="This trial has plot entries saved, but no plant entries. Plant entries are needed for plant level phenotyping. You can create plant entries in Design->Plant Entries section on this page."><small>Has Plots<br/>No Plants&nbsp;&nbsp;</small><span class="glyphicon glyphicon-info-sign"></span></p>
' );
#line 63 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
  }
} }, '/page/info_section.mas', id=>"trial_completion_layout_section", title=>"Field Design", collapsible=>1, collapsed=>1
 );
#line 64 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
$m->print( '

' );
#line 66 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
$m->comp( { content => sub {
#line 66 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
$m->print( '

            <div id="trial_completion_phenotype_section_div">
                <div class="well well-sm">LOADING...</div>
            </div>
<!--
' );
#line 72 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
  if ($phenotypes_fully_uploaded) {
$m->print( '            <p class="text-success" title="All recorded phenotypes for this trial are saved in the database. You can change this by clicking [Phenotypes Fully Uploaded?] in the Files section on this page."><small>Phenotyping<br/>Complete&nbsp;&nbsp;</small><span class="glyphicon glyphicon-ok-sign"></span></p>
' );
#line 74 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
  } else {
$m->print( '            <p class="text-info" title="Once phenotypes are fully uploaded for a trial, you can click [Phenotypes Fully Uploaded?] in the Files section on this page."><small>Phenotyping<br/>Incomplete&nbsp;&nbsp;</small><span class="glyphicon glyphicon-info-sign"></span></p>
' );
#line 76 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
  }
$m->print( '-->
' );
#line 78 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
} }, '/page/info_section.mas', id=>"trial_completion_phenotype_section", title=>"Phenotyping", collapsible=>1, collapsed=>1
 );
#line 78 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
$m->print( '

</div>

' );
#line 82 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
$m->comp(   '/breeders_toolbox/trial/update_trial_status_dialog.mas', trial_id => $trial_id, trial_name => $trial_name, user_name => $user_name   
); #line 82 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
$m->print( '

<script defer="defer">

jQuery(document).ready(function () {

    jQuery(\'#trial_activities_table\').DataTable({
        \'autoWidth\': false,
        \'searching\': false,
        \'info\': false,
        \'paging\': false,
        \'order\': false,
        \'ajax\':\'/ajax/breeders/trial/\'+ ' );
#line 94 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
$m->print(  $trial_id  );
#line 94 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
$m->print( ' + \'/all_trial_activities\',
    });

    jQuery(\'#trial_completion_layout_section_onswitch\').click( function() {
        jQuery.ajax ( {
            url : \'/ajax/breeders/trial/\'+ ' );
#line 99 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
$m->print(  $trial_id  );
#line 99 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
$m->print( ' + \'/trial_completion_layout_section\',
            success: function(response){
                var html = \'\';
                if (response.has_layout == 1){
                    html += \'<p class="text-success" title="This trial has plots and their layout information saved in the database. All relationships between accessions, plots, seedlots, plants, and subplots are consistent. You can view and download this information in the Design section on this page."><small>Has Field Layout&nbsp;&nbsp;</small><span class="glyphicon glyphicon-ok-sign"></span></p>\';
                } else {
                    html += \'<p class="text-danger" title="There is something wrong with the layout! If this occurs please contact us because this should not occur! (click here for more info)"><span id="layout_error_button"><small>Bad Field Layout&nbsp;&nbsp;</small><span class="glyphicon glyphicon-remove-sign"></span></span></p>\';
                }
                if (response.has_physical_map == 1){
                    html += \'<p class="text-success" title="This trial has a physical map saved. You can view and edit the physical map in the Physical Trial Layout section on this page."><small>Has Physial Map&nbsp;&nbsp;</small><span class="glyphicon glyphicon-ok-sign"></span></p>\';
                } else {
                    html += \'<p class="text-info" title="This trial does not have physical map information. This means the map will not appear in the Physical Trial Layout section. You can add physical map info by clicking [Upload Trial Coordinates] in the Physical Trial Layout section on this page. (click here for more info)"><span id="physical_map_error_button"><small>No Physical Map&nbsp;&nbsp;</small><span class="glyphicon glyphicon-info-sign"></span></span></p>\';
                }
                if (response.has_seedlots == 1){
                    html += \'<p class="text-success" title="This trial has seedlots linked to plots (and the accessions are in sync). This allows us to track breeding material on the seedlots detail page. You can view this data and navigate to the seedlots on the Design section of this page."><small>Has Seedlots&nbsp;&nbsp;</small><span class="glyphicon glyphicon-ok-sign"></span></p>\';
                } else {
                    html += \'<p class="text-info" title="This trial does not have seedlots saved. This means we cannot track your breeding material using seedlots. You can upload this information by clicking [Upload Seedlots Planted in Trial] in the Design section on this page. (click here for more info)"><span id="seedlot_error_button"><small>No Seedlot Info&nbsp;&nbsp;</small><span class="glyphicon glyphicon-info-sign"></span></span></p>\';
                }
                jQuery(document).on(\'click\', \'span[id="layout_error_button"]\', function(){
                    alert(response.layout_errors);
                });
                jQuery(document).on(\'click\', \'span[id="physical_map_error_button"]\', function(){
                    alert(response.physical_map_errors);
                });
                jQuery(document).on(\'click\', \'span[id="seedlot_error_button"]\', function(){
                    alert(response.seedlot_errors);
                });
                jQuery(\'#trial_completion_layout_section_div\').html(html);
            },
            error: function(response){
                alert(\'Error retrieving trial completion layout section\');
            }
        });
    });

    jQuery(\'#trial_completion_phenotype_section_onswitch\').click( function() {
        jQuery.ajax ( {
            url : \'/ajax/breeders/trial/\'+ ' );
#line 136 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
$m->print(  $trial_id  );
#line 136 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_status.mas"
$m->print( ' + \'/trial_completion_phenotype_section\',
            success: function(response){
                var html = \'\';
                if (response.has_phenotypes == 1){
                    html = \'<p class="text-success" title="This trial has phenotypes saved. You can view and download this data in the Traits Assayed section on this page."><small>Has Phenotypes&nbsp;&nbsp;</small><span class="glyphicon glyphicon-ok-sign"></span></p>\';
                } else {
                    html = \'<p class="text-info" title="This trial does not have any phenotypes stored. You can upload phenotypes in the Files section on this page."><small>No Phenotypes&nbsp;&nbsp;</small><span class="glyphicon glyphicon-info-sign"></span></p>\';
                }
                jQuery(\'#trial_completion_phenotype_section_div\').html(html);
            },
            error: function(response){
                alert(\'Error retrieving trial completion phenotype section\');
            }
        });
    });

});

</script>
' );
;return;
},
'declared_args' => {
  '$breeding_program_name' => { default => undef },
  '$design_name' => { default => ' undef' },
  '$folder_id' => { default => ' undef' },
  '$harvest_date' => { default => ' undef' },
  '$has_plant_entries' => { default => ' undef' },
  '$location_name' => { default => undef },
  '$phenotypes_fully_uploaded' => { default => ' undef' },
  '$planting_date' => { default => ' undef' },
  '$trial_description' => { default => ' undef' },
  '$trial_id' => { default => undef },
  '$trial_name' => { default => undef },
  '$trial_type' => { default => ' undef' },
  '$user_can_modify' => { default => ' undef' },
  '$user_name' => { default => undef },
  '$year' => { default => ' undef' }
},
'load_time' => 1763102299,

)
;