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 );
{
    my %pos;
    for ( my $x = 0; $x < @_; $x += 2 )
    {
        $pos{ $_[$x] } = $x + 1;
    }

    foreach my $arg ( qw( trial_id ) )
    {
        HTML::Mason::Exception::Params->throw
            ( error => "no value sent for required parameter '$arg'" )
                unless exists $pos{$arg};
    }
#line 3 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
    $trial_id = $_[ $pos{'trial_id'} ];
#line 4 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
     $trial_name = exists $pos{'trial_name'} ? $_[ $pos{'trial_name'} ] :  undef;
}
$m->debug_hook( $m->current_comp->path ) if ( HTML::Mason::Compiler::IN_PERL_DB() );

#line 1 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print( '
' );
#line 6 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print( '
<div class="modal fade" id="add_subplots_dialog" name="add_subplots_dialog" tabindex="-1" role="dialog" aria-labelledby="addSubplotsDialog">
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="addSubplotsDialog">Add subplots to ' );
#line 12 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print(  $trial_name  );
#line 12 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print( '</h4>
      </div>
      <div class="modal-body">
        <div class="container-fluid">

	       <form class="form-horizontal" role="form" method="post" id="add_subplots_dialog_form" name="add_subplots_dialog_form">
	        <div class="form-group">
      	      <label class="col-sm-3 control-label">Maximum number of subplots per plot: </label>
      	      <div class="col-sm-9" >
                <input name="add_subplots_per_plot_num" id="add_subplots_per_plot_num" class="form-control" type="number" autofocus/>
              </div>
	        </div>
            <div class="form-group">
      	      <label class="col-sm-3 control-label">Inherits Treatment(s) From Plots: </label>
      	      <div class="col-sm-9" >
                <input name="add_subplots_per_plot_inherit_treatments" id="add_subplots_per_plot_inherit_treatments" type="checkbox" checked disabled/>
              </div>
	        </div>
	       </form><br/>

        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" name="add_subplots_cancel_button" id="add_subplots_cancel_button" data-dismiss="modal">Close</button>
	      <button type="button" class="btn btn-primary" name="add_subplots_save_button" id="add_subplots_save_button" title="Save">Save</button>
      </div>
    </div>
  </div>
</div>

<div class="modal fade" id="upload_subplots_dialog" name="upload_subplots_dialog" tabindex="-1" role="dialog" aria-labelledby="uploadSubplotsDialog">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="uploadSubplotsDialog">Upload subplots to ' );
#line 47 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print(  $trial_name  );
#line 47 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print( '</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">

                    ' );
#line 52 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->comp( { content => sub {
#line 52 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print( '
                        <p>
                            <b>File format information</b>
                            <br>
                            <a id="trial_upload_subplots_spreadsheet_info_format">Spreadsheet format</a>
                        </p>
                    ' );
#line 58 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
} }, '/page/explanation.mas', title=>'Template information'
 );
#line 58 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print( '

                    <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" encoding="multipart/form-data" id="upload_subplots_dialog_form" name="upload_subplots_dialog_form">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">Upload File (.xls or .xlsx): </label>
                            <div class="col-sm-8" >
                                <input type="file" name="trial_upload_subplots_file" id="trial_upload_subplots_file" encoding="multipart/form-data" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">Maximum number of subplots per plot: </label>
                            <div class="col-sm-8" >
                                <input name="upload_subplots_per_plot_number" id="upload_subplots_per_plot_number" class="form-control" type="number" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">Inherits Treatment(s) From Plots: </label>
                            <div class="col-sm-8" >
                                <input name="upload_subplots_per_plot_inherit_treatments" id="upload_subplots_per_plot_inherit_treatments" type="checkbox" checked disabled/>
                            </div>
                        </div>
                    </form><br/>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" name="upload_subplots_cancel_button" id="upload_subplots_cancel_button" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary" name="upload_subplots_save_button" id="upload_subplots_save_button" title="Upload">Upload</button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="upload_subplots_spreadsheet_info_dialog" name="upload_subplots_spreadsheet_info_dialog" tabindex="-1" role="dialog" aria-labelledby="uploadSubplotsInfoDialog">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header" style="text-align: center">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="uploadSubplotsInfoDialog">Upload Template Information</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">
                    <b>This is for recording individual subplots in a plot.</b>
                    <br/>
                    <b>Subplot names may be uploaded in an Excel file (.xls or .xlsx)</b>
                    <br />
                    <b>Header:</b>
                    <br>
                    The first row (header) should contain the following:
                    <br />

                    <table class="table table-hover table-bordered table-condensed" >
                        <thead></thead>
                        <tbody>
                            <tr>
                                <td>plot_name</td>
                                <td>subplot_name</td>
                            </tr>
                        </tbody>
                    </table>

                    <b>Required fields:</b>
                    <br/>
                    plot_name (must exist in the database already)
                    <br />
                    subplot_name (must be globally unique. usually this is a concatenation of plot_name + subplot_number, such as MyTrial_plot101_subplot1)
                </div>
            </div>
            <div class="modal-footer">
                <button id="close_upload_subplot_info_dialog" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="upload_subplots_with_index_number_dialog" name="upload_subplots_with_index_number_dialog" tabindex="-1" role="dialog" aria-labelledby="uploadSubplotsWithIndexNumberDialog">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="uploadSubplotsWithIndexNumberDialog">Upload subplots to ' );
