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-lg" 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 <&| /page/explanation.mas, title=>'Template information' &>
16 <b>File format information</b>
18 <a id="seedlot_upload_spreadsheet_format_info">Spreadsheet format</a>
22 <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" encoding="multipart/form-data" id="upload_seedlot_form" name="upload_seedlot_form">
24 <div class="form-group">
25 <label class="col-sm-3 control-label">Breeding Program: </label>
26 <div class="col-sm-9" >
27 <div id="upload_seedlot_breeding_program_div"></div>
30 <div class="form-group">
31 <label class="col-sm-3 control-label">Location: </label>
32 <div class="col-sm-9" >
33 <input class="form-control" name="upload_seedlot_location" id="upload_seedlot_location" placeholder="Required">
36 <div class="form-group">
37 <label class="col-sm-3 control-label">Population Name: </label>
38 <div class="col-sm-9" >
39 <input class="form-control" name="upload_seedlot_population_name" id="upload_seedlot_population_name" placeholder="Optional">
42 <div class="form-group">
43 <label class="col-sm-3 control-label">Organization Name: </label>
44 <div class="col-sm-9" >
45 <input class="form-control" name="upload_seedlot_organization_name" id="upload_seedlot_organization_name" placeholder="Optional">
48 <div class="form-group">
49 <label class="col-sm-3 control-label">Upload File (.xls): </label>
50 <div class="col-sm-9" >
51 <input type="file" name="seedlot_uploaded_file" id="seedlot_uploaded_file" encoding="multipart/form-data" />
58 <div class="modal-footer">
59 <button id="upload_seedlot_button" type="button" class="btn btn-default" >Submit</button>
65 <div class="modal fade" id="seedlot_upload_spreadsheet_info_dialog" name="seedlot_upload_spreadsheet_info_dialog" tabindex="-1" role="dialog" aria-labelledby="uploadSeedlotInfoDialog">
66 <div class="modal-dialog modal-lg" role="document">
67 <div class="modal-content">
68 <div class="modal-header" style="text-align: center">
69 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
70 <h4 class="modal-title" id="uploadSeedlotInfoDialog">Upload Template Information</h4>
72 <div class="modal-body">
73 <div class="container-fluid">
74 <b>Seedlots may be uploaded in an Excel file (.xls)</b>
76 (.xlsx format not supported)
80 The first row (header) should contain the following:
83 <table class="table table-hover table-bordered table-condensed" >
88 <td>accession_name</td>
95 <b>Required fields:</b>
97 seedlot_name (must be unique)
99 accession_name (must exist in the database)
101 <b>Optional fields:</b>
103 amount (number of seeds in seedlot. if not given will default to 0)
108 <div class="modal-footer">
109 <button id="close_seedlot_info_upload_dialog" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
116 jQuery(document).ready(function(){
118 jQuery("#upload_seedlot_location").autocomplete({
119 source: '/ajax/stock/geolocation_autocomplete',
122 jQuery('#seedlot_bulk_upload').click( function() {
123 jQuery('#upload_seedlot_dialog').modal('show');
124 get_select_box('breeding_programs', 'upload_seedlot_breeding_program_div', { 'name' : 'upload_seedlot_breeding_program_id', 'id' : 'upload_seedlot_breeding_program_id' });
127 jQuery("#seedlot_upload_spreadsheet_format_info").click( function () {
128 jQuery("#seedlot_upload_spreadsheet_info_dialog" ).modal("show");
131 jQuery('#upload_seedlot_button').click(function () {
132 upload_seedlot_button();
134 function upload_seedlot_button() {
135 var uploadFile = jQuery("#seedlot_uploaded_file").val();
136 var location = jQuery("#upload_seedlot_location").val();
137 var breeding_program = jQuery("#upload_seedlot_breeding_program_id").val();
138 jQuery('#upload_seedlot_form').attr("action", "/ajax/breeders/seedlot-upload");
139 if (breeding_program === '') {
140 alert("Please choose a breeding program");
143 if (location === '') {
144 alert("Please give a location");
147 if (uploadFile === '') {
148 alert("Please select a file");
151 jQuery("#upload_seedlot_form").submit();
154 jQuery('#upload_seedlot_form').iframePostForm({
157 var uploadedSeedlotFile = jQuery("#seedlot_uploaded_file").val();
158 jQuery('#working_modal').modal("show");
159 if (uploadedSeedlotFile === '') {
160 jQuery('#working_modal').modal("hide");
161 alert("No file selected");
164 complete: function (response) {
165 console.log(response);
166 jQuery('#working_modal').modal("hide");
168 if (response.error_string) {
169 alert(response.error_string);
172 if (response.success) {
173 alert("File uploaded successfully");
174 jQuery('#upload_seedlot_dialog').modal('hide');
175 seedlots_table.ajax.reload();