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 ( $dataset_id );
{
    my %pos;
    for ( my $x = 0; $x < @_; $x += 2 )
    {
        $pos{ $_[$x] } = $x + 1;
    }
#line 3 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
     $dataset_id = exists $pos{'dataset_id'} ? $_[ $pos{'dataset_id'} ] :  undef;
}
$m->debug_hook( $m->current_comp->path ) if ( HTML::Mason::Compiler::IN_PERL_DB() );

#line 1 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->print( '
' );
#line 5 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->print( '
' );
#line 6 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->comp(   '/util/import_javascript.mas', entries => ["wizard"]   
); #line 6 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->print( '
' );
#line 7 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->comp(   '/util/import_css.mas', paths => ['wizard.css']   
); #line 7 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->print( '

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css" />

' );
#line 12 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->comp(   '/page/page_title.mas', title=>"Search Wizard"   
); #line 12 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->print( '

<div class="row">
  <div class="col-md-12" style="margin-bottom:1em; text-align:right;">
    Don\'t see your data? <button id="update_wizard_lists" class="btn btn-default">Refresh Lists</button>
    <button id="update_wizard_show" class="btn btn-default">Update Wizard</button>
  </div>
</div>

' );
#line 21 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->comp(   '/breeders_toolbox/breeder_search_page_dataset_overlay.mas'  
); #line 21 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->print( '

<div id="wizard" class="row">
  <span class="wizard-main">
    <span class="wizard-columns"></span>
    <div class="templates" style="display: none !important;">

      <div class="wizard-unselected">
        <div class="btn-group wizard-list-item">
          <button type="button" class="btn btn-xs btn-success wizard-list-add">&#x2b;</button>
          <a target="_blank" class="btn btn-xs btn-default wizard-list-name"></a>
        </div>
      </div>

      <div class="wizard-selected">
        <div class="btn-group wizard-list-item">
          <button type="button" class="btn btn-xs btn-danger wizard-list-rem">&#10005;</button>
          <a target="_blank" class="btn btn-xs btn-default wizard-list-name"></a>
        </div>
      </div>

      <div class="wizard-column">
        <div class="wizard-panel panel panel-default">

          <div class="panel-heading">
            <select class="wizard-type-select form-control input-sm form-inline">
              <option value="" disabled selected>Select Column Type</option>
              <optgroup class="wizard-types-group" label="--------------------"></optgroup>
              <optgroup class="wizard-lists-group" label="Load Selection from List:"></optgroup>
            </select>
          </div>

          <div class="wizard-search-container">
            <textarea class="wizard-search form-control" placeholder="Search"></textarea>
            <div class="wizard-search-options">
              <div class="wizard-search-options-group btn-group" role="group">
                <button type="button" class="btn btn-xs btn-primary active wizard-search-options-btn wizard-search-options-contains">Contains</button>
                <button type="button" class="btn btn-xs btn-default wizard-search-options-btn wizard-search-options-exact">Exact</button>
              </div>
              <div class="btn-group" role="group">
                <button type="button" class="btn btn-xs btn-danger wizard-search-options-clear">
                  &nbsp;<span class="glyphicon glyphicon-remove" style="top: 2px"></span>&nbsp;
                </button>
                <button type="button" class="btn btn-xs btn-info wizard-search-options-done">
                  &nbsp;<span class="glyphicon glyphicon-chevron-up" style="top: 2px"></span>&nbsp;
                </button>
              </div>
            </div>
          </div>

          <div class="panel-body">

            <div class="wizard-btn-center">
              <div class="btn-group">
                <button class="wizard-select-all btn btn-default btn-xs">Select All</button
                ><button class="wizard-btn-tag btn btn-primary btn-xs">
                  <span class="wizard-count-selected">0</span>/<span class="wizard-count-all">0</span>
                </button
                ><button class="wizard-select-clear btn btn-default btn-xs">Clear</button>
              </div>
            </div>

            <div style="position: relative">
              <span class="wizard-loader glyphicon glyphicon-refresh" aria-hidden="true"></span>
              <ul class="wizard-list-unselected wizard-list well"></ul>
              <ul class="wizard-list-selected wizard-list well"></ul>
            </div>

            <div class="wizard-btn-center wizard-union-toggle">
              <div class="btn-group wizard-union-toggle-btn-group">
                <button type="button" class="btn btn-xs btn-default disabled">Match</button>
                <button type="button" class="btn btn-xs wizard-union-toggle-btn wizard-union-toggle-btn-any btn-primary active">ANY</button>
                <button type="button" class="btn btn-xs wizard-union-toggle-btn wizard-union-toggle-btn-min btn-default">MIN</button>
                <button type="button" class="btn btn-xs wizard-union-toggle-btn wizard-union-toggle-btn-all btn-default">ALL</button>
              </div>
              <div class="input-group input-group-sm wizard-union-toggle-min-group">
                <span class="input-group-btn">
                  <button class="btn btn-default disabled" type="button">>=</button>
                </span>
                <input type="text" class="form-control wizard-union-toggle-min-value">
                <span class="input-group-btn">
                  <button class="btn btn-xs wizard-union-toggle-min-type wizard-union-toggle-min-type-percent btn-primary active" type="button">%</button>
                  <button class="btn btn-xs wizard-union-toggle-min-type wizard-union-toggle-min-type-count btn-default" type="button">#</button>
                </span>
              </div>
            </div>

          </div>

          <table class="wizard-save-to-list table panel-footer">
            ' );