#line 137 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print(  $trial_name  );
#line 137 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print( ' with subplot index number</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">

                    ' );
#line 142 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->comp( { content => sub {
#line 142 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print( '
                        <p>
                            <b>File format information</b>
                            <br>
                            <a id="trial_upload_subplots_with_index_number_spreadsheet_info_format">Spreadsheet format</a>
                        </p>
                    ' );
#line 148 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
} }, '/page/explanation.mas', title=>'Template information'
 );
#line 148 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print( '

                    <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" encoding="multipart/form-data" id="upload_subplots_with_index_number_dialog_form" name="upload_subplots_with_index_number_dialog_form">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">Upload File (.xls or .xlsx): </label>
                            <div class="col-sm-8" >
                                <input type="file" name="trial_upload_subplots_with_index_number_file" id="trial_upload_subplots_with_index_number_file" encoding="multipart/form-data" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">Maximum number of subplots per plot: </label>
                            <div class="col-sm-8" >
                                <input name="upload_subplots_with_index_number_per_plot_number" id="upload_subplots_with_index_number_per_plot_number" class="form-control" type="number" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">Inherits Treatment(s) From Plots: </label>
                            <div class="col-sm-8" >
                                <input name="upload_subplots_with_index_number_inherit_treatments" id="upload_subplots_with_index_number_inherit_treatments" type="checkbox" checked disabled/>
                            </div>
                        </div>
                    </form><br/>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" name="upload_subplots_with_index_number_cancel_button" id="upload_subplots_with_index_number_cancel_button" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary" name="upload_subplots_with_index_number_save_button" id="upload_subplots_with_index_number_save_button" title="Upload">Upload</button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="upload_subplots_with_index_number_spreadsheet_info_dialog" name="upload_subplots_with_index_number_spreadsheet_info_dialog" tabindex="-1" role="dialog" aria-labelledby="uploadSubplotsWithIndexNumberInfoDialog">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header" style="text-align: center">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="uploadSubplotsWithIndexNumberInfoDialog">Upload Template Information</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">
                    <b>This is for recording individual subplots in a plot. The subplot name will be saved as a concatenation of plot_name + _ + subplot_index_number</b>
                    <br/>
                    <b>May be uploaded in an Excel file (.xls or .xlsx)</b>
                    <br />
                    <b>Header:</b>
                    <br>
                    The first row (header) should contain the following:
                    <br />

                    <table class="table table-hover table-bordered table-condensed" >
                        <thead></thead>
                        <tbody>
                            <tr>
                                <td>plot_name</td>
                                <td>subplot_index_number</td>
                            </tr>
                        </tbody>
                    </table>

                    <b>Required fields:</b>
                    <br/>
                    plot_name (must exist in the database already)
                    <br />
                    subplot_index_number (must be a number. the saved subplot name will be a concatenation of plot_name + subplot_index_number, such as MyTrial_plot101_subplot1.)
                </div>
            </div>
            <div class="modal-footer">
                <button id="close_upload_subplots_with_index_number_info_dialog" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="upload_subplots_with_number_of_subplots_number_dialog" name="upload_subplots_with_number_of_subplots_number_dialog" tabindex="-1" role="dialog" aria-labelledby="uploadSubplotsWithNumSubplotsPerPlotDialog">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="uploadSubplotsWithNumSubplotsPerPlotDialog">Upload subplots to ' );
#line 227 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print(  $trial_name  );
#line 227 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print( ' with number of subplots per plot</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">

                    ' );
#line 232 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->comp( { content => sub {
#line 232 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print( '
                        <p>
                            <b>File format information</b>
                            <br>
                            <a id="trial_upload_subplots_with_num_subplots_spreadsheet_info_format">Spreadsheet format</a>
                        </p>
                    ' );
#line 238 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
} }, '/page/explanation.mas', title=>'Template information'
 );
