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/trial_soil_data.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/trial_soil_data.mas"
$m->print( '
' );
#line 5 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_soil_data.mas"
$m->comp(   '/util/import_javascript.mas', classes => ['jquery','jquery.dataTables']   
); #line 5 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_soil_data.mas"
$m->print( '
' );
#line 6 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_soil_data.mas"
$m->comp(   '/util/import_css.mas', paths => ['/documents/inc/datatables/jquery.dataTables.css']   
); #line 6 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_soil_data.mas"
$m->print( '



' );
#line 10 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_soil_data.mas"
$m->comp( { content => sub {
#line 10 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_soil_data.mas"
$m->print( '
    <div class = "well well-sm">
        <div class = "panel panel-default">
            <div class = "panel-body">
                <div style="overflow:scroll">
                    <table id = "soil_data_table" class="table table-hover table-striped">
                    </table>
                </div>
            </div>
        </div>
    </div>
' );
#line 21 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_soil_data.mas"
} }, '/page/info_section.mas', title => "Trial Soil Data", collapsible=>1, collapsed=>0
 );
#line 21 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_soil_data.mas"
$m->print( '

<script defer="defer">

jQuery(document).ready(function () {

    var soil_data_table = jQuery(\'#soil_data_table\').DataTable({
        \'searching\': false,
        \'order\': false,
        \'autoWidth\': false,
        \'ajax\':\'/ajax/breeders/trial/\'+ ' );
#line 31 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_soil_data.mas"
$m->print(  $trial_id  );
#line 31 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_soil_data.mas"
$m->print( ' + \'/all_soil_data\',
        columns: [
            { title: "Soil Data ID", "data": "prop_id" },
            { title: "Description", "data": "description" },
            { title: "Date", "data": "date" },
            { title: "GPS", "data": "gps" },
            { title: "Type of Sampling", "data": "type_of_sampling" },
            { title: "Soil Data", "data": "soil_data" },
            { title: "Download", "data": "download_link" },
            { title: "Delete", "data": "null", "render": function ( data, type, row ) { return "<a onclick=\'deleteSoilData("+row.prop_id+")\'>Delete</a>"; } },
        ]
    });

});

function deleteSoilData(prop_id){
    var confirmation = confirm(\'Are you sure you want to delete this soil data id. The deletion cannot be undone.\');

    if (confirmation) {
        jQuery.ajax({
            url : \'/ajax/breeders/trial/\'+ ' );
#line 51 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_soil_data.mas"
$m->print(  $trial_id  );
#line 51 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/trial_soil_data.mas"
$m->print( ' + \'/delete_soil_data\',
            method: \'POST\',
            data : {
                \'prop_id\': prop_id
            },

            destroy: true,
            beforeSend: function(response) {
                jQuery(\'#working_modal\').modal(\'show\');
            },
            success: function(response) {
                jQuery(\'#working_modal\').modal(\'hide\');
                if (response.success == 1) {
                    alert(\'Deletion was successful\');
                    location.reload();
                }
                if (response.error) {
                    alert(response.error);
                }
            },
            error: function(response) {
                jQuery(\'#working_modal\').modal(\'hide\');
                alert(\'An error occurred during deletion\');
            }
        });
    }
}


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

)
;