X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/dfa741a109ca3d114efc4980bd1e9d240e036581..9fd5b006e7ab3119d659a3ddbee27a99b6b83b05:/js/kivi.SalesPurchase.js diff --git a/js/kivi.SalesPurchase.js b/js/kivi.SalesPurchase.js index 0b09bebf8..2fcd2132e 100644 --- a/js/kivi.SalesPurchase.js +++ b/js/kivi.SalesPurchase.js @@ -224,22 +224,28 @@ namespace('kivi.SalesPurchase', function(ns) { }; // Sending records via email. - this.send_email = function() { + this.check_required_email_fields = function() { var unset = $('#email_form_to,#email_form_subject,#email_form_message').filter(function(idx, elt) { return $(elt).val() === ''; }); - if (unset.length > 0) { - alert(kivi.t8("The recipient, subject or body is missing.")); - $(unset[0]).focus(); + if (unset.length === 0) + return true; + + alert(kivi.t8("The recipient, subject or body is missing.")); + $(unset[0]).focus(); + + return false; + }; + this.send_email = function() { + if (!kivi.SalesPurchase.check_required_email_fields()) return false; - } $('#send_email_dialog').children().remove().appendTo('#email_inputs'); $('#send_email_dialog').dialog('close'); - kivi.submit_form_with_action('#form', 'send_sales_purchase_email'); + kivi.submit_form_with_action('#form', $('#form').data('send-email-action')); return true; }; @@ -259,7 +265,9 @@ namespace('kivi.SalesPurchase', function(ns) { return true; }; - this.show_email_dialog = function() { + this.show_email_dialog = function(send_action) { + $('#form').data('send-email-action', send_action || 'send_sales_purchase_email'); + kivi.popup_dialog({ id: 'send_email_dialog', url: 'io.pl', @@ -303,10 +311,16 @@ namespace('kivi.SalesPurchase', function(ns) { this.print_record = function() { $('#print_dialog').dialog('close'); - kivi.submit_form_with_action('#form', 'print'); + var action = $('#form').data('print-action'); + if (action.match("^js:")) + return kivi.run(action.substring(3)); + + kivi.submit_form_with_action('#form', action); }; - this.show_print_dialog = function() { + this.show_print_dialog = function(print_action) { + $('#form').data('print-action', print_action || 'print'); + kivi.popup_dialog({ id: 'print_dialog', dialog: {