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.
59 lines
1.9 KiB
59 lines
1.9 KiB
$(document).ready(function() {
|
|
var email_form = $('#doc-email-form');
|
|
|
|
email_form.dialog({
|
|
modal: true,
|
|
autoOpen: false,
|
|
minWidth: 380
|
|
});
|
|
$('[name="doc_format"]').on('change', function(){
|
|
if ($(this).val() == 'xls') {
|
|
$('#id_insert_sign').attr('checked', false);
|
|
$('#id_insert_sign').prop('disabled', true);
|
|
} else {
|
|
$('#id_insert_sign').prop('disabled', false);
|
|
}
|
|
})
|
|
|
|
$('button[name=close-form]', email_form).click(function() {
|
|
email_form.dialog('close');
|
|
return false;
|
|
});
|
|
|
|
setup_doc_email_links(email_form);
|
|
});
|
|
|
|
function setup_doc_email_links(form) {
|
|
$('.doc-panel a.doc.email-link').each(function() {
|
|
$(this).click(function() {
|
|
|
|
$('#id_insert_sign').prop('disabled', false);
|
|
var link = $(this);
|
|
|
|
var form_action = link.attr('href') + 'ajax/'; // url to post form
|
|
form.attr('action', form_action); // update form action
|
|
|
|
form.clearForm();
|
|
$('span.client', form).html('');
|
|
$('input[name=doc_format]:first', form).prop('checked', true); // restore radio select
|
|
clear_form_errors(form);
|
|
|
|
var get_url = link.attr('href').replace('email/', 'get/ajax/'); // url to fetch document fields
|
|
var obj_values = fetch_data(get_url);
|
|
|
|
if (obj_values.client) {
|
|
var client_id = obj_values.client;
|
|
var client_get_url = CLIENT.get_url_pattern.replace(/(.*\/)(\d+)(\/\.*)/, '$1' + client_id + '$3');
|
|
var client = fetch_data(client_get_url);
|
|
|
|
obj_values.to = client.contact_email; // set client's email
|
|
$('span.client', form).html('«' + client.name + '»');
|
|
}
|
|
|
|
update_form_fields(form, obj_values);
|
|
|
|
form.dialog('open');
|
|
return false;
|
|
});
|
|
});
|
|
}
|
|
|