#line 238 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print( '

                    <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" encoding="multipart/form-data" id="upload_subplots_with_num_subplots_dialog_form" name="upload_subplots_with_num_subplots_dialog_form">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">Upload File (.xls or .xlsx): </label>
                            <div class="col-sm-8" >
                                <input type="file" name="trial_upload_subplots_with_number_of_subplots_file" id="trial_upload_subplots_with_number_of_subplots_file" encoding="multipart/form-data" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">Maximum number of subplots per plot: </label>
                            <div class="col-sm-8" >
                                <input name="upload_subplots_with_num_subplots_per_plot_number" id="upload_subplots_with_num_subplots_per_plot_number" class="form-control" type="number" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">Inherits Treatment(s) From Plots: </label>
                            <div class="col-sm-8" >
                                <input name="upload_subplots_with_num_subplots_inherit_treatments" id="upload_subplots_with_num_subplots_inherit_treatments" type="checkbox" checked disabled/>
                            </div>
                        </div>
                    </form><br/>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" name="upload_subplots_with_num_subplots_cancel_button" id="upload_subplots_with_num_subplots_cancel_button" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary" name="upload_subplots_with_num_subplots_save_button" id="upload_subplots_with_num_subplots_save_button" title="Upload">Upload</button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="upload_subplots_with_num_subplots_spreadsheet_info_dialog" name="upload_subplots_with_num_subplots_spreadsheet_info_dialog" tabindex="-1" role="dialog" aria-labelledby="uploadSubplotsWithNumSubplotsInfoDialog">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header" style="text-align: center">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="uploadSubplotsWithNumSubplotsInfoDialog">Upload Template Information</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">
                    <b>This is for recording individual subplots in a plot. The subplot name will be saved as a concatenation of plot_name + _ + subplot_index_number for as many subplots as specfied by num_subplots_per_plot</b>
                    <br/>
                    <b>May be uploaded in an Excel file (.xls or .xlsx)</b>
                    <br />
                    <b>Header:</b>
                    <br>
                    The first row (header) should contain the following:
                    <br />

                    <table class="table table-hover table-bordered table-condensed" >
                        <thead></thead>
                        <tbody>
                            <tr>
                                <td>plot_name</td>
                                <td>num_subplots_per_plot</td>
                            </tr>
                        </tbody>
                    </table>

                    <b>Required fields:</b>
                    <br/>
                    plot_name (must exist in the database already)
                    <br />
                    num_subplots_per_plot (must be a number. the number of subplots in the plot. the saved subplot name will be a concatenation of plot_name + subplot_number, such as MyTrial_plot101_subplot1)
                </div>
            </div>
            <div class="modal-footer">
                <button id="close_upload_subplots_with_number_subplots_info_dialog" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>


<script>

