4 <& /util/import_javascript.mas, classes => ['jquery.dataTables-buttons-min', 'jquery.iframe-post-form', 'jszip-min','buttons.bootstrap-min', 'buttons.html5-min', 'buttons.print-min'] &>
6 <div class="modal fade" id="upload_locations_dialog" name="upload_locations_dialog" tabindex="-1" role="dialog" aria-labelledby="uploadLocationsDialog">
7 <div class="modal-dialog modal-lg" role="document">
8 <div class="modal-content">
9 <div class="modal-header">
10 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
11 <h4 class="modal-title" id="uploadLocationsDialog">Upload Locations</h4>
13 <div class="modal-body">
14 <div class="container-fluid">
15 <b>Locations may be uploaded in an Excel file (.xls)</b><br>
16 (.xlsx format not supported)
19 The first row (header) must contain the following:
21 <table class="table table-bordered table-hover">
36 <b>Required columns:</b><br><br>
37 <b>Name:</b> must not conflict with an existing location name<br>
38 <b>Abbreviation</b><br>
39 <b>Country Code:</b> must be an <a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3">ISO Alpha-3 country code</a><br>
40 <b>Country Name:</b> must be an uppercase english short name from the <a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3">ISO standard</a><br>
41 <b>Program:</b> must be an exisiting Breeding Program in the database, or multiple breeding programs separated by '&'<br>
42 <b>Type:</b> must be one of the following: Farm, Field, Greenhouse, Screenhouse, Lab, Storage, Other<br>
43 <b>Latitude:</b> (in degrees) must be a number between 90 and -90.<br>
44 <b>Longitude:</b> (in degrees) must be a number between 180 and -180.<br>
45 <b>Altitude:</b> (in meters) must be a number between -418 (Dead Sea) and 8,848 (Mt. Everest).<br>
48 <form method="post" enctype="multipart/form-data" encoding="multipart/form-data" id="upload_locations_form" name="upload_locations_form">
49 <label for="locations_upload_file" style="display: inline-block;">Location File:</label>
50 <input type="file" name="locations_upload_file" id="locations_upload_file" encoding="multipart/form-data" />
54 <div class="modal-footer">
55 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
56 <button type="button" class="btn btn-primary" name="upload_locations_dialog_submit" id="upload_locations_dialog_submit">Upload</button>
62 <div class="modal fade" id="locations_result_dialog" tabindex="-1" role="dialog" aria-labelledby="locationsResultDialog">
63 <div class="modal-dialog modal-lg" role="document">
64 <div class="modal-content ui-front">
65 <div class="modal-header text-center">
66 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
67 <h4 class="modal-title" id="locationsResultDialog">Results</h4>
69 <div id="locations_result_body" class="container-fluid">
71 <div class="modal-footer">
72 <button id="locations_result_close_button" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
78 <script defer="defer">
80 jQuery(document).ready(function() {
82 jQuery('#upload_locations_link').click( function() {
83 jQuery('#upload_locations_dialog').modal("show");
86 jQuery('#upload_locations_dialog_submit').click( function() {
87 var uploadFile = jQuery("#locations_upload_file").val();
88 jQuery('#upload_locations_form').attr("action", "/ajax/locations/upload");
89 if (uploadFile === '') {
90 alert("Please select a file");
93 jQuery("#upload_locations_form").submit();
96 jQuery('#upload_locations_form').iframePostForm({
99 jQuery('#working_modal').modal("show");
101 complete: function (response) {
102 jQuery('#working_modal').modal("hide");
103 //console.log(response);
104 if (response.error) {
106 for (i = 0; i < response.error.length; i++) {
107 errors.push( '<p>'+response.error[i]+'</p>');
109 var html = '<br><center><b>Upload failed.</b><br><b>Please fix the following errors in </b>'+response.filename+'<b> and try again:</b></center><br>';
110 html += errors.join('') + '<br>';
111 document.getElementById('locations_result_body').innerHTML = html;
112 jQuery('#locations_result_dialog').modal("show");
115 jQuery('#upload_locations_dialog').modal("hide");
116 var saved_locations = [];
117 for (var key in response) {
118 saved_locations.push( '<p>'+key+': '+response[key]+'</p>');
120 var html = '<br><center>'+saved_locations.join('')+'</center>';
121 document.getElementById('locations_result_body').innerHTML = html;
122 jQuery('#locations_result_dialog').modal("show");
123 jQuery('#locations_result_close_button').click( function() {
128 error: function(response) {
129 jQuery('#working_modal').modal("hide");
130 alert("An error occurred");