4 <div class="modal fade" id="upload_seedlot_dialog" name="upload_seedlot_dialog" tabindex="-1" role="dialog" aria-labelledby="seedlot_upload_dialog">
5 <div class="modal-dialog modal-xl" role="document">
6 <div class="modal-content">
7 <div class="modal-header">
8 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
9 <h4 class="modal-title" id="seedlot_upload_dialog">Upload Seedlots</h4>
11 <div class="modal-body">
12 <div class="container-fluid">
14 <&| /util/workflow.mas, id=> "upload_seedlot_main_workflow" &>
15 <&| /util/workflow.mas:step, title=> "Intro" &>
16 <& /page/page_title.mas, title=>"What are seedlots?" &>
18 <li>Seedlots represent physical seed in packets.</li>
19 <li>This seed can be from crosses or for named accessions.</li>
20 <li>Seedlots can have a specific location, box, weight(g), and count.</li>
21 <li>Seedlots can belong to breeding programs and organizations.</li>
22 <li>Seedlots can be used in trials (e.g. they were planted in a plot) and they can be harvested from a plot or plant (e.g. a cross was performed and seeds were collected.)</li>
27 <button class="btn btn-primary" onclick="Workflow.complete(this);">Go to Next Step</button>
31 <&| /util/workflow.mas:step, title=> "What seedlots do you have?" &>
32 <& /page/page_title.mas, title=>"Seedlots fall into two categories" &>
34 <div class="form-group">
35 <label class="col-sm-3 control-label">Select One: </label>
36 <div class="col-sm-9">
37 <select class="form-control" id="upload_seedlots_type_select" name="upload_seedlots_type_select">
38 <option value=""></option>
39 <option data-desc="If you have seed lots for named accessions, such as seed that was ordered from a vendor, use this option. Use this option if the seed was not harvested from a cross that is in the database." value="from_accession">I have seed lots for named accessions</option>
40 <option data-desc="If you have seed lots that were harvested from crosses that are in the database, use this option." value="from_cross">I have seed lots harvested from crosses</option>
45 <div id="upload_seedlots_types_description">
49 <button disabled id="seedlot_upload_type_select_button" class="btn btn-primary" onclick="Workflow.complete(this);">Go to Next Step</button>
53 <&| /util/workflow.mas:step, title=> "File format" &>
54 <& /page/page_title.mas, title=>"Make sure your file matches the correct file format" &>
57 <div id="upload_seedlots_accessions_template_section" style="display:none">
58 <button class="btn btn-info" name="guided_help_seedlot_upload_format_button">Information about file format for uploading seedlots of named accessions</button><br/><br/>
60 <div id="upload_seedlots_crosses_template_section" style="display:none">
61 <button class="btn btn-info" name="guided_help_seedlot_crosses_upload_format_button">Information about file format for uploading seed lots harvested</button><br/><br/>
63 <button class="btn btn-primary" onclick="Workflow.complete(this);">Once you think your file matches, go to Next Step</button>
67 <&| /util/workflow.mas:step, title=> "Upload seedlots" &>
68 <& /page/page_title.mas, title=>"Provide basic information about the seedlots and upload your file" &>
70 <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" encoding="multipart/form-data" id="upload_seedlot_form" name="upload_seedlot_form">
72 <div class="form-group">
73 <label class="col-sm-3 control-label">Breeding Program: </label>
74 <div class="col-sm-9" >
75 <div id="upload_seedlot_breeding_program_div"></div>
78 <div class="form-group">
79 <label class="col-sm-3 control-label">Location of seedlot storage: </label>
80 <div class="col-sm-9" >
81 <input class="form-control" name="upload_seedlot_location" id="upload_seedlot_location" placeholder="Required">
85 <div class="form-group">
86 <label class="col-sm-3 control-label">Population Name: </label>
87 <div class="col-sm-9" >
88 <input class="form-control" name="upload_seedlot_population_name" id="upload_seedlot_population_name" placeholder="Optional">
92 <div class="form-group">
93 <label class="col-sm-3 control-label">Organization Name: </label>
94 <div class="col-sm-9" >
95 <input class="form-control" name="upload_seedlot_organization_name" id="upload_seedlot_organization_name" placeholder="Optional">
99 <div id="upload_seedlots_accessions_section" style="display:none">
100 <div class="form-group">
101 <label class="col-sm-3 control-label">Upload File (.xls): </label>
102 <div class="col-sm-9" >
103 <input type="file" name="seedlot_uploaded_file" id="seedlot_uploaded_file" encoding="multipart/form-data" />
108 <div id="upload_seedlots_harvested_section" style="display:none">
109 <div class="form-group">
110 <label class="col-sm-3 control-label">Upload File (.xls): </label>
111 <div class="col-sm-9" >
112 <input type="file" name="seedlot_harvested_uploaded_file" id="seedlot_harvested_uploaded_file" encoding="multipart/form-data" />
119 <button type="button" class="btn btn-lg btn-primary" onclick="Workflow.complete(this, false);" name="upload_seedlot_button" >Upload Seedlots</button><br/><br/>
123 <&| /util/workflow.mas:step, title=> "Fix errors in file" &>
124 <& /page/page_title.mas, title=>"Fix all errors in your file" &>
126 <div id="upload_seedlots_missing_accessions_or_crosses_div" style="display:none">
127 <div id="upload_seedlots_missing_accessions_div" style="display:none">
130 <li>Accessions must exist in the database prior to adding seedlots of them. The reason for this is that an accession can be exist in many seedlots and therefore exists as a separate entity in the database. We also want to be careful about adding new accessions into the database because we do not want incorrectly duplicated data.</li>
131 <li>When adding accessions into the database, you can use either a list of accessions or an Excel file.</li>
135 <div id="upload_seedlots_add_missing_accessions_html">
138 <button class="btn btn-info" name="add_accessions_link">Add your accessions to the database</button><br/><br/>
139 <button class="btn btn-primary" onclick="Workflow.complete(this);">Once all your accessions are in the database Click Here</button><br/><br/>
141 <div id="upload_seedlots_missing_crosses_div" style="display:none">
144 <li>Crosses must exist in the database before adding your seed lots. The reason for this is that a cross can produce many seed lots and so the cross must exists as a separate entity in the database. We also want to be careful about adding new crosses into the database because we do not want data to be incorrectly linked to duplicates.</li>
148 <li>When adding crosses into the database, you can upload an Excel file or you can add seedlots one at a time.<br/><br/>
150 <li><button class="btn btn-info" name="upload_crosses_link">Upload Excel file</button><br/><br/></li>
151 <li><button class="btn btn-info" name="create_cross_link">Add One Cross</button></li>
156 <button class="btn btn-primary" onclick="Workflow.complete(this);">Once all your crosses are in the database Click Here</button><br/><br/>
160 <div id="upload_seedlots_error_display" style="display:none">
162 <h3>Seedlot Upload Error Messages</h3>
163 <div class="panel panel-danger">
164 <div class="panel-body">
172 <div id="upload_seedlots_no_error_messages_accessions_html">
174 <div name="upload_seedlots_completed_message">
178 <&| /util/workflow.mas:step, title=> "Try submitting seedlots again" &>
179 <& /page/page_title.mas, title=>"Submit your seedlots again. You should have corrected all errors by now, but if not please take a look at the errors in the red box below. You can continue to modify your file and then click Upload until it works." &>
180 <div id="seedlot_upload_show_repeat_upload_button">
182 <button type="button" class="btn btn-lg btn-primary" name="upload_seedlot_button" >Upload Seedlots</button><br/><br/>
186 <div name="upload_seedlots_completed_message">
190 <div id="upload_seedlots_error_display_second_try" style="display:none">
192 <h3>There exist these problems in your file:</h3>
193 <div class="panel panel-danger">
194 <div class="panel-body">
202 <&| /util/workflow.mas:complete, title=> "Complete" &>
203 <& /page/page_title.mas, title=>"Finished! Your seedlots are now in the database" &>
205 <span class="ui-icon ui-icon-circle-check" style="float: left; margin: 0 7px 50px 0;"></span>
206 The seedlot file was uploaded successfully
210 <li>You may want to proceed to the seedlot detail page(s) for the seedlot(s) you just created.</li>
211 <li>You can print barcodes for the seedlots.</li>
215 <button class="btn btn-primary" name="upload_seedlot_success_complete_button">The seedlots were saved to the database with no errors! Congrats Click Here</button><br/><br/>
222 <div class="modal-footer">
223 <button id="close_seedlot_upload_dialog" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
229 <div class="modal fade" id="seedlot_upload_spreadsheet_info_dialog" name="seedlot_upload_spreadsheet_info_dialog" tabindex="-1" role="dialog" aria-labelledby="uploadSeedlotInfoDialog">
230 <div class="modal-dialog modal-xl" role="document">
231 <div class="modal-content">
232 <div class="modal-header" style="text-align: center">
233 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
234 <h4 class="modal-title" id="uploadSeedlotInfoDialog">Upload Template Information For Named Accessions</h4>
236 <div class="modal-body">
237 <div class="container-fluid">
238 <b>Seedlots may be uploaded in an Excel file (.xls)</b>
240 (.xlsx format not supported)
244 The first row (header) must contain the following:
247 <table class="table table-hover table-bordered table-condensed" >
251 <td>seedlot_name</td>
252 <td>accession_name</td>
253 <td>operator_name</td>
262 <b>Required fields:</b>
264 <li>seedlot_name (must be unique)</li>
265 <li>accession_name (must exist in the database. the accession_name is the unique identifier for the named genotype)</li>
266 <li>operator_name (the name of the person who oversaw the inventory process. can be any name.)</li>
268 amount (number of seeds in seedlot. can be provided in conjunction with weight(g). must provide a value for amount or weight(g) or both.)
269 <br/><b>AND/OR</b><br/>
270 weight(g) (weight in grams of seedlot. can be provided in conjunction with amount. must provide a value for amount or weight(g) or both.)
272 <li>box_name (the box name that the seed is located in. can be any name.)</li>
275 <b>Optional fields:</b>
277 <li>description (information about why this seedlot is being added)</li>
282 <div class="modal-footer">
283 <button id="close_seedlot_info_upload_dialog" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
289 <div class="modal fade" id="seedlot_upload_spreadsheet_harvested_info_dialog" name="seedlot_upload_spreadsheet_harvested_info_dialog" tabindex="-1" role="dialog" aria-labelledby="uploadSeedlotHarvestedInfoDialog">
290 <div class="modal-dialog modal-xl" role="document">
291 <div class="modal-content">
292 <div class="modal-header" style="text-align: center">
293 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
294 <h4 class="modal-title" id="uploadSeedlotHarvestedInfoDialog">Upload Template Information For Harvested Seedlots</h4>
296 <div class="modal-body">
297 <div class="container-fluid">
298 <b>Seedlots may be uploaded in an Excel file (.xls)</b>
300 (.xlsx format not supported)
304 The first row (header) must contain the following:
307 <table class="table table-hover table-bordered table-condensed" >
311 <td>seedlot_name</td>
312 <td>cross_unique_id</td>
313 <td>operator_name</td>
322 <b>Required fields:</b>
324 <li>seedlot_name (must be unique)</li>
325 <li>cross_unique_id (must exist in the database. a cross_unique_id can represent a cross between accessions e.g. AxB, but a cross can also represent a cross between specific plots in the field if you have this information)</li>
326 <li>operator_name (the name of the person who oversaw the inventory process. can be any name.)</li>
328 amount (number of seeds in seedlot. can be provided in conjunction with weight(g). must provide a value for amount or weight(g) or both.)
329 <br/><b>AND/OR</b><br/>
330 weight(g) (weight in grams of seedlot. can be provided in conjunction with amount. must provide a value for amount or weight(g) or both.)
332 <li>box_name (the box name that the seed is located in. can be any name.)</li>
335 <b>Optional fields:</b>
337 <li>description (information about why this seedlot is being added)</li>
342 <div class="modal-footer">
343 <button id="close_seedlot_harvested_info_upload_dialog" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
352 jQuery(document).ready(function(){
354 jQuery("#upload_seedlot_location").autocomplete({
355 source: '/ajax/stock/geolocation_autocomplete',
358 jQuery('#upload_seedlots_type_select').change(function(){
359 if (jQuery(this).val() != ''){
360 jQuery('#seedlot_upload_type_select_button').attr('disabled', false);
361 jQuery('#upload_seedlots_types_description').html('<br/><div class="well"><p>'+jQuery(this).find("option:selected").data("desc")+'</p></div>');
363 jQuery('#seedlot_upload_type_select_button').attr('disabled', true);
364 jQuery('#upload_seedlots_types_description').html('');
367 if(jQuery(this).val() == 'from_accession'){
368 jQuery('#upload_seedlots_accessions_template_section').show();
369 jQuery('#upload_seedlots_crosses_template_section').hide();
370 jQuery('#upload_seedlots_accessions_section').show();
371 jQuery('#upload_seedlots_harvested_section').hide();
373 if(jQuery(this).val() == 'from_cross'){
374 jQuery('#upload_seedlots_crosses_template_section').show();
375 jQuery('#upload_seedlots_accessions_template_section').hide();
376 jQuery('#upload_seedlots_accessions_section').hide();
377 jQuery('#upload_seedlots_harvested_section').show();
381 jQuery('[name="seedlot_bulk_upload"]').click( function() {
382 jQuery('#upload_seedlot_dialog').modal('show');
383 get_select_box('breeding_programs', 'upload_seedlot_breeding_program_div', { 'name' : 'upload_seedlot_breeding_program_id', 'id' : 'upload_seedlot_breeding_program_id' });
386 jQuery("[name='guided_help_seedlot_upload_format_button']").click( function () {
387 jQuery("#seedlot_upload_spreadsheet_info_dialog" ).modal("show");
390 jQuery("[name='guided_help_seedlot_crosses_upload_format_button']").click( function () {
391 jQuery("#seedlot_upload_spreadsheet_harvested_info_dialog" ).modal("show");
394 jQuery('[name="upload_seedlot_button"]').click(function () {
395 upload_seedlot_button();
397 function upload_seedlot_button() {
398 var uploadSeedlotAccessionsFile = jQuery("#seedlot_uploaded_file").val();
399 var uploadSeedlotsHarvestedFile = jQuery("#seedlot_harvested_uploaded_file").val();
400 var location = jQuery("#upload_seedlot_location").val();
401 var breeding_program = jQuery("#upload_seedlot_breeding_program_id").val();
402 jQuery('#upload_seedlot_form').attr("action", "/ajax/breeders/seedlot-upload");
403 if (breeding_program === '') {
404 alert("Please choose a breeding program");
407 if (location === '') {
408 alert("Please give a location");
411 if (uploadSeedlotAccessionsFile === '' && uploadSeedlotsHarvestedFile == '') {
412 alert("Please select a file");
415 jQuery("#upload_seedlot_form").submit();
418 jQuery('#upload_seedlot_form').iframePostForm({
421 var uploadSeedlotAccessionsFile = jQuery("#seedlot_uploaded_file").val();
422 var uploadSeedlotsHarvestedFile = jQuery("#seedlot_harvested_uploaded_file").val();
423 jQuery('#working_modal').modal("show");
424 if (uploadSeedlotAccessionsFile === '' && uploadSeedlotsHarvestedFile == '') {
425 jQuery('#working_modal').modal("hide");
426 alert("No file selected");
429 complete: function (response) {
430 console.log(response);
431 jQuery('#working_modal').modal("hide");
433 if (response.error) {
434 alert(response.error);
437 else if (response.error_string) {
439 if (response.missing_accessions || response.missing_crosses) {
440 jQuery('#upload_seedlots_missing_accessions_or_crosses_div').show();
441 if (response.missing_accessions){
442 jQuery('#upload_seedlots_missing_accessions_div').show();
443 var missing_accessions_html = "<div class='well well-sm'><h3>Add the missing accessions to a list</h3><div id='upload_seedlots_missing_accessions' style='display:none'></div><div id='upload_seedlots_add_missing_accessions'></div></div><br/>";
444 jQuery("#upload_seedlots_add_missing_accessions_html").html(missing_accessions_html);
446 var missing_accessions_vals = '';
447 for(var i=0; i<response.missing_accessions.length; i++) {
448 missing_accessions_vals = missing_accessions_vals + response.missing_accessions[i] + '\n';
450 jQuery("#upload_seedlots_missing_accessions").html(missing_accessions_vals);
451 addToListMenu('upload_seedlots_add_missing_accessions', 'upload_seedlots_missing_accessions', {
453 listType: 'accessions'
455 } else if (response.missing_crosses){
456 jQuery('#upload_seedlots_missing_crosses_div').show();
459 jQuery('#upload_seedlots_missing_accessions_or_crosses_div').hide();
460 var no_missing_accessions_html = '<button class="btn btn-primary" onclick="Workflow.skip(this);">There were no errors regarding missing accessions or crosses Click Here</button><br/><br/>';
461 jQuery('#upload_seedlots_no_error_messages_accessions_html').html(no_missing_accessions_html);
462 Workflow.skip('#upload_seedlots_missing_accessions_or_crosses_div', false);
465 jQuery("#upload_seedlots_error_display").show();
466 jQuery("#upload_seedlots_error_display tbody").html(response.error_string);
467 jQuery("#upload_seedlots_error_display_second_try").show();
468 jQuery("#upload_seedlots_error_display_second_try tbody").html(response.error_string);
470 if (response.missing_accessions || response.missing_crosses){
471 Workflow.focus("#upload_seedlot_main_workflow", 4);
472 } else if(response.error_string){
473 Workflow.focus("#upload_seedlot_main_workflow", 5);
474 jQuery("#upload_seedlots_error_display_second_try").show();
476 if (response.success) {
477 jQuery("#upload_seedlots_error_display").hide();
478 jQuery("#upload_seedlots_error_display_second_try").hide();
479 jQuery('#seedlot_upload_show_repeat_upload_button').hide();
480 jQuery('[name="upload_seedlots_completed_message"]').html('<button class="btn btn-primary" name="upload_seedlot_success_complete_button">The seedlots were saved to the database with no errors! Congrats Click Here</button><br/><br/>');
481 Workflow.skip('#upload_seedlots_missing_accessions_or_crosses_div', false);
482 Workflow.skip('#upload_seedlots_error_display_second_try', false);
483 Workflow.focus("#upload_seedlot_main_workflow", -1); //Go to success page
484 Workflow.check_complete("#upload_seedlot_main_workflow");
490 jQuery(document).on('click', '[name="upload_seedlot_success_complete_button"]', function(){
491 alert('Seedlots were saved in the database');
492 jQuery('#upload_seedlot_dialog').modal('hide');