#line 111 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->comp( { content => sub {
#line 111 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->print( '
              <tr>
                <td>
                  <select class="wizard-add-to-list-id form-control input-sm">
                    <option selected value="" disabled>Add to List...</option>
                    <optgroup class="wizard-lists-group" label="--------------------"></optgroup>
                  </select>
                </td>
                <td>
                  <button class="wizard-add-to-list btn btn-sm btn-primary btn-block">Add</button>
                </td>
              </tr>
              <tr>
                <td>
                  <input class="wizard-create-list-name form-control input-sm" type="text" placeholder="Create New List..."></input>
                </td>
                <td>
                  <button class="wizard-create-list btn btn-primary btn-sm btn-block">Create</button>
                </td>
              </tr>
            ' );
#line 131 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
} }, '/util/user.mas:logged_in'
 );
#line 131 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->print( '
            ' );
#line 132 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->comp( { content => sub {
#line 132 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->print( '
              <tr>
                <td><button class="btn btn-xs btn-primary" name="site_login_button">Log In</button> to save lists.</td>
              </tr>
            ' );
#line 136 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
} }, '/util/user.mas:logged_out'
 );
#line 136 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->print( '
          </table>

        </div>
      </div>

    </div>
  </span>

  <div class="clearfix col-xs-12"></div>

  <div class="wizard-datasets panel-group col-sm-12 col-md-6">
    <div class="panel panel-default wizard-panel">
      <div class="panel-heading">
        ' );
#line 150 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->comp( { content => sub {
#line 150 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->print( '<button class="btn btn-xs btn-primary" name="site_login_button">Log In</button> to' );
#line 150 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
} }, '/util/user.mas:logged_out'
 );
#line 150 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->print( '
        Load/Create Datasets using <button class="btn btn-xs btn-default disabled wizard-btn-tag">Match</button> Columns
      </div>
      ' );
#line 153 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->comp( { content => sub {
#line 153 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->print( '
        <div class="panel-body">
          <div class="input-group">
            <select class="form-control input-sm wizard-dataset-select">
              <option selected value="" disabled>Load Dataset</option>
              <optgroup class="wizard-dataset-group" label="--------------------"></optgroup>
            </select>
            <span class="input-group-btn">
              <span><button style="width:5em;margin-left:4px;" class="btn btn-sm btn-primary wizard-dataset-load">Load</button></span>
              <span><button style="width:9em;margin-left:4px;" class="btn btn-sm btn-primary wizard-dataset-public">Make Public</button></span>
              <span><button style="width:5em;margin-left:4px;" class="btn btn-sm btn-danger wizard-dataset-delete">Delete</button></span>
            </span>
          </div>
        </div>
        <div class="panel-body" style="margin-top:-1px;">
          <div class="input-group">
            <input type="text" placeholder="Create New Dataset" class="form-control input-sm wizard-dataset-name" />
            <span class="input-group-btn">
              <span><button style="width:5em;margin-left:4px;" class="btn btn-sm btn-primary wizard-dataset-create">Create</button></span>
            </span>
          </div>
        </div>
      ' );
#line 175 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
} }, '/util/user.mas:logged_in'
 );
#line 175 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->print( '
    </div>
  </div>

  <div class="wizard-downloads panel-group col-sm-12 col-md-6" id="wiz-down-group" role="tablist" aria-multiselectable="true">
    ' );
#line 180 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->comp( { content => sub {
#line 180 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->print( '
      <div class="panel panel-default">
        <div class="panel-heading">
          <button class="btn btn-xs btn-primary" name="site_login_button">Log In</button> to download related data.
        </div>
      </div>
    ' );
#line 186 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
} }, '/util/user.mas:logged_out'
 );
#line 186 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->print( '
    ' );
