X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=js%2Fkivi.Order.js;h=7294072741eed88765b89941906c676f357531aa;hb=fa0c33348c090ddc68edb8ca9131c70fd1365095;hp=7c97a97e48094d74cbed00de908ac207b8a64e4e;hpb=2d586b8b6946ba269b14e728ceba8148a406ef10;p=kivitendo-erp.git diff --git a/js/kivi.Order.js b/js/kivi.Order.js index 7c97a97e4..729407274 100644 --- a/js/kivi.Order.js +++ b/js/kivi.Order.js @@ -96,6 +96,9 @@ namespace('kivi.Order', function(ns) { $('#print_options_form table').first().remove().appendTo('#email_form_print_options'); + $('select#format').change(kivi.Order.adjust_email_attachment_name_for_template_format); + kivi.Order.adjust_email_attachment_name_for_template_format(); + var to_focus = $('#email_form_to').val() === '' ? 'to' : 'subject'; $('#email_form_' + to_focus).focus(); }; @@ -155,6 +158,20 @@ namespace('kivi.Order', function(ns) { email_dialog.dialog("close"); }; + ns.adjust_email_attachment_name_for_template_format = function() { + var $filename_elt = $('#email_form_attachment_filename'); + var $format_elt = $('select#format'); + + if (!$filename_elt || !$format_elt) + return; + + var format = $format_elt.val().toLowerCase(); + var new_ext = format == 'html' ? 'html' : format == 'opendocument' ? 'odt' : 'pdf'; + var filename = $filename_elt.val(); + + $filename_elt.val(filename.replace(/[^.]+$/, new_ext)); + }; + ns.set_number_in_title = function(elt) { $('#nr_in_title').html($(elt).val()); };