jQuery(document).ready(function() {

    jQuery(\'#create_subplot_entries_button\').click( function () {
        jQuery(\'#add_subplots_dialog\').modal("show");
    });

    jQuery(\'#upload_subplot_entries_button\').click( function () {
        jQuery(\'#upload_subplots_dialog\').modal("show");
    });

    jQuery(\'#trial_upload_subplots_spreadsheet_info_format\').click( function () {
        jQuery(\'#upload_subplots_spreadsheet_info_dialog\').modal("show");
    });

    jQuery(\'#upload_subplot_entries_with_index_number_button\').click( function () {
        jQuery(\'#upload_subplots_with_index_number_dialog\').modal("show");
    });

    jQuery(\'#trial_upload_subplots_with_index_number_spreadsheet_info_format\').click( function () {
        jQuery(\'#upload_subplots_with_index_number_spreadsheet_info_dialog\').modal("show");
    });

    jQuery(\'#trial_upload_subplots_with_num_subplots_button\').click( function () {
        jQuery(\'#upload_subplots_with_number_of_subplots_number_dialog\').modal("show");
    });

    jQuery(\'#trial_upload_subplots_with_num_subplots_spreadsheet_info_format\').click( function () {
        jQuery(\'#upload_subplots_with_num_subplots_spreadsheet_info_dialog\').modal("show");
    });


    jQuery(\'#add_subplots_save_button\').click( function () {
        add_subplots_to_trial();
    });

    jQuery(\'#upload_subplots_save_button\').click( function () {
        upload_subplots_to_trial();
    });

    jQuery(\'#upload_subplots_with_index_number_save_button\').click( function () {
        upload_subplots_with_index_number_to_trial();
    });

    jQuery(\'#upload_subplots_with_num_subplots_save_button\').click( function () {
        upload_subplots_with_num_subplots_to_trial();
    });


    function add_subplots_to_trial() {

        var is_checked;
        if(jQuery(\'#add_subplots_per_plot_inherit_treatments\').is(":checked")){
            is_checked = 1;
        }

        jQuery.ajax( {
            url: \'/ajax/breeders/trial/\'+' );
#line 371 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print(  $trial_id  );
#line 371 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print( '+\'/create_subplot_entries/\',
            type: \'POST\',
            beforeSend: function() {
                jQuery("#working_modal").modal("show");
            },
            data: {
                \'subplots_per_plot\' : jQuery(\'#add_subplots_per_plot_num\').val(),
                \'inherits_plot_treatments\' : is_checked
            },
            success: function(response) {
                jQuery("#working_modal").modal("hide");
                if (response.error) {
                    alert(response.error);
                }
                else {
                    alert("Successfully created subplot entries.");
                    jQuery(\'#add_subplots_dialog\').modal("hide");
                    window.location.replace(\'/breeders/trial/\'+' );
#line 388 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print(  $trial_id  );
#line 388 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print( ');
                }
            },
            error: function(response) {
                jQuery("#working_modal").modal("hide");
                alert("An error occurred saving subplot entries");
            },
        });

    }


    function upload_subplots_to_trial() {
        var uploadFile = jQuery("#trial_upload_subplots_file").val();
        jQuery(\'#upload_subplots_dialog_form\').attr("action", "/ajax/breeders/trial/' );
#line 402 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print(  $trial_id  );
#line 402 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print( '/upload_subplots");
        if (uploadFile === \'\') {
            alert("Please select a file");
            return;
        }
        jQuery("#upload_subplots_dialog_form").submit();
    }

    jQuery(\'#upload_subplots_dialog_form\').iframePostForm({
        json: true,
        post: function () {
            var uploadedSubplotsFile = jQuery("#trial_upload_subplots_file").val();
            jQuery(\'#working_modal\').modal("show");
            if (uploadedSubplotsFile === \'\') {
                jQuery(\'#working_modal\').modal("hide");
                alert("No file selected");
            }
        },
        complete: function (response) {
            console.log(response);
            jQuery(\'#working_modal\').modal("hide");

            if (response.error_string) {
                alert(response.error_string);
                return;
            }
            if (response.success) {
                alert("File uploaded successfully");
                window.location.replace(\'/breeders/trial/\'+' );
#line 430 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print(  $trial_id  );
#line 430 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print( ');
            }
        }
    });


    function upload_subplots_with_index_number_to_trial() {
        var uploadFile = jQuery("#trial_upload_subplots_with_index_number_file").val();
        jQuery(\'#upload_subplots_with_index_number_dialog_form\').attr("action", "/ajax/breeders/trial/' );
#line 438 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print(  $trial_id  );
#line 438 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print( '/upload_subplots_with_subplot_index_number");
        if (uploadFile === \'\') {
            alert("Please select a file");
            return;
        }
        jQuery("#upload_subplots_with_index_number_dialog_form").submit();
    }

    jQuery(\'#upload_subplots_with_index_number_dialog_form\').iframePostForm({
        json: true,
        post: function () {
            var uploadedSubplotsFile = jQuery("#trial_upload_subplots_with_index_number_file").val();
            jQuery(\'#working_modal\').modal("show");
            if (uploadedSubplotsFile === \'\') {
                jQuery(\'#working_modal\').modal("hide");
                alert("No file selected");
            }
        },
        complete: function (response) {
            console.log(response);
            jQuery(\'#working_modal\').modal("hide");

            if (response.error_string) {
                alert(response.error_string);
                return;
            }
            if (response.success) {
                alert("File uploaded successfully");
                window.location.replace(\'/breeders/trial/\'+' );
#line 466 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print(  $trial_id  );
#line 466 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print( ');
            }
        }
    });


    function upload_subplots_with_num_subplots_to_trial() {
        var uploadFile = jQuery("#trial_upload_subplots_with_number_of_subplots_file").val();
        jQuery(\'#upload_subplots_with_num_subplots_dialog_form\').attr("action", "/ajax/breeders/trial/' );
#line 474 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print(  $trial_id  );
#line 474 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print( '/upload_subplots_with_number_of_subplots");
        if (uploadFile === \'\') {
            alert("Please select a file");
            return;
        }
        jQuery("#upload_subplots_with_num_subplots_dialog_form").submit();
    }

    jQuery(\'#upload_subplots_with_num_subplots_dialog_form\').iframePostForm({
        json: true,
        post: function () {
            var uploadedSubplotsFile = jQuery("#trial_upload_subplots_with_number_of_subplots_file").val();
            jQuery(\'#working_modal\').modal("show");
            if (uploadedSubplotsFile === \'\') {
                jQuery(\'#working_modal\').modal("hide");
                alert("No file selected");
            }
        },
        complete: function (response) {
            console.log(response);
            jQuery(\'#working_modal\').modal("hide");

            if (response.error_string) {
                alert(response.error_string);
                return;
            }
            if (response.success) {
                alert("File uploaded successfully");
                window.location.replace(\'/breeders/trial/\'+' );
#line 502 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print(  $trial_id  );
#line 502 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_subplots_per_plot.mas"
$m->print( ');
            }
        }
    });



});

</script>
' );
;return;
},
'declared_args' => {
  '$trial_id' => { default => undef },
  '$trial_name' => { default => ' undef' }
},
'load_time' => 1763102299,

)
;