5 <& /util/import_javascript.mas, classes => [ 'jquery.iframe-post-form' ] &>
7 <div id="stock_additional_uploaded_files_div">
11 <div class="modal fade" id="accession_upload_additional_file_dialog" name="stock_upload_additional_file_dialog" tabindex="-1" role="dialog" aria-labelledby="stockUploadAdditionalFileDialog">
12 <div class="modal-dialog" role="document">
13 <div class="modal-content">
14 <div class="modal-header">
15 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
16 <h4 class="modal-title" id="stockUploadAdditionalFileDialog">Upload Additional File to Accession</h4>
18 <div class="modal-body">
19 <div class="container-fluid">
20 <&| /page/explanation.mas, title=>'Template information' &>
22 <b>File upload information</b>
24 <a id="accession_upload_additional_file_format">Upload Information</a>
28 <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" encoding="multipart/form-data" id="accession_upload_additional_file_form" name="accession_upload_additional_file_form">
30 <div class="form-group">
31 <label class="col-sm-4 control-label">Upload File: </label>
32 <div class="col-sm-8" >
33 <input type="file" name="accession_upload_additional_file" id="accession_upload_additional_file" encoding="multipart/form-data" />
40 <div class="modal-footer">
41 <button type="button" class="btn btn-default" name="accession_upload_additional_file_cancel_button" id="accession_upload_additional_file_cancel_button" data-dismiss="modal">Close</button>
42 <button type="button" class="btn btn-primary" name="accession_upload_additional_file_submit_button" id="accession_upload_additional_file_submit_button" title="Submit">Submit</button>
48 <div class="modal fade" id="accession_upload_additional_file_info_dialog" name="accession_upload_additional_file_info_dialog" tabindex="-1" role="dialog" aria-labelledby="stockUploadAdditionalFileInfoDialog">
49 <div class="modal-dialog modal-lg" role="document">
50 <div class="modal-content">
51 <div class="modal-header" style="text-align: center">
52 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
53 <h4 class="modal-title" id="stockUploadAdditionalFileInfoDialog">Upload Information</h4>
55 <div class="modal-body">
56 <div class="container-fluid">
57 <b>This is for uploading any additional files you may have for the accession.</b>
59 <p>Possible additional files inlude, but are not limited to:</p>
61 <li>Accession Related Images, such as a physical field image or an aerial picture of the field.</li>
62 <li>Accession Related Documentation, such as protocols or permits for the accession.</li>
63 <li>Accession Related Reports, such as supplementary information or publications.</li>
64 <li>Accession Related Recordings, whether audio or video.</li>
68 <div class="modal-footer">
69 <button id="close_accession_upload_additional_file_info_dialog" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
77 jQuery(document).ready(function(){
79 display_stock_additional_upload_files();
81 jQuery('#accession_upload_additional_files_link').click( function(){
82 jQuery('#accession_upload_additional_file_dialog').modal('show');
85 jQuery('#accession_upload_additional_file_format').click( function(){
86 jQuery('#accession_upload_additional_file_info_dialog').modal('show');
89 jQuery('#accession_upload_additional_file_submit_button').click(function () {
91 var uploadFile = jQuery("#accession_upload_additional_file").val();
93 if (uploadFile === '') {
94 alert("Please select a file");
97 jQuery('#accession_upload_additional_file_form').attr("action", "/stock/"+<% $stock_id %>+"/upload_additional_file");
98 jQuery("#accession_upload_additional_file_form").submit();
101 jQuery('#accession_upload_additional_file_form').iframePostForm({
104 console.log("Responseeee" , "response");
105 jQuery('#working_modal').modal("show");
107 complete: function (r) {
108 var clean_r = r.replace(/^<pre[^>]*>/, '');
109 clean_r = clean_r.replace('</pre>', '');
110 response = JSON.parse(clean_r);
112 jQuery('#working_modal').modal("hide");
114 if (response.error) {
115 alert(response.error);
118 if (response.error_string) {
119 alert(response.error_string);
122 if (response.success) {
123 alert("File uploaded successfully");
130 function display_stock_additional_upload_files (){
132 url : '/stock/'+<% $stock_id %>+'/get_uploaded_additional_file',
133 beforeSend : function(){
134 jQuery('#stock_additional_uploaded_files_div').html("[LOADING...]");
136 success: function(response){
137 console.log("response" ,response);
138 var html = "<table class='table table-hover table-condensed table-bordered' id='stock_additional_uploaded_files_table'><thead><tr><th>Filename</th><th>Date Uploaded</th><th>Uploaded By</th><th>Options</th></tr></thead><tbody>";
139 for (i=0; i<response.files.length; i++) {
140 html = html + '<tr><td>'+response.files[i][4]+'</td><td>'+response.files[i][1]+'</td><td><a href="/solpeople/profile/'+response.files[i][2]+'">'+response.files[i][3]+'</a></td><td><a href="/breeders/phenotyping/download/'+response.files[i][0]+'">Download</a> </td></tr>';
142 html = html + "</tbody></table>";
143 jQuery('#stock_additional_uploaded_files_div').html(html);
144 jQuery('#stock_additional_uploaded_files_table').DataTable();
146 error: function(response){
147 alert("Error retrieving additional uploaded files.");
153 function obsolete_additional_file(stock_id, file_id) {
154 var yes = confirm('Are you sure you want to obsolete this file? This operation cannot be undone.');
157 url: '/stock/'+stock_id+'/obsolete_uploaded_additional_file/'+file_id,
158 success: function(r) {
159 if (r.error) { alert(r.error); }
161 jQuery('#stock_additional_uploaded_files_table').DataTable().clear().draw();
162 alert("The file has been obsoleted.");
165 error: function(r) { alert("An error occurred!") }