You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
2.4 KiB
68 lines
2.4 KiB
$(document).ready(function() { |
|
|
|
$('#pdf_download').click(function() |
|
{ |
|
wait_button(this); |
|
$.ajax({ |
|
type:'GET', |
|
url: '/pdf_report/'+$('#visit_id').val(), |
|
processData: false, // tell jQuery not to process the data |
|
contentType: false, // tell jQuery not to set contentType |
|
success: (data) => { |
|
var a = document.createElement('a'); |
|
a.href = '/pdf/'+ data; |
|
filename = $('#patient_full_name').html() |
|
a.download = filename + '.pdf'; |
|
document.body.append(a); |
|
a.click(); |
|
a.remove(); |
|
window.URL.revokeObjectURL('/pdf/'+ data); |
|
resume_button(this); |
|
$('#pdf_download').attr("disabled", false); |
|
}, |
|
error:function (jqXHR, exception) { |
|
show_error('Не сформировать PDF файл',0); |
|
console.log('resume button') |
|
resume_button(this); |
|
$('#pdf_download').attr("disabled", false); |
|
} |
|
}); |
|
}) |
|
|
|
$('#send_patient_pdf').click(function() |
|
{ |
|
wait_button(this); |
|
var message = { |
|
visit_id : $('#visit_id').val() |
|
} |
|
$.ajax({ |
|
type:'POST', |
|
url: '/send_pdf_report', |
|
processData: false, // tell jQuery not to process the data |
|
contentType: false, // tell jQuery not to set contentType |
|
data: JSON.stringify(message), |
|
success: (data) => { |
|
if(data['success'] == true) |
|
{ |
|
show_success('PDF успешно отправлена', false); |
|
} |
|
else |
|
{ |
|
if(data.hasOwnProperty('message')) |
|
{ |
|
show_error(data.message,0); |
|
} |
|
else |
|
{ |
|
show_error('Не удалось отправить PDF файл',0); |
|
} |
|
} |
|
resume_button(this); |
|
}, |
|
error:function (jqXHR, exception) { |
|
show_error('Ошибка сервера. Не удалось отправить PDF файл',0); |
|
resume_button(this); |
|
} |
|
}); |
|
}) |
|
}); |