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_plants_per_subplot.mas"
    $trial_id = $_[ $pos{'trial_id'} ];
#line 4 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_plants_per_subplot.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_plants_per_subplot.mas"
$m->print( '
' );
#line 6 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_plants_per_subplot.mas"
$m->print( '
<div class="modal fade" id="add_plants_subplot_dialog" name="add_plants_subplot_dialog" tabindex="-1" role="dialog" aria-labelledby="addPlantsSubplotDialog">
  <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="addPlantsSubplotDialog">Add plants to ' );
#line 12 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_plants_per_subplot.mas"
$m->print(  $trial_name  );
#line 12 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_plants_per_subplot.mas"
$m->print( ' subplots</h4>
      </div>
      <div class="modal-body">
        <div class="container-fluid">

	       <form class="form-horizontal" role="form" method="post" id="add_plants_subplot_dialog_form" name="add_plants_subplot_dialog_form">
	        <div class="form-group">
      	      <label class="col-sm-3 control-label">Maximum number of plants per subplot: </label>
      	      <div class="col-sm-9" >
                <input name="add_plants_per_subplot_num" id="add_plants_per_subplot_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_plants_per_subplot_inherit_treatments" id="add_plants_per_subplot_inherit_treatments" type="checkbox" checked disabled/>
              </div>
	        </div>
            <div class="form-group">
      	      <label class="col-sm-3 control-label">Assign row and column data to plants within plots?</label>
      	      <div class="col-sm-9" >
                <input name="add_rows_and_columns_to_subplot_plants" id="add_rows_and_columns_to_subplot_plants" type="checkbox"/>
                <div id="subplot_plant_row_column_format_dialog" style="display:none">
                    <p><i>One plant per (row,column) coordinate. Rows and columns will be populated in a zigzag pattern. Row and column numbers start at 1 within each subplot.</i></p>
                    <table style="width:60%">
                        <tr>
                            <td>
                                <label>Number of rows per plot</label>
                            </td>
                            <td>
                                <input name="rows_per_subplot" id="rows_per_subplot" type="number"/>
                            </td>
                        </tr><tr>
                            <td>
                                <label>Number of columns per plot</label>
                            </td>
                            <td>
                                <input name="cols_per_subplot" id="cols_per_subplot" type="number"/>
                            </td>
                        </tr>
                    </table>
                </div>
              </div>
	        </div>
	       </form><br/>

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

<div class="modal fade" id="upload_plants_subplot_dialog" name="upload_plants_subplot_dialog" tabindex="-1" role="dialog" aria-labelledby="uploadPlantsSubplotDialog">
    <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="uploadPlantsSubplotDialog">Upload plants to ' );
#line 73 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_plants_per_subplot.mas"
$m->print(  $trial_name  );
#line 73 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_plants_per_subplot.mas"
$m->print( ' subplots</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">

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

                    <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" encoding="multipart/form-data" id="upload_plants_subplot_dialog_form" name="upload_plants_subplot_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_plants_subplot_file" id="trial_upload_plants_subplot_file" encoding="multipart/form-data" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">Maximum number of plants per subplot: </label>
                            <div class="col-sm-8" >
                                <input name="upload_plants_per_subplot_number" id="upload_plants_per_subplot_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_plants_per_subplot_inherit_treatments" id="upload_plants_per_subplot_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_plants_subplot_cancel_button" id="upload_plants_subplot_cancel_button" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary" name="upload_plants_subplot_save_button" id="upload_plants_subplot_save_button" title="Upload">Upload</button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="upload_plants_subplot_spreadsheet_info_dialog" name="upload_plants_subplot_spreadsheet_info_dialog" tabindex="-1" role="dialog" aria-labelledby="uploadPlantsSubplotInfoDialog">
    <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="uploadPlantsSubplotInfoDialog">Upload Template Information</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">
                    <b>This is for recording individual plants in a subplot.</b>
                    <br/>
                    <b>Plant 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>subplot_name</td>
                                <td>plant_name</td>
                            </tr>
                        </tbody>
                    </table>

                    <b>Required fields:</b>
                    <br/>
                    subplot_name (must exist in the database already)
                    <br />
                    plant_name (must be globally unique. usually this is a concatenation of subplot_name + plant_number, such as MyTrial_plot101_subplot1_plant1)
                    <br>
                    <b>Optional fields:</b>
                    <br>
                    - row_num
                    <br>
                    - col_num
                    <br>
                    Rows and columns are at the subplot level if each subplot contains multiple plants. If including this data, both fields must be present.
                </div>
            </div>
            <div class="modal-footer">
                <button id="close_upload_plants_subplot_info_dialog" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>


<div class="modal fade" id="upload_plants_subplot_with_index_number_dialog" name="upload_plants_subplot_with_index_number_dialog" tabindex="-1" role="dialog" aria-labelledby="uploadPlantsSubplotWithIndexNumberDialog">
    <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="uploadPlantsWithIndexNumberDialog">Upload plants to ' );
#line 172 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_plants_per_subplot.mas"
$m->print(  $trial_name  );
#line 172 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_plants_per_subplot.mas"
$m->print( ' subplots with plant index number</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">

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

                    <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" encoding="multipart/form-data" id="upload_plants_subplot_with_index_number_dialog_form" name="upload_plants_subplot_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_plants_subplot_with_index_number_file" id="trial_upload_plants_subplot_with_index_number_file" encoding="multipart/form-data" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">Maximum number of plants per subplot: </label>
                            <div class="col-sm-8" >
                                <input name="upload_plants_subplot_with_index_number_per_subplot_number" id="upload_plants_subplot_with_index_number_per_subplot_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_plants_subplot_with_index_number_inherit_treatments" id="upload_plants_subplot_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_plants_subplot_with_index_number_cancel_button" id="upload_plants_subplot_with_index_number_cancel_button" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary" name="upload_plants_subplot_with_index_number_save_button" id="upload_plants_subplot_with_index_number_save_button" title="Upload">Upload</button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="upload_plants_subplot_with_index_number_spreadsheet_info_dialog" name="upload_plants_subplot_with_index_number_spreadsheet_info_dialog" tabindex="-1" role="dialog" aria-labelledby="uploadPlantsSubplotWithIndexNumberInfoDialog">
    <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="uploadPlantsSubplotWithIndexNumberInfoDialog">Upload Template Information</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">
                    <b>This is for recording individual plants in a subplot. The plant name will be saved as a concatenation of subplot_name + _ + plant_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>subplot_name</td>
                                <td>plant_index_number</td>
                            </tr>
                        </tbody>
                    </table>

                    <b>Required fields:</b>
                    <br/>
                    subplot_name (must exist in the database already)
                    <br />
                    plant_index_number (must be a number. the saved plant name will be a concatenation of subplot_name + plant_index_number, such as MyTrial_plot101_subplot1_plant1.)
                    <br>
                    <b>Optional fields:</b>
                    <br>
                    - row_num
                    <br>
                    - col_num
                    <br>
                    Rows and columns are at the subplot level if each subplot contains multiple plants. If including this data, both fields must be present.
                </div>
            </div>
            <div class="modal-footer">
                <button id="close_upload_plants_subplot_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_plants_subplot_with_number_of_plants_number_dialog" name="upload_plants_subplot_with_number_of_plants_number_dialog" tabindex="-1" role="dialog" aria-labelledby="uploadPlantsSubplotWithNumPlantsPerPlotDialog">
    <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="uploadPlantsSubplotWithNumPlantsPerPlotDialog">Upload plants to ' );
#line 270 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_plants_per_subplot.mas"
$m->print(  $trial_name  );
#line 270 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_plants_per_subplot.mas"
$m->print( ' subplots with number of plants per subplot</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">

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

                    <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" encoding="multipart/form-data" id="upload_plants_subplot_with_num_plants_dialog_form" name="upload_plants_subplot_with_num_plants_dialog_form">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">Upload File (.xls): </label>
                            <div class="col-sm-8" >
                                <input type="file" name="trial_upload_plants_subplot_with_number_of_plants_file" id="trial_upload_plants_subplot_with_number_of_plants_file" encoding="multipart/form-data" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">Maximum number of plants per subplot: </label>
                            <div class="col-sm-8" >
                                <input name="upload_plants_subplot_with_num_plants_per_subplot_number" id="upload_plants_subplot_with_num_plants_per_subplot_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_plants_subplot_with_num_plants_inherit_treatments" id="upload_plants_subplot_with_num_plants_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_plants_subplot_with_num_plants_cancel_button" id="upload_plants_subplot_with_num_plants_cancel_button" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary" name="upload_plants_subplot_with_num_plants_save_button" id="upload_plants_subplot_with_num_plants_save_button" title="Upload">Upload</button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="upload_plants_subplot_with_num_plants_spreadsheet_info_dialog" name="upload_plants_subplot_with_num_plants_spreadsheet_info_dialog" tabindex="-1" role="dialog" aria-labelledby="uploadPlantsSubplotWithNumPlantsInfoDialog">
    <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="uploadPlantsSubplotWithNumPlantsInfoDialog">Upload Template Information</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">
                    <b>This is for recording individual plants in a subplot. The plant name will be saved as a concatenation of subplot_name + _ + plant_index_number for as many plants as specfied by num_plants_per_subplot</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>subplot_name</td>
                                <td>num_plants_per_subplot</td>
                            </tr>
                        </tbody>
                    </table>

                    <b>Required fields:</b>
                    <br/>
                    subplot_name (must exist in the database already)
                    <br />
                    num_plants_per_subplot (must be a number. the number of plants in the subplot. the saved plant name will be a concatenation of subplot_name + plant_number, such as MyTrial_plot101_subplot1_plant1)
                    <br>
                    <b>Optional fields:</b>
                    <br>
                    - num_rows
                    <br>
                    - num_cols
                    <br>
                    The number of spaces given by the rows and columns should be greater than or equal to the num_plants_per_subplot. Plants will be assigned rows and columns in zigzag pattern, starting from (1,1).
                </div>
            </div>
            <div class="modal-footer">
                <button id="close_upload_plants_subplot_with_number_plants_info_dialog" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>


<script>

jQuery(document).ready(function() {

    jQuery(\'#create_plant_entries_subplots_button\').click( function () {
        jQuery(\'#add_plants_subplot_dialog\').modal("show");
    });

    jQuery(\'#upload_plant_entries_subplots_button\').click( function () {
        jQuery(\'#upload_plants_subplot_dialog\').modal("show");
    });

    jQuery(\'#upload_plant_entries_with_index_number_subplots_button\').click( function () {
        jQuery(\'#upload_plants_subplot_with_index_number_dialog\').modal("show");
    });

    jQuery(\'#trial_upload_plants_with_num_plants_subplots_button\').click( function () {
        jQuery(\'#upload_plants_subplot_with_number_of_plants_number_dialog\').modal("show");
    });



    jQuery(\'#add_plants_subplot_save_button\').click( function () {
        add_plants_subplot_to_trial();
    });


    jQuery(\'#trial_upload_plants_subplot_spreadsheet_info_format\').click( function () {
        jQuery(\'#upload_plants_subplot_spreadsheet_info_dialog\').modal("show");
    });

    jQuery(\'#upload_plants_subplot_save_button\').click( function () {
        upload_plants_subplot_to_trial();
    });


    jQuery(\'#trial_upload_plants_subplot_with_index_number_spreadsheet_info_format\').click( function () {
        jQuery(\'#upload_plants_subplot_with_index_number_spreadsheet_info_dialog\').modal("show");
    });

    jQuery(\'#upload_plants_subplot_with_index_number_save_button\').click( function () {
        upload_plants_subplot_with_index_number_to_trial();
    });


    jQuery(\'#trial_upload_plants_subplot_with_num_plants_spreadsheet_info_format\').click( function () {
        jQuery(\'#upload_plants_subplot_with_num_plants_spreadsheet_info_dialog\').modal("show");
    });

    jQuery(\'#upload_plants_subplot_with_num_plants_save_button\').click( function () {
        upload_plants_subplot_with_num_plants_to_trial();
    });

    jQuery(\'#add_rows_and_columns_to_subplot_plants\').click( function () {
        if (jQuery(\'#add_rows_and_columns_to_subplot_plants\').is(\':checked\')){
            jQuery(\'#subplot_plant_row_column_format_dialog\').show();
        } else {
            jQuery(\'#subplot_plant_row_column_format_dialog\').hide();
        }

    });



    function add_plants_subplot_to_trial() {

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

        var num_rows = jQuery(\'#rows_per_subplot\').val();
        var num_cols = jQuery(\'#cols_per_subplot\').val();
        var plants_per_subplot = jQuery(\'#add_plants_per_subplot_num\').val();
        var include_plant_coordinates = 0;

        if (jQuery(\'#add_rows_and_columns_to_subplot_plants\').is(\':checked\')) {

            include_plant_coordinates = 1;

            if (num_rows == "" || num_cols == "" || num_rows * num_cols == 0) {
                alert("You need to specify the number of rows and columns to give plant coordinates within plots.");
                return;
            }
            if (num_rows * num_cols < plants_per_subplot) {
                alert("Only one plant per (row, column) coordinate is allowed. You must specify fewer plants per plot, or add rows and columns.");
                return;
            }
        }

        jQuery.ajax( {
            url: \'/ajax/breeders/trial/\'+' );
#line 455 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_plants_per_subplot.mas"
$m->print(  $trial_id  );
#line 455 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_plants_per_subplot.mas"
$m->print( '+\'/create_plant_subplot_entries/\',
            type: \'POST\',
            beforeSend: function() {
                jQuery("#working_modal").modal("show");
            },
            data: {
                \'plants_per_subplot\' : plants_per_subplot,
                \'inherits_plot_treatments\' : is_checked,
                \'include_plant_coordinates\' : include_plant_coordinates,
                \'rows_per_plot\' : num_rows,
                \'cols_per_plot\' : num_cols
            },
            success: function(response) {
                jQuery("#working_modal").modal("hide");
                if (response.error) {
                    alert(response.error);
                }
                else {
                    alert("Successfully created plant entries.");
                    jQuery(\'#add_plants_subplot_dialog\').modal("hide");
                    window.location.replace(\'/breeders/trial/\'+' );
#line 475 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_plants_per_subplot.mas"
$m->print(  $trial_id  );
#line 475 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_plants_per_subplot.mas"
$m->print( ');
                }
            },
            error: function(response) {
                jQuery("#working_modal").modal("hide");
                alert("An error occurred saving plant entries");
            },
        });

    }


    function upload_plants_subplot_to_trial() {
        var uploadFile = jQuery("#trial_upload_plants_subplot_file").val();
        jQuery(\'#upload_plants_subplot_dialog_form\').attr("action", "/ajax/breeders/trial/' );
#line 489 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_plants_per_subplot.mas"
$m->print(  $trial_id  );
#line 489 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_plants_per_subplot.mas"
$m->print( '/upload_plants_subplot");
        if (uploadFile === \'\') {
            alert("Please select a file");
            return;
        }
        jQuery("#upload_plants_subplot_dialog_form").submit();
    }

    jQuery(\'#upload_plants_subplot_dialog_form\').iframePostForm({
        json: true,
        post: function () {
            var uploadedPlantsFile = jQuery("#trial_upload_plants_subplot_file").val();
            jQuery(\'#working_modal\').modal("show");
            if (uploadedPlantsFile === \'\') {
                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 517 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_plants_per_subplot.mas"
$m->print(  $trial_id  );
#line 517 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_plants_per_subplot.mas"
$m->print( ');
            }
        }
    });


    function upload_plants_subplot_with_index_number_to_trial() {
        var uploadFile = jQuery("#trial_upload_plants_subplot_with_index_number_file").val();
        jQuery(\'#upload_plants_subplot_with_index_number_dialog_form\').attr("action", "/ajax/breeders/trial/' );
#line 525 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_plants_per_subplot.mas"
$m->print(  $trial_id  );
#line 525 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_plants_per_subplot.mas"
$m->print( '/upload_plants_subplot_with_plant_index_number");
        if (uploadFile === \'\') {
            alert("Please select a file");
            return;
        }
        jQuery("#upload_plants_subplot_with_index_number_dialog_form").submit();
    }

    jQuery(\'#upload_plants_subplot_with_index_number_dialog_form\').iframePostForm({
        json: true,
        post: function () {
            var uploadedPlantsFile = jQuery("#trial_upload_plants_subplot_with_index_number_file").val();
            jQuery(\'#working_modal\').modal("show");
            if (uploadedPlantsFile === \'\') {
                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 553 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_plants_per_subplot.mas"
$m->print(  $trial_id  );
#line 553 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_plants_per_subplot.mas"
$m->print( ');
            }
        }
    });


    function upload_plants_subplot_with_num_plants_to_trial() {
        var uploadFile = jQuery("#trial_upload_plants_subplot_with_number_of_plants_file").val();
        jQuery(\'#upload_plants_subplot_with_num_plants_dialog_form\').attr("action", "/ajax/breeders/trial/' );
#line 561 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_plants_per_subplot.mas"
$m->print(  $trial_id  );
#line 561 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_plants_per_subplot.mas"
$m->print( '/upload_plants_subplot_with_number_of_plants");
        if (uploadFile === \'\') {
            alert("Please select a file");
            return;
        }
        jQuery("#upload_plants_subplot_with_num_plants_dialog_form").submit();
    }

    jQuery(\'#upload_plants_subplot_with_num_plants_dialog_form\').iframePostForm({
        json: true,
        post: function () {
            var uploadedPlantsFile = jQuery("#trial_upload_plants_subplot_with_number_of_plants_file").val();
            jQuery(\'#working_modal\').modal("show");
            if (uploadedPlantsFile === \'\') {
                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 589 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_plants_per_subplot.mas"
$m->print(  $trial_id  );
#line 589 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/add_plants_per_subplot.mas"
$m->print( ');
            }
        }
    });

});

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

)
;