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 );
{
    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 2 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/upload_plot_gps_dialogs.mas"
    $trial_id = $_[ $pos{'trial_id'} ];
}
$m->debug_hook( $m->current_comp->path ) if ( HTML::Mason::Compiler::IN_PERL_DB() );

#line 4 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/upload_plot_gps_dialogs.mas"
$m->print( '
<div class="modal fade" id="upload_plot_gps_dialog" name="upload_plot_gps_dialog" tabindex="-1" role="dialog" aria-labelledby="uploadPlotGPSDialog">
    <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="uploadPlotGPSDialog">Upload GPS Coordinates for Plots</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">

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

                    <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" encoding="multipart/form-data" id="upload_plot_gps_dialog_form" name="upload_plot_gps_dialog_form">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">Coordinates Type: </label>
                            <div class="col-sm-9">
                                <select class="form-control" id="upload_gps_coordinate_type" name="upload_gps_coordinate_type">
                                    <option value="polygon">Polygon</option>
                                    <option value="point">Point</option>
                                </select>
                            </div>
                            <label class="col-sm-4 control-label">Upload File (.xls or .xlsx): </label>
                            <div class="col-sm-8" >
                                <input type="file" name="trial_upload_plot_gps_file" id="trial_upload_plot_gps_file" encoding="multipart/form-data" />
                            </div>
                        </div>
                    </form><br/>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" name="upload_plot_gps_cancel_button" id="upload_plot_gps_cancel_button" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary" name="upload_plot_gps_save_button" id="upload_plot_gps_save_button" title="Upload">Upload</button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="upload_plot_gps_spreadsheet_info_dialog" name="upload_plot_gps_spreadsheet_info_dialog" tabindex="-1" role="dialog" aria-labelledby="uploadPlotGPSInfoDialog">
    <div class="modal-dialog modal-xl" 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="uploadPlotGPSInfoDialog">Upload Template Information</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">
                    <b>This is for recording the GPS coordinates of plots.</b>
                    <br/>
                    <b>GPS coordinates may be uploaded in an Excel file (.xls or .xlsx)</b>
                    <br />
                    <b>Header:</b>
                    <br>
                    The first row (header) should contain the following:

                    <h2>Uploading Polygons:</h2>
                    <h3>Each plot is represented as a polygon with four corners. You can choose to upload UTM31N and/or WGS84 coordinates.</h3>

                    <table class="table table-hover table-bordered table-condensed" >
                        <thead></thead>
                        <tbody>
                            <tr>
                                <td>plot_name</td>
                                <td>WGS84_bottom_left_x</td>
                                <td>WGS84_bottom_left_y</td>
                                <td>WGS84_bottom_right_x</td>
                                <td>WGS84_bottom_right_y</td>
                                <td>WGS84_top_right_x</td>
                                <td>WGS84_top_right_y</td>
                                <td>WGS84_top_left_x</td>
                                <td>WGS84_top_left_y</td>
                            </tr>
                        </tbody>
                    </table>

                    <b>Required fields:</b>
                    <br/>
                    plot_name (must exist in the database)
                    <br />
                    WGS84_bottom_left_x (WGS84 longitude coordinate of bottom left corner of plot)
                    <br />
                    WGS84_bottom_left_y (WGS84 latitude coordinate of bottom left corner of plot)
                    <br />
                    WGS84_bottom_right_x (WGS84 longitude coordinate of bottom right corner of plot)
                    <br />
                    WGS84_bottom_right_y (WGS84 latitude coordinate of bottom right corner of plot)
                    <br />
                    WGS84_top_right_x (WGS84 longitude coordinate of top right corner of plot)
                    <br />
                    WGS84_top_right_y (WGS84 latitude coordinate of top right corner of plot)
                    <br />
                    WGS84_top_left_x (WGS84 longitude coordinate of top left corner of plot)
                    <br />
                    WGS84_top_left_y (WGS84 latitude coordinate of top left corner of plot)

                    <h2>Uploading Points:</h2>
                    <h3>Each plot is represented as a point with one coordinate pair. You can upload WGS84 coordinates.</h3>

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

                    <b>Required fields:</b>
                    <br/>
                    plot_name (must exist in the database)
                    <br />
                    WGS84_x (WGS84 longitude coordinate of the point)
                    <br />
                    WGS84_y (WGS84 latitude coordinate of the point)
                </div>
            </div>
            <div class="modal-footer">
                <button id="close_upload_plot_gps_info_dialog" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>


<script>

jQuery(document).ready(function () {

    jQuery(\'#trial_upload_plot_gps_button\').click( function () {
        jQuery(\'#upload_plot_gps_dialog\').modal("show");
    });

    jQuery(\'#trial_upload_plot_gps_spreadsheet_info_format\').click( function () {
        jQuery(\'#upload_plot_gps_spreadsheet_info_dialog\').modal("show");
    });
    
    jQuery(\'#upload_plot_gps_save_button\').click( function () {
        upload_plot_gps();
    });

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

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

});

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

)
;