#line 187 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->comp( { content => sub {
#line 187 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->print( '
      <div class="panel panel-default">
        <div class="panel-heading" role="button" data-toggle="collapse" data-parent="#wiz-down-group" href="#wiz-down-1-c" aria-controls="wiz-down-1-c">
          <span class="btnn btn-link">Related Genotype Data</span>
        </div>
        <div id="wiz-down-1-c" class="panel-collapse collapse" role="tabpanel">
          <p style="margin: 15px; text-color: #999; font-size: 90%">Download matching genotype records from the database.  Select a <strong>single genotyping protocol</strong> and <strong>one or more accessions</strong> to download the matching genotype data.</p>
          <table class="table">
            <tr>
              <td colspan="4">
                <span class="glyphicon glyphicon-info-sign" title="To download related genotype data, select 1 or more Accessions and optionally no more than 1 Genotyping Protocol in the wizard. If no genotyping protocol is selected, the database default protocol will be used. Click the checkbox here to compute genotypes for the selected accessions from genotypes of parents; this works for downloading genotypes, downloading the GRM, and performing GWAS."></span>
                <span>Download Genotype Data</span>
                <input class="wizard-download-genotypes-info form-control input-sm" type="text" disabled></input>
              </td>
              <td colspan="4">
                  <span>Compute From Parents</span><br/>
                  <input type="checkbox" class="wizard-download-genotypes-parents-compute">
              </td>
              <td colspan="4">
                  <span>Include Duplicate Genotypes</span><br/>
                  <input type="checkbox" class="wizard-download-genotypes-duplicates-include">
              </td>
            </tr>
          </table>
          <div class="panel-footer" style="border-top: 1px solid #ddd;">
            <table class="table">
                <tr>
                    <td colspan="12">
                        <span class="glyphicon glyphicon-info-sign" title="You can use either chromosome or markers (markerset) to filter genotyping data. You cannot use both criteria at the same time."></span>
                        <span>Filter by Chromosome or Markerset</span>
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        <span>Chromosome</span>
                        <select class="wizard-download-genotypes-chromosome-number form-control input-sm"></select>
                    </td>
                    <td colspan="4">
                        <span>Start Position</span>
                        <input placeholder="" type="number" class="wizard-download-genotypes-start-position form-control input-sm">
                    </td>
                    <td colspan="4">
                        <span>End Position</span>
                        <input placeholder="" type="number" class="wizard-download-genotypes-end-position form-control input-sm">
                    </td>
                </tr>
                <tr>
                    <td colspan="6">
                        <span>Marker / Markerset Filter</span>
                        <select class="wizard-download-genotypes-marker-set-list-id form-control input-sm" id="wizard-download-genotypes-marker-set-list-id"></select>
                    </td>
                    <td colspan="6">
                        <br/>
                        <button class="btn btn-sm btn-default" onClick="window.open(\'/breeders/markers\', \'_blank\');">Manage Markersets</button>
                    </td>
                </tr>
                <tr>
                    <td colspan="6">
                        <span>Genotypes Download Format</span>
                        <select class="wizard-download-genotypes-format form-control input-sm" >
                            <option value="VCF">VCF File Format</option>
                            <option value="DosageMatrix">Dosage Matrix File Format (.tsv)</option>
                        </select>
                    </td>
                    <td colspan="6">
                    </td>
                </tr>
                <tr>
                    <td colspan="8">
                        <span class="glyphicon glyphicon-info-sign" title="Select accessions, and optionally a genotyping protocol. If no genotyping protocol is selected, the default genotyping protocol is used in your system. If you want to filter genotypes, use the chromosome, start position, end position, or markerset. Can compute genotypes from parents if the parents of the accessions you selected have genotypes by checking the checkbox. Genotypes can be downloaded in VCF and Dosage Matrix Formats."></span>
                        <span>Download Genotypes</span><br/>
                        <button class="wizard-download-genotypes btn btn-sm btn-primary">
                            <span class="glyphicon glyphicon-download" aria-hidden="true"></span>
                            Download Genotypes
                        </button>
                        <input class="wizard-download-genotypes-info2 form-control btn-warning" type="text"></input>  <!-- warn too many genotype protocols-->
                        <input class="wizard-download-genotypes-info3 form-control btn-warning" type="text"></input>  <!-- show default protocol -->
                        <input class="wizard-download-genotypes-info4 form-control btn-warning" type="text"></input>  <!-- show slow download warning -->
                    </td>
                    <td colspan="4">
                    </td>
                </tr>
            </table>
          </div>
          <div class="panel-footer" style="border-top: 1px solid #ddd;">
            <table class="table">
                <tr>
                    <td colspan="6">
                      <span>Minor Allele Frequency</span>
                      <input placeholder="0.05" value="0.05" type="number" class="wizard-download-genotypes-grm-maf form-control input-sm">
                    </td>
                    <td colspan="3">
                      <span>Marker Filter</span>
                      <input placeholder="0.60" value="0.60" type="number" class="wizard-download-genotypes-grm-marker-filter form-control input-sm">
                    </td>
                    <td colspan="3">
                      <span>Individuals Filter</span>
                      <input placeholder="0.80" value="0.80" type="number" class="wizard-download-genotypes-grm-individuals-filter form-control input-sm">
                    </td>
                </tr>
              <tr>
                <td colspan="12">
                  <span>Genomic Relationship Matrix (GRM) Download Format</span>
                  <select class="wizard-download-genotypes-grm-format form-control input-sm" >
                      <option value="matrix_uniquenames">Matrix Stock Names (.tsv)</option>
                      <option value="three_column_uniquenames">3-Column Stock Names (.tsv)</option>
                      <option value="three_column_reciprocal_uniquenames">3-Column Reciprocal Stock Names (.tsv)</option>
                      <option value="heatmap">Heatmap (.pdf)</option>
                      <option value="matrix">Matrix Stock IDs (.tsv)</option>
                      <option value="three_column">3-Column Stock IDs(.tsv)</option>
                      <option value="three_column_stock_id_integer">3-Column Stock IDs Integer (.tsv)</option>
                      <option value="three_column_reciprocal">3-Column Reciprocal Stock IDs (.tsv)</option>
                      <option value="three_column_reciprocal_stock_id_integer">3-Column Reciprocal Stock IDs Integer (.tsv)</option>
                  </select>
                  <br/>
                    <span class="glyphicon glyphicon-info-sign" title="Select accessions, and optionally a genotyping protocol. If no genotyping protocol is selected, the default genotyping protocol is used in your system. Specify minor allele frequency (MAF), marker filter, and individuals filter. Can compute genotypes from parents if the parents of the accessions you selected have genotypes by checking the checkbox. GRM can be downloaded in a matrix format (.tsv) and a three column format."></span>
                    <span>Download GRM</span><br/>
                    <button class="wizard-download-genetic-relationship-matrix btn btn-sm btn-primary">
                        <span class="glyphicon glyphicon-download" aria-hidden="true"></span>
                        Download GRM
                    </button>
                </td>
              </tr>
              <tr>
                  <td colspan="12">
                    <span>Genome Wide Association Study (GWAS) Download Format</span>
                    <select class="wizard-download-genotypes-gwas-format form-control input-sm" >
                        <option value="manhattan_qq_plots">Manhattan + QQ Plots (.pdf)</option>
                        <option value="results_tsv">GWAS Results (.tsv)</option>
                    </select>
                    <br/>
                    <span>Selected Traits Are All Repeated Measurements</span>
                    <select class="wizard-download-genotypes-gwas-repeated-measurements form-control input-sm" >
                        <option value="no">No</option>
                        <option value="yes">Yes</option>
                    </select>
                    <br/>
                        <span class="glyphicon glyphicon-info-sign" title="Select accessions, traits, and optionally a genotyping protocol. If no genotyping protocol is selected, the default genotyping protocol is used in your system. When many traits are selected and these traits are not treated as repeated measurements, the traits are treated separately and distinct results are returned e.g. several Manhattan plots are returned. If the selected traits are in fact repeated measurements, then select \'yes\'; a single GWAS will be run against all of the phenotypes e.g. a single Manhattan plot is returned. Specify minor allele frequency (MAF), marker filter, and individuals filter. Can compute genotypes from parents if the parents of the accessions you selected have genotypes by checking the checkbox. GWAS uses a fixed effect for different field trials and a fixed effect for replicate. GWAS uses Kinship matrix calculated from the genotype data. MAF and missing data used to filter prior to GWAS and Kinship matrix calculation. Can select whether to return results in Manhattan and QQ Plot (.pdf) form or as the tabular results (.tsv)."></span>
                        <span>Run GWAS</span><br/>
                      <button class="wizard-download-gwas btn btn-sm btn-primary">
                          <span class="glyphicon glyphicon-download" aria-hidden="true"></span>
                          Download GWAS
                      </button>
                  </td>
              </tr>
            </table>

          </div>
        </div>
      </div>

      <div class="panel panel-default">
        <div class="panel-heading" role="button" data-toggle="collapse" data-parent="#wiz-down-group" href="#wiz-down-1-c-a" aria-controls="wiz-down-1-c-a">
          <span class="btnn btn-link">Archived Genotype Data</span>
        </div>
        <div id="wiz-down-1-c-a" class="panel-collapse collapse" role="tabpanel">
          <p style="margin: 15px; text-color: #999; font-size: 90%">Download the original archived VCF files of entire genotyping projects.  Select <strong>one or more genotyping projects and/or genotyping protocols</strong> to download a VCF file of any matching project(s).</p>
          <div id="wiz-down-1-c-a-body" style="min-height: 50px"></div>
        </div>
      </div>

      <div class="panel panel-default">
        <div class="panel-heading" role="button" data-toggle="collapse" data-parent="#wiz-down-group" href="#wiz-down-2-c" aria-controls="wiz-down-2-c">
          <span class="btnn btn-link">Related Trial Metadata</span>
        </div>
        <div id="wiz-down-2-c" class="panel-collapse collapse" role="tabpanel">
          <table class="table">
            <tr>
              <td>
                <input class="wizard-download-tmetadata-info form-control input-sm" type="text" disabled value="No Trials Selected"></input>
              </td>
              <td>
                <select class="wizard-download-tmetadata-format form-control input-sm">
                  <option value="" disabled>Format</option>
                  <option selected value="csv">CSV</option>
                  <option value="xlsx">XLSX</option>
                </select>
              </td>
            </tr>
          </table>
          <div class="panel-footer" style="border-top: 1px solid #ddd;">
            <button class="wizard-download-tmetadata btn btn-sm btn-primary">
                <span class="glyphicon glyphicon-download" aria-hidden="true"></span>
                Metadata
            </button>
          </div>
        </div>
      </div>

      <div class="panel panel-default">
        <div class="panel-heading" role="button" data-toggle="collapse" data-parent="#wiz-down-group" href="#wiz-down-3-c" aria-controls="wiz-down-3-c">
          <span class="btnn btn-link">Related Trial Phenotypes</span>
        </div>
        <div id="wiz-down-3-c" class="panel-collapse collapse" role="tabpanel">
          <table class="table">
            <tr>
              <td colspan="3">
                <input class="wizard-download-phenotypes-info form-control input-sm" type="text" disabled></input>
              </td>
            </tr>
            <tr>
            <td colspan="1">
              <select class="wizard-download-phenotypes-speed form-control input-sm">
                <option value="" disabled>Download Type</option>
                <option selected value="Native">Default</option>
                <option value="MaterializedViewTable">Fast (Improves speed but may miss recent changes)</option>
              </select>
            </td>
              <td colspan="1">
                <select class="wizard-download-phenotypes-format form-control input-sm">
                  <option value="" disabled>Download Format</option>
                  <option selected value="csv">CSV</option>
                  <option value="xlsx">XLSX</option>
                </select>
              </td>
              <td colspan="1">
                <select class="wizard-download-phenotypes-level form-control input-sm">
                  <option value="" disabled>Data Level</option>
                  <option selected value="all">All</option>
                  <option value="plot">Plots</option>
                  <option value="plant">Plants</option>
                </select>
              </td>
            </tr>
            <tr>
              <td>
                <div class="checkbox">
                  <label>
                    <input class="wizard-download-phenotypes-timestamp" type="checkbox" />
                    Include timestamps
                  </label>
                </div>
              </td>
              <td colspan="2">
                <div class="checkbox">
                  <label>
                    <input class="wizard-download-phenotypes-entry-numbers" type="checkbox" />
                    Include accession entry numbers
                  </label>
                </div>
              </td>
            </tr>
            <tr>
              <td style="border-top: none; padding-top: 0">
                <div class="checkbox">
                  <label>
                    <input class="wizard-download-phenotypes-outliers" type="checkbox" />
                    Supress user defined phenotype outliers
                  </label>
                </div>
              </td>
	      <td style="border-top: none; padding-top: 0">
		Repetitive measurements: <br />

		<select class="wizard-download-repetitive-measurements-type" >
                  <option value="first">First value</option>
                  <option value="last">Last value</option>
                  <option value="average" selected>Averaged value</option>
                  <option value="sum">Sum values</option>
                  <option value="all_values_single_line">All Values Single Line</option>
                  <option value="all_values_multiple_line">All Values Multiple Line</option>
		</select>
	      </td>
	      <td style="border-top: none; padding-top: 0">
		&nbsp;
	      </td>
            </tr>
	    <tr>
		<td>
		    From:  <input type="text" class="wizard-download-start-date" id="phenotype_start_date" title="phenotype_start_date"  />
		</td>
		<td>
		    To: <input type="text" class="wizard-download-end-date" id="phenotype_end_date" title="phenotype_end_date" />	
		</td>
		<td>
		    <input type="checkbox" id="include_dateless_items" checked="1" > include items without a date</input>
		</td>
		</tr>	
            <tr>
              <td>
                <span>Trait Name Contains</span>
                <input placeholder="e.g. plant height" type="text" class="wizard-download-phenotypes-name form-control">
              </td>
              <td>
                <span>Min Value</span>
                <input placeholder="-&#8734;" type="text" class="wizard-download-phenotypes-min form-control">
              </td>
              <td>
                <span>Max Value</span>
                <input placeholder="&#8734;" type="text" class="wizard-download-phenotypes-max form-control">
              </td>
            </tr>
          </table>
          <div class="panel-footer" style="border-top: 1px solid #ddd;">
            <button class="wizard-download-phenotypes btn btn-sm btn-primary">
                <span class="glyphicon glyphicon-download" aria-hidden="true"></span>
                Download Phenotypes
            </button>
          </div>
        </div>
      </div>
    ' );
#line 488 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
} }, '/util/user.mas:logged_in'
 );
#line 488 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->print( '
  </div>

</div>

<script>
  window.sWizard = jsMod[\'wizard\'].WizardSetup("#wizard");
</script>

<div class="modal fade" id="update_wizard_dialog" name="update_wizard_dialog" tabindex="-1" role="dialog" aria-labelledby="updateWizardDialog">
  <div class="modal-dialog" 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>
        <h3 class="modal-title" id="updateWizardDialog">Update Search Wizard</h3>
      </div>
      <div class="modal-body">
        <div class="container-fluid">
	     <h4>How the wizard works</h4>
	     	     <p>For the search wizard to be fast and flexible, it avoids querying the database directly. Instead, it stores a copy of the data from the database in a temporary format that is optimized for the types of queries the wizard makes.</p><p>For this to be practical, the copy must be updated regularly. Updates usually start every time new data is uploaded, however users with submitter status or higher can also initiate them manually.</p><p>If an update isn\'t already in progress, you can initiate one below. It will run independently on the server without any additional input required from the user. Depending on the size of the database, it will take from a few minutes to a few hours to complete.</p>
	<div><h4>Current status:</h4><p id="wizard_status"></p></div>
        </div>
      </div>
      <div class="modal-footer">
        <div class="well well-sm" id="update_wizard_error" style="display:none;"></div>
        <button type="button" class="btn btn-primary wiz-update" name="update_wizard" data-loading-text="Working..." id="update_wizard">Update search wizard</button>
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>

<script>

document.addEventListener("DOMContentLoaded", function() {
    var check_outliers = "' );
#line 523 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->print(  $c->get_conf('exclude_phenotype_outliers') || 0  );
#line 523 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->print( '";

    if (parseInt(check_outliers) === 1) {
        // Set the checkbox to checked
        var outlierCheckbox = document.querySelector(\'.wizard-download-phenotypes-outliers\');
        if (outlierCheckbox) {
            outlierCheckbox.checked = true;
        }
    }
});


  jQuery(document).ready(function (){
' );
#line 536 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
  if ($dataset_id){
$m->print( '      document.getElementsByClassName("wizard-dataset-select")[0].value = ' );
#line 537 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->print(  $dataset_id  );
#line 537 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->print( ';
      document.getElementsByClassName("wizard-dataset-load")[0].click();
' );
#line 539 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
  }
$m->print( '   $(".wizard-download-genotypes-info2").hide();
   $(".wizard-download-genotypes-info3").hide();
   $(".wizard-download-genotypes-info4").hide();
  });

  d3.select(\'#update_wizard_show\').on(\'click\', function () {
    $(\'#update_wizard_dialog\').modal("show");
    jsMod[\'wizard\'].updateStatus("#wizard_status")
      .then(function(isLoading){
        if(isLoading) {
          d3.select("#update_wizard")
          .attr("title","A search wizard update is already in progress...")
          .attr("disabled",true);
        }
        else {
          d3.select("#update_wizard")
          .attr("title","Refresh the search wizard to include newly uploaded data")
          .attr("disabled",null)
        }
      });
  });

  d3.select("#update_wizard").on(\'click\',function(){
    jsMod[\'wizard\'].refreshMatviews("fullview",this);
  });

  d3.select("#update_wizard_lists").on(\'click\',function(){
    window.sWizard.reload_lists();
  });


  // Wizard Callback: get archived vcf files available for selected genotyping protocol / project
  window.sWizard.wizard.on_change(function(categories, selections, operations) {
    var protocols = (selections.genotyping_protocols || []).map((i) => i.id);
    var projects = (selections.genotyping_projects || []).map((i) => i.id);
    if ( protocols.length === 0 && projects.length === 0 ) {
      updateArchivedVCFFiles({ no_geno_selected: true });
    }
    else {
      updateArchivedVCFFiles({ loading: true });
      jQuery.ajax({
        url: \'/ajax/genotyping_project/has_archived_vcf\',
        method: \'GET\',
        data: {
          genotyping_protocol_id: !projects || projects.length === 0 ? (protocols.length > 0 ? protocols.join(\',\') : undefined) : undefined,
          genotyping_project_id: projects.length > 0 ? projects.join(\',\') : undefined,
          limit: true
        },
        error: function(response) {
          console.log(`ERROR: Could not query database for archived vcf files [protocols: ${protocols.join(\',\')}, projects: ${projects.join(\',\')}]`);
          console.log(response);
          updateArchivedVCFFiles({ error: true });
        },
        success: function(response) {
          updateArchivedVCFFiles({ data: response });
        }
      });
    }
  });
  updateArchivedVCFFiles({ no_geno_selected: true });
  
  // Set the display of the Archived Genotype Data section
  function updateArchivedVCFFiles({ no_geno_selected = false, loading = false, error = false, data = {} } = {}) {
    let html = \'\';
    if ( no_geno_selected ) {
      html += "<p style=\'text-align: center; margin: 15px; font-size: 90%\'>Select one or more <em>genotyping protocols</em> and/or <em>genotyping projects</em>...</p>";
    }
    else if ( loading ) {
      html += "<p style=\'text-align: center; margin: 15px\'>Loading...</p>";
    }
    else if ( error ) {
      html += "<p style=\'text-align: center; margin: 15px\'>Error: Could not check for archived files</p>";
    }
    else if ( data ) {
      html += "<table class=\'table table-hover table-striped\'>";
      html += "<thead><tr><th>Protocol</th><th>Project</th><th>VCF File</th></tr></thead>";
      html += "<tbody>";
      Object.keys(data).forEach((proj_id) => {
        const files = data[proj_id];
        files.forEach((file) => {
          html += "<tr>";
          html += `<td><a href="/breeders_toolbox/protocol/${file.genotyping_protocol_id}" target="_blank">${file.genotyping_protocol_name}</td>`;
          html += `<td><a href="/breeders/trial/${file.genotyping_project_id}" target="_blank">${file.genotyping_project_name}</td>`;
          if ( file.exists === \'true\' ) {
            html += `<td><a href="/ajax/genotyping_project/download_archived_vcf?genotyping_project_id=${file.genotyping_project_id}&basename=${file.basename}" target="_blank">Download</a></td>`;
          }
          else {
            html += "<td>File not found</td>";
          }
          html += "</tr>";
        });
      });
      html += "</tbody>";
      html += "</table>";
    }

    jQuery(\'#wiz-down-1-c-a-body\').html(html);
  }

  // Wizard Callback: get chromosome names for a single selected genotyping protocol
  var SELECTED_GENOTYPING_PROTOCOL = undefined;
  var SELECTED_GENOTYPING_PROJECT = undefined;
  var SELECTED_ACCESSIONS = undefined;
  var num_markers = 0;
  var download_units = 0;
  window.sWizard.wizard.on_change(function(categories, selections, operations) {
    var selected_genotyping_protocols = selections.hasOwnProperty(\'genotyping_protocols\') ? selections.genotyping_protocols : [];
    var selected_genotyping_projects = selections.hasOwnProperty(\'genotyping_projects\') ? selections.genotyping_projects : [];
    var selected_accessions = selections.hasOwnProperty(\'accessions\') ? selections.accessions : [];
    selected_accessions = selected_accessions.length;
    if ( selected_genotyping_protocols.length >= 1 ) {
      $(".wizard-download-genotypes-info3").hide();
      var selected_genotyping_protocol = selected_genotyping_protocols.length === 1 ? selected_genotyping_protocols[0].id : "";
      if ( selected_genotyping_protocol != SELECTED_GENOTYPING_PROTOCOL ) {
        SELECTED_GENOTYPING_PROTOCOL = selected_genotyping_protocol;
        jQuery.ajax({
          url: \'/ajax/breeder/search/genotyping_protocol_chromosomes\',
          method: "GET",
          data: { \'genotyping_protocol\': SELECTED_GENOTYPING_PROTOCOL },
          error: function(response) {
            console.log("ERROR: Could not get chromosome names for genotyping protocol #" + SELECTED_GENOTYPING_PROTOCOL);
            console.log(response);
            updateChromosomeNames();
          },
          success: function(response) {
            if (response.error) {
              console.log("ERROR: Server returned an error trying to get the chromosome names for genotyping protocol #" + SELECTED_GENOTYPING_PROTOCOL);
              console.log(repsonse.error);
              updateChromosomeNames();
            } else {
              updateChromosomeNames(response.chromosome_names);
            }
          }
        });
        jQuery.ajax({
          url: \'/ajax/genotyping_protocol/num_markers\',
          method: "GET",
          data: { \'protocol_ids\': SELECTED_GENOTYPING_PROTOCOL },
          error: function(response) {
            console.log("ERROR: Could not get markers for genotyping protocol #" + SELECTED_GENOTYPING_PROTOCOL);
            console.log(response);
          },
          success: function(response) {
            if (response.error) {
              console.log("ERROR: Server returned an error trying to get markers for genotyping protocol #" + SELECTED_GENOTYPING_PROTOCOL);
              console.log(repsonse.error);
            } else {
              num_markers = response.data;
            }
          }
        });
      }
      if ( selected_genotyping_protocols.length > 1 ) {
        $(".wizard-download-genotypes-info2").show();
        $(".wizard-download-genotypes-info2").val("too many genotype protocols");
      } else {
        $(".wizard-download-genotypes-info2").hide();
      }
    } else if ( selected_genotyping_projects.length >= 1 ) {
      var selected_genotyping_project = selected_genotyping_projects[0].id;
      if ( selected_genotyping_project !== SELECTED_GENOTYPING_PROJECT ) {
        SELECTED_GENOTYPING_PROJECT = selected_genotyping_project;
        jQuery.ajax({
          url: \'/ajax/genotyping_project/protocols\',
          method: "GET",
          data: { \'genotyping_project_id\': SELECTED_GENOTYPING_PROJECT },
          error: function(response) {
            console.log("ERROR: Could not get protocol for genotyping project #" + SELECTED_GENOTYPING_PROJECT);
            console.log(response);
          },
          success: function(response) {
            if (response.error) {
              console.log("ERROR: Server returned an error trying to get protocol for genotyping project #" + SELECTED_GENOTYPING_PROJECT);
              console.log(response.error);
            }
            else {
              genotyping_protocol = response.data;
              SELECTED_GENOTYPING_PROTOCOL = genotyping_protocol[0]["protocol_id"];
              // console.log(genotyping_protocol[0]["protocol_id"]);
              // console.log(genotyping_protocol[0]["protocol_name"]);
              if ( selected_genotyping_protocols.length < 1 ) {
                $(".wizard-download-genotypes-info3").show();
                $(".wizard-download-genotypes-info3").val("genotype protocol \\"" + genotyping_protocol[0]["protocol_name"] + "\\""); 
              }
            }
            jQuery.ajax({
              url: \'/ajax/breeder/search/genotyping_protocol_chromosomes\',
              method: "GET",
              data: { \'genotyping_protocol\': SELECTED_GENOTYPING_PROTOCOL },
              error: function(response) {
                console.log("ERROR: Could not get chromosome names for genotyping protocol #" + SELECTED_GENOTYPING_PROTOCOL);
                console.log(response);
                updateChromosomeNames();
              },
              success: function(response) {
                if (response.error) {
                  console.log("ERROR: Server returned an error trying to get the chromosome names for genotyping protocol #" + SELECTED_GENOTYPING_PROTOCOL);
                  console.log(repsonse.error);
                  updateChromosomeNames();
                } else {
                  updateChromosomeNames(response.chromosome_names);
                }
              }
            });
            // console.log("calling ajax " + SELECTED_GENOTYPING_PROTOCOL);
            jQuery.ajax({
              url: \'/ajax/genotyping_protocol/num_markers\',
              method: "GET",
              data: { \'protocol_ids\': SELECTED_GENOTYPING_PROTOCOL },
              error: function(response) {
                console.log("ERROR: Could not get markers for genotyping protocol #" + SELECTED_GENOTYPING_PROTOCOL);
                console.log(response);
              },
              success: function(response) {
                if (response.error) {
                  console.log("ERROR: Server returned an error trying to get markers for genotyping protocol #" + SELECTED_GENOTYPING_PROTOCOL);
                  console.log(repsonse.error);
                } else {
                  num_markers = response.data;
                }
             }
            });
          }
        });
      }
    } else {
      var protocol_name = \'' );
#line 766 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->print(  $c->config->{default_genotyping_protocol}  );
#line 766 "/home/production/cxgn/sgn/mason/breeders_toolbox/breeder_search_page.mas"
$m->print( '\';
      $(".wizard-download-genotypes-info3").show();
      $(".wizard-download-genotypes-info3").val("genotype protocol \\"" + protocol_name + "\\""); 
      jQuery.ajax({
          url: \'/get/genotyping/protocols/\',
          method: "POST",
          dataType: "json",
          error: function(response) {
            console.log("ERROR: Could not get genotyping protocol");
            console.log(response);
          },
          success: function(response) {
           if (response.error) {
              console.log("ERROR: Server returned an error trying to get genotyping protocol #" + SELECTED_GENOTYPING_PROTOCOL);
              console.log(repsonse.error);
            } else {
              SELECTED_GENOTYPING_PROTOCOL = response.default_protocol.protocol_id;
              jQuery.ajax({
                url: \'/ajax/genotyping_protocol/num_markers\',
                method: "GET",
                data: { \'protocol_ids\': SELECTED_GENOTYPING_PROTOCOL },
                error: function(response) {
                  console.log("ERROR: Could not get markers for genotyping protocol #" + SELECTED_GENOTYPING_PROTOCOL);
                  console.log(response);
                },
                success: function(response) {
                  if (response.error) {
                    console.log("ERROR: Server returned an error trying to get markers for genotyping protocol #" + SELECTED_GENOTYPING_PROTOCOL);
                    console.log(repsonse.error);
                  } else {
                    num_markers = response.data;
                  }
               }
              });
            }
          }
      });
    }
    if ( selected_accessions !== SELECTED_ACCESSIONS ) {
      SELECTED_ACCESSIONS = selected_accessions;
      download_units = parseInt((num_markers * selected_accessions) / 1000000);
      if (download_units > 1) {
            $(".wizard-download-genotypes-info4").show();
            $(".wizard-download-genotypes-info4").val(download_units + "M values, download will be slow");
            // console.log("download units " + download_units);
      } else {
            $(".wizard-download-genotypes-info4").hide();
            $(".wizard-download-genotypes-info4").val(download_units.toString());
      }
    }
  });
  // updateChromosomeNames();

  // Set the chromosome names for the select dropdown menu
  function updateChromosomeNames(names) {
    var html = "";
    if ( names )  {
      html += "<option value=\'\'>All</option>";
      for ( var i = 0; i < names.length; i++ ) {
        html += "<option value=\'" + names[i] + "\'>" + names[i] + "</option>";
      }
    }
    $(".wizard-download-genotypes-chromosome-number").html(html);
  }

  jQuery(\'input[title="phenotype_start_date"]\').daterangepicker(
   {
       "singleDatePicker": true,
       "showDropdowns": true,
       "autoUpdateInput": true,
       "startDate": "1960-01-01",
       "yearSelect" : true,
       "minDate": "1960-01-01",
       "maxDate": "2030-12-31",
       locale: { 
        format: \'YYYY-MM-DD\'
      }
   },

);


jQuery(\'input[title="phenotype_end_date"]\').daterangepicker(
   {
       "singleDatePicker": true,
       "showDropdowns": true,
       "autoUpdateInput": true,
       //"startDate": "1960-01-01",
       "yearSelect" : true,
       "minDate": "1960-01-01",
       "maxDate": "2030-12-31",
       locale: { 
        format: \'YYYY-MM-DD\'
      }
   },

);


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

)
;