1 namespace('kivi.MassInvoiceCreatePrint', function(ns) {
2 this.checkSalesOrderSelection = function() {
3 if ($("[data-checkall=1]:checked").size() > 0)
5 alert(kivi.t8('No delivery orders have been selected.'));
9 this.checkDeliveryOrderSelection = function() {
10 if ($("[data-checkall=1]:checked").size() > 0)
12 alert(kivi.t8('No delivery orders have been selected.'));
16 this.checkInvoiceSelection = function() {
17 if ($("[data-checkall=1]:checked").size() > 0)
19 alert(kivi.t8('No invoices have been selected.'));
23 this.createPrintAllInitialize = function() {
25 id: 'create_print_all_dialog',
27 title: kivi.t8('Create and print all invoices')
32 this.createPrintAllStartProcess = function() {
33 $('#cpa_start_process_button,.ui-dialog-titlebar button.ui-dialog-titlebar-close').prop('disabled', 'disabled');
34 $('#cpa_start_process_abort_link').remove();
36 var filter = $('[name^=filter\\.]').serializeArray();
38 action: 'MassInvoiceCreatePrint/create_print_all_start',
39 number_of_invoices: $('#cpa_number_of_invoices').val(),
40 bothsided: $('#cpa_bothsided').val(),
41 printer_id: $('#cpa_printer_id').val(),
42 copy_printer_id: $('#cpa_copy_printer_id').val(),
43 transdate: $('#transdate').val()
46 $(filter).each(function(index, obj){ data[obj.name] = obj.value; });
48 $.post('controller.pl', data, kivi.eval_json_result);
51 this.createPrintAllFinishProcess = function() {
52 $('#create_print_all_dialog').dialog('close');
53 window.location.href = 'controller.pl?action=MassInvoiceCreatePrint%2flist_invoices&noshow=1';
56 this.massConversionStarted = function() {
57 $('#create_print_all_dialog').data('timerId', setInterval(function() {
58 $.get("controller.pl", {
59 action: 'MassInvoiceCreatePrint/create_print_all_status',
60 job_id: $('#cpa_job_id').val()
61 }, kivi.eval_json_result);
65 this.massConversionFinished = function() {
66 clearInterval($('#create_print_all_dialog').data('timerId'));
67 $('.ui-dialog-titlebar button.ui-dialog-titlebar-close').prop('disabled', '')
70 ns.showMassPrintOptions = function() {
71 $('#printer_options_printer_id').val($('#printer_id').val());
76 title: kivi.t8('Print options'),
85 ns.showMassPrintOptionsOrDownloadDirectly = function() {
86 if (!kivi.MassInvoiceCreatePrint.checkInvoiceSelection())
89 if ($('#print_options_printer_id').length === 0)
90 return kivi.MassInvoiceCreatePrint.massPrint();
91 return kivi.MassInvoiceCreatePrint.showMassPrintOptions();
94 ns.massPrint = function() {
95 $('#print_options').dialog('close');
97 $('#printer_id').val($('#print_options_printer_id').val());
98 $('#bothsided').val($('#print_options_bothsided').prop('checked') ? 1 : 0);
99 $('#action').val('MassInvoiceCreatePrint/print');
101 $('#report_form').submit();
106 this.resetSearchForm = function() {
107 $("#filter_table input